你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux设备驱动编程模型之设备篇

[日期:2012-02-26] 来源:Linux社区  作者:bullbat [字体:大 中 小]

下面数据结构用以描述结构间关系的

[cpp]
  1. /** 
  2.  * struct device_private - structure to hold the private to the driver core portions of the device structure. 
  3.  * 
  4.  * @klist_children - klist containing all children of this device 
  5.  * @knode_parent - node in sibling list 
  6.  * @knode_driver - node in driver list 
  7.  * @knode_bus - node in bus list 
  8.  * @driver_data - private pointer for driver specific info.  Will turn into a 
  9.  * list soon. 
  10.  * @device - pointer back to the struct class that this structure is 
  11.  * associated with. 
  12.  * 
  13.  * Nothing outside of the driver core should ever touch these fields. 
  14.  */  
  15. struct device_private {  
  16.     struct klist klist_children;  
  17.     struct klist_node knode_parent;  
  18.     struct klist_node knode_driver;  
  19.     struct klist_node knode_bus;  
  20.     void *driver_data;  
  21.     struct device *device;  
  22. };  
[cpp]
  1. struct class_private {  
  2.     struct kset class_subsys;  
  3.     struct klist class_devices;  
  4.     struct list_head class_interfaces;  
  5.     struct kset class_dirs;  
  6.     struct mutex class_mutex;  
  7.     struct class *class;  
  8. };  
[cpp]
  1. /** 
  2.  * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure. 
  3.  * 
  4.  * @subsys - the struct kset that defines this bus.  This is the main kobject 
  5.  * @drivers_kset - the list of drivers associated with this bus 
  6.  * @devices_kset - the list of devices associated with this bus 
  7.  * @klist_devices - the klist to iterate over the @devices_kset 
  8.  * @klist_drivers - the klist to iterate over the @drivers_kset 
  9.  * @bus_notifier - the bus notifier list for anything that cares about things 
  10.  * on this bus. 
  11.  * @bus - pointer back to the struct bus_type that this structure is associated 
  12.  * with. 
  13.  * 
  14.  * This structure is the one that is the actual kobject allowing struct 
  15.  * bus_type to be statically allocated safely.  Nothing outside of the driver 
  16.  * core should ever touch these fields. 
  17.  */  
  18. struct bus_type_private {  
  19.     struct kset subsys;  
  20.     struct kset *drivers_kset;  
  21.     struct kset *devices_kset;  
  22.     struct klist klist_devices;  
  23.     struct klist klist_drivers;  
  24.     struct blocking_notifier_head bus_notifier;  
  25.     unsigned int drivers_autoprobe:1;  
  26.     struct bus_type *bus;  
  27. };  
  28.   
  29. struct driver_private {  
  30.     struct kobject kobj;  
  31.     struct klist klist_devices;  
  32.     struct klist_node knode_bus;  
  33.     struct module_kobject *mkobj;  
  34.     struct device_driver *driver;  
  35. };  

描述属性文件的结构

[cpp]
  1. /* FIXME 
  2.  * The *owner field is no longer used. 
  3.  * x86 tree has been cleaned up. The owner 
  4.  * attribute is still left for other arches. 
  5.  */  
  6. struct attribute {  
  7.     const char      *name;  
  8.     struct module       *owner;  
  9.     mode_t          mode;  
  10. };  

后面有时间我会补上上面数据结构之间的关系图,便于理解。

linux
相关资讯       Linux驱动 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款