diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-07-27 21:58:47 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-07-27 21:58:47 +0200 |
commit | f91f7747879ec28606293426720c136ec15b0e2d (patch) | |
tree | 883a065bed100b63f4dd1f5e663d9db305ca9c06 /drivers | |
parent | 989d3ebf78ad149ee4e9930d7b73ac7370373a28 (diff) | |
parent | 2863db306e02b14c31dd7ea1fa4857bc3675e42c (diff) | |
download | barebox-f91f7747879ec28606293426720c136ec15b0e2d.tar.gz barebox-f91f7747879ec28606293426720c136ec15b0e2d.tar.xz |
Merge branch 'for-next/watchdog'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/wd_core.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index a17234f4b6..ab1dcaa40a 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -45,6 +45,9 @@ int watchdog_set_timeout(struct watchdog *wd, unsigned timeout) if (timeout > wd->timeout_max) return -EINVAL; + if (watchdog_hw_running(wd) == false) + return 0; + pr_debug("setting timeout on %s to %ds\n", watchdog_name(wd), timeout); ret = wd->set_timeout(wd, timeout); @@ -273,3 +276,30 @@ struct watchdog *watchdog_get_by_name(const char *name) return NULL; } EXPORT_SYMBOL(watchdog_get_by_name); + +int watchdog_inhibit_all(void) +{ + struct watchdog *wd; + int ret = 0; + + list_for_each_entry(wd, &watchdog_list, list) { + int err; + if (!wd->priority || watchdog_hw_running(wd) == false) + continue; + + err = watchdog_set_timeout(wd, 0); + if (!err) + continue; + + if (err != -ENOSYS || !IS_ENABLED(CONFIG_WATCHDOG_POLLER)) { + ret = err; + continue; + } + + wd->poller_enable = true; + watchdog_poller_start(wd); + } + + return ret; +} +EXPORT_SYMBOL(watchdog_inhibit_all); |