Hybrid Device Driver Model
In a Linux system, there are a class of character devices, which have the same main device number (10), but the second device number is different, we call this device a hybrid device (Miscdevice). All promiscuous devices form a linked list, and the kernel locates the corresponding promiscuous device according to the secondary device number when accessing the device.
I. Description of equipment
A struct miscdevice is used in Linux to describe a hybrid device.
1 structMiscdevice {2 intMinor/*Secondary Device number*/3 Const Char*name;/*Device Name*/4 Const structFile_operations *fops;/*file Operations*/5 structlist_head list;6 structDevice *parent;7 structDevice *This_device;8};
Minor is the secondary device number, name is the device name. There is also a struct file_operations structure that we need to initialize.
Second, equipment registration
Linux uses the Misc_register function to register a hybrid device driver.
int misc_register (struct miscdevice * misc)
So to implement a hybrid device driver. The first is to initialize our miscdevice structure, and then we use the Misc_register function to register a hybrid device.
Three, hybrid device driver summary
12. Hybrid Device Driver Model