To use a character driver, first you should register it with the system. Then you should expose it to the user space.
1. cdev_init
and cdev_add
functions perform the character device registration. cdev_add
adds the character device to the system. When cdev_add
function successfully completes, the device is live and the kernel can invoke its operations.
2. class_create is used to create a virtual device class, so that in the user space this virtual device node under /dev can be accessed, first of all under the folder sys/class there will have one classfolder under which contains the all specified devices. After this then creating a device and registering it with sysfs
using the device_create function. device_create
will create a device file in /dev.
more kernel function can refer this link, where all the function and headfile components will be listed.
kernel function library