【整理】Linux驱动中,probe函数何时被调用
声明:以下主要内容参考自:
关于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函数何时被调用相关推荐
- linux驱动中probe函数是怎么调用的
linux驱动的三个概念:设备.驱动.总线 probe何时被调用:在总线上驱动和设备的名字匹配,就会调用驱动的probe函数 probe函数被调用后,系统就调用platform设备的probe函数完成 ...
- linux probe函数调用,Linux驱动中probe函数何时被调用?
关于struct device_driver结构中的probe探测函数的调用 用SourceInsight跟踪: 从driver_register看起,此处我的这里是: int driver_regi ...
- linux probe函数调用,linux spi设备驱动中probe函数何时被调用
这两天被设备文件快搞疯了,也怪自己学东西一知半解吧,弄了几天总算能把设备注册理清楚一点点了.就以spi子设备的注册为例总结一下,免得自己忘记. 首先以注册一个spidev的设备为例: static s ...
- linux中 probe函数的何时调用的?
点击打开链接 linux中 probe函数何时调用的 所以的驱动教程上都说:只有设备和驱动的名字匹配,BUS就会调用驱动的probe函数,但是有时我们要看看probe函数里面到底做了什么,还有传递给p ...
- linux中probe函数的pm管理,linux中 probe函数的何时调用的
所以的驱动教程上都说:只有设备和驱动的名字匹配,BUS就会调用驱动的probe函数,但是有时我们要看看probe函数里面到底做了什么,还有传递给probe函数的参数我们就不知道在哪定义(反正不是我们在 ...
- linux probe函数调用,【整理】Linux驱动中,probe函数何时被调用
[整理]Linux驱动中,probe函数何时被调用 用SourceInsight跟踪: 从driver_register看起,此处我的这里是: int driver_register(struct d ...
- Linux驱动中,probe函数何时被调用
最近看到linux的设备驱动模型,关于Kobject.Kset等还不是很清淅.看到了struct device_driver这个结构时,想到一个问题:它的初始化函数到底在哪里调用呢?以前搞PCI驱动时 ...
- linux中probe函数中传递的参数来源(上)
点击打开链接 上一篇中,我们追踪了probe函数在何时调用,知道了满足什么条件会调用probe函数,但probe函数中传递的参数我们并不知道在何时定义,到底是谁定义的,反正不是我们在驱动中定义的(当然 ...
- linux中probe函数传递参数的寻找(下)
点击打开链接 linux中probe函数传递参数的寻找(下) 通过追寻driver的脚步,我们有了努力的方向:只有找到spi_bus_type的填充device即可,下面该从device去打通,当两个 ...
最新文章
- (C++)判断一个序列是non-increasing/non-decreasing还是两者都不的两个方法
- springAop @AfterReturning注解 获取返回值
- 华为链路汇聚命令(静态)
- 让您的Eclipse具有千变万化的外观
- java中char类型_【考点】JAVA中的char类型
- 基于mysql数据库的应用_MySQL数据库应用
- C++泛型编程实现哈希表(闭散列---线性探测)
- Nodejs架构之json空处理
- android webview 图表,Android WebView 无法正常显示网页图表
- php 大型系统开法流程图,有一个php项目源码,如何搞清楚执行过程?画出其流程图...
- Bootstrap CSS 编码规范之Less 和 Sass 中的操作符
- sheet中没有getcolumns()方法吗_家庭亲子教育中的八种方法,你做到了吗?
- vscode快捷键:多行同时输入
- MySQL · 引擎介绍 · Sphinx源码剖析(二)
- mysql的学习笔记(六)
- Tomcat + Spring MVC + HttpClient:怎样使用PUT和PATCH方法传递数据
- 代码检查技术Checkstyle与p3c调研
- win10系统无法删除文件提示找不到该项目解决办法
- 黑马程序员-随笔-我与程序员
- mysql中重复数据的查询