This is inspired by the behavior of lspci -tv (pciutils).
Example output:
$ ./lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
|__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 6: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
$ ./lsusb -tv
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
|__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 046d:c077 Logitech, Inc. M105 Optical Mouse
|__ Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 0461:0010 Primax Electronics, Ltd HP PR1101U / Primax PMX-KPR1101U Keyboard
|__ Port 6: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 0461:0010 Primax Electronics, Ltd HP PR1101U / Primax PMX-KPR1101U Keyboard
$ ./lsusb -tvv
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
/sys/bus/usb/devices/usb1 /dev/bus/usb/001/001
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
/sys/bus/usb/devices/1-1 /dev/bus/usb/001/002
|__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 046d:c077 Logitech, Inc. M105 Optical Mouse
/sys/bus/usb/devices/1-1.2 /dev/bus/usb/001/003
|__ Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 0461:0010 Primax Electronics, Ltd HP PR1101U / Primax PMX-KPR1101U Keyboard
/sys/bus/usb/devices/1-1.6 /dev/bus/usb/001/004
|__ Port 6: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
ID 0461:0010 Primax Electronics, Ltd HP PR1101U / Primax PMX-KPR1101U Keyboard
/sys/bus/usb/devices/1-1.6 /dev/bus/usb/001/004
Signed-off-by: Darsey Litzenberger <dlitz@dlitz.net>
All of these default to GPLv2-only, except for lsusb.h which is GPLv2+
as it refers to a GPLv2+ file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>