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

转自: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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值