【技术】ACPI 启动下platform_driver定义时是否要用of_match_ptr

匿名 (未验证) 提交于 2019-12-03 00:22:01

转自:https://blog.csdn.net/tiantao2012/article/details/72779331
一般驱动要同时兼容dt和acpi的话,需要在定义platform_driver的时候同时指定of_match_table和acpi_match_table

static struct platform_driver hns_nic_dev_driver = {     .driver = {         .name = "hns-nic",         .of_match_table = hns_enet_of_match,         .acpi_match_table = ACPI_PTR(hns_enet_acpi_match),     },     .probe = hns_nic_dev_probe,     .remove = hns_nic_dev_remove, };

但是这段code,其实按照下面的写法会更好

static struct platform_driver hns_nic_dev_driver = {     .driver = {         .name = "hns-nic",         .of_match_table = of_match_ptr(hns_enet_of_match),         .acpi_match_table = ACPI_PTR(hns_enet_acpi_match),     },     .probe = hns_nic_dev_probe,     .remove = hns_nic_dev_remove, };

即和ACPI_PTR对应的是of_match_ptr

#ifdef CONFIG_OF #define of_match_ptr(_ptr)    (_ptr) #else #define of_match_ptr(_ptr)    (null) #endif

同样ACPI_PTR的定义如下:

#ifdef CONFIG_ACPI #define ACPI_PTR(_ptr)    (_ptr) #else #define of_match_ptr(_ptr)    (null) #endif

但是现实情况是CONFIG_ACPI和CONFIG_OF 会同时定义,因为ACPI启动下需要通过dt来得到systab.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!