深入理解Linux设备模型
1. 总线注册
总线控制器本身也是一种设备,在绝大多数情况下,总线属于平台设备。例如,PCI控制器就是一个平台设备,其对应的驱动程序也是如此。要向内核注册总线,需要使用 bus_register(struct *bus_type) 函数。以下是一个名为 packt 的总线结构示例:
/*
* This is our bus structure
*/
struct bus_type packt_bus_type = {
.name = "packt",
.match = packt_device_match,
.probe = packt_device_probe,
.remove = packt_device_remove,
.shutdown = packt_device_shutdown,
};
总线控制器作为一个设备,需要向内核注册,并作为挂载在该总线上设备的父设备。这通常在总线控制器的探测或初始化函数中完成。以 packt 总线为例,代码如下:
/*
* Bus device, the master.
*
*/
struct device packt_bus = {
.release = packt_bus_release,
.parent = NULL, /* Root device, no parent needed */
超级会员免费看
订阅专栏 解锁全文
1248

被折叠的 条评论
为什么被折叠?



