3 # Copyright: 2009 Greg Kroah-Hartman <greg@kroah.com>
4 # 2009 Randy Dunlap <rdunlap@xenotime.net>
5 # 2009 Frans Pop <elendil@planet.nl>
7 # This software may be used and distributed according to the terms of
8 # the GNU General Public License (GPL), version 2, or at your option
15 echo "S: $name=`cat $file`"
20 local class=$1 # v4: in hex
49 addr=`cat $eppath/bEndpointAddress`
50 attr=`cat $eppath/bmAttributes`
51 dir=`cat $eppath/direction`
52 eptype=`cat $eppath/type`
53 maxps_hex="0x`cat $eppath/wMaxPacketSize`"
54 # Extract MaxPS size (bits 0-10) and multiplicity values (bits 11-12)
55 maxps=`printf "%4i*%s\n" $(($maxps_hex & 0x7ff)) \
56 $((1 + (($maxps_hex >> 11) & 0x3)))`
57 interval=`cat $eppath/interval`
59 printf "E: Ad=%s(%s) Atr=%s(%s) MxPS=%s Ivl=%s\n" \
60 $addr $dir $attr $eptype "$maxps" $interval
66 ifnum=`cat $ifpath/bInterfaceNumber`
67 altset=`cat $ifpath/bAlternateSetting`
68 numeps=`cat $ifpath/bNumEndpoints`
69 class=`cat $ifpath/bInterfaceClass`
70 subclass=`cat $ifpath/bInterfaceSubClass`
71 protocol=`cat $ifpath/bInterfaceProtocol`
72 if [ -L $ifpath/driver ]; then # v4: allow for no driver
73 driver=`readlink $ifpath/driver`
74 driver=`basename $driver`
78 classname=`class_decode $class`
79 printf "I: If#=%2i Alt=%2i #EPs=%2i Cls=%s(%s) Sub=%s Prot=%s Driver=%s\n" \
80 $ifnum $altset $numeps $class "$classname" $subclass \
83 for endpoint in $ifpath/ep_??
85 if [ -L $endpoint ]; then # v4: verify endpoint exists
86 print_endpoint $endpoint
97 [ -d $devpath ] || return
100 local busnum=`cat busnum`
101 local devnum=`cat devnum`
103 if [ $level -gt 0 ]; then
104 port=$((${devpath##*[-.]} - 1))
109 maxchild=`cat maxchild`
110 printf "\nT: Bus=%02i Lev=%02i Prnt=%02i Port=%02i Cnt=%02i Dev#=%3i Spd=%-3s MxCh=%2i\n" \
111 $busnum $level $parent $port $count $devnum $speed $maxchild
114 devclass=`cat bDeviceClass`
115 devsubclass=`cat bDeviceSubClass`
116 devprotocol=`cat bDeviceProtocol`
117 maxps0=`cat bMaxPacketSize0`
118 numconfigs=`cat bNumConfigurations`
119 classname=`class_decode $devclass`
120 printf "D: Ver=%5s Cls=%s(%s) Sub=%s Prot=%s MxPS=%2i #Cfgs=%3i\n" \
121 $ver $devclass "$classname" $devsubclass $devprotocol \
124 vendid=`cat idVendor`
125 prodid=`cat idProduct`
126 revmajor=`cat bcdDevice | cut -c 1-2`
127 revminor=`cat bcdDevice | cut -c 3-4`
128 printf "P: Vendor=%s ProdID=%s Rev=%s.%s\n" \
129 $vendid $prodid $revmajor $revminor
131 print_string manufacturer "Manufacturer"
132 print_string product Product
133 print_string serial SerialNumber
135 numifs=`cat bNumInterfaces`
136 cfgnum=`cat bConfigurationValue`
137 attr=`cat bmAttributes`
138 maxpower=`cat bMaxPower`
139 printf "C: #Ifs=%2i Cfg#=%2i Atr=%s MxPwr=%s\n" \
140 $numifs $cfgnum $attr $maxpower
142 # There's not really any useful info in endpoint 00
143 #print_endpoint $devpath/ep_00
145 for interface in $busnum-*:?.*
147 print_interface $devpath/$interface
151 for subdev in $busnum-*
153 echo "$subdev" | grep -Eq "^$busnum-[0-9]+(\.[0-9]+)*$" \
156 devcount=$(($devcount + 1))
157 if [ -d $devpath/$subdev ]; then
158 print_device $devpath/$subdev \
159 $devnum $(($level +1)) $devcount
164 if [ ! -d /sys/bus ]; then
165 echo "Error: directory /sys/bus does not exist; is sysfs mounted?" >&2
169 for device in /sys/bus/usb/devices/usb*
171 print_device $device 0 0 0