9. Summary
Relationship between 9.1 bus, device, driver and class
L bus is equivalent to a container. It is the management mechanism of device and device_driver. It contains a device set (devices_kset) and a driver set (drivers_kset ), indicates all devices attached to the bus and all drivers.
L The driver is attached to the bus and contains a device chain (klist_devices) used to traverse the devices on the bus. The driver also contains a bus_type pointer, indicating the bus to which the driver is attached.
L The device Mount bus contains a device_driver pointer, indicating the device driver of the device. It also contains bus_type, indicating the bus to which the device is attached
L class is classified according to the functions of devices. devices with the same functions are classified into one type, and bus with the same functions (the actual bus is also a device) may also be classified.
L it should be noted that an actual bus is represented by two structures in the device model: bus_type and device. bus_type represents the bus type and appears in the/sys/bus/directory; device indicates a bus device that appears in the/sys/devices/directory. This indicates that the actual bus is essentially a device. device and device_driver are usually embedded in other data structures, not used separately.
9.2 instance relationship
Is the diagram drawn from the above experiments
You can download the instance source code through git: git clone git: // github.com/cjok/device-model.git