Skip to content

Commit ac51982

Browse files
Uwe Kleine-Königsre
authored andcommitted
power: supply: twl4030_madc_battery: 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/20230918133700.1254499-29-u.kleine-koenig@pengutronix.de Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 83ef1db commit ac51982

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/power/supply/twl4030_madc_battery.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static int twl4030_madc_battery_probe(struct platform_device *pdev)
244244
return ret;
245245
}
246246

247-
static int twl4030_madc_battery_remove(struct platform_device *pdev)
247+
static void twl4030_madc_battery_remove(struct platform_device *pdev)
248248
{
249249
struct twl4030_madc_battery *bat = platform_get_drvdata(pdev);
250250

@@ -253,16 +253,14 @@ static int twl4030_madc_battery_remove(struct platform_device *pdev)
253253
iio_channel_release(bat->channel_vbat);
254254
iio_channel_release(bat->channel_ichg);
255255
iio_channel_release(bat->channel_temp);
256-
257-
return 0;
258256
}
259257

260258
static struct platform_driver twl4030_madc_battery_driver = {
261259
.driver = {
262260
.name = "twl4030_madc_battery",
263261
},
264262
.probe = twl4030_madc_battery_probe,
265-
.remove = twl4030_madc_battery_remove,
263+
.remove_new = twl4030_madc_battery_remove,
266264
};
267265
module_platform_driver(twl4030_madc_battery_driver);
268266

0 commit comments

Comments
 (0)