Linux设备模型中的总线落实在USB子系统里就是usb_bus_type,它在usb_init的函数bus_register(&usb_bus_type)里注册。usb_bus_type定义如下:
struct bus_type usb_bus_type = {
.name = "usb",
.match = usb_device_match,
.uevent = usb_uevent,
.suspend = usb_suspend,
.resume = usb_resume,
};
显然,在这个结构体里重要的是usb_device_match函数,以后会专门一节来详细分析。
static int usb_device_match(struct device *dev, struct device_driver *drv)
{
/* devices and interfaces are handled separately */
if (is_usb_device(dev)) {
/* interface drivers never match devices */
if (!is_usb_device_driver(drv))
return 0;usb_device_driver
/* TODO: Add real matching code */
return 1;

本文介绍了Linux USB设备模型中的总线设备与接口,重点解析了struct usb_device和struct usb_interface结构体,包括altsetting、minor、condition等字段的作用。讨论了设备号的概念,解释了USB_MAJOR作为主设备号的用途,并指出USB设备通常会关联input、video等子系统,不一定直接使用USB_MAJOR。最后,说明了当USB设备与其它子系统关联时如何注册和分配设备号。
最低0.47元/天 解锁文章

513

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



