mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@kymetacorp.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/4] misc: Add iodevice support
Date: Thu, 10 Dec 2015 20:42:42 +0000	[thread overview]
Message-ID: <1449780168.26955.81.camel@rtred1test09.kymeta.local> (raw)
In-Reply-To: <1449565539-29374-2-git-send-email-s.hauer@pengutronix.de>

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?  

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.

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.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-12-10 20:44 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 [this message]
2015-12-11  7:37     ` Sascha Hauer
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=1449780168.26955.81.camel@rtred1test09.kymeta.local \
    --to=tpiepho@kymetacorp.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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