29

I have a piece of usb hardware, for which I know the driver. However, the vendor id and product id do not match the VID, PID pair registered in the driver. Is there a way in linux to force a driver to be associated with a known device, that do not involve kernel module recompilation to add a PID / VID pair ?

3 Answers 3

31

Find the module in the sysfs tree. In this case it was in

/sys/bus/usb-serial/drivers/cp2101

In this directory, there is a new_id file entry that can be used to dynamically add VID PID pair like this :

echo VID PID >new_id

Here is a LWN entry about this feature

1
  • 4
    +1: Nice answer. On my machine for USB, I found paths as: /sys/bus/usb/drivers/usb/usb4/idVendor and /sys/bus/usb/drivers/usb/usb4/idProduct Jan 28, 2011 at 4:51
8

In case you want to make this change permanent and assign specific driver to device (VID, PID) you may find this answer useful.

For example create new file/etc/udev/rules.d/98-joystick.rules with content:

ACTION=="add", ATTRS{idVendor}=="1345", ATTRS{idProduct}=="6005", RUN+="/sbin/modprobe xpad" RUN+="/bin/sh -c 'echo 1345 6005 > /sys/bus/usb/drivers/xpad/new_id'"

Replace 1345 with your VID and 6005 with your PID.

Replace xpad with appropriate driver.

Run following command:

$ sudo udevadm control --reload

Unplug and plug your device back and check if the new driver is loaded.

Example shown here is for fixing driver issues with Speedlink Strike FX Gamepad (SL-6537-BK)

1

You don't need actually recompile the whole kernel, recompiling only relevant kernel module with updated match table will be enough, in case that this answer, does not work on your kernel.

Not the answer you're looking for? Browse other questions tagged or ask your own question.