声明:以下主要内容参考自:
关于struct device_driver结构中的probe探测函数的调用
http://blog.chinaunix.net/u2/71164/showart.php?id=1361188用SourceInsight跟踪:
从driver_register看起,此处我的这里是:
int driver_register(struct device_driver * drv)
{
if ((drv->bus->probe && drv->probe) ||(drv->bus->remove && drv->remove) ||(drv->bus->shutdown && drv->shutdown)) {printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name);
}
klist_init(&drv->klist_devices, NULL, NULL);
return bus_add_driver(drv);
}klist_init不相关,不用管他,具体再去看bus_add_driver:int bus_add_driver(struct device_driver *drv)
{
1.先kobject_set_name(&drv->kobj, "%s", drv->name);
2.再kobject_register(&drv->kobj)
3.然后调用了:driver_attach(drv)
}int driver_attach(struct device_driver * drv)
{
return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
}真正起作用的是__driver_attach:static int __driver_attach(struct device * dev, void * data)
{
。。。
if (!dev->driver)driver_probe_device(drv, dev);
。。。
}int driver_probe_device(struct device_driver * drv, struct device * dev)
{
。。。
//1.先是判断bus是否match:
if (drv->bus->match && !drv->bus->match(dev, drv))goto done;
//2.再具体执行probe:
ret = really_probe(dev, drv);
。。。
}really_probe才是我们要找的函数:
static int really_probe(struct device *dev, struct device_driver *drv)
{
。。。
//1.先是调用的驱动所属总线的probe函数:
if (dev->bus->probe) {ret = dev->bus->probe(dev);if (ret)goto probe_failed;} else if (drv->probe) {
//2.再调用你的驱动中的probe函数:ret = drv->probe(dev);if (ret)goto probe_failed;
}
。。。
}其中,drv->probe(dev),才是真正调用你的驱动实现的具体的probe函数。
也就是对应此文标题所问的,probe函数此时被调用。

转载于:https://www.cnblogs.com/yuzaipiaofei/archive/2011/09/29/4124317.html

【整理】Linux驱动中,probe函数何时被调用相关推荐

  1. linux驱动中probe函数是怎么调用的

    linux驱动的三个概念:设备.驱动.总线 probe何时被调用:在总线上驱动和设备的名字匹配,就会调用驱动的probe函数 probe函数被调用后,系统就调用platform设备的probe函数完成 ...

  2. linux probe函数调用,Linux驱动中probe函数何时被调用?

    关于struct device_driver结构中的probe探测函数的调用 用SourceInsight跟踪: 从driver_register看起,此处我的这里是: int driver_regi ...

  3. linux probe函数调用,linux spi设备驱动中probe函数何时被调用

    这两天被设备文件快搞疯了,也怪自己学东西一知半解吧,弄了几天总算能把设备注册理清楚一点点了.就以spi子设备的注册为例总结一下,免得自己忘记. 首先以注册一个spidev的设备为例: static s ...

  4. linux中 probe函数的何时调用的?

    点击打开链接 linux中 probe函数何时调用的 所以的驱动教程上都说:只有设备和驱动的名字匹配,BUS就会调用驱动的probe函数,但是有时我们要看看probe函数里面到底做了什么,还有传递给p ...

  5. linux中probe函数的pm管理,linux中 probe函数的何时调用的

    所以的驱动教程上都说:只有设备和驱动的名字匹配,BUS就会调用驱动的probe函数,但是有时我们要看看probe函数里面到底做了什么,还有传递给probe函数的参数我们就不知道在哪定义(反正不是我们在 ...

  6. linux probe函数调用,【整理】Linux驱动中,probe函数何时被调用

    [整理]Linux驱动中,probe函数何时被调用 用SourceInsight跟踪: 从driver_register看起,此处我的这里是: int driver_register(struct d ...

  7. Linux驱动中,probe函数何时被调用

    最近看到linux的设备驱动模型,关于Kobject.Kset等还不是很清淅.看到了struct device_driver这个结构时,想到一个问题:它的初始化函数到底在哪里调用呢?以前搞PCI驱动时 ...

  8. linux中probe函数中传递的参数来源(上)

    点击打开链接 上一篇中,我们追踪了probe函数在何时调用,知道了满足什么条件会调用probe函数,但probe函数中传递的参数我们并不知道在何时定义,到底是谁定义的,反正不是我们在驱动中定义的(当然 ...

  9. linux中probe函数传递参数的寻找(下)

    点击打开链接 linux中probe函数传递参数的寻找(下) 通过追寻driver的脚步,我们有了努力的方向:只有找到spi_bus_type的填充device即可,下面该从device去打通,当两个 ...

最新文章

  1. (C++)判断一个序列是non-increasing/non-decreasing还是两者都不的两个方法
  2. springAop @AfterReturning注解 获取返回值
  3. 华为链路汇聚命令(静态)
  4. 让您的Eclipse具有千变万化的外观
  5. java中char类型_【考点】JAVA中的char类型
  6. 基于mysql数据库的应用_MySQL数据库应用
  7. C++泛型编程实现哈希表(闭散列---线性探测)
  8. Nodejs架构之json空处理
  9. android webview 图表,Android WebView 无法正常显示网页图表
  10. php 大型系统开法流程图,有一个php项目源码,如何搞清楚执行过程?画出其流程图...
  11. Bootstrap CSS 编码规范之Less 和 Sass 中的操作符
  12. sheet中没有getcolumns()方法吗_家庭亲子教育中的八种方法,你做到了吗?
  13. vscode快捷键:多行同时输入
  14. MySQL · 引擎介绍 · Sphinx源码剖析(二)
  15. mysql的学习笔记(六)
  16. Tomcat + Spring MVC + HttpClient:怎样使用PUT和PATCH方法传递数据
  17. 代码检查技术Checkstyle与p3c调研
  18. win10系统无法删除文件提示找不到该项目解决办法
  19. 黑马程序员-随笔-我与程序员
  20. mysql中重复数据的查询

热门文章

  1. Jenkins 快速上手指南
  2. 网易SRC指责白帽子私自披露已修复漏洞,强势表态违刑必究
  3. 详解COOKIE和SESSION关系和区别
  4. [coursera machine learning] Week 1
  5. json.parse()和json.stringify()
  6. Servlet3.0 Test
  7. 在Eclipse中制作SSH配置文件提示插件
  8. Exchange 2003允许部分用户发送邮件到部分外网服务器
  9. 现在可以插入MSN表情了
  10. Git提交到多个远程仓库(多看两个文档)