Skip to content
Advertisement

Difference between spi_driver.id_table and spi_driver.driver.of_match_table

I’m currently trying to understand how linux drivers work. As far as I know, A driver’s probe/init function is called when the kernel parses the corresponding .compatible string in the device tree. However, in the arizona-spi driver it looks like there are multiple compatible strings referenced in different members:

JavaScript

This is an excerpt from here.

So what is the difference between arizona_spi_driver.id_table and arizona_spi_driver.driver.of_match_table?

Advertisement

Answer

There are several mechanism for driver matching. The id_table is intended to be used for finding a match from stripped device-tree entries (without vendor part), while of_match_table is used to find a match from full device-tree entries (the ones with vendor part).

If you check, arizona_of_match is defined as this:

JavaScript

wlf is the vendor part for this case, while arizona_spi_ids doesn’t contain the vendor part.

Hence, if you have something like this in your device tree:

compatible = “myvendor,wm5102”

Your device will match against id_table but not against of_match_table since the vendor is different.

The kernel will do matching against of_match_table first before check id_table (see spi_get_device_id in here). The device matching priority is: of_match_table > acpi_driver > id_table.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement