Get the App
SLTechnology News&Howtos  ›  Servers  › 

How linux discovers and loads corresponding USB device drivers

Shulou Source: shulou.com Published: 2022-06-02 10:02:21 09月30日 Update

Linux How to find and load the corresponding USB device driver

1. overall process

Load USB Device Driver--> Register USB Device (Registered USB Device Structure contains Vendor ID and Product ID of USB Device)

After the USB device is inserted, match the vendor ID and product ID, that is, call the probe function in the USB registration structure to start communicating with the USB device.

2. USB device structure

static struct usb_driver test_usb_driver={

.OWNER = THIS_MODULE,

.name = "test USB device",

.id_table = test_usb_table_id,

.probe = test_usb_probe,

.disconnect = test_usb_disconnect

};

USB device table ID

static struct usb_device_id test_usb_table_id={

{USB_DEVICE(TEST_USB_VENDOR_ID,TEST_USB_PRODUCT_ID)};

{}

};

Extension:

usb device table ID corresponds to usb_device_id

i2c device table ID corresponds to i2c_device_id

The USB device table id is stored in the USB device. After inserting host (master device) as a device slave device, host is read from the USB device through port 0.

The i2c device is defined in the device tree. After the kernel is started, traverse the device tree and load the corresponding i2c device driver.

Tags: Device device driver driver structure main device function whole process Port Communication Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Redmi NVidia Docker macOS