你了解Embeded linux中的probe.doc
《你了解Embeded linux中的probe.doc》由会员分享,可在线阅读,更多相关《你了解Embeded linux中的probe.doc(5页珍藏版)》请在三一文库上搜索。
1、你了解Embeded linux中的probe一、基于linux-3.18.20、mac驱动二、启动时机:所谓的probe”,是指在Linux内核中,如果存在相同名称的device和device_driver,内核就会执行device_driver中的probe回调函数,而该函数就是所有driver的入口,可以执行诸如硬件设备初始化、字符设备注册、设备文件操作ops注册等动作(remove”是它的反操作,发生在device或者device_driver任何一方从内核注销时。将struct device类型的变量注册到内核中时自动触发(device_register,device_add,dev
2、ice_create_vargs,device_create)将struct device_driver类型的变量注册到内核中时自动触发(driver_register)手动查找同一bus下的所有device_driver,如果有和指定device同名的driver,执行probe操作(device_attach)手动查找同一bus下的所有device,如果有和指定driver同名的device,执行probe操作(driver_attach)自行调用driver的probe接口,并在该接口中将该driver绑定到某个device结构中-即设置dev-driver(device_bind_dr
3、iver)三、流程3.1 注册平台驱动ret = platform_driver_register(#define platform_driver_register(drv) platform_driver_register(drv, THIS_MODULE)_platform_driver_register(drv, THIS_MODULE).return driver_register(int driver_attach(struct device_driver *drv).ret = bus_add_driver(drv);.int bus_add_driver(struct devic
4、e_driver *drv).return bus_for_each_dev(drv-bus, NULL, drv, _driver_attach);.本函数没有给_driver_attach传递参数。int bus_for_each_dev(struct bus_type *bus, struct device *start,void *data, int (*fn)(struct device *, void *).klist_iter_init_node(while (dev = next_device(.分支一:赋值i-i_klist、i-i_cur因为start为NULL,故传递的第
5、三个参数n为NULLvoid klist_iter_init_node(struct klist *k, struct klist_iter *i,struct klist_node *n)i-i_klist = k;i-i_cur = n;if (n)kref_get(其中i-i_klist =k =i-i_cur =n =(start ? 分之二:static struct device *next_device(struct klist_iter *i)struct klist_node *n = klist_next(i);struct device *dev = NULL;struc
6、t device_private *dev_prv;if (n)dev_prv = to_device_private_bus(n);dev = dev_prv-device;return dev;#define to_device_private_bus(obj) container_of(obj, struct device_private, knode_bus)参数:i为struct klist_iter struct klist *i_klist;struct klist_node *i_cur;被赋值为i-i_klist = k;i-i_cur = n;next_device(str
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 你了解Embeded linux中的probe 了解 Embeded linux 中的 probe
链接地址:https://www.31doc.com/p-3381530.html