Search code examples
linuxlinux-kernelusblinux-device-driver

Where does Linux kernel get its information about USB device names?


When plugging in a USB device, dmesg logs that the Linux kernel recognizes it, here dmesg also describes the product in prosa ("USB2.0 Camera" in the following example)

[   12.621009] Linux video capture interface: v2.00
[   12.685253] uvcvideo: Found UVC 1.00 device USB 2.0 Camera (0c45:6340)
[   12.712522] input: USB 2.0 Camera as /devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0/input/input8

My question: where does the kernel gets this descriptive information from (the "name" of the device), based on vendorId and productId? How can I access this information? I guess the text is not delivered by the device itself, but there exists a "known devices" mapping in the kernel. Or am I wrong?


Solution

  • The message is printed here:

    dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n",
             dev->uvc_version >> 8, dev->uvc_version & 0xff,
             udev->product ? udev->product : "<unnamed>",
             le16_to_cpu(udev->descriptor.idVendor),
             le16_to_cpu(udev->descriptor.idProduct));
    

    udev->product, in turn, is set here:

             udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
    

    In other words, it is read from the USB descriptors stored in the device itself.