linux id_table与of_match_table
来源:互联网 发布:linux图标为什么是企鹅 编辑:程序博客网 时间:2024/05/18 03:06
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:
static const struct spi_device_id arizona_spi_ids[] = {{ "wm5102", WM5102 },{ "wm5110", WM5110 },{ },};MODULE_DEVICE_TABLE(spi, arizona_spi_ids);static struct spi_driver arizona_spi_driver = {.driver = { .name = "arizona", .owner = THIS_MODULE, .pm = &arizona_pm_ops, // Contains e.g. "wlf,wm5102" .of_match_table = of_match_ptr(arizona_of_match),},.probe = arizona_spi_probe,.remove = arizona_spi_remove,.id_table = arizona_spi_ids, // Contains "wm5102" and "wm5110"};
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?
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:
const struct of_device_id arizona_of_match[] = { { .compatible = "wlf,wm5102", .data = (void *)WM5102 }, { .compatible = "wlf,wm5110", .data = (void *)WM5110 }, { .compatible = "wlf,wm8280", .data = (void *)WM8280 }, { .compatible = "wlf,wm8997", .data = (void *)WM8997 }, {},};
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 (seespi_get_device_id in here). The device matching priority is: of_match_table > acpi_driver > id_table.
- linux id_table与of_match_table
- 关于platform中的id_table
- 关于platform中的id_table
- id_match_table和id_table
- 驱动中id_table的分析
- 驱动中id_table的分析(Input/I2C)
- 驱动中id_table的分析(Input/I2C)
- 【I2C设备驱动】必须将id_table[]数组的最后一个元素设置为空的原因
- Linux与硬盘分区
- Linux与硬盘分区
- Linux 程序与资源管理
- Pthread 与 Linux
- Linux与硬盘分区
- linux 与 tv
- 启动与关闭Linux
- LINUX 站点与软件
- linux压缩与解压缩
- Linux与硬盘分区
- 隐马尔科夫过程简介(一)
- PHP-wampserver配置Apache框架的本地web服务
- C++不同发展方向的知识点储备
- week1
- 练习1: 使用公式C=(5/9)(F-32)打印下列华氏温度与摄氏温度对照表。
- linux id_table与of_match_table
- c++中的函数模板和类模板
- WOJ1351-Olympic
- 富文本编辑器UEditor的配置使用方法
- Java实现几种最短路径问题
- Git and Github
- 根据实例化bean用get,set获得所有属性值
- 数字和为sum的方法数 滴滴笔试题
- CentOS7下安装Scrapy