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

thermal/drivers/stm32: 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 (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

authored by

Uwe Kleine-König and committed by
Daniel Lezcano
2ef95331 a5639fad

+5 -7
+1 -3
drivers/thermal/st/st_thermal.c
··· 227 227 } 228 228 EXPORT_SYMBOL_GPL(st_thermal_register); 229 229 230 - int st_thermal_unregister(struct platform_device *pdev) 230 + void st_thermal_unregister(struct platform_device *pdev) 231 231 { 232 232 struct st_thermal_sensor *sensor = platform_get_drvdata(pdev); 233 233 234 234 st_thermal_sensor_off(sensor); 235 235 thermal_zone_device_unregister(sensor->thermal_dev); 236 - 237 - return 0; 238 236 } 239 237 EXPORT_SYMBOL_GPL(st_thermal_unregister); 240 238
+1 -1
drivers/thermal/st/st_thermal.h
··· 94 94 95 95 extern int st_thermal_register(struct platform_device *pdev, 96 96 const struct of_device_id *st_thermal_of_match); 97 - extern int st_thermal_unregister(struct platform_device *pdev); 97 + extern void st_thermal_unregister(struct platform_device *pdev); 98 98 extern const struct dev_pm_ops st_thermal_pm_ops; 99 99 100 100 #endif /* __STI_RESET_SYSCFG_H */
+3 -3
drivers/thermal/st/st_thermal_memmap.c
··· 172 172 return st_thermal_register(pdev, st_mmap_thermal_of_match); 173 173 } 174 174 175 - static int st_mmap_remove(struct platform_device *pdev) 175 + static void st_mmap_remove(struct platform_device *pdev) 176 176 { 177 - return st_thermal_unregister(pdev); 177 + st_thermal_unregister(pdev); 178 178 } 179 179 180 180 static struct platform_driver st_mmap_thermal_driver = { ··· 184 184 .of_match_table = st_mmap_thermal_of_match, 185 185 }, 186 186 .probe = st_mmap_probe, 187 - .remove = st_mmap_remove, 187 + .remove_new = st_mmap_remove, 188 188 }; 189 189 190 190 module_platform_driver(st_mmap_thermal_driver);