summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-06-22 17:11:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-06-23 10:18:11 +0200
commit0b944fce55f4750000a6a0df477034a9e4971b6f (patch)
tree7c35ed053a069b6ee0356ea870cedce8dd29ec0c /drivers
parent70a550c0125ea5c9170129e4826715243ff49db5 (diff)
downloadbarebox-0b944fce55f4750000a6a0df477034a9e4971b6f.tar.gz
barebox-0b944fce55f4750000a6a0df477034a9e4971b6f.tar.xz
watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogs
A watchdog that can't be stopped returns -ENOSYS on set_timeout(0). If the watchdog supports communicating whether it's running, we could still allow `wd 0`, if it hasn't been started yet. Setting device parameter .priority=0 disables a watchdog. One would expect this to always succeed for a not-running watchdog, but currently it doesn't, if the driver's set_timeout(0) returns -ENOSYS. With this fix, this is supported making the user API less surprising. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/watchdog/wd_core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index a17234f4b6..377fd2378a 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);