porting driver 2.4 -> 2.6, confused by device model
Greg KH
greg at kroah.com
Sat Feb 24 23:46:15 CST 2007
On Sat, Feb 24, 2007 at 12:24:12AM -0700, Sebastian Kuzminsky wrote:
> Greg KH <greg at kroah.com> wrote:
> > On Fri, Feb 23, 2007 at 11:03:04PM -0700, Sebastian Kuzminsky wrote:
> > > One thing I'm not sure how to do, I'd like to group the device files
> > > in directories. Something like /dev/dmm/cardX/adcY. How do I create
> > > the directories?
> >
> > Create a udev rule that adds them in a subdirectory. See the rule that
> > creates the /dev/bus/usb/BUS_NUM/DEVICE_NUM directories for an example
> > of one way to do this.
>
> Yeah, I see how that's done, good example. Man, that's some funky syntax!
>
> That'd take care of the /dev nodes, but it'd be nice if the /sys/class/dmm
> tree was organized the same way. (dmm is my module and class, named
> for the Diamond-MM card that it drives.)
Yeah, we've tried doing that in the past, that is why you are using a
real device now, not a struct class_device. You can show the heiarchy
that way:
$ tree /sys/class/sound/
/sys/class/sound/
|-- card0 -> ../../devices/pci0000:00/0000:00:1b.0/card0
|-- controlC0 -> ../../devices/pci0000:00/0000:00:1b.0/card0/controlC0
|-- pcmC0D0c -> ../../devices/pci0000:00/0000:00:1b.0/card0/pcmC0D0c
|-- pcmC0D0p -> ../../devices/pci0000:00/0000:00:1b.0/card0/pcmC0D0p
|-- pcmC0D2c -> ../../devices/pci0000:00/0000:00:1b.0/card0/pcmC0D2c
|-- pcmC0D6c -> ../../devices/pci0000:00/0000:00:1b.0/card0/pcmC0D6c
|-- pcmC0D6p -> ../../devices/pci0000:00/0000:00:1b.0/card0/pcmC0D6p
`-- timer -> ../../devices/virtual/sound/timer
> I was hoping I could just give the full paths to device_create(),
> but that fails. Can the "parent" argument to device_create() be used
> for this? Currently I'm passing in NULL for all the parents.
Yes, set the parent properly, and you can show a tree properly, that's
what the parent pointer is for.
thanks,
greg k-h
More information about the Kernel-mentors
mailing list