驱动开发学习20250522

总线

总线控制器驱动程序功能:

  • 必须定义总线特定的驱动程序结构和总线特定的设备结构
  • 为探测到的每个物理设备分配总线特定的设备结构,并负责初始化设备的bus和parent字段,向LDM内核注册设备
    总线管理的列表:
  • 添加到总线的设备列表
  • 注册到总线的驱动程序列表

设备

cpp 复制代码
struct device {
	struct device *parent;
	struct kobject kobj;
	const struct device_type *type;
	struct bus_type *bus;
	struct device_driver *driver;
	void *platform_data;
	void *driver_data;
	struct device_node *of_node;
	struct class *class;
	const struct attribute_group **groups;
	void (*release)(struct device *dev); 
};
  • *parent:代表设备的父设备,用于构建设备树层次结构
  • *bus:代表设备所在总线。总线驱动程序必须配置该字段
  • *type:标识设备类型
  • kobj:句柄引用计数和设备模型支持中的kobject
  • *of_node:指向与设备相关的OF节点的指针
  • platform_data:指向设备特有的平台数据的指针,通常设备配置期间在开发板特有的文件中声明
  • driver_data:指向驱动程序私有数据的指针
  • class:指向设备所属类的指针
  • *group:指向struct attribute_group列表的指针,用作设备的默认属性
  • release:设备引用计数达到零时调用的回调。总线负责设置这个字段,

kobject结构

cpp 复制代码
struct kobject {
	const char *name;
	struct list_head entry;
	struct kobject *parent;
	struct kset *kset;
	struct kobj_type *ktype;
	struct sysfs_dirent *sd;
	struct kref kref;
};
  • name:指向这个kobject的名称。使用kobject_set_name(struct kobject * kobj, const char * name)函数可以修改它
  • parent:指向此kobject父项的指针
  • sd:指向struct sysfs_dirent结构
  • kref:提供kobject上的引用计数
  • ktype:描述该对象,kset说明这个对象属于哪组对象
相关推荐
哈哈浩丶1 小时前
Linux系统移植⑦:uboot启动流程详解-board_init_r执行过程
linux·驱动开发
楼台的春风1 天前
【Linux驱动开发 ---- 2.1_深入理解 Linux 内核架构】
linux·c++·人工智能·驱动开发·嵌入式硬件·ubuntu·架构
jasonslaex4 天前
stm32传感器通用驱动代码
驱动开发·stm32·嵌入式硬件
thinkMoreAndDoMore4 天前
linux驱动开发(9)- 信号量
linux·运维·驱动开发
sukalot5 天前
window显示驱动开发—为 DirectX VA 2.0 扩展模式提供功能(一)
驱动开发
Suagrhaha5 天前
驱动开发前传及led驱动(s5pv210)
驱动开发
sukalot6 天前
window 显示驱动开发-处理视频帧
驱动开发·音视频
sukalot6 天前
window 显示驱动开发-为视频处理创建渲染目标图面
驱动开发
thinkMoreAndDoMore6 天前
linux驱动开发(7)-互斥与同步
linux·运维·驱动开发
我不是加奈8 天前
QMC5883L的驱动
c语言·驱动开发·单片机·嵌入式硬件