1CDEV_DEVICE_ADD(9)               Char devices               CDEV_DEVICE_ADD(9)
2
3
4

NAME

6       cdev_device_add - add a char device and it's corresponding struct
7       device, linkink
8

SYNOPSIS

10       int cdev_device_add(struct cdev * cdev, struct device * dev);
11

ARGUMENTS

13       cdev
14           the cdev structure
15
16       dev
17           the device structure
18

DESCRIPTION

20       cdev_device_add adds the char device represented by cdev to the system,
21       just as cdev_add does. It then adds dev to the system using device_add
22       The dev_t for the char device will be taken from the struct device
23       which needs to be initialized first. This helper function correctly
24       takes a reference to the parent device so the parent will not get
25       released until all references to the cdev are released.
26
27       This helper uses dev->devt for the device number. If it is not set it
28       will not add the cdev and it will be equivalent to device_add.
29
30       This function should be used whenever the struct cdev and the struct
31       device are members of the same structure whose lifetime is managed by
32       the struct device.
33

NOTE

35       Callers must assume that userspace was able to open the cdev and can
36       call cdev fops callbacks at any time, even if this function fails.
37
39Kernel Hackers Manual 3.10         June 2019                CDEV_DEVICE_ADD(9)
Impressum