i2c_driver的detect函数的调用
来源:互联网 发布:森海塞尔大馒头 知乎 编辑:程序博客网 时间:2024/05/16 05:36
在i2c_register_adapter 中会调用
/* Notify drivers */
mutex_lock(&core_lock);
bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
mutex_unlock(&core_lock);
来通知所有总线类型是i2c_bus_type的driver,现在已经增加新增加了adapter了
static int __process_new_adapter(struct device_driver *d, void *data)
{
return i2c_do_add_adapter(to_i2c_driver(d), data);
}
i2c_do_add_adapter->i2c_detect->i2c_detect_address 中有一段关键code
err = driver->detect(temp_client, &info);
if (err) {
/* -ENODEV is returned if the detection fails. We catch it
here as this isn't an error. */
return err == -ENODEV ? 0 : err;
}
来检测是否有i2c_driver 存在。这里的detect是在定义i2c_driver的时候定义的。
static struct i2c_driver ssif_i2c_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = DEVICE_NAME
},
.probe = ssif_probe,
.remove = ssif_remove,
.alert = ssif_alert,
.id_table = ssif_id,
.detect = ssif_detect
};
static int ssif_detect(struct i2c_client *client, struct i2c_board_info *info)
{
unsigned char *resp;
unsigned char msg[3];
int rv;
int len;
resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
if (!resp)
return -ENOMEM;
/* Do a Get Device ID command, since it is required. */
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
msg[1] = IPMI_GET_DEVICE_ID_CMD;
rv = do_cmd(client, 2, msg, &len, resp);
if (rv)
rv = -ENODEV;
else
strlcpy(info->type, DEVICE_NAME, I2C_NAME_SIZE);
kfree(resp);
return rv;
}
可以看到是通过i2c_client 来发送命令的
/* Notify drivers */
mutex_lock(&core_lock);
bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
mutex_unlock(&core_lock);
来通知所有总线类型是i2c_bus_type的driver,现在已经增加新增加了adapter了
static int __process_new_adapter(struct device_driver *d, void *data)
{
return i2c_do_add_adapter(to_i2c_driver(d), data);
}
i2c_do_add_adapter->i2c_detect->i2c_detect_address 中有一段关键code
err = driver->detect(temp_client, &info);
if (err) {
/* -ENODEV is returned if the detection fails. We catch it
here as this isn't an error. */
return err == -ENODEV ? 0 : err;
}
来检测是否有i2c_driver 存在。这里的detect是在定义i2c_driver的时候定义的。
static struct i2c_driver ssif_i2c_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = DEVICE_NAME
},
.probe = ssif_probe,
.remove = ssif_remove,
.alert = ssif_alert,
.id_table = ssif_id,
.detect = ssif_detect
};
static int ssif_detect(struct i2c_client *client, struct i2c_board_info *info)
{
unsigned char *resp;
unsigned char msg[3];
int rv;
int len;
resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
if (!resp)
return -ENOMEM;
/* Do a Get Device ID command, since it is required. */
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
msg[1] = IPMI_GET_DEVICE_ID_CMD;
rv = do_cmd(client, 2, msg, &len, resp);
if (rv)
rv = -ENODEV;
else
strlcpy(info->type, DEVICE_NAME, I2C_NAME_SIZE);
kfree(resp);
return rv;
}
可以看到是通过i2c_client 来发送命令的
阅读全文
0 0
- i2c_driver的detect函数的调用
- i2c_driver的注册及probe探测函数调用
- 关于Linux下I2C驱动的Probe方式没有自动生成i2c_client且没有自动调用i2c_driver的.probe指向的函数的问题解决
- i2c驱动程序(2) i2c_driver probe被调用的流程分析
- linux I2C 驱动之----i2c_driver的注册 .
- linux I2C 驱动之----i2c_driver的注册
- linux I2C 驱动之----i2c_driver的注册
- linux I2C 驱动之----i2c_driver的注册
- Linux i2c_client和i2c_driver的创建与绑定
- linux内核的I2C子系统详解5——i2c_driver的注册、i2c_client的来源
- 简单的string问题解决:Detect Capital
- 520. Detect Capital 的OJ代码笔记
- LeetCode 520. Detect Capital 自己的解法
- 直接调用函数的函数
- 汇编函数的调用
- 函数的递归调用
- 函数的调用约定
- 3、函数的调用
- php URL解析函数parse_str和parse_url的区别
- LeetCode--40. Combination Sum II
- 读取多轮对话数据dstc的python脚本
- TreeSet存储自定义对象并遍历练习1(按照姓名排序)
- Android查看办公文档方案大全
- i2c_driver的detect函数的调用
- R1 STM32的系统定时器SysTick笔记
- echarts图表——条形图(柱状图)的动态横向显示设置
- 设计模式之Builder建造者模式
- spoon测试指定设备
- C++ 中数据存储的分析
- TreeSet存储自定义对象并遍历练习2(按照姓名的长度排序)
- SecureCRT 设置 vim 颜色
- 多线程