Linux内核device结构体分析
1、前言 Linux内核中的设备驱动模型,是建立在sysfs设备文件系统和kobject上的,由总线(bus)、设备(device)、驱动(driver)和类(class)所组成的关系结构,在底层,Linux系统中的每个设备都有一个device结构体的实例,本文将对Linux内核的device结构体以及相关结构进行简要分析。 2、device结构体 在Linux内核源码中,struct device结构体的定义在include/linux/device.h中,实现的主要方法在drivers/base/core.c文件中,device结构体的定义如下所示: struct device { struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; /* initial name of the device */ const struct device_type *type; struct mutex mutex; /* mutex to synchronize calls to * its driver. */ struct bus_type *bus; /* type of bus device is on */ struct device_driver