From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v2 5/6] watchdog: provide timeout_cur value
Date: Tue, 13 Mar 2018 09:33:27 +0100 [thread overview]
Message-ID: <20180313083328.25705-5-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20180313083328.25705-1-o.rempel@pengutronix.de>
timeout_cur will be used for watchdog poller.
Provided values should be good enough for most users
and still can be changed for separate projects and
fit to needed requirements.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/watchdog/wd_core.c | 18 ++++++++++++++++++
include/watchdog.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 31a88a377..69663b39c 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -31,6 +31,16 @@ static const char *watchdog_name(struct watchdog *wd)
return "unknown";
}
+static int watchdog_set_cur(struct param_d *param, void *priv)
+{
+ struct watchdog *wd = priv;
+
+ if (wd->timeout_cur > wd->timeout_max)
+ return -EINVAL;
+
+ return 0;
+}
+
static int watchdog_register_dev(struct watchdog *wd, const char *name, int id)
{
wd->dev.parent = wd->hwdev;
@@ -63,11 +73,19 @@ int watchdog_register(struct watchdog *wd)
if (!wd->timeout_max)
wd->timeout_max = 60 * 60 * 24;
+ if (!wd->timeout_cur || wd->timeout_cur > wd->timeout_max)
+ wd->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->timeout_cur, "%u", wd);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
+
list_add_tail(&wd->list, &watchdog_list);
pr_debug("registering watchdog %s with priority %d\n", watchdog_name(wd),
diff --git a/include/watchdog.h b/include/watchdog.h
index a2459d255..2f1874c19 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -20,6 +20,7 @@ struct watchdog {
struct device_d dev;
unsigned int priority;
unsigned int timeout_max;
+ unsigned int timeout_cur;
struct list_head list;
};
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-03-13 8:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 8:33 [PATCH v2 1/6] watchdog: rename dev to hwdev Oleksij Rempel
2018-03-13 8:33 ` [PATCH v2 2/6] watchdog: move max timeout test in to wd_core Oleksij Rempel
2018-03-13 8:33 ` [PATCH v2 3/6] watchdog: register watchdog virtual device with short name wdog Oleksij Rempel
2018-03-13 8:33 ` [PATCH v2 4/6] watchdog: set some reasonable timeout_max value if no other is available Oleksij Rempel
2018-03-13 8:33 ` Oleksij Rempel [this message]
2018-03-13 8:33 ` [PATCH v2 6/6] watchdog: add watchdog poller Oleksij Rempel
2018-03-19 8:01 ` 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=20180313083328.25705-5-o.rempel@pengutronix.de \
--to=o.rempel@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