From: Guenter Roeck <linux@roeck-us.net>
To: Justin Chen <justinpopo6@gmail.com>
Cc: linux-kernel@vger.kernel.org, wim@iguana.be,
linux-watchdog@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com
Subject: Re: [PATCH] watchdog_dev: Use device tree alias for naming watchdogs
Date: Tue, 1 Sep 2015 10:53:19 -0700 [thread overview]
Message-ID: <20150901175319.GA30006@roeck-us.net> (raw)
In-Reply-To: <CAJx26kVz2Sem6PSBgKnQoa+1zo1frsmhx8a7eJBC8v+WY=gpvA@mail.gmail.com>
On Tue, Sep 01, 2015 at 10:20:36AM -0700, Justin Chen wrote:
> On Sat, Aug 29, 2015 at 2:53 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> > On 08/28/2015 02:58 PM, Justin Chen wrote:
> >>
> >> 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>
> >
> >
> > Interesting idea. Checking through other subsystems, many others do the
> > same,
> > so it makes sense to use that mechanism.
> >
> > However, the id assignment should be in the calling code, in
> > __watchdog_register_device,
> > to avoid that another id, possibly conflicting, is assigned through the
> ida
> > mechanism.
> >
> > This is a bit more complicated than it looks like to ensure correct id
> > assignment.
> > Have a look into the i2c code to see how it is handled. Essentially we
> must
> > pass
> > the requested number to ida_simple_get().
> >
> > Thanks,
> > Guenter
>
> Ok that makes sense. I will put a wrapper function around ida_simple_get()
> that will request a specific number, if that fails then do a normal request.
> Something like this...
>
> ret = of_alias_get_id(....)
>
> id = ida_simple_get(&watchdog_ida, ret, ret, GFP_KERNEL);
>
ret, ret + 1
but something like
ret = of_alias_get_id(...);
if (ret >= 0)
id = ida_simple_get(&watchdog_ida, ret, ret + 1, GFP_KERNEL);
else
id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL);
if (id < 0)
return id;
would be better. Passing 'ret' directly would not work, because
ida_simple_get() expects an unsigned range as parameters, and
of_alias_get_id() can return a negative error code.
Thanks,
Guenter
next prev parent reply other threads:[~2015-09-01 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 21:58 [PATCH] watchdog_dev: Use device tree alias for naming watchdogs Justin Chen
2015-08-29 9:53 ` Guenter Roeck
[not found] ` <CAJx26kVz2Sem6PSBgKnQoa+1zo1frsmhx8a7eJBC8v+WY=gpvA@mail.gmail.com>
2015-09-01 17:53 ` Guenter Roeck [this message]
-- strict thread matches above, loose matches on Subject: below --
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=20150901175319.GA30006@roeck-us.net \
--to=linux@roeck-us.net \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=justinpopo6@gmail.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