Re: [PATCH 1/4] misc: Add iodevice support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux