probe函数个人理解
来源:互联网 发布:pigalle红磨坊 知乎 编辑:程序博客网 时间:2024/05/16 05:31
主要是做一些初始化工作
1、首先这是从网上找到的相关对probe的描述
staticint 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;
} elseif (drv->probe) {
//2.再调用你的驱动中的probe函数:
ret= drv->probe(dev);
if (ret)
goto probe_failed;
}
...
}
{
...
//1.先是调用的驱动所属总线的probe函数:
if (dev->bus->probe) {
ret = dev->bus->probe(dev);
if (ret)
goto probe_failed;
} elseif (drv->probe) {
//2.再调用你的驱动中的probe函数:
ret= drv->probe(dev);
if (ret)
goto probe_failed;
}
...
}
2、probe函数执行的时机(以瑞芯微rk3026芯片为例)
i2c设备在arch/arm/mach-rk3026/board-rk3026-86v.c里面注册一些i2c设备信息,如:
static struct i2c_board_info __initdata i2c1_info[] = {
#if defined (CONFIG_GS_MMA7660)
{
.type = "gs_mma7660",//gs_mma7660
.addr = 0x4c,
.flags = 0,
.irq = MMA7660_INT_PIN,
.platform_data = &mma7660_info,
},
#endif
#if defined (CONFIG_GS_MMA8452){.type = "gs_mma8452",.addr = 0x1d,.flags = 0,.irq = MMA8452_INT_PIN,.platform_data = &mma8452_info,},#endif
}
其中mma8452_info是用户自己定义的结构体,定义为:
static int mma8452_init_platform_hw(void)
{
return 0;
}
static struct sensor_platform_data mma8452_info = {
.type = SENSOR_TYPE_ACCEL,
.irq_enable = 1,
.poll_delay_ms = 30,
.init_platform_hw = mma8452_init_platform_hw,
.orientation = {1, 0, 0, 0, -1, 0, 0, 0, 1},
};
这些信息用在哪先不用管。
所有的设备信息会通过i2c-core.c提供的接口,写到一个i2c全局的链表里面去;
i2c_adapter注册的时候就会扫描所有的已注册的2c_board_info,并为连接自己的i2c设备建立一个i2c_client。这样在2c_board_info中的同名i2c_driver注册的时候,i2c_client就会和i2c_driver绑定了,i2c_driver的probe函数被调用。
注:static const struct i2c_device_id sensor_id[] = {
/*gsensor*/
{"gsensor", ACCEL_ID_ALL},
{"gs_mma8452", ACCEL_ID_MMA845X},
{"gs_kxtik", ACCEL_ID_KXTIK},
{"gs_kxtj9", ACCEL_ID_KXTJ9},
{"gs_lis3dh", ACCEL_ID_LIS3DH},
{"gs_mma7660", ACCEL_ID_MMA7660},
{"gs_mxc6225", ACCEL_ID_MXC6225},
}
sensor_id结构体包含多少个和i2c_board_info相匹配,则probe函数就执行几次。(结果是验证过的,但不知道为什么)。
- probe函数个人理解
- probe函数
- mipi_dsim probe函数
- match()和probe()函数
- PROBE函数何时调用
- probe()函数何时调用
- lcd probe函数 赏析
- probe函数调用
- 个人对构造函数理解
- 似然函数个人理解
- USB Storage Probe 函数分析
- 驱动注册的probe函数
- s3c2410nandflash驱动probe函数解析
- Linux驱动 probe函数调用
- 驱动注册的probe函数
- platform驱动之probe函数
- 驱动注册的probe函数
- platform驱动之probe函数
- 百度搜索引擎
- 1.1 《硬啃设计模式》 第1章 大话设计模式
- xcode:关于Other Linker Flags
- LIRe提供的6种图像特征描述方法的评测
- android菜单机制
- probe函数个人理解
- Missian指南三:创建一个Missian服务器(使用spring)
- 三大框架整合ssh(三)-----service层
- c++ 析构函数为虚函数 可以防止内存泄露
- xcode编译错误总结
- Paper Notes: On Community Detection in Real-world Networks and the Importance of Degree Assortativit
- get和post的区别
- android中异步加载类AsyncTask的使用
- 机器学习中的相似性度量