Linux总线驱动-02: struct bus_type 结构体
Linux总线驱动-02: struct bus_type 结构体
本文测试系统为:Ubuntu 10.10 x86_64 2.6.35-24-generic
上节《Linux总线驱动-01: 一个简单的示例》中,除了简单的框架,我们还看到了一个和总线驱动相关的结构体bus_type。这个结构体的定义在include/linux/device.h中。本节先简单介绍结构体中的成员,再对每个成员作详细描述。
- struct bus_type {
- const char *name;
- struct bus_attribute *bus_attrs;
- struct device_attribute *dev_attrs;
- struct driver_attribute *drv_attrs;
- int (*match)(struct device *dev, struct device_driver *drv);
- int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
- int (*probe)(struct device *dev);
- int (*remove)(struct device *dev);
- void (*shutdown)(struct device *dev);
- int (*suspend)(struct device *dev, pm_message_t state);
- int (*resume)(struct device *dev);
- const struct dev_pm_ops *pm;
- struct bus_type_private *p;
- };
1. 成员简单介绍
- const char *name;
- 总线名称。
- struct bus_attribute *bus_attrs;
- 总线属性。
- struct device_attribute *dev_attrs;
- 该总线上所有设备的默认属性。
- struct driver_attribute *drv_attrs;
- 该总线上所有驱动的默认属性。
- int (*match)(struct device *dev, struct device_driver *drv);
- 驱动匹配。
- int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
- 添加环境变量。
- int (*probe)(struct device *dev);
- 驱动匹配。
- int (*remove)(struct device *dev);
- 设备移除时调用。
- void (*shutdown)(struct device *dev);
- 关机时调用。
- int (*suspend)(struct device *dev, pm_message_t state);
- 挂起(投入休眠)时调用。
- int (*resume)(struct device *dev);
- 恢复时调用。
- const struct dev_pm_ops *pm;
- 设备电源管理。
- struct bus_type_private *p;
- 私有数据。完全由驱动核心初始化并使用。
|
评论暂时关闭