关于struct device_driver结构中的probe探测函数的调用
来源:互联网 发布:淘宝美工招聘信息深圳 编辑:程序博客网 时间:2024/05/01 18:12
用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函数此时被调用。
从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函数此时被调用。
0 0
- 关于struct device_driver结构中的probe探测函数的调用
- [转载]关于struct device_driver结构中的probe探测函数的调用
- 关于struct device_driver结构中的probe探测函数的调用(内核版本:2.6.29)
- struct device_driver的probe的调用
- struct device_driver的probe的调用
- struct device_driver的probe的调用
- i2c_driver的注册及probe探测函数调用
- struct device / device_driver 结构体
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数
- struct device_driver {
- struct device_driver
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 关于platform_driver 是如何匹配 platform_device的和如何调用到platform_driver中的probe函数的研究
- 改善异常处理的 6 个技巧
- base64编码解码-解决xml输出转义问题
- java实现的HTTP简易服务器
- android手势识别ViewFlipper触摸动画
- Hadoop2调优(一):如何控制job的map任务和reduce任务的数量
- 关于struct device_driver结构中的probe探测函数的调用
- android install location
- 回望 Linux 和开源技术 2014 的大起大落
- 使用apache ab命令压力测试时发送post请求
- TextView字体加粗
- 第十七周项目5:玩日期时间
- HDU - 1233 - 还是畅通工程 (最小生成树!!)
- Java多线程编程(十)-并发编程原理(分布式环境中并发问题)
- 输入一颗二元树,从上往下按层打印树的每个结点,同一层中按照从左往右的顺序打印