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

hwmon: (mc13783-adc) 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() is 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/20230918085951.1234172-11-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Uwe Kleine-König and committed by
Guenter Roeck
13af7eee 19eae13a

+2 -4
+2 -4
drivers/hwmon/mc13783-adc.c
··· 285 285 return ret; 286 286 } 287 287 288 - static int mc13783_adc_remove(struct platform_device *pdev) 288 + static void mc13783_adc_remove(struct platform_device *pdev) 289 289 { 290 290 struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); 291 291 kernel_ulong_t driver_data = platform_get_device_id(pdev)->driver_data; ··· 299 299 sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_16chans); 300 300 301 301 sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); 302 - 303 - return 0; 304 302 } 305 303 306 304 static const struct platform_device_id mc13783_adc_idtable[] = { ··· 315 317 MODULE_DEVICE_TABLE(platform, mc13783_adc_idtable); 316 318 317 319 static struct platform_driver mc13783_adc_driver = { 318 - .remove = mc13783_adc_remove, 320 + .remove_new = mc13783_adc_remove, 319 321 .driver = { 320 322 .name = DRIVER_NAME, 321 323 },