After a Linux kernel version of 2.6, devfs no longer exists, and udev becomes a replacement for devfs. Compared with devfs, udev has many advantages, so it won't be long-winded here. Note that udev is the application layer, so do not try to find it in the Kernel configuration options; it is very easy to add udev support, take the character Device Driver written by the author as an example.CodeCall class_create to create a class for the device, and then call
Class_device_create: create a device. The general usage is as follows:
Struct class * myclass = class_create (this_module, "my_device_driver ");
Class_device_create (myclass, null, mkdev (major_num, 0), null, "my_device ");
When such a module is loaded , Udev daemon will automatically create the my_device file under/dev .
Class_create ()
-------------------------------------------------
Linux-2.6.22/include/Linux/device. h
Struct class * class_create (struct module * owner, const char * name)
Class_create-create a struct Class Structure
@ Owner: pointer to the module that is to "own" This struct class
@ Name: pointer to a string for the name of this class.
Create a class directory under/sys/class/
Class_device_create ()
-------------------------------------------------
Linux-2.6.22/include/Linux/device. h
Struct class_device * class_device_create (struct class * CLs,
Struct class_device * parent,
Dev_t devt,
Struct device * device,
Const char * FMT ,...)
Class_device_create-creates a Class Device and registers it with sysfs
@ CLS: pointer to the struct class that this device shoshould be registered.
@ Parent: pointer to the parent struct class_device of this new device, if any.
@ Devt: The dev_t for the char device to be added.
@ Device: a pointer to a struct device that is assiociated with this class device.
@ FMT: string for the class device's name