diff options
author | Guenter Roeck <linux@roeck-us.net> | 2016-02-28 22:12:18 +0100 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2016-03-16 21:11:19 +0100 |
commit | 15013ad813f6544be8e79afc23672745950d59bc (patch) | |
tree | 8cb6da1a21407a0a30d8430fb10a6993863c371b /drivers/watchdog/watchdog_dev.c | |
parent | watchdog: Make stop function optional (diff) | |
download | linux-15013ad813f6544be8e79afc23672745950d59bc.tar.xz linux-15013ad813f6544be8e79afc23672745950d59bc.zip |
watchdog: Add support for minimum time between heartbeats
Some watchdogs require a minimum time between heartbeats.
Examples are the watchdogs in DA9062 and AT91SAM9x.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/watchdog_dev.c')
-rw-r--r-- | drivers/watchdog/watchdog_dev.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 5163c3eb3428..2d6110278eac 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -64,6 +64,7 @@ struct watchdog_core_data { struct watchdog_device *wdd; struct mutex lock; unsigned long last_keepalive; + unsigned long last_hw_keepalive; struct delayed_work work; unsigned long status; /* Internal status bits */ #define _WDOG_DEV_OPEN 0 /* Opened ? */ @@ -137,8 +138,19 @@ static inline void watchdog_update_worker(struct watchdog_device *wdd) static int __watchdog_ping(struct watchdog_device *wdd) { + struct watchdog_core_data *wd_data = wdd->wd_data; + unsigned long earliest_keepalive = wd_data->last_hw_keepalive + + msecs_to_jiffies(wdd->min_hw_heartbeat_ms); int err; + if (time_is_after_jiffies(earliest_keepalive)) { + mod_delayed_work(watchdog_wq, &wd_data->work, + earliest_keepalive - jiffies); + return 0; + } + + wd_data->last_hw_keepalive = jiffies; + if (wdd->ops->ping) err = wdd->ops->ping(wdd); /* ping the watchdog */ else @@ -819,6 +831,9 @@ static int watchdog_cdev_register(struct watchdog_device *wdd, dev_t devno) return err; } + /* Record time of most recent heartbeat as 'just before now'. */ + wd_data->last_hw_keepalive = jiffies - 1; + /* * If the watchdog is running, prevent its driver from being unloaded, * and schedule an immediate ping. |