Transferred from: http://blog.csdn.net/rockrockwu/article/details/7357648
System boot process platform device, the driver registration is complete, why in the/dev directory is automatically created a good device node?
The Automatically created device node in the/dev directory can be passed class_create () and then Device_create (). But in tracking
Kernel platform registration process can be found, in fact, there is no appeal two function, then platform registration
How do I create a device file node in the/dev directory?
[CPP]View PlainCopy
- int Device_add (struct device *dev)
- {
- ... ...
- if (MAJOR (dev->devt)) {
- Error = Device_create_file (dev, &devt_attr);
- if (Error)
- Goto Ueventattrerror;
- Error = Device_create_sys_dev_entry (dev);
- if (Error)
- Goto Devtattrerror;
- Devtmpfs_create_node (Dev);
- }
- ... ...
- }
In the process of Device_add can find the appeal code, first determine whether the dev in the device number, and some of the file creation
Finally, the device node is created in the/dev function through the function devtmpfs_dreate_node (dev).
Platform-type device automatically creates analysis "go" of device nodes in the/dev directory