diff options
Diffstat (limited to 'drivers/watchdog/softdog.c')
-rw-r--r-- | drivers/watchdog/softdog.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c index 0dc5e323d..99a06f9e3 100644 --- a/drivers/watchdog/softdog.c +++ b/drivers/watchdog/softdog.c @@ -43,7 +43,6 @@ #include <linux/types.h> #include <linux/timer.h> #include <linux/watchdog.h> -#include <linux/notifier.h> #include <linux/reboot.h> #include <linux/init.h> #include <linux/jiffies.h> @@ -87,6 +86,7 @@ static struct timer_list watchdog_ticktock = static void watchdog_fire(unsigned long data) { + module_put(THIS_MODULE); if (soft_noboot) pr_crit("Triggered - Reboot ignored\n"); else if (soft_panic) { @@ -105,13 +105,16 @@ static void watchdog_fire(unsigned long data) static int softdog_ping(struct watchdog_device *w) { - mod_timer(&watchdog_ticktock, jiffies+(w->timeout*HZ)); + if (!mod_timer(&watchdog_ticktock, jiffies+(w->timeout*HZ))) + __module_get(THIS_MODULE); return 0; } static int softdog_stop(struct watchdog_device *w) { - del_timer(&watchdog_ticktock); + if (del_timer(&watchdog_ticktock)) + module_put(THIS_MODULE); + return 0; } @@ -122,26 +125,9 @@ static int softdog_set_timeout(struct watchdog_device *w, unsigned int t) } /* - * Notifier for system down - */ - -static int softdog_notify_sys(struct notifier_block *this, unsigned long code, - void *unused) -{ - if (code == SYS_DOWN || code == SYS_HALT) - /* Turn the WDT off */ - softdog_stop(NULL); - return NOTIFY_DONE; -} - -/* * Kernel Interfaces */ -static struct notifier_block softdog_notifier = { - .notifier_call = softdog_notify_sys, -}; - static struct watchdog_info softdog_info = { .identity = "Software Watchdog", .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, @@ -175,18 +161,11 @@ static int __init watchdog_init(void) softdog_dev.timeout = soft_margin; watchdog_set_nowayout(&softdog_dev, nowayout); - - ret = register_reboot_notifier(&softdog_notifier); - if (ret) { - pr_err("cannot register reboot notifier (err=%d)\n", ret); - return ret; - } + watchdog_stop_on_reboot(&softdog_dev); ret = watchdog_register_device(&softdog_dev); - if (ret) { - unregister_reboot_notifier(&softdog_notifier); + if (ret) return ret; - } pr_info("Software Watchdog Timer: 0.08 initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d (nowayout=%d)\n", soft_noboot, soft_margin, soft_panic, nowayout); @@ -197,7 +176,6 @@ static int __init watchdog_init(void) static void __exit watchdog_exit(void) { watchdog_unregister_device(&softdog_dev); - unregister_reboot_notifier(&softdog_notifier); } module_init(watchdog_init); |