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>
Subject: [PATCH 3/3] watchdog: add timeout_cur parameter only when poller is enabled
Date: Thu, 24 Oct 2019 17:24:28 +0200	[thread overview]
Message-ID: <20191024152428.4536-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20191024152428.4536-1-a.fatoum@pengutronix.de>

timeout_curr is the timeout programmed into the watchdog hardware every
500 milliseconds. If watchdog poller support is disabled, it still
shows up as a configurable device parameter, but has no effect.

Improve user experience by having it show up only if watchdog poller
support was compiled in. This is already the case for the autoping
parameter. The timeout_max parameter is a generic parameter and will
remain unchanged.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/watchdog/wd_core.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 5b984db8586a..1ce5a360eb61 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -134,20 +134,21 @@ int watchdog_register(struct watchdog *wd)
 	if (!wd->timeout_max)
 		wd->timeout_max = 60 * 60 * 24;
 
-	if (!wd->poller_timeout_cur || wd->poller_timeout_cur > wd->timeout_max)
-		wd->poller_timeout_cur = wd->timeout_max;
-
 	p = dev_add_param_uint32_ro(&wd->dev, "timeout_max",
 			&wd->timeout_max, "%u");
 	if (IS_ERR(p))
 		return PTR_ERR(p);
 
-	p = dev_add_param_uint32(&wd->dev, "timeout_cur", watchdog_set_cur, NULL,
-			&wd->poller_timeout_cur, "%u", wd);
-	if (IS_ERR(p))
-		return PTR_ERR(p);
-
 	if (IS_ENABLED(CONFIG_WATCHDOG_POLLER)) {
+		if (!wd->poller_timeout_cur ||
+		    wd->poller_timeout_cur > wd->timeout_max)
+			wd->poller_timeout_cur = wd->timeout_max;
+
+		p = dev_add_param_uint32(&wd->dev, "timeout_cur", watchdog_set_cur,
+				NULL, &wd->poller_timeout_cur, "%u", wd);
+		if (IS_ERR(p))
+			return PTR_ERR(p);
+
 		ret = watchdog_register_poller(wd);
 		if (ret)
 			return ret;
-- 
2.23.0


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

  parent reply	other threads:[~2019-10-24 15:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 15:24 [PATCH 1/3] watchdog: remove wrong uses of timeout_cur Ahmad Fatoum
2019-10-24 15:24 ` [PATCH 2/3] watchdog: rename timeout_curr to poller_timeout_curr internally Ahmad Fatoum
2019-10-24 15:24 ` Ahmad Fatoum [this message]
2019-10-24 16:30 ` [PATCH 1/3] watchdog: remove wrong uses of timeout_cur Oleksij Rempel
2019-10-28 17:29   ` Ahmad Fatoum
2019-10-28 11:41 ` 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=20191024152428.4536-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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