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

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

 



On Wed, 4 May 2011, Daniel Baluta wrote:

> >  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

  yes, shortly after i asked, i refreshed my memory and teased out
most of the above, nice to have it confirmed, though.  thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux