bus driver device data type relation

linux2.6.36.3, drivers\base\base.h

 /**
 * struct device_private - structure to hold the private to the driver core portions of the device structure.
 *
 * @klist_children - klist containing all children of this device
 * @knode_parent - node in sibling list
 * @knode_driver - node in driver list
 * @knode_bus - node in bus list
 * @driver_data - private pointer for driver specific info.  Will turn into a
 * list soon.
 * @device - pointer back to the struct class that this structure is
 * associated with.
 *
 * Nothing outside of the driver core should ever touch these fields.
 */
struct device_private {
 struct klist klist_children;                                                  //the list head of the children devices
 struct klist_node knode_parent;                                     //the node of klist_children in device_private
 struct klist_node knode_driver;                                      //the node of klist_devices in driver_private
 struct klist_node knode_bus;                                          //the node of klist_devices in bus_type_private
 void *driver_data;
 struct device *device;
};

struct driver_private {
 struct kobject kobj;
 struct klist klist_devices;                                                   //the list head of devices
 struct klist_node knode_bus;                                          //the node of klist_drivers in bus_type_private
 struct module_kobject *mkobj;
 struct device_driver *driver;
};

/**
 * 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 kobject
 * @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_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;                                                                //the bus subsystem
 struct kset *drivers_kset;
 struct kset *devices_kset;                                                    //
 struct klist klist_devices;                                                      //the list head of devices
 struct klist klist_drivers;                                                        //the list head of drivers
 struct blocking_notifier_head bus_notifier;
 unsigned int drivers_autoprobe:1;
 struct bus_type *bus;
};

这三个结构层层相扣 组成了linux的kernel<-bus<-drivers<-devices层次结构

int bus_register(struct bus_type *bus)

void bus_unregister(struct bus_type *bus)

向kernel注册/注销总线

int bus_add_driver(struct device_driver *drv)

void bus_remove_driver(struct device_driver *drv)

向总线添加/删除设备驱动

int device_register(struct device *dev)

void device_unregister(struct device *dev)

向设备驱动注册/注销设备

int bus_add_device(struct device *dev)

void bus_remove_device(struct device *dev)

向总线添加/删除设备

这些函数都是操作kset、kobject对象的,从而将bus, device driver, devices串联起来

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值