The Linux device model has three important concepts: Bus, device, driver, namely bus, device, and driver.

Source: Internet
Author: User

ZZ from http://blog.csdn.net/fudan_abc/archive/2007/06/23/1662739.aspx

By the way, record this blog: the Linux USB driver development of Mingyue may be available in the future.


The three important concepts of the Linux device model are bus, device, and driver. that is, bus, device, driver. In fact, the kernel also defines such data structures. They are struct bus_type, struct device, struct device_driver, all three important data structures come from one place, including/Linux/device. h. we know that there are many bus types, such as PCI bus, SCSI bus, and USB bus, so we will see the Linux KernelCodePci_bus_type, scsi_bus_type, and usb_bus_type appear. They are all struct bus_type variables. in the struct bus_type structure, two very important members are struct kset drivers and struct kset devices. kset and kobject are the basic elements of the device model in Linux kernel 2.6, but we don't want to talk about them here because we don't need to know them for the time being. we will encounter many people and things in our lives, but more people and things just pass us by, just passing by in our lives. in our life movies, they may have only one camera, or even the camera was cut off later. here we only need to know that the existence of drivers and devices makes struct bus_type relate to two linked lists, one is the devices linked list and the other is the drivers linked list, that is, knowing the data structure corresponding to a bus, you can find out which devices are associated with the bus and which drivers support these devices.Program.

To achieve this, you need to report to the bus every time a device appears, or register it. Each time a driver appears, you need to report to the bus or register it. for example, when the system is initialized, It scans which devices are connected and creates a variable of struct device for each device. Each time there is a driver, prepare a variable in the struct device_driver structure. add all these variables to the corresponding linked list, insert device into the devices linked list, and insert driver into the drivers linked list. in this way, each device and driver can be found through the bus.

However, if only the device has no corresponding driver in the computer, the device cannot work. in turn, if only the driver has no device, the driver will not play any role. before they met each other, both sides were like the weeds on the same path. One was floating, one was shaking, and no one knew where the future was. They could only shake in the wind of life. as a result, the two tables on the bus slowly hung up the many lonely souls. there are more devices, and more drivers. They are like two from the world. The devices are warm to each other, and the drivers are Carnival together, but one of them is the same, they are waiting for the other half of their own.

I have always been curious about the code to see if they are the same as in our reality. Some are destined to wait for others, while others are destined to be waited.

 

Related Article

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.