Embedded Linux development practice (16): Linux driver model driver model

Insert image description here

Driver model under embedded Linux:

1. Driver binding

driver binding driver binding

Driver binding is the process of associating a device device with a device driver that can control it. Bus drivers usually handle this because there are bus-specific structures to represent device devices and drivers. Using common device and device driver structures, most bindings can be made using common code.

Bus

The bus type structure contains a list of all devices on that bus type in the system. When device_register is called for a device, it is inserted at the end of the list. The bus object also contains a list of all drivers for that bus type. When driver_register is called for a driver, it is inserted at the end of the list. These are two events that trigger driver binding, one is device_register and the other is driver_register.

Device register device_register

When a new device is added, the bus's driver list is iterated to find a driver that supports it. In order to determine this, the device's device ID must match one of the device IDs supported by the driver. The format and semantics of comparison IDs are bus-specific. Rather than trying to derive complex state machines and matching algorithms, the bus driver provides a callback that compares the device to the driver's ID. Returns 1 if a match is found; 0 otherwise.
int match (struct device dev, struct device dev

Guess you like

Origin blog.csdn.net/weixin_49369227/article/details/132687024