diff options
author | Guenter Roeck <linux@roeck-us.net> | 2019-04-08 22:38:44 +0300 |
---|---|---|
committer | Wim Van Sebroeck <wim@linux-watchdog.org> | 2019-05-05 22:02:21 +0300 |
commit | 4689ba97550ed0969be8f6211852e2a98dee1fca (patch) | |
tree | 841574f1019d57e4a378f3be465c940ac402c41d /drivers/watchdog/kempld_wdt.c | |
parent | b7b6adf32c9c82b9f4a4b917ba204d5a9c6fd2da (diff) | |
download | linux-4689ba97550ed0969be8f6211852e2a98dee1fca.tar.xz |
watchdog: kempld_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 assignments to otherwise unused variables
- Drop empty remove function
- Use local variable 'struct device *dev' consistently
- Use devm_watchdog_register_driver() to register watchdog device
- Replace shutdown function with call to watchdog_stop_on_reboot()
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers/watchdog/kempld_wdt.c')
-rw-r--r-- | drivers/watchdog/kempld_wdt.c | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c index e268add43010..543eb0f27a42 100644 --- a/drivers/watchdog/kempld_wdt.c +++ b/drivers/watchdog/kempld_wdt.c @@ -467,7 +467,7 @@ static int kempld_wdt_probe(struct platform_device *pdev) KEMPLD_WDT_CFG_GLOBAL_LOCK)) { if (!nowayout) dev_warn(dev, - "Forcing nowayout - watchdog lock enabled!\n"); + "Forcing nowayout - watchdog lock enabled!\n"); nowayout = true; } @@ -492,7 +492,9 @@ static int kempld_wdt_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, wdt_data); - ret = watchdog_register_device(wdd); + watchdog_stop_on_reboot(wdd); + watchdog_stop_on_unregister(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) return ret; @@ -501,26 +503,6 @@ static int kempld_wdt_probe(struct platform_device *pdev) return 0; } -static void kempld_wdt_shutdown(struct platform_device *pdev) -{ - struct kempld_wdt_data *wdt_data = platform_get_drvdata(pdev); - - kempld_wdt_stop(&wdt_data->wdd); -} - -static int kempld_wdt_remove(struct platform_device *pdev) -{ - struct kempld_wdt_data *wdt_data = platform_get_drvdata(pdev); - struct watchdog_device *wdd = &wdt_data->wdd; - int ret = 0; - - if (!nowayout) - ret = kempld_wdt_stop(wdd); - watchdog_unregister_device(wdd); - - return ret; -} - #ifdef CONFIG_PM /* Disable watchdog if it is active during suspend */ static int kempld_wdt_suspend(struct platform_device *pdev, @@ -567,8 +549,6 @@ static struct platform_driver kempld_wdt_driver = { .name = "kempld-wdt", }, .probe = kempld_wdt_probe, - .remove = kempld_wdt_remove, - .shutdown = kempld_wdt_shutdown, .suspend = kempld_wdt_suspend, .resume = kempld_wdt_resume, }; |