Message ID | 20221212220217.3777176-1-u.kleine-koenig@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Daniel Lezcano |
Headers | show |
Series | thermal: imx_sc_thermal: Drop empty platform remove function | expand |
On 12/12/2022 23:02, Uwe Kleine-König wrote: > A remove callback just returning 0 is equivalent to no remove callback > at all. So drop the useless function. AFAIU, without the remove callback the module can not be unloaded, no? > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- > drivers/thermal/imx_sc_thermal.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c > index 5d92b70a5d53..4df925e3a80b 100644 > --- a/drivers/thermal/imx_sc_thermal.c > +++ b/drivers/thermal/imx_sc_thermal.c > @@ -127,11 +127,6 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) > return 0; > } > > -static int imx_sc_thermal_remove(struct platform_device *pdev) > -{ > - return 0; > -} > - > static int imx_sc_sensors[] = { IMX_SC_R_SYSTEM, IMX_SC_R_PMIC_0, -1 }; > > static const struct of_device_id imx_sc_thermal_table[] = { > @@ -142,7 +137,6 @@ MODULE_DEVICE_TABLE(of, imx_sc_thermal_table); > > static struct platform_driver imx_sc_thermal_driver = { > .probe = imx_sc_thermal_probe, > - .remove = imx_sc_thermal_remove, > .driver = { > .name = "imx-sc-thermal", > .of_match_table = imx_sc_thermal_table, > > base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476
Hi Daniel, On 22-12-13, Daniel Lezcano wrote: > On 12/12/2022 23:02, Uwe Kleine-König wrote: > > A remove callback just returning 0 is equivalent to no remove callback > > at all. So drop the useless function. > > AFAIU, without the remove callback the module can not be unloaded, no? This should be unrelated according: https://elixir.bootlin.com/linux/latest/source/drivers/base/platform.c#L1419 Regards, Marco > > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > > --- > > drivers/thermal/imx_sc_thermal.c | 6 ------ > > 1 file changed, 6 deletions(-) > > > > diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c > > index 5d92b70a5d53..4df925e3a80b 100644 > > --- a/drivers/thermal/imx_sc_thermal.c > > +++ b/drivers/thermal/imx_sc_thermal.c > > @@ -127,11 +127,6 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) > > return 0; > > } > > -static int imx_sc_thermal_remove(struct platform_device *pdev) > > -{ > > - return 0; > > -} > > - > > static int imx_sc_sensors[] = { IMX_SC_R_SYSTEM, IMX_SC_R_PMIC_0, -1 }; > > static const struct of_device_id imx_sc_thermal_table[] = { > > @@ -142,7 +137,6 @@ MODULE_DEVICE_TABLE(of, imx_sc_thermal_table); > > static struct platform_driver imx_sc_thermal_driver = { > > .probe = imx_sc_thermal_probe, > > - .remove = imx_sc_thermal_remove, > > .driver = { > > .name = "imx-sc-thermal", > > .of_match_table = imx_sc_thermal_table, > > > > base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476 > > -- > <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs > > Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | > <http://twitter.com/#!/linaroorg> Twitter | > <http://www.linaro.org/linaro-blog/> Blog > > >
Hello Daniel, On Tue, Dec 13, 2022 at 08:46:45AM +0100, Daniel Lezcano wrote: > On 12/12/2022 23:02, Uwe Kleine-König wrote: > > A remove callback just returning 0 is equivalent to no remove callback > > at all. So drop the useless function. > > AFAIU, without the remove callback the module can not be unloaded, no? This is a wrong expectation. As Marko already pointed out the relevant code path in platform_remove(), having no remove callback is equivalent to a remove callback that returns zero unconditionally. Note that driver unbinding and module unloading are two separate concepts. If you want to prevent driver unbinding, you can set struct device_driver::suppress_bind_attrs. For modules your assumption is true: If there is an init but no exit function, a module cannot be unloaded[1]. Also while a reference to the module is held, the module won't go away. (E.g. a bound device holds such a reference.) Best regards Uwe [1] apart from MODULE_FORCE_UNLOAD
On 13/12/2022 08:54, Marco Felsch wrote: > Hi Daniel, > > On 22-12-13, Daniel Lezcano wrote: >> On 12/12/2022 23:02, Uwe Kleine-König wrote: >>> A remove callback just returning 0 is equivalent to no remove callback >>> at all. So drop the useless function. >> >> AFAIU, without the remove callback the module can not be unloaded, no? > > This should be unrelated according: > https://elixir.bootlin.com/linux/latest/source/drivers/base/platform.c#L1419 Indeed :) >> >>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> >>> --- >>> drivers/thermal/imx_sc_thermal.c | 6 ------ >>> 1 file changed, 6 deletions(-) >>> >>> diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c >>> index 5d92b70a5d53..4df925e3a80b 100644 >>> --- a/drivers/thermal/imx_sc_thermal.c >>> +++ b/drivers/thermal/imx_sc_thermal.c >>> @@ -127,11 +127,6 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) >>> return 0; >>> } >>> -static int imx_sc_thermal_remove(struct platform_device *pdev) >>> -{ >>> - return 0; >>> -} >>> - >>> static int imx_sc_sensors[] = { IMX_SC_R_SYSTEM, IMX_SC_R_PMIC_0, -1 }; >>> static const struct of_device_id imx_sc_thermal_table[] = { >>> @@ -142,7 +137,6 @@ MODULE_DEVICE_TABLE(of, imx_sc_thermal_table); >>> static struct platform_driver imx_sc_thermal_driver = { >>> .probe = imx_sc_thermal_probe, >>> - .remove = imx_sc_thermal_remove, >>> .driver = { >>> .name = "imx-sc-thermal", >>> .of_match_table = imx_sc_thermal_table, >>> >>> base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476 >> >> -- >> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs >> >> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | >> <http://twitter.com/#!/linaroorg> Twitter | >> <http://www.linaro.org/linaro-blog/> Blog >> >> >>
On 13/12/2022 09:13, Uwe Kleine-König wrote: > Hello Daniel, > > On Tue, Dec 13, 2022 at 08:46:45AM +0100, Daniel Lezcano wrote: >> On 12/12/2022 23:02, Uwe Kleine-König wrote: >>> A remove callback just returning 0 is equivalent to no remove callback >>> at all. So drop the useless function. >> >> AFAIU, without the remove callback the module can not be unloaded, no? > > This is a wrong expectation. As Marko already pointed out the relevant > code path in platform_remove(), having no remove callback is equivalent > to a remove callback that returns zero unconditionally. In a previous discussion (don't remember which one) someone asserted a null remove callback will prevent the module removal like not having the exit module callback but I did not double check. Thanks for the clarification.
On 12/12/2022 23:02, Uwe Kleine-König wrote: > A remove callback just returning 0 is equivalent to no remove callback > at all. So drop the useless function. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > --- Applied thanks
diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c index 5d92b70a5d53..4df925e3a80b 100644 --- a/drivers/thermal/imx_sc_thermal.c +++ b/drivers/thermal/imx_sc_thermal.c @@ -127,11 +127,6 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) return 0; } -static int imx_sc_thermal_remove(struct platform_device *pdev) -{ - return 0; -} - static int imx_sc_sensors[] = { IMX_SC_R_SYSTEM, IMX_SC_R_PMIC_0, -1 }; static const struct of_device_id imx_sc_thermal_table[] = { @@ -142,7 +137,6 @@ MODULE_DEVICE_TABLE(of, imx_sc_thermal_table); static struct platform_driver imx_sc_thermal_driver = { .probe = imx_sc_thermal_probe, - .remove = imx_sc_thermal_remove, .driver = { .name = "imx-sc-thermal", .of_match_table = imx_sc_thermal_table,
A remove callback just returning 0 is equivalent to no remove callback at all. So drop the useless function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/thermal/imx_sc_thermal.c | 6 ------ 1 file changed, 6 deletions(-) base-commit: 830b3c68c1fb1e9176028d02ef86f3cf76aa2476