Scroll to navigation

CDEV_DEVICE_ADD(9) Char devices CDEV_DEVICE_ADD(9)

NAME

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

SYNOPSIS

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

ARGUMENTS

cdev

the cdev structure

dev

the device structure

DESCRIPTION

cdev_device_add adds the char device represented by cdev to the system, just as cdev_add does. It then adds dev to the system using device_add The dev_t for the char device will be taken from the struct device which needs to be initialized first. This helper function correctly takes a reference to the parent device so the parent will not get released until all references to the cdev are released.

This helper uses dev->devt for the device number. If it is not set it will not add the cdev and it will be equivalent to device_add.

This function should be used whenever the struct cdev and the struct device are members of the same structure whose lifetime is managed by the struct device.

NOTE

Callers must assume that userspace was able to open the cdev and can call cdev fops callbacks at any time, even if this function fails.

COPYRIGHT

June 2024 Kernel Hackers Manual 3.10