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 4/6] watchdog: export priority as device parameter
Date: Wed, 23 Oct 2019 18:55:59 +0200	[thread overview]
Message-ID: <20191023165601.16441-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20191023165601.16441-1-a.fatoum@pengutronix.de>

8f4cf30903 ("watchdog: Allow multiple watchdogs") introduced the ability
to set a per-watchdog priority from within drivers, which is usually
populated with of_get_watchdog_priority.

For debugging, it can be useful to query and override this priority on
the fly.  Provide a device parameter to do so.
As watchdog_get_default only considers priorities > 0, it makes sense
to have a newly set priority of 0 disable the watchdog.

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

diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index e6e5ddecd2f8..ae29a76064aa 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -41,6 +41,16 @@ static int _watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
 	return wd->set_timeout(wd, timeout);
 }
 
+static int watchdog_set_priority(struct param_d *param, void *priv)
+{
+	struct watchdog *wd = priv;
+
+	if (wd->priority == 0)
+		return _watchdog_set_timeout(wd, 0);
+
+	return 0;
+}
+
 static int watchdog_set_cur(struct param_d *param, void *priv)
 {
 	struct watchdog *wd = priv;
@@ -130,6 +140,12 @@ int watchdog_register(struct watchdog *wd)
 	if (!wd->priority)
 		wd->priority = WATCHDOG_DEFAULT_PRIORITY;
 
+	p = dev_add_param_uint32(&wd->dev, "priority",
+				 watchdog_set_priority, NULL,
+				 &wd->priority, "%u", wd);
+	if (IS_ERR(p))
+		return PTR_ERR(p);
+
 	/* set some default sane value */
 	if (!wd->timeout_max)
 		wd->timeout_max = 60 * 60 * 24;
-- 
2.23.0


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

  parent reply	other threads:[~2019-10-23 16:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 16:55 [PATCH 1/6] Documentation: efi: emphasize watchdog deactivation on ExitBootServices Ahmad Fatoum
2019-10-23 16:55 ` [PATCH 2/6] efi: efi-image: don't mask x86 interrupts on boot Ahmad Fatoum
2019-10-23 16:55 ` [PATCH 3/6] watchdog: efi: bump down priority below default Ahmad Fatoum
2019-10-23 16:55 ` Ahmad Fatoum [this message]
2019-10-23 16:56 ` [PATCH 5/6] watchdog: export API to configure watchdogs by name Ahmad Fatoum
2019-10-23 16:56 ` [PATCH 6/6] commands: wd: support configuring watchdog " Ahmad Fatoum
2019-10-24  6:34 ` [PATCH 1/6] Documentation: efi: emphasize watchdog deactivation on ExitBootServices Oleksij Rempel
2019-10-24  7:59 ` 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=20191023165601.16441-4-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