int (*match)(struct device *dev, struct device_driver *drv);设备和驱动能否对应,就是有该总线的match方式决定。不同总线的match方式不一样。 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 (*suspend_late)(struct device *dev, pm_message_t state); int (*resume_early)(struct device *dev); int (*resume)(struct device *dev);
struct pm_ext_ops *pm; struct bus_type_private *p; }; 现在如上数据结构和书中讲的有所不同,只不过有包装了一层数据结构struct bus_type_private *p,源码如下:/** * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure. * * @subsys - the struct kset that defines this bus. This is the main kobjectsubsys描述该总线的子系统,它连接到全局量kset bus_subsys中。 * @drivers_kset - the list of drivers associated with this bus该总线系统里所有驱动的集合 * @devices_kset - the list of devices associated with this bus该总线系统里所有设备的集合 * @klist_devices - the klist to iterate over the @devices_kset该总线里的设备用klist指针连成一个链表 * @klist_drivers - the klist to iterate over the @drivers_kset驱动链表 * @bus_notifier - the bus notifier list for anything that cares about things * on this bus. * @bus - pointer back to the struct bus_type that this structure is associated * with. * * This structure is the one that is the actual kobject allowing struct * bus_type to be statically allocated safely. Nothing outside of the driver * core should ever touch these fields. */ struct bus_type_private { struct kset subsys; struct kset *drivers_kset; struct kset *devices_kset; struct klist klist_devices; struct klist klist_drivers; struct blocking_notifier_head bus_notifier; unsigned int drivers_autoprobe:1; struct bus_type *bus; }; 在sysfs文件系统中,我们可以清晰地看到它们之间的联系。kset bus_subsys对应于/sys/bus这个目录。每个bus_type对象都对应/sys/bus目录下的一个子目录,如PCI类型对应于/sys/bus/pci。在每个这样的目录下都存在两个子目录:devices和drivers。