mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/7] watchdog: Give watchdogs a name
Date: Wed, 26 Aug 2015 13:17:12 +0200	[thread overview]
Message-ID: <1440587836-22105-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1440587836-22105-1-git-send-email-s.hauer@pengutronix.de>

This adds a dev and name member to struct watchdog which helps distinguishing
between different watchdogs. Also add some debugging aids.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/watchdog/davinci_wdt.c |  1 +
 drivers/watchdog/im28wd.c      |  1 +
 drivers/watchdog/imxwd.c       |  1 +
 drivers/watchdog/wd_core.c     | 15 ++++++++++++++-
 include/watchdog.h             |  2 ++
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index ecf6e89..dfabee2 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -147,6 +147,7 @@ static int davinci_wdt_probe(struct device_d *dev)
 	clk_enable(davinci_wdt->clk);
 
 	davinci_wdt->wd.set_timeout = davinci_wdt_set_timeout;
+	davinci_wdt->wd.dev = dev;
 
 	ret = watchdog_register(&davinci_wdt->wd);
 	if (ret < 0)
diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
index a9093a7..3510776 100644
--- a/drivers/watchdog/im28wd.c
+++ b/drivers/watchdog/im28wd.c
@@ -197,6 +197,7 @@ static int imx28_wd_probe(struct device_d *dev)
 	if (IS_ERR(priv->regs))
 		return PTR_ERR(priv->regs);
 	priv->wd.set_timeout = imx28_watchdog_set_timeout;
+	priv->wd.dev = dev;
 
 	if (!(readl(priv->regs + MXS_RTC_STAT) & MXS_RTC_STAT_WD_PRESENT)) {
 		rc = -ENODEV;
diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index 4621d41..dd11a62 100644
--- a/drivers/watchdog/imxwd.c
+++ b/drivers/watchdog/imxwd.c
@@ -186,6 +186,7 @@ static int imx_wd_probe(struct device_d *dev)
 	}
 	priv->ops = ops;
 	priv->wd.set_timeout = imx_watchdog_set_timeout;
+	priv->wd.dev = dev;
 	priv->dev = dev;
 
 	if (IS_ENABLED(CONFIG_WATCHDOG_IMX)) {
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index b8473b7..0b75a51 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -21,6 +21,16 @@
 
 static LIST_HEAD(watchdog_list);
 
+static const char *watchdog_name(struct watchdog *wd)
+{
+	if (wd->dev)
+		return dev_name(wd->dev);
+	if (wd->name)
+		return wd->name;
+
+	return "unknown";
+}
+
 int watchdog_register(struct watchdog *wd)
 {
 	if (!wd->priority)
@@ -28,7 +38,8 @@ int watchdog_register(struct watchdog *wd)
 
 	list_add_tail(&wd->list, &watchdog_list);
 
-	pr_debug("registering watchdog with priority %d\n", wd->priority);
+	pr_debug("registering watchdog %s with priority %d\n", watchdog_name(wd),
+			wd->priority);
 
 	return 0;
 }
@@ -70,6 +81,8 @@ int watchdog_set_timeout(unsigned timeout)
 	if (!wd)
 		return -ENODEV;
 
+	pr_debug("setting timeout on %s to %ss\n", watchdog_name(wd), timeout);
+
 	return wd->set_timeout(wd, timeout);
 }
 EXPORT_SYMBOL(watchdog_set_timeout);
diff --git a/include/watchdog.h b/include/watchdog.h
index a833aea..fd24b5b 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -15,6 +15,8 @@
 
 struct watchdog {
 	int (*set_timeout)(struct watchdog *, unsigned);
+	const char *name;
+	struct device_d *dev;
 	unsigned int priority;
 	struct list_head list;
 };
-- 
2.5.0


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

  parent reply	other threads:[~2015-08-26 11:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-26 11:17 Allow multiple restart/watchdog/reset-source handlers Sascha Hauer
2015-08-26 11:17 ` [PATCH 1/7] restart: replace reset_cpu with registered restart handlers Sascha Hauer
2015-08-26 11:17 ` [PATCH 2/7] watchdog: Allow multiple watchdogs Sascha Hauer
2015-08-26 11:17 ` Sascha Hauer [this message]
2015-08-26 11:17 ` [PATCH 4/7] reset-source: Use globalvar_add_simple_enum Sascha Hauer
2015-08-26 11:17 ` [PATCH 5/7] reset-source: Allow different priorities Sascha Hauer
2015-08-26 11:17 ` [PATCH 6/7] mfd: da9063: add da9063 watchdog and system restart driver Sascha Hauer
2015-08-26 11:17 ` [PATCH 7/7] mfd: da9053: add da9053 " 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=1440587836-22105-4-git-send-email-s.hauer@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