Linux总线驱动-02: struct bus_type 结构体


本文测试系统为:Ubuntu 10.10 x86_64 2.6.35-24-generic

上节《Linux总线驱动-01: 一个简单的示例》中,除了简单的框架,我们还看到了一个和总线驱动相关的结构体bus_type。这个结构体的定义在include/linux/device.h中。本节先简单介绍结构体中的成员,再对每个成员作详细描述。

  1. struct bus_type {   
  2.     const char      *name;   
  3.     struct bus_attribute    *bus_attrs;   
  4.     struct device_attribute *dev_attrs;   
  5.     struct driver_attribute *drv_attrs;   
  6.     int (*match)(struct device *dev, struct device_driver *drv);   
  7.     int (*uevent)(struct device *dev, struct kobj_uevent_env *env);   
  8.     int (*probe)(struct device *dev);   
  9.     int (*remove)(struct device *dev);   
  10.     void (*shutdown)(struct device *dev);   
  11.     int (*suspend)(struct device *dev, pm_message_t state);   
  12.     int (*resume)(struct device *dev);   
  13.     const struct dev_pm_ops *pm;   
  14.     struct bus_type_private *p;   
  15. };  

1. 成员简单介绍

  1. const char *name;   
  2.   总线名称。   
  3. struct bus_attribute *bus_attrs;   
  4.   总线属性。   
  5. struct device_attribute    *dev_attrs;   
  6.   该总线上所有设备的默认属性。   
  7. struct driver_attribute    *drv_attrs;   
  8.   该总线上所有驱动的默认属性。   
  9. int (*match)(struct device *dev, struct device_driver *drv);   
  10.   驱动匹配。   
  11. int (*uevent)(struct device *dev, struct kobj_uevent_env *env);   
  12.   添加环境变量。   
  13. int (*probe)(struct device *dev);   
  14.   驱动匹配。   
  15. int (*remove)(struct device *dev);   
  16.   设备移除时调用。   
  17. void (*shutdown)(struct device *dev);   
  18.   关机时调用。   
  19. int (*suspend)(struct device *dev, pm_message_t state);   
  20.   挂起(投入休眠)时调用。   
  21. int (*resume)(struct device *dev);   
  22.   恢复时调用。   
  23. const struct dev_pm_ops *pm;   
  24.   设备电源管理。   
  25. struct bus_type_private *p;   
  26.   私有数据。完全由驱动核心初始化并使用。  
  • 1
  • 2
  • 3
  • 4
  • 下一页

相关内容