Commit Graph

24 Commits

Author SHA1 Message Date
Teresa Remmet
da155d965a usb-devices: Fix usb-devices with busybox
The busybox find command is missing the -printf parameter leading to
the error:

find: unrecognized: -printf

Replace the parameter with sed.

This patch was originally created by Daniel Fancsali.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
2024-09-05 08:46:52 +02:00
Dominique Leuenberger
3b79e9c866
usb-devices: fix bashism
> checkbashisms usb-devices
possible bashism in usb-devices line 78 ('((' should be '$(('):
	maxps=$(($(printf "%4i*%s\n" $((maxps_hex & 0x7ff)) \
                $((1 + ((maxps_hex >> 11) & 0x3))))))

Signed-off-by: Dominique Leuenberger <dimstar@opensuse.org>
2023-11-28 14:28:50 +01:00
Lukas Nykryn
89dd6ffbca usb-devices: make shellcheck happy
This change should not make any difference in behavior,
but fixes all shellcheck warnings besides https://www.shellcheck.net/wiki/SC3043

Also replacing 'var=`cat file`' with 'read' makes usb-devices much faster.

Old:
real	0m0,849s
user	0m0,388s
sys	0m0,531s

New:
real	0m0,245s
user	0m0,109s
sys	0m0,155s

Signed-off-by: Lukas Nykryn <lnykryn@redhat.com>
2023-03-31 14:01:37 +02:00
Greg Kroah-Hartman
4bf4819a0d usb-devices: fix field width on device speed field
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-20 11:40:59 +01:00
Greg Kroah-Hartman
b1c3171213 usb-devices: use 'local' variable type to handle recursion
When recursing into a long USB tree, the local variables in the
print_device() function would get confused and take on the value of the
previous device it printed.  This caused devices to not get printed out
at all, the exact opposite of what we wanted.

Resolve this by using the non-POSIX 'local' variable declaration.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-15 16:07:17 +02:00
Greg Kroah-Hartman
9b5f18e2df usb-devices: list the root devices in numerical order
Previously "usb10" would come before "usb2"

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-15 16:06:13 +02:00
Lukas Zaoral
3121a078a3
usb-devices: do not use local in a POSIX shell script
Fixes:
$ ksh /bin/usb-devices
/bin/usb-devices[92]: local: not found [No such file or directory]

Signed-off-by: Lukas Zaoral <lzaoral@redhat.com>
2021-07-21 14:06:47 +02:00
Ruslan Kabatsayev
d131266685 Fix formatting of max endpoint packet size to match /sys/kernel/debug/usb/devices
Max packet size is printed as a single number in
/sys/kernel/debug/usb/devices, rather than a product of the form X*Y.
This patch makes the output of usb-devices match
/sys/kernel/debug/usb/devices.

Signed-off-by: Ruslan Kabatsayev <b7.10110111@gmail.com>
2021-02-23 14:45:39 +03:00
Ruslan Kabatsayev
9a8fef9f31 Fix formatting of endpoint type to match /sys/kernel/debug/usb/devices
Endpoint type is given as "Control" or "Interrupt" in
/sys/bus/usb/devices/..../type, while in /sys/kernel/debug/usb/devices
it's instead "Ctrl" or "Int.", respectively. This patch adds conversion
so that the relevant output of usb-devices matches
/sys/kernel/debug/usb/devices.

Signed-off-by: Ruslan Kabatsayev <b7.10110111@gmail.com>
2021-02-23 14:45:32 +03:00
Ruslan Kabatsayev
fa02764527 Fix formatting of endpoint direction to match /sys/kernel/debug/usb/devices
Direction of an endpoint is formatted as "I", "O" or "B" in
/sys/kernel/debug/usb/devices, while in
/sys/bus/usb/devices/..../direction it's instead "in", "out" or "both". This
patch adds the conversion to make the relevant output of usb-devices
look like /sys/kernel/debug/usb/devices.

Signed-off-by: Ruslan Kabatsayev <b7.10110111@gmail.com>
2021-02-22 22:31:39 +03:00
Ruslan Kabatsayev
1a19bf5d8e Fix formatting of interface descriptors to match /sys/kernel/debug/usb/devices
Interface and number of endpoints are formatted as decimals in
/sys/kernel/debug/usb/devices, while their formatting in dedicated files
under /sys/bus/usb/devices/ is in hexadecimal without 0x prefix. This
patch ensures the correct conversion for both.

Signed-off-by: Ruslan Kabatsayev <b7.10110111@gmail.com>
2021-02-22 22:22:31 +03:00
Ruslan Kabatsayev
993a9817d5 Fix locating endpoint when it's a directory rather than a symlink
This is required at least on my Linux 4.14.157 system, as well as Ubuntu
20.04 with Linux 5.4.0-42-generic.

Signed-off-by: Ruslan Kabatsayev <b7.10110111@gmail.com>
2021-02-22 18:36:14 +03:00
Greg Kroah-Hartman
23b232bf36 rename "GPL-2.0+" to "GPL-2.0-or-later"
This makes `reuse lint` happy as well as license lawyers...

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-22 14:25:02 +01:00
Rob Gill
434a7cc56e Additional device classes for usb-devices script
Several newer USB Device classes are not presently reported individually by
usb-devices, (They are reported as "unk. ").

