porting driver 2.4 -> 2.6, confused by device model

Greg KH greg at kroah.com
Fri Feb 23 17:02:49 CST 2007


On Fri, Feb 23, 2007 at 03:27:40PM -0700, Sebastian Kuzminsky wrote:
> Hi folks, I've got a driver I wrote for 2.4 and now I'm trying to port
> it to 2.6.  The port was pretty straight-forward, but I'm having trouble
> figuring out how to make uevent/udev automatically creates the device
> nodes in /dev.
> 
> The hardware is a data acquisition device that sits on the ISA bus.
> It's got 16 ADCs, 2 DACs, and 8 bits of digital input and 8 bits
> of digital output.  In 2.4 my driver was a character device, and I
> represented each card by 19 minors.  The two 8-bit digitals were merged
> into one, differentiated by read vs write.  I statically created the
> device nodes in /dev, and each device node was easy to use with dd,
> hexdump, etc.
> 
> In the 2.6 driver I'd like to use dynamically allocated major & minor
> numbers, and I'd like device node creation to be automatic.  It seems
> like the cleaner way to go.
> 
> As far as I can tell, this device does not fit well into any of the
> existing classes.  LDD3 talks about a "simple" class, but it seems like
> it's been removed since that book was written.  Should I create a new
> class for the device?

Have you looked into the comedi interface?  It should provide what you
need for a framework that creates the proper device ids.  I think it
will end up in the kernel tree soon/eventually, so you might want to use
it.

> Should I create a cdev for each minor?  Seems that way.

No.

> Should I somehow call make a kobject for each device node and call
> kobject_uevent() directly?

If you really want to do this on your own, see the chapter about the
driver model in the book, Linux Device Drivers, third edition, online
for free, that talks about how to hook up your code to let udev work
properly.

Note that the book is a bit out of date, and the functions that it tells
you to use there are no longer present.  Instead use the device_create()
functions.

If you have specific questions after reading this, please let me know.

thanks,

greg k-h


More information about the Kernel-mentors mailing list