diff options
author | Guenter Roeck <linux@roeck-us.net> | 2019-04-09 10:23:55 -0700 |
---|---|---|
committer | Wim Van Sebroeck <wim@linux-watchdog.org> | 2019-05-05 21:02:27 +0200 |
commit | 72dbc27c83d6f40b612f206060fda55d9a22f8ed (patch) | |
tree | 42f2888d5e2fba50e8d0a36ff30332f34d342933 /drivers | |
parent | dcc3ce0b7d010be7b092f0c3ce26e6c35bb39bbb (diff) | |
download | linux-72dbc27c83d6f40b612f206060fda55d9a22f8ed.tar.gz linux-72dbc27c83d6f40b612f206060fda55d9a22f8ed.tar.bz2 linux-72dbc27c83d6f40b612f206060fda55d9a22f8ed.zip |
watchdog: sirfsoc_wdt: Convert to use device managed functions and other improvements
Use device managed functions to simplify error handling, reduce
source code size, improve readability, and reduce the likelyhood of bugs.
Other improvements as listed below.
The conversion was done automatically with coccinelle using the
following semantic patches. The semantic patches and the scripts
used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches
- Drop empty remove function
- Introduce local variable 'struct device *dev' and use it instead of
dereferencing it repeatedly
- Replace shutdown function with call to watchdog_stop_on_reboot()
- Replace stop on remove with call to watchdog_stop_on_unregister()
- Use devm_watchdog_register_driver() to register watchdog device
Cc: Barry Song <baohua@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/sirfsoc_wdt.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/drivers/watchdog/sirfsoc_wdt.c b/drivers/watchdog/sirfsoc_wdt.c index 2559062d35da..e79a4097d50b 100644 --- a/drivers/watchdog/sirfsoc_wdt.c +++ b/drivers/watchdog/sirfsoc_wdt.c @@ -146,6 +146,7 @@ static struct watchdog_device sirfsoc_wdd = { static int sirfsoc_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; void __iomem *base; @@ -155,11 +156,13 @@ static int sirfsoc_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(&sirfsoc_wdd, (__force void *)base); - watchdog_init_timeout(&sirfsoc_wdd, timeout, &pdev->dev); + watchdog_init_timeout(&sirfsoc_wdd, timeout, dev); watchdog_set_nowayout(&sirfsoc_wdd, nowayout); - sirfsoc_wdd.parent = &pdev->dev; + sirfsoc_wdd.parent = dev; - ret = watchdog_register_device(&sirfsoc_wdd); + watchdog_stop_on_reboot(&sirfsoc_wdd); + watchdog_stop_on_unregister(&sirfsoc_wdd); + ret = devm_watchdog_register_device(dev, &sirfsoc_wdd); if (ret) return ret; @@ -168,19 +171,6 @@ static int sirfsoc_wdt_probe(struct platform_device *pdev) return 0; } -static void sirfsoc_wdt_shutdown(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - - sirfsoc_wdt_disable(wdd); -} - -static int sirfsoc_wdt_remove(struct platform_device *pdev) -{ - sirfsoc_wdt_shutdown(pdev); - return 0; -} - #ifdef CONFIG_PM_SLEEP static int sirfsoc_wdt_suspend(struct device *dev) { @@ -218,8 +208,6 @@ static struct platform_driver sirfsoc_wdt_driver = { .of_match_table = sirfsoc_wdt_of_match, }, .probe = sirfsoc_wdt_probe, - .remove = sirfsoc_wdt_remove, - .shutdown = sirfsoc_wdt_shutdown, }; module_platform_driver(sirfsoc_wdt_driver); |