registering a character driver without cdev_init()/cdev_add()

Daniel Baluta daniel.baluta at gmail.com
Wed May 4 07:45:15 EDT 2011


>  so rather than the canonical combination of cdev_init() and
> cdev_add(), this appears to register the pre-defined DSP56K major
> number, then goes straight to registering the driver with sysfs.
>

Check register_chrdev code. [1]
As you can see register_chrdev does cdev_alloc + cdev_add.

>  is this now an alternative way of registering character drivers, if
> you want to register them with sysfs as well?  as i read it,
> device_create() will create the /dev file so is this just a newer way
> to register character drivers?

Yes, it is an alternative way of registering chrdev, but it doesn't have
anything to do with sysfs layer.

* device_create
  * creates a device object and link it into sysfs tree.
  * generates an event -> udev  creates /dev/ file in userspace.
* register_chrdev - reserves major/minor and sets up char device
file operations.
>
>  i don't think i've run across any other drivers that have this
> structure but, then again, i haven't been looking that hard.  yet.

thanks,
Daniel.

[1] http://lxr.linux.no/linux+v2.6.38/fs/char_dev.c#L264



More information about the Kernelnewbies mailing list