Messages in this thread | | | Subject | Re: UIO device name | From | Joakim Tjernlund <> | Date | Wed, 24 Sep 2008 13:33:01 +0200 |
| |
On Wed, 2008-09-24 at 12:22 +0200, Hans J. Koch wrote: > On Wed, Sep 24, 2008 at 11:57:59AM +0200, Joakim Tjernlund wrote: > > On Wed, 2008-09-24 at 18:35 +0900, Paul Mundt wrote: > > > On Wed, Sep 24, 2008 at 11:21:33AM +0200, Joakim Tjernlund wrote: > > > > As far as I can see there isn't a way to name the /dev/uio%d device file > > > > to something more useful, is that so? > > > > I would like to name the device file from within the kernel so I can > > > > find the correct device from userspace. > > > > The very least is to control the minor(%d) number. > > > > > > > You have a couple of options for this: > > > > > > - the 'name' sysfs entry for each of the uio devices, which > > > corresponds to the uio device name. > > > - extracting the relevant data from things like 'lsuio'. > > > - hooking in the pretty mame through udev to create an alias. > > > > Right, but I want to do it from within the kernel when I create the > > device because that the only place I truly know what HW the uio maps to. > > Set info->name to something that's useful for the userspace part of the > driver. You can create an individual string for each HW so userspace can > easily identify the devices. The string in info->name can be anything > you like, it's only used as info given in the "name" sysfs file.
All suggestions so far implies changes i 3 different areas, the kernel needs to set a name, then udev(I am using mdev btw so that won't work for me) or add some RC scripts to translate the name to the wanted /dev/name and then the app needs to know the name.
The udev/scripts is pure overhead and makes it harder for me to have a generic root FS. I don't see why not uio can offer the kernel to select another name than the standard uio%d name.
> > > > > I found that this works: > > struct uio_info *info, > > struct uio_device *idev; > > > > idev = info->uio_dev; > > device_rename(idev->dev, "irq4"); > > > > but then I have to copy the private uio_device struct from uio.c > > That's a clear sign that the UIO authors didn't want people to do that > ;-) > > > Is there a better way to get at idev->dev? > > No hackery, please. The "name" attribute is there for this purpose, use > it. Or use one of the other possibilities Paul mentioned.
Yes, this is a hack until UIO has a proper API for choosing a name other than uio%d. Seems like it is very essy to do, just pass the wanted name to __uio_register_device() and offer an new uio_register_device_name() method or add a dev_name field to struct uio_info.
Jocke
| |