Device and driver matching mechanism explained
Device drivers and devices are always registered with the bus. When it comes to exporting the devices that are supported by the driver, you can use driver.of_match_table
, driver.of_match_table
, or <bus>_driver.id_table
(which is specific to the device type; for example, i2c_device.id_table
or platform_device.id_table
).
Each bus driver has the responsibility of providing its match function, which is run by the kernel whenever a new device or device driver is registered with this bus. That said, there are three matching mechanisms for platform devices, all of which consist of string comparison. Those matching mechanisms are based on the DT table, ACPI table, device, and driver name. Let's see how the pseudo-platform and i2c buses implement their matching functions using those mechanisms:
static int platform_match(struct device *dev, ...