This patch adds the following classes: 10h (USB Type-C combined Audio/Video
devices) 11h (USB billboard), 12h (USB Type-C Bridge).
As defined at [https://www.usb.org/defined-class-codes]

Signed-off-by: Rob Gill <rrobgill@protonmail.com>
2020-06-21 13:57:09 +10:00
Ross Burton
508d1acf42
usb-devices: use /bin/sh hashbang
This script doesn't use any bashisms, so change the hashbang to /bin/sh.

Fixes #73.

Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-07-27 15:35:15 +01:00
Greg Kroah-Hartman
d77b57e2fb usb-devices: reword the copyright identifier
Now tools can correctly pick up the copyright identifier for this file.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-15 12:07:11 +02:00
Greg Kroah-Hartman
f6f293c82d Add correct SPDX license identifiers to all files
This removes the "boiler-plate" license texts in the individual files to
use SPDX identifiers instead.  Cleans up the text a lot.

All copyright notices were left intact, as this does not change
anything.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08 15:46:10 +01:00
Grueninger, Tobias
00b975b4d8 USB: usb-devices: Interface number can be a string
At least with one new LTE Modem (Gemalto PLS8-E) I found
that the Interface Number can also be a character (a, b, c and d). This leads
to that the printf gives an error and the line is not displayed correctly

Changing the configuration to string fixes this for both int and string
Interface Enumerators

Signed-off-by: Tobias Grueninger  <tobias.grueninger@infoteam.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-27 09:21:38 +01:00
Raphaël Droz
704d56fdc3 usb-devices: hexadecimal bInterfaceNumber handling
# lsusb -s 1:2
Bus 001 Device 002: ID 0421:0264 Nokia Mobile Phone
# cat /sys/bus/usb/devices/usb1/1-2/1-2:1.10/bInterfaceNumber
0a
# bash -vx usb-devices
[...]
printf 'I:  If#=%2i Alt=%2i #EPs=%2i Cls=%s(%s) Sub=%s Prot=%s Driver=%s\n' 0a 0 00 02 commc 0b 00 '(none)'
bash: printf: 0a: invalid number
[...]
2014-10-11 10:28:01 -03:00
Aurelien Jarno
c8b0710dbb usb-devices: correctly quote driver path
Some drivers have a name containing spaces. This causes quoting issues:

  + '[' -L /sys/bus/usb/devices/usb1/1-1/1-1.4/1-1.4.1/1-1.4.1:1.0/driver ']'
  ++ readlink /sys/bus/usb/devices/usb1/1-1/1-1.4/1-1.4.1/1-1.4.1:1.0/driver
  + driver='../../../../../../../../bus/usb/drivers/MOSCHIP usb-ethernet driver'
  ++ basename ../../../../../../../../bus/usb/drivers/MOSCHIP usb-ethernet driver
  basename: extra operand `driver'
  Try `basename --help' for more information.
  + driver=

Reported-by: Vincent Smeets <Vincent.VSmeets@GMail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 16:15:50 -07:00
Bjørn Mork
bac065fe7b usb-devices: avoid numbers being seen as octal by printf
This prevents ugly error messages like this caused by
feeding 08 or 09 to printf:

T:  Bus=02 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 77 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1199 ProdID=68a2 Rev=00.06
S:  Manufacturer=Sierra Wireless, Incorporated
S:  Product=MC7710
S:  SerialNumber=3581xxxxxxxx
C:  #Ifs= 6 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=qcserial
I:  If#=13 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=qcserial
I:  If#=14 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qcserial
/usr/bin/usb-devices: line 79: printf: 08: invalid octal number
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan

Signed-off-by: Bjørn Mork <bjorn@mork.no>
2012-11-14 01:18:27 +01:00
Aurelien Jarno
70be91cb18 usb-devices: fix parsing of bcdDevice
The kernel already provide bcdDevice in the right format, there is no
need to reinterpret the value. Doing it leads to the following error
with some devices:

| ...
| T:  Bus=06 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  2 Spd=12  MxCh= 0
| D:  Ver= 1.10 Cls=ff(vend.) Sub=ff Prot=ff MxPS= 8 #Cfgs=  1
| /usr/sbin/usb-devices: line 128: printf: 0c: invalid number
| P:  Vendor=08ff ProdID=1600 Rev= 0.10
| ...

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-08-17 15:20:58 -07:00
Frans Pop
d757b05894 usb-devices: harmonize class descriptions with usb/devices file
Some class descriptions are different from the ones defined in the
kernel and used in the usb/devices file. This harmonizes them.

Signed-off-by: Frans Pop <elendil@planet.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-25 13:21:21 -07:00
Greg Kroah-Hartman
381341bbae usb-devices: add script and man page.
Thanks to Frans Pop <elendil@planet.nl> and Randy Dunlap for the
script and documentation.
2009-06-25 09:02:51 -07:00