From: Sascha Hauer <s.hauer@pengutronix.de>
To: Trent Piepho <tpiepho@kymetacorp.com>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/4] misc: Add iodevice support
Date: Fri, 11 Dec 2015 08:37:09 +0100 [thread overview]
Message-ID: <20151211073709.GU11966@pengutronix.de> (raw)
In-Reply-To: <1449780168.26955.81.camel@rtred1test09.kymeta.local>
On Thu, Dec 10, 2015 at 08:42:42PM +0000, Trent Piepho wrote:
> On Tue, 2015-12-08 at 10:05 +0100, Sascha Hauer wrote:
> > +int iodevice_register(struct iodevice *iodev)
> > +{
> > + const char *devname = NULL;
> > + int i, ret;
> > +
> > + if (iodev->hwdev->device_node) {
> > + devname = of_alias_get(iodev->hwdev->device_node);
> > + iodev->dev.id = DEVICE_ID_SINGLE;
> > + }
> > +
> > + if (!devname) {
> > + devname = "io";
> > + iodev->dev.id = DEVICE_ID_DYNAMIC;
> > + }
> > +
> > + strcpy(iodev->dev.name, devname);
> > +
> > + iodev->dev.parent = iodev->hwdev;
> > +
> > + ret = register_device(&iodev->dev);
>
> Why does every driver/subsystem need to implement its own alias
> support?
I think that has historic reasons. When beginning with device tree we
didn't want to change the behaviours of all unrelated drivers. Now that
we are more familiar with device tree and adopt the aliases approach to
more and more drivers you are right: We can push the alias resolving
out of the drivers and more to the framework level.
>
> Since register_device() has access to
> (&iodev->dev)->parent->device_node, couldn't it do the alias lookup
> instead, so that each driver doesn't need to?
>
> Then one could write:
>
> iodev->dev.parent = iodev->hwdev;
> strcpy(iodev->dev.name, "io");
> iodev->dev.id = DEVICE_ID_DYNAMIC;
> ret = register_device(&iodev->dev);
>
> I guess this doesn't work exactly for net drivers, since they want to do
> s/ethernet(\d+)/eth\1/ on the alias name.
The network drivers already do something similar. They pick only the
number from the "ethernetx" alias, see net/eth.c:
edev->dev.id = of_alias_get_id(edev->dev.parent->device_node, "ethernet");
>
> And some drivers create a cdev the alias should be applied to instead of
> a dev. Though I supposed devfs_create() could do the same thing.
I'm not sure if we should handle aliases in devfs_create(), but at least
we should handle it in the subsystem so that the individual drivers no
longer have to care about it.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-12-11 7:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-08 9:05 [RFC] " Sascha Hauer
2015-12-08 9:05 ` [PATCH 1/4] misc: Add " Sascha Hauer
2015-12-10 20:42 ` Trent Piepho
2015-12-11 7:37 ` Sascha Hauer [this message]
2015-12-08 9:05 ` [PATCH 2/4] misc: Add basic LM75 temperature driver Sascha Hauer
2015-12-08 9:05 ` [PATCH 3/4] misc: Add Microchip MCP342x support Sascha Hauer
2015-12-08 9:05 ` [PATCH 4/4] misc: Add PT100 temperature sensor support Sascha Hauer
2015-12-10 6:24 ` [RFC] iodevice support Andrey Smirnov
2015-12-10 10:25 ` 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=20151211073709.GU11966@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=tpiepho@kymetacorp.com \
/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