"Linux Drive Analytics" Misc device drivers

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.