Re: can't find device_create funtion in a driver containing cdev (habanalabs)

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

 



On Thu, Apr 29, 2021 at 09:56:09AM +0900, ckim@xxxxxxxxxx wrote:
> Hi, Greg KH,
> 
> To me cdev_device_add seems to be calling only cdev_add(below). 
> In this case since dev->devt already holds dev_t value ("hl%d"), it just
> sets cdev_set_parent and cdev_add. 
> 
> int cdev_device_add(struct cdev *cdev, struct device *dev)
> {       
>     int rc = 0;
>         
>     if (dev->devt) {
>         cdev_set_parent(cdev, &dev->kobj);
> 
>         rc = cdev_add(cdev, dev->devt, 1);
>         if (rc)
>             return rc;
>     }   
>     
>     rc = device_add(dev);

Right here is the line you are looking for.

device_create() is a wrapper around a call to device_initialize() and
device_add().  To use cdev_device_add() you have to have already called
device_initialize() which the habannalabs code already did.

Only on device_add() is the device really "added" to the driver core,
and the uevents are sent out and lots of other stuff happens.
device_create() wraps a lot of housekeeping logic up into a simpler call
if your driver doesn't need that level of flexibility, but there is no
requirement to call only it at all.

Hope this helps,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://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