Tian haili @ csdn
2011/08/26
In the device driver model of Linux 2.6, all devices are connected by bus. When device_register ()/driver_register () is executed, the driver/device on the enumeration bus is used for binding. This article describes this process. This is the basis for the entire Linux device driver. The registration of platform devices, I2C devices, and other devices is also implemented by calling the registration function described in this article.
The registration of Linux device is ultimately implemented through device_register (), and the registration of driver is ultimately implemented through driver_register. The registration process of device and driver is described in comparison.
The diagram above is clear at a glance, and the detailed process will not be repeated. Note the following:
- Bus p-> drivers_autoprobe; 1 is true by default.
- Bus_for_each_drv () performs the _ device_attach () operation on all drivers on the bus. Similarly, bus_for_each_dev () performs the _ driver_attach () operation on all devices on the bus () operation.
- The. Match () function implemented on the bus defines the rules when device and driver are bound. For example, platform compares id_table and name rules first. If the bus match () function is not implemented, it is considered that all the devices and drivers on the bus are matched. The specific subsequent process depends on the implementation of probe.
- The probe rule is: If probe is implemented on the bus, the probe of the bus will be used; otherwise, the probe of the driver will be used.
Device is generally registered prior to the driver, but not all in this order. During the registration process of device and driver in Linux, all drivers and devices mounted on the bus are enumerated respectively to achieve this time series independence.
*** Welcome to reprint, and please indicate the original from http://blog.csdn.net/thl789/article/details/6723350 ***