zoukankan      html  css  js  c++  java
  • linux内核源码分析plat-form 分析

    先贴出调用拓扑图:

    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字段。

  • 相关阅读:
    ubuntu 软件管理
    java split方法
    linux tcpdump抓包
    linux 文件压缩与解压
    AngularJs出现错误Error: [ng:areq]
    php 跨域设置
    npm 安装完bower 后,提示'bower' 不是内部或外部命令
    less--Module build failed: TypeError: loaderContext.getResolve is not a function
    npm init npm ERR! code EINVALIDTAGNAME
    yarn报错:Found incompatible module
  • 原文地址:https://www.cnblogs.com/hulig7/p/9927857.html
Copyright © 2011-2022 走看看