bus device driver

struct bus_type {
const char *name;  //名字
const char *dev_name;
struct device *dev_root;  //根设备
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); // uevent函数

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 iommu_ops *iommu_ops;  //mmu接口


struct subsys_private *p;  
struct lock_class_key lock_key;  

};


struct subsys_private {
struct kset subsys;  

-》kobj.kset = bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);

-》kobj.ktype = &bus_ktype


struct kset *devices_kset; = kset_create_and_add("devices", NULL,
 &priv->subsys.kobj);
struct list_head interfaces; // struct subsys_interface 链表头
struct mutex mutex;


struct kset *drivers_kset;= kset_create_and_add("drivers", NULL,
 &priv->subsys.kobj);
struct klist klist_devices;  //总线上的设备集合
struct klist klist_drivers;   总线上的驱动集合
struct blocking_notifier_head bus_notifier; //通知函数链表
unsigned int drivers_autoprobe:1;  //自动probe
struct bus_type *bus;  //指向bus


struct kset glue_dirs;
struct class *class; //所属class
};



struct device_driver {
const char *name;  //名字
struct bus_type*bus; //所属总线


struct module *owner;
const char *mod_name; /* used for built-in modules */


bool suppress_bind_attrs;/* disables bind/unbind via sysfs */


const struct of_device_id*of_match_table;  //匹配表
const struct acpi_device_id*acpi_match_table; //acpi匹配表


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 attribute_group **groups; //属性组


const struct dev_pm_ops *pm;


struct driver_private *p;
};


struct driver_private {
struct kobject kobj;  --》kobj.kset = bus->p->drivers_kset;  kobject_init_and_add(&priv->kobj, &driver_ktype, NULL,
    "%s", drv->name);
struct klist klist_devices; //挂设备的klist
struct klist_node knode_bus;  //klist_add_tail(&priv->knode_bus, &bus->p->klist_drivers);
struct module_kobject *mkobj;
struct device_driver *driver; //指向device driver
};



struct device {
struct device *parent; //父设备


struct device_private*p;


struct kobject kobj; //根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 *driver;  //绑定的驱动  /* which driver has allocated this
  device */
void *platform_data;  //平台私有数据  /* Platform specific data, device
  core doesn't touch it */
struct dev_pm_infopower;  //电源管理信息
struct dev_pm_domain*pm_domain; //电源管理接口


#ifdef CONFIG_PINCTRL
struct dev_pin_info*pins; 
#endif


#ifdef CONFIG_NUMA
int numa_node;/* NUMA node this device is close to */
#endif
u64 *dma_mask;  //dma掩码 /* dma mask (if dma'able device) */
u64 coherent_dma_mask;//coherent dma掩码///* Like dma_mask, but for
    alloc_coherent mappings as
    not all hardware supports
    64 bit addresses for consistent
    allocations such descriptors. */


struct device_dma_parameters *dma_parms; //dma参数



struct list_headdma_pools;  //dma池/* dma pools (if dma'ble) */


struct dma_coherent_mem*dma_mem; /* internal for coherent mem
    override */
#ifdef CONFIG_CMA
struct cma *cma_area;/* contiguous memory area for dma
  allocations */
#endif
/* arch specific additions */
struct dev_archdataarchdata;


struct device_node*of_node; /* associated device tree node */
struct acpi_dev_nodeacpi_node; /* associated ACPI device node */


dev_t devt;/* dev_t, creates the sysfs "dev" */
u32 id;/* device instance */


spinlock_t devres_lock;
struct list_headdevres_head;


struct klist_nodeknode_class;
struct class *class;
const struct attribute_group **groups;/* optional groups */


void (*release)(struct device *dev);
struct iommu_group*iommu_group;
};


struct device_type {
const char *name; //名字
const struct attribute_group **groups; //属性组
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
char *(*devnode)(struct device *dev, umode_t *mode,
kuid_t *uid, kgid_t *gid);
void (*release)(struct device *dev);


const struct dev_pm_ops *pm;
};

struct device_private {
struct klist klist_children; //子设备的klist
struct klist_node knode_parent;klist_add_tail(&dev->p->knode_parent,
      &parent->p->klist_children);
struct klist_node knode_driver;klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
struct klist_node knode_bus;    klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices);
struct list_head deferred_probe;list_add_tail(&dev->p->deferred_probe, &deferred_probe_pending_list);
}
void *driver_data; //私有数据
struct device *device;
};



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值