Transferred from: http://blog.csdn.net/thl789/article/details/6723350
In the Linux 2.6 device-driven model, all devices are connected by bus. Device_register ()/Driver_register () executes the binding by enumerating the Driver/device on the bus, this article describes the process. This is the basis of the entire Linux device driver, platform devices, devices such as I²c's registration is ultimately called the registration function described in this article to achieve.
the registration of Linux device is finally realized through Device_register (), and driver's registration is finally realized through Driver_register () . The registration process for device and driver is illustrated in comparison.
The above diagram at a glance, the detailed process no longer repeat. Note the following remarks:
- The p->drivers_autoprobe;1 of bus is true by default.
- Bus_for_each_drv () is a __device_attach () operation on all driver on the bus, andBus_for_each_dev() is also a __driver_attach () operation on all device on the bus.
- The . Match () function implemented on the bus that defines the rules for device and driver binding. Platform, for example, is to compare id_table first and then compare the rules for name. If the bus's match () function is not implemented, it is assumed that all the device and driver on the bus are match, and the specific follow-up process depends on the implementation of probe ().
- probe rule is : if the bus on the realization of probe on the bus probe, otherwise will be used driver probe.
device is generally registered before driver , but it is not all in this order. The registration process for Linux device and driver enumerates all driver and device hooks on the bus, respectively, to achieve this timing independence.
Linux Platform Device/driver (iii)--platform device and Platform_driver registration process code Comparison