diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2016-10-07 15:41:38 +0300 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2016-10-08 10:27:27 +0200 |
commit | 2accf320786210db92f36866cc71fa894f510a4a (patch) | |
tree | dbdd5b499043fffc3741974608b13f0c042be49b /drivers/watchdog | |
parent | 89873a711dd20b614abb6e4038fb4b5462f4c701 (diff) | |
download | op-kernel-dev-2accf320786210db92f36866cc71fa894f510a4a.zip op-kernel-dev-2accf320786210db92f36866cc71fa894f510a4a.tar.gz |
watchdog: softdog: implement pretimeout support
Give devices which do not have hardware support for pretimeout at least a
software version of it.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/softdog.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c index 1ae469e..c7bdc98 100644 --- a/drivers/watchdog/softdog.c +++ b/drivers/watchdog/softdog.c @@ -72,10 +72,27 @@ static void softdog_fire(unsigned long data) static struct timer_list softdog_ticktock = TIMER_INITIALIZER(softdog_fire, 0, 0); +static struct watchdog_device softdog_dev; + +static void softdog_pretimeout(unsigned long data) +{ + watchdog_notify_pretimeout(&softdog_dev); +} + +static struct timer_list softdog_preticktock = + TIMER_INITIALIZER(softdog_pretimeout, 0, 0); + static int softdog_ping(struct watchdog_device *w) { if (!mod_timer(&softdog_ticktock, jiffies + (w->timeout * HZ))) __module_get(THIS_MODULE); + + if (w->pretimeout) + mod_timer(&softdog_preticktock, jiffies + + (w->timeout - w->pretimeout) * HZ); + else + del_timer(&softdog_preticktock); + return 0; } @@ -84,12 +101,15 @@ static int softdog_stop(struct watchdog_device *w) if (del_timer(&softdog_ticktock)) module_put(THIS_MODULE); + del_timer(&softdog_preticktock); + return 0; } static struct watchdog_info softdog_info = { .identity = "Software Watchdog", - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | + WDIOF_PRETIMEOUT, }; static const struct watchdog_ops softdog_ops = { |