Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: light: cm3605: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new() which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230919174931.1417681-37-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Uwe Kleine-König and committed by
Jonathan Cameron
3e1e6787 b06ab8c8

+2 -4
+2 -4
drivers/iio/light/cm3605.c
··· 266 266 return ret; 267 267 } 268 268 269 - static int cm3605_remove(struct platform_device *pdev) 269 + static void cm3605_remove(struct platform_device *pdev) 270 270 { 271 271 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 272 272 struct cm3605 *cm3605 = iio_priv(indio_dev); ··· 276 276 gpiod_set_value_cansleep(cm3605->aset, 0); 277 277 iio_device_unregister(indio_dev); 278 278 regulator_disable(cm3605->vdd); 279 - 280 - return 0; 281 279 } 282 280 283 281 static int cm3605_pm_suspend(struct device *dev) ··· 318 320 .pm = pm_sleep_ptr(&cm3605_dev_pm_ops), 319 321 }, 320 322 .probe = cm3605_probe, 321 - .remove = cm3605_remove, 323 + .remove_new = cm3605_remove, 322 324 }; 323 325 module_platform_driver(cm3605_driver); 324 326