mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Bastian Krause <bst@pengutronix.de>
Subject: [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd
Date: Tue, 18 Aug 2020 15:18:16 +0200	[thread overview]
Message-ID: <20200818131816.7700-1-a.fatoum@pengutronix.de> (raw)

Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but
inactive, watchdogs") silently broke use of non-stoppable, but inactive,
watchdogs altogether. Because those always had watchdog_hw_running
evaluating to false, it early exited without a chance to ever actually
set the timeout (and for watchdog_hw_running to evaluate to != false).

This results in following watchdog drivers being broken in v2020.08.0:

 - imxwd
 - f71808e_wdt
 - at91sam9_wdt

Fixes: 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogs")
Reported-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Please apply to master (and to v2020.08.1?).
---
 drivers/watchdog/wd_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index ab1dcaa40a3a..4247288dbd0a 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -45,12 +45,11 @@ 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);
+	if (ret == -ENOSYS && watchdog_hw_running(wd) == false)
+		return 0;
 	if (ret)
 		return ret;
 
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2020-08-18 13:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 13:18 Ahmad Fatoum [this message]
2020-08-19  6:59 ` Sascha Hauer
2020-08-19  7:18   ` Ahmad Fatoum
2020-08-19  7:33     ` Sascha Hauer
2020-08-19  7:38 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200818131816.7700-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=bst@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox