Misc Device driver. Also known as hybrid device driver.
Misc Device driver shares a device driver number misc_major. It is defined in Include\linux\major.h:
#define MISC_MAJOR the structure of the miscdevice is as follows, itDefined in Include\linux\miscdevice.h:struct Miscdevice {int minor;const char *name;const struct File_operations *fops;struct List_head list;struct device *parent;struct device *this_device;const char *nodename;mode_t mode;};Misc Device-driven registration and logoff with these two functions, they are also defined in the include\linux\miscdevice.h:extern int Misc_register (struct miscdevice * misc);extern int Misc_deregister (struct miscdevice *misc);
Example: When this device number is redistributed, it can be set to Misc_dynamic_minor. This will voluntarily assign this device number, such as:static struct Miscdevice misc = {. minor = Misc_dynamic_minor,. Name = Device_name,. FoPs = &dev_fops,};The following is the file_operations structure:static struct File_operations dev_fops = {. Owner = This_module,. Unlocked_ioctl = Sbc2440_leds_ioctl,};Registration and Logoff functions:static int __init dev_init (void){int ret;... ....
ret = Misc_register (&MISC);PRINTK (device_name "\tinitialized\n");return ret;}
static void __exit dev_exit (void){Misc_deregister (&MISC);}
"Linux Drive Analytics" Misc device drivers