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

Configure Feed

Select the types of activity you want to include in your feed.

watchdog: txx9: Stop using module_platform_driver_probe()

On today's platforms the benefit of platform_driver_probe() isn't that
relevant any more. It allows to drop some code after booting (or module
loading) for .probe() and discard the .remove() function completely if
the driver is built-in. This typically saves a few 100k.

The downside of platform_driver_probe() is that the driver cannot be
bound and unbound at runtime which is ancient and also slightly
complicates testing. There are also thoughts to deprecate
platform_driver_probe() because it adds some complexity in the driver
core for little gain. Also many drivers don't use it correctly. This
driver for example misses to mark the driver struct with __refdata which
is needed to suppress a (W=1) modpost warning:

WARNING: modpost: drivers/watchdog/txx9wdt: section mismatch in reference: txx9wdt_driver+0x4 (section: .data) -> txx9wdt_remove (section: .exit.text)

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20231106154807.3866712-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Uwe Kleine-König and committed by
Wim Van Sebroeck
de81f74b 86aa2919

+5 -5
+5 -5
drivers/watchdog/txx9wdt.c
··· 98 98 .ops = &txx9wdt_ops, 99 99 }; 100 100 101 - static int __init txx9wdt_probe(struct platform_device *dev) 101 + static int txx9wdt_probe(struct platform_device *dev) 102 102 { 103 103 int ret; 104 104 ··· 145 145 return ret; 146 146 } 147 147 148 - static int __exit txx9wdt_remove(struct platform_device *dev) 148 + static int txx9wdt_remove(struct platform_device *dev) 149 149 { 150 150 watchdog_unregister_device(&txx9wdt); 151 151 clk_disable_unprepare(txx9_imclk); ··· 159 159 } 160 160 161 161 static struct platform_driver txx9wdt_driver = { 162 - .remove = __exit_p(txx9wdt_remove), 162 + .probe = txx9wdt_probe, 163 + .remove = txx9wdt_remove, 163 164 .shutdown = txx9wdt_shutdown, 164 165 .driver = { 165 166 .name = "txx9wdt", 166 167 }, 167 168 }; 168 - 169 - module_platform_driver_probe(txx9wdt_driver, txx9wdt_probe); 169 + module_platform_driver(txx9wdt_driver); 170 170 171 171 MODULE_DESCRIPTION("TXx9 Watchdog Driver"); 172 172 MODULE_LICENSE("GPL");