Linux设备驱动模型_bus

Linux设备驱动模型中的bus是管理设备和驱动的核心,它维护device和device_driver的链表并进行匹配。当设备和驱动注册到bus上时,通过match函数尝试匹配,匹配成功后调用probe函数进行初始化。bus的数据结构包含关键成员如match、probe和用于存储device及driver链表的klist。
摘要由CSDN通过智能技术生成

1. 概述

总线(bus)是linux设备模型中抽象出来的一个概念,用于统一管理所有设备和驱动。在linux内核中,每个设备都会被挂载到相应的bus总线上,这个bus可以是对应真实的系统总线,如I2C总线,SPI总线等,也可以是虚拟总线,如platform bus。

在bus上,挂载有另外两个概念,设备(device)和驱动(device_driver)。
device即真实的物理设备,提供各种硬件资源和信息。device_driver提供用于读写访问device所需要的各种驱动方法。device和device_driver都通过注册挂载到bus上。

bus最主要的工作,就是维护device和device_driver的链表,并将挂载在bus上的device和device_driver进行匹配。当device或者device_driver注册到bus上时,都将调用bus的match函数,试图将注册的device和device_driver进行匹配。一旦匹配成功,意味着设备找到了相应的驱动,将调用probe函数,在probe中实现设备的各种初始化等工作。

 2. 核心数据结构

/**
 * struct bus_type - The bus type of the device
 *
 * @name:	The name of the bus.
 * @dev_name:	Used for subsystems to enumerate devices like ("foo%u", dev->id).
 * @dev_root:	Default device to use as the parent.
 * @dev_attrs:	Default attributes of the devices on the bus.
 * @bus_groups:	Default attributes of the bus.
 * @dev_groups:	Default attributes of the devices on the bus.
 * @drv_groups: Default attributes of the device drivers on the bus.
 * @match:	Called, perhaps multiple times, whenever a new device or driver
 *		is added for this bus. It should return a nonzero value if the
 *		given device can be handled by the given drive
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值