I have a USB VID and PID for an attached device on GNU / Linux. 045e:0084
, for example. I want the binding so I grep the output of lsusb
for the VID:PID
and massage it into a format acceptable for udevadm
lookup. Finally, I take the basename of the resultant path. Something like:
bus_dev=$(lsusb|grep VID:PID...) # Grep / Sed magic to extract bus and device from VID and PID.
path=$(udevadm info -q path -n /dev/bus/usb/$bus_dev) # e.g., -n /dev/bus/usb/003/018
basename $path # e.g., /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.3/3-2.3.1
# e.g., yields 3-2.3.1
I can then use it like so:
echo 3-2.3.1|sudo tee /sys/bus/usb/drivers/usb/unbind
What's the preferred way to get the binding from a USB vendor and product ID?
You mean something like this?