linux内核区分usb设备速度原理
对于linux系统,系统初始时候hub驱动初始化了一个工作队列不停的轮训hub事件 ,事件的具体执行函数是hub_event,当有usb设备插入时候,会调到
port_event-> Y:\kernel\drivers\usb\core\hub.c
hub_port_connect_change->
hub_port_connect->
hub_port_init->
usb_speed_string(udev->speed); //如上所述
const char *usb_speed_string(enum usb_device_speed speed) //drivers/usb/common/common.c
{
if (speed < 0 || speed >= ARRAY_SIZE(speed_names))
speed = USB_SPEED_UNKNOWN;
return speed_names[speed];
}
static const char *const speed_names[] = { //drivers/usb/common/common.c
[USB_SPEED_UNKNOWN] = “UNKNOWN”,
[USB_SPEED_LOW] = “low-speed”,
[USB_SPEED_FULL] = “full-speed”,
[USB_SPEED_HIGH] = “high-speed”,
[USB_SPEED_WIRELESS] = “wireless”,
[USB_SPEED_SUPER] = “super-speed”,
[USB_SPEED_SUPER_PLUS] = “super-speed-plus”,
};
而这个full-speed与high-speed就是平时我们插入usb设备所打印的设备信息,通过这个信息即可判断usb设备版本是1.0还是2.0及3.0.
USB_SPEED_LOW 对应1.0
USB_SPEED_FULL对应usb 2.0
USB_SPEED_HIGH对应usb3…0
linux内核区分usb设备速度原理
最新推荐文章于 2022-09-07 15:52:22 发布