linux内核源码分析platform分析风

您所在的位置:网站首页 linux开源代码在哪 linux内核源码分析platform分析风

linux内核源码分析platform分析风

2023-03-15 03:56| 来源: 网络整理| 查看: 265

先贴出调用拓扑图:

driver_init   platform_driver_register     if (drv->probe)       drv->driver.probe = platform_drv_probe;     driver_register       bus_add_driver         driver_attach           bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); // 扫面bus上每个设备,调用__driver_attach             driver_probe_device             if (drv->bus->match && !drv->bus->match(dev, drv)) // 调用bus->match , bus_type             really_probe               ret = dev->bus->probe(dev); // 实际上就是驱动程序实现的probe

 

再看match

platform_driver_register

  drv->driver.bus = &platform_bus_type;        // platform_bus_type 定义如下

struct bus_type platform_bus_type = { .name = "platform", .dev_attrs = platform_dev_attrs, .match = platform_match, .uevent = platform_uevent, .suspend = platform_suspend, .suspend_late = platform_suspend_late, .resume_early = platform_resume_early, .resume = platform_resume, };

 

 

可以看到bus->match 最终就是platform_match

platform_match   return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0);

 

这里就明白了, 实际上, match是根据device 和 driver 的name字段。

 



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3