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

hwmon: (abituguru) 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>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230918085951.1234172-3-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
68d66551 a7dee82a

+2 -4
+2 -4
drivers/hwmon/abituguru.c
··· 1428 1428 return res; 1429 1429 } 1430 1430 1431 - static int abituguru_remove(struct platform_device *pdev) 1431 + static void abituguru_remove(struct platform_device *pdev) 1432 1432 { 1433 1433 int i; 1434 1434 struct abituguru_data *data = platform_get_drvdata(pdev); ··· 1439 1439 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1440 1440 device_remove_file(&pdev->dev, 1441 1441 &abituguru_sysfs_attr[i].dev_attr); 1442 - 1443 - return 0; 1444 1442 } 1445 1443 1446 1444 static struct abituguru_data *abituguru_update_device(struct device *dev) ··· 1531 1533 .pm = pm_sleep_ptr(&abituguru_pm), 1532 1534 }, 1533 1535 .probe = abituguru_probe, 1534 - .remove = abituguru_remove, 1536 + .remove_new = abituguru_remove, 1535 1537 }; 1536 1538 1537 1539 static int __init abituguru_detect(void)