小编Joh*_*ang的帖子

spi_driver.id_table 和 spi_driver.driver.of_match_table 的区别

我目前正在尝试了解 linux 驱动程序是如何工作的。据我所知,当内核解析设备树中相应的 .compatible 字符串时,会调用驱动程序的probe/init 函数。但是,在 arizona-spi 驱动程序中,似乎在不同的成员中引用了多个兼容的字符串:

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"
};
Run Code Online (Sandbox Code Playgroud)

这是这里的摘录。

那么 arizona_spi_driver.id_table 和 arizona_spi_driver.driver.of_match_table 有什么区别呢?

linux linux-device-driver linux-kernel device-tree

4
推荐指数
1
解决办法
2279
查看次数