Signed-off-by: Janusz Uzycki diff --git a/linux-3.14.17/drivers/watchdog/stmp3xxx_rtc_wdt.c b/linux-3.14.17/drivers/watchdog/stmp3xxx_rtc_wdt.c index b4d6b34..3546f03 100644 --- a/linux-3.14.17/drivers/watchdog/stmp3xxx_rtc_wdt.c +++ b/linux-3.14.17/drivers/watchdog/stmp3xxx_rtc_wdt.c @@ -67,7 +67,7 @@ static struct watchdog_device stmp3xxx_wdd = { .ops = &stmp3xxx_wdt_ops, .min_timeout = 1, .max_timeout = STMP3XXX_MAX_TIMEOUT, - .status = WATCHDOG_NOWAYOUT_INIT_STATUS, + .status = WATCHDOG_NOWAYOUT_INIT_STATUS | WATCHDOG_KEEP_ON, }; static int stmp3xxx_wdt_probe(struct platform_device *pdev) diff --git a/linux-3.14.17/drivers/watchdog/watchdog_dev.c b/linux-3.14.17/drivers/watchdog/watchdog_dev.c index d4fae2c..f16955d 100644 --- a/linux-3.14.17/drivers/watchdog/watchdog_dev.c +++ b/linux-3.14.17/drivers/watchdog/watchdog_dev.c @@ -41,8 +41,8 @@ #include /* For handling misc devices */ #include /* For __init/__exit/... */ #include /* For copy_to_user/put_user/... */ -#include /* for kernel ping timer (dynamic) */ -#include /* for kernel ping timer */ +#include /* for 'keep on' timer (dynamic) */ +#include /* for 'keep on' timer */ #include "watchdog_core.h" @@ -279,32 +279,27 @@ out_ioctl: return err; } -/* kernel ping feature */ -static void watchdog_kping_timer_cb(unsigned long data) +/* 'keep on' feature */ +static void watchdog_keepon_timer_cb(unsigned long data) { struct watchdog_device *wdd = (struct watchdog_device *)data; - if (test_bit(WDOG_KERNEL_PING, &wdd->status) && !test_bit(WDOG_DEV_OPEN, &wdd->status)) { - watchdog_ping(wdd); - /* call next ping a second or 0.5s before hardware timeout */ - mod_timer(wdd->kping_timer, wdd->timeout > 1 ? - jiffies + (wdd->timeout - 1) * HZ : jiffies + HZ/2); - } + watchdog_ping(wdd); + /* call next ping half the timeout value */ + mod_timer(wdd->keepon_timer, + jiffies + wdd->timeout * (HZ/2)); } -static void watchdog_kping_start(struct watchdog_device *wdd) +static void watchdog_keepon_start(struct watchdog_device *wdd) { - if (wdd->ops->ref) - wdd->ops->ref(wdd); watchdog_start(wdd); + /* watchdog_keepon_timer_cb((unsigned long)wdd); or the code below: */ watchdog_ping(wdd); - mod_timer(wdd->kping_timer, jiffies + HZ/2); + mod_timer(wdd->keepon_timer, jiffies + HZ/2); } -static void watchdog_kping_stop(struct watchdog_device *wdd) +static void watchdog_keepon_stop(struct watchdog_device *wdd) { - del_timer_sync(wdd->kping_timer); - if (wdd->ops->unref) - wdd->ops->unref(wdd); + del_timer_sync(wdd->keepon_timer); } /* @@ -460,8 +455,8 @@ static int watchdog_open(struct inode *inode, struct file *file) if (!try_module_get(wdd->ops->owner)) goto out; - if (test_bit(WDOG_KERNEL_PING, &wdd->status)) - watchdog_kping_stop(wdd); + if (test_bit(WDOG_KEEP_ON, &wdd->status)) + watchdog_keepon_stop(wdd); err = watchdog_start(wdd); if (err < 0) @@ -506,8 +501,8 @@ static int watchdog_release(struct inode *inode, struct file *file) err = 0; else if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) || !(wdd->info->options & WDIOF_MAGICCLOSE)) { - if (test_bit(WDOG_KERNEL_PING, &wdd->status)) { - watchdog_kping_start(wdd); + if (test_bit(WDOG_KEEP_ON, &wdd->status)) { + watchdog_keepon_start(wdd); err = 0; } else err = watchdog_stop(wdd); @@ -562,14 +557,16 @@ int watchdog_dev_register(struct watchdog_device *watchdog) { int err, devno; - if (test_bit(WDOG_KERNEL_PING, &watchdog->status)) { + if (test_bit(WDOG_KEEP_ON, &watchdog->status)) { if (!try_module_get(watchdog->ops->owner)) return -ENODEV; - watchdog->kping_timer = kzalloc(sizeof(*watchdog->kping_timer), GFP_KERNEL); - if (!watchdog->kping_timer) + watchdog->keepon_timer = + kzalloc(sizeof(*watchdog->keepon_timer), GFP_KERNEL); + if (!watchdog->keepon_timer) return -ENOMEM; - setup_timer(watchdog->kping_timer, watchdog_kping_timer_cb, (unsigned long)watchdog); - watchdog_kping_start(watchdog); + setup_timer(watchdog->keepon_timer, watchdog_keepon_timer_cb, + (unsigned long)watchdog); + watchdog_keepon_start(watchdog); } if (watchdog->id == 0) { @@ -624,11 +621,11 @@ int watchdog_dev_unregister(struct watchdog_device *watchdog) old_wdd = NULL; } - if (test_bit(WDOG_KERNEL_PING, &watchdog->status) || watchdog->kping_timer) { - watchdog_kping_stop(watchdog); - watchdog_stop(watchdog); - kfree(watchdog->kping_timer); - watchdog->kping_timer = NULL; + if (test_bit(WDOG_KEEP_ON, &watchdog->status) || + watchdog->keepon_timer) { + watchdog_keepon_stop(watchdog); + kfree(watchdog->keepon_timer); + watchdog->keepon_timer = NULL; watchdog_stop(watchdog); module_put(watchdog->ops->owner); } diff --git a/linux-3.14.17/include/linux/watchdog.h b/linux-3.14.17/include/linux/watchdog.h index 8cf9148..57b552a 100644 --- a/linux-3.14.17/include/linux/watchdog.h +++ b/linux-3.14.17/include/linux/watchdog.h @@ -12,7 +12,7 @@ #include #include #include -#include /* for kernel ping timer */ +#include /* for 'keep on' timer */ #include struct watchdog_ops; @@ -96,9 +96,9 @@ struct watchdog_device { #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */ #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */ #define WDOG_UNREGISTERED 4 /* Has the device been unregistered */ -#define WDOG_KERNEL_PING 5 /* Ping is done by kernel if device not opened by userland */ - struct timer_list *kping_timer; /* kernel ping timer */ -#define WATCHDOG_KERNEL_PING (1 << WDOG_KERNEL_PING) +#define WDOG_KEEP_ON 5 /* Is 'keep on' feature set? */ + struct timer_list *keepon_timer;/* 'keep on' timer */ +#define WATCHDOG_KEEP_ON (1 << WDOG_KEEP_ON) }; #ifdef CONFIG_WATCHDOG_NOWAYOUT