-
- DTS中的 i2c设备节点(子节点) (例如:AT24C02)被转化为i2c_client结构体,其所在的 i2c控制器节点(父节点)转化为platform_device 结构体,匹配到对应的 platform_driver 结构体,调用对应的 probe 函数,该函数中实现:①分配、设置、注册 i2c_adapter 结构体;②解析字节点,分配、设置、注册 i2c_client 结构体,该结构体对应i2c_bus 总线框架,匹配到对应的 i2c_driver 驱动,调用其中的 probe 函数,实现major、file_operations、register_chrdev、class_create,入口出口等。
-
struct i2c_adapter { struct module *owner; unsigned int class; /* classes to allow probing for */ const struct i2c_algorithm *algo; /* the algorithm to access the bus */ void *algo_data; /* data fields that are valid for all devices */ const struct i2c_lock_operations *lock_ops; struct rt_mutex bus_lock; struct rt_mutex mux_lock; int timeout; /* in jiffies */ int retries; struct device dev; /* the adapter device */ int nr; char name[48]; struct completion dev_released; struct mutex userspace_clients_lock; struct list_head userspace_clients; struct i2c_bus_recovery_info *bus_recovery_info; const struct i2c_adapter_quirks *quirks; }; struct i2c_client { unsigned short flags; /* div., see below */ unsigned short addr; /* chip address - NOTE: 7bit */ /* addresses are stored in the */ /* _LOWER_ 7 bits */ char name[I2C_NAME_SIZE]; struct i2c_adapter *adapter; /* the adapter we sit on */ struct device dev; /* the device structure */ int irq; /* irq issued by device */ struct list_head detected; #if IS_ENABLED(CONFIG_I2C_SLAVE) i2c_slave_cb_t slave_cb; /* callback for slave mode */ #endif };
- probe中应用输入系统框架:
- 为了适配以前写好的应用程序,上述probe函数中 使用到了输入系统 input_dev;不再是实现 major 这些,因为以前的应用程序可能不会去open一个你创建的设备节点,现在要去适配以前的应用程序,所以用到输入系统。
-
原文地址:http://www.cnblogs.com/xuan01/p/16875118.html
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,请务用于商业用途!
3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员!
8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载
声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性