mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] watchdog: core: use new dev_add_param_tristate helper for .running param
Date: Thu, 21 Nov 2019 09:40:04 +0100	[thread overview]
Message-ID: <20191121084005.683-2-ahmad@a3f.at> (raw)
In-Reply-To: <20191121084005.683-1-ahmad@a3f.at>

Previous commit added a dev_add_param_tristate_ro that can be readily
used instead of the enum parameter here. Use it.
This also fixes the issue that running_names had external linkage.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/watchdog/wd_core.c | 9 +--------
 include/watchdog.h         | 5 ++++-
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index fcead1175558..b6e2a37b1f0c 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -152,12 +152,6 @@ static unsigned int dev_get_watchdog_priority(struct device_d *dev)
 	return priority;
 }
 
-const char *running_names[] = {
-	[WDOG_HW_RUNNING_UNSUPPORTED] = "unknown",
-	[WDOG_HW_RUNNING] = "1",
-	[WDOG_HW_NOT_RUNNING] = "0",
-};
-
 int watchdog_register(struct watchdog *wd)
 {
 	struct param_d *p;
@@ -176,8 +170,7 @@ int watchdog_register(struct watchdog *wd)
 	if (ret)
 		return ret;
 
-	p = dev_add_param_enum_ro(&wd->dev, "running", &wd->running,
-				  running_names, ARRAY_SIZE(running_names));
+	p = dev_add_param_tristate_ro(&wd->dev, "running", &wd->running);
 	if (IS_ERR(p))
 		return PTR_ERR(p);
 
diff --git a/include/watchdog.h b/include/watchdog.h
index 5790205a487b..9741570ce229 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -15,9 +15,12 @@
 
 #include <poller.h>
 #include <driver.h>
+#include <param.h>
 
 enum wdog_hw_runnning {
-	 WDOG_HW_RUNNING_UNSUPPORTED, WDOG_HW_RUNNING, WDOG_HW_NOT_RUNNING
+	 WDOG_HW_RUNNING_UNSUPPORTED = PARAM_TRISTATE_UNKNOWN,
+	 WDOG_HW_RUNNING = PARAM_TRISTATE_TRUE,
+	 WDOG_HW_NOT_RUNNING = PARAM_TRISTATE_FALSE
 };
 
 struct watchdog {
-- 
2.20.1


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

  reply	other threads:[~2019-11-21  8:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21  8:40 [PATCH 1/3] param: add dev_add_param_tristate(_ro) helpers Ahmad Fatoum
2019-11-21  8:40 ` Ahmad Fatoum [this message]
2019-11-21  8:40 ` [PATCH 3/3] remoteproc: add .stop device parameter for stopping remote processor Ahmad Fatoum
2019-11-25  8:28   ` Sascha Hauer
2019-11-25  9:45     ` Ahmad Fatoum
2019-12-04 13:07     ` Ahmad Fatoum
2019-12-05  8:10       ` 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=20191121084005.683-2-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --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