thermal/drivers/stm32: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 16 Jun 2023 16:56:41 +0000 (18:56 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 26 Jun 2023 10:03:14 +0000 (12:03 +0200)
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 (mostly) ignored
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.

st_thermal_unregister() always returned zero, so convert it to return void
without any loss and then just drop the return from st_mmap_remove().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230616165641.1055854-1-u.kleine-koenig@pengutronix.de
drivers/thermal/st/st_thermal.c
drivers/thermal/st/st_thermal.h
drivers/thermal/st/st_thermal_memmap.c

index 2d30420984454e4bbc071fd275c61f6dd2f37b71..0d6249b36609efc16903cd0f4358273da0296cb0 100644 (file)
@@ -227,14 +227,12 @@ sensor_off:
 }
 EXPORT_SYMBOL_GPL(st_thermal_register);
 
-int st_thermal_unregister(struct platform_device *pdev)
+void st_thermal_unregister(struct platform_device *pdev)
 {
        struct st_thermal_sensor *sensor = platform_get_drvdata(pdev);
 
        st_thermal_sensor_off(sensor);
        thermal_zone_device_unregister(sensor->thermal_dev);
-
-       return 0;
 }
 EXPORT_SYMBOL_GPL(st_thermal_unregister);
 
index d661b2f2ef29f2c548277b2184a544ba7041ef5d..75a84e6ec6a729bfce9027b467526f90713c33ee 100644 (file)
@@ -94,7 +94,7 @@ struct st_thermal_sensor {
 
 extern int st_thermal_register(struct platform_device *pdev,
                               const struct of_device_id *st_thermal_of_match);
-extern int st_thermal_unregister(struct platform_device *pdev);
+extern void st_thermal_unregister(struct platform_device *pdev);
 extern const struct dev_pm_ops st_thermal_pm_ops;
 
 #endif /* __STI_RESET_SYSCFG_H */
index d68596c40be99009513c7c6d2ac87ddd7e26ac25..e8cfa83b724a774b53e0be33d1e462601b070f07 100644 (file)
@@ -172,9 +172,9 @@ static int st_mmap_probe(struct platform_device *pdev)
        return st_thermal_register(pdev,  st_mmap_thermal_of_match);
 }
 
-static int st_mmap_remove(struct platform_device *pdev)
+static void st_mmap_remove(struct platform_device *pdev)
 {
-       return st_thermal_unregister(pdev);
+       st_thermal_unregister(pdev);
 }
 
 static struct platform_driver st_mmap_thermal_driver = {
@@ -184,7 +184,7 @@ static struct platform_driver st_mmap_thermal_driver = {
                .of_match_table = st_mmap_thermal_of_match,
        },
        .probe          = st_mmap_probe,
-       .remove         = st_mmap_remove,
+       .remove_new     = st_mmap_remove,
 };
 
 module_platform_driver(st_mmap_thermal_driver);