简单记录,不是标准类图,只是为了将相关数据结构联系起来 首先是基本的设备——总线——驱动模型 bus_subsys_private和class_subsys_private指的都是内核中的subsys_private,但为了区分所以分开表示 device p class p knode_class/klist_devices knode_bus/klist_devices driver p knode_bus/klist_drivers driver knode_driver/klist_devices p bus class device struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; const struct device_type *type; struct bus_type *bus; struct device_driver *driver; struct klist_node knode_class; struct class *class; device_private struct klist klist_children; struct klist_node knode_parent; struct klist_node knode_driver; struct klist_node knode_bus; struct list_head deferred_probe; struct device *device; u8 dead:1; bus_type const char *name; struct subsys_private *p; Class const char *name; struct subsys_private *p; bus_subsys_private struct bus_type *bus; struct klist klist_devices; struct klist klist_drivers; struct class *class; class_subsys_private struct bus_type *bus; struct klist klist_devices; struct klist klist_drivers; struct class *class; device_driver struct bus_type *bus; struct driver_private *p; driver_private struct klist klist_devices; struct klist_node knode_bus; struct device_driver *driver; 下图截取自《存储技术原理》 接下来是scsi相关数据结构的关系 device_type class bus hostt shost_gendev shost_dev parent sdev_gendev sdev_dev dev silbings/__targets silbings/__devices same_target_siblings/devices parent bus bus parent parent device driver disk parent dev device0 device1 device2 device3 device4 device5 scsi_bus_type .name = "scsi", .match = scsi_bus_match, shost_class .name = "scsi_host", .dev_release = scsi_host_cls_release, scsi_host_type .name = "scsi_host", .release = scsi_host_dev_release, scsi_host_template Scsi_Host struct list_head __devices; struct list_head __targets; struct scsi_host_template *hostt; unsigned int host_no; struct device shost_gendev; struct device shost_dev; unsigned long hostdata[0]; scsi_device struct Scsi_Host *host; struct list_head siblings; struct list_head same_target_siblings; void *hostdata; struct device sdev_gendev, struct device sdev_dev; scsi_target struct list_head siblings; struct list_head devices; struct device dev; void *hostdata; scsi_disk struct scsi_driver *driver; struct scsi_device *device; struct device dev; struct gendisk *disk; g_sd_template gendisk 下图截取自《存储技术原理》