How to get bus id of an usb device

devicesusb

I would like to bind/unbind my usb device – a wireless adapter.

echo -n "1-1:1.0" > /sys/bus/usb/drivers/ub/unbind

So to able to do that, I need the bus ID. lsusb prints out the following:

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 148f:2573 Ralink Technology, Corp. RT2501/RT2573 Wireless Adapter

And lsusb -t:

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/3p, 480M
        |__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
        |__ Port 2: Dev 4, If 0, Class=vend., Driver=rt73usb, 480

So where can I find this bus ID? Thanks!
Update:
here is the detailed info about the wireless devide: (lsusb -v | grep -E '\<(Bus|iProduct|bDeviceClass|bDeviceProtocol)' 2>/dev/null)

Bus 001 Device 004: ID 148f:2573 Ralink Technology, Corp. RT2501/RT2573 Wireless Adapter
  bDeviceClass            0 (Defined at Interface level)
  bDeviceProtocol         0 
  iProduct                2

Best Answer

You can read off the sequence from the device tree you get with lsusb -t. The number before the hyphen is the bus, the numbers after the hyphen are the port sequence. Your device is on bus 01, on port 1 of the root hub for this bus is another hub, and on port 3 of this hub is your device: So you get 1-1.3.

If you know the vendor id from lsusb (like 148f for Ralink), you can also grep for it with

grep 148f /sys/bus/usb/devices/*/idVendor

and you'll get something like

/sys/bus/usb/devices/1-1.3/idVendor:148f

as answer. If there are several devices from the same vendor, you can narrow it down with idProduct.

Related Question