From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 1/3] watchdog: cleanup timeout_cur parameter
Date: Tue, 12 Nov 2024 10:16:04 +0100 [thread overview]
Message-ID: <20241112-k3-watchdog-v1-1-ceb254779735@pengutronix.de> (raw)
In-Reply-To: <20241112-k3-watchdog-v1-0-ceb254779735@pengutronix.de>
Currently a watchdog has a timeout_cur device parameter which has
a slightly confusing behaviour. The parameter has nothing to do with the
currently configured watchdog timeout, instead it is merely used by
the automatic watchdog feeder which configures the watchdog timeout
with that value.
Refine the semantics of the parameter by using it as the watchdog
timeout as the name suggests. When read, it returns the currently
configured timeout. When set, it configures the watchdog timeout
and starts it (unless it's set to 0 in which case the watchdog will
be disabled).
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/watchdog/wd_core.c | 23 +++++++++++------------
include/watchdog.h | 1 -
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index d4de213fa5..663a6e5c75 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -71,17 +71,18 @@ static int watchdog_set_cur(struct param_d *param, void *priv)
{
struct watchdog *wd = priv;
- if (wd->poller_timeout_cur > wd->timeout_max)
- return -EINVAL;
-
- return 0;
+ return watchdog_set_timeout(wd, wd->timeout_cur);
}
static void watchdog_poller_cb(void *priv);
static void watchdog_poller_start(struct watchdog *wd)
{
- watchdog_set_timeout(wd, wd->poller_timeout_cur);
+ unsigned int timeout_s;
+
+ timeout_s = wd->timeout_cur ?: wd->timeout_max;
+
+ watchdog_set_timeout(wd, timeout_s);
poller_call_async(&wd->poller, 500 * MSECOND,
watchdog_poller_cb, wd);
@@ -201,16 +202,14 @@ int watchdog_register(struct watchdog *wd)
dev_add_param_uint32_ro(&wd->dev, "timeout_max",
&wd->timeout_max, "%u");
- 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;
+ if (wd->timeout_cur > wd->timeout_max)
+ wd->timeout_cur = wd->timeout_max;
- dev_add_param_uint32(&wd->dev, "timeout_cur", watchdog_set_cur,
- NULL, &wd->poller_timeout_cur, "%u", wd);
+ dev_add_param_uint32(&wd->dev, "timeout_cur", watchdog_set_cur,
+ NULL, &wd->timeout_cur, "%u", wd);
+ if (IS_ENABLED(CONFIG_WATCHDOG_POLLER))
watchdog_register_poller(wd);
- }
dev_add_param_uint32(&wd->dev, "seconds_to_expire", param_set_readonly,
seconds_to_expire_get, &wd->seconds_to_expire, "%d", wd);
diff --git a/include/watchdog.h b/include/watchdog.h
index eaea07910c..8084f27596 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -23,7 +23,6 @@ struct watchdog {
unsigned int priority;
unsigned int timeout_max;
unsigned int timeout_cur;
- unsigned int poller_timeout_cur;
unsigned int poller_enable;
uint64_t last_ping;
int seconds_to_expire;
--
2.39.5
next prev parent reply other threads:[~2024-11-12 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 9:16 [PATCH 0/3] watchdog: Add TI rti_wdg support Sascha Hauer
2024-11-12 9:16 ` Sascha Hauer [this message]
2024-11-12 9:16 ` [PATCH 2/3] watchdog: add watchdog ping support Sascha Hauer
2024-11-12 9:16 ` [PATCH 3/3] watchdog: add rti_wdt support Sascha Hauer
2024-11-13 11:33 ` [PATCH 0/3] watchdog: Add TI rti_wdg support 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=20241112-k3-watchdog-v1-1-ceb254779735@pengutronix.de \
--to=s.hauer@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