From: Justin Chen <justinpopo6@gmail.com>
To: <linux-kernel@vger.kernel.org>
Cc: <wim@iguana.be>, <linux-watchdog@vger.kernel.org>,
<bcm-kernel-feedback-list@broadcom.com>,
Justin Chen <justinpopo6@gmail.com>
Subject: [PATCH] watchdog_dev: Use device tree alias for naming watchdogs
Date: Fri, 28 Aug 2015 14:58:06 -0700 [thread overview]
Message-ID: <1440799086-14683-1-git-send-email-justinpopo6@gmail.com> (raw)
Currently there is no way to easily differentiate multiple
watchdog devices. The watchdogs are named by the order they
are probed.
1st probed watchdog: /dev/watchdog0
2nd probed watchdog: /dev/watchdog1
...
This change uses the alias of the watchdog device node for
the name of the watchdog.
aliases {
watchdog0 = "/...../...."
watchdog3 = "/..../....."
watchdog2 = "/..../....."
...
}
This will translate to...
/dev/watchdog0
/dev/watchdog3
/dev/watchdog2
Signed-off-by: Justin Chen <justinpopo6@gmail.com>
---
drivers/watchdog/watchdog_dev.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 6aaefba..52b1f0b 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -41,6 +41,7 @@
#include <linux/miscdevice.h> /* For handling misc devices */
#include <linux/init.h> /* For __init/__exit/... */
#include <linux/uaccess.h> /* For copy_to_user/put_user/... */
+#include <linux/of.h>
#include "watchdog_core.h"
@@ -522,7 +523,13 @@ static struct miscdevice watchdog_miscdev = {
int watchdog_dev_register(struct watchdog_device *watchdog)
{
- int err, devno;
+ int err, devno, ret;
+
+ if (watchdog->parent) {
+ ret = of_alias_get_id(watchdog->parent->of_node, "watchdog");
+ if (ret >= 0)
+ watchdog->id = ret;
+ }
if (watchdog->id == 0) {
old_wdd = watchdog;
--
2.1.0
next reply other threads:[~2015-08-28 21:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 21:58 Justin Chen [this message]
2015-08-29 9:53 ` Guenter Roeck
[not found] ` <CAJx26kVz2Sem6PSBgKnQoa+1zo1frsmhx8a7eJBC8v+WY=gpvA@mail.gmail.com>
2015-09-01 17:53 ` Guenter Roeck
2015-09-02 18:00 Justin Chen
2015-09-02 20:19 ` Guenter Roeck
2015-10-27 15:47 ` Wim Van Sebroeck
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=1440799086-14683-1-git-send-email-justinpopo6@gmail.com \
--to=justinpopo6@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=wim@iguana.be \
/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
all inboxes | Powered by JetHome®