Understanding sysfs and usb

Reference’s

1) http://www.makelinux.net/ldd3/chp-13-sect-2.shtml

2) Allen Stern’s description

:/sys/bus/usb/devices# ls -al usb*
usb1 -> ../../../devices/pci0000:00/0000:00:1d.7/usb1
usb2 -> ../../../devices/pci0000:00/0000:00:1d.0/usb2
usb3 -> ../../../devices/pci0000:00/0000:00:1d.1/usb3
usb4 -> ../../../devices/pci0000:00/0000:00:1d.2/usb4
usb5 -> ../../../devices/pci0000:00/0000:00:1d.3/usb5

this shows that it has 5 root hubs. Now, lets try to corelate it with lsusb. A simple shell script which will print only RootHubs available on your machine.

#!/bin/sh
TOTAL_BUS_NUM=$1
for (( i=1; i <= $TOTAL_BUS_NUM; i++ ))
do
lsusb -s $i:1
done

READ  Framework for registering Linux kernel driver as class device / How to add new class to Linux kernel

Run it as “bash lsusb.sh”

:~/USB$ bash lsusb.sh 5
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Leave a Reply

Your email address will not be published. Required fields are marked *