aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2023-10-13 11:22:12 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-16 20:04:12 +0200
commita5372a371f7a0c74df3f79f8384418416eda76ec (patch)
treea94f7298d69bc2702b864e0519b682cbe052e358
parentdb068dbef5935242bba6a2f9fef657c0a2e663dc (diff)
downloadusbutils-a5372a371f7a0c74df3f79f8384418416eda76ec.tar.gz
usbutils: lsusb-t: print entries for devices with no interfaces
Not all USB devices have interfaces. This is true in particular of the STMicroelectronics STEVAL-USBC2DP Type-C to DisplayPort adapter, as well as possibly other USB-C devices. As a result these devices do not show up in the output from "lsusb -t", because the logic in print_tree_dev_interface() lists interfaces, not devices (as implied by the function's name). This means that the output from "lsusb -t" can be inconsistent with the output from "lsusb", since some devices are omitted. To fix the problem, we make the subroutine call print_usbdevice() at least once even if the device has no interfaces, and make the latter routine print a minimal description of such devices (anything that does not require access to the interface descriptor). Reported-and-tested-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/linux-usb/70c563f1-847c-32a1-cf4d-6bf9802017ab@interlog.com/ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--lsusb-t.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lsusb-t.c b/lsusb-t.c
index 167b92e..b119414 100644
--- a/lsusb-t.c
+++ b/lsusb-t.c
@@ -179,9 +179,12 @@ static void print_usbdevice(struct usbdevice *d, struct usbinterface *i)
char lanes[32];
lanes_to_str(lanes, d->tx_lanes, d->rx_lanes);
- get_class_string(subcls, sizeof(subcls), i->bInterfaceClass);
+ if (i)
+ get_class_string(subcls, sizeof(subcls), i->bInterfaceClass);
- if (i->bInterfaceClass == 9)
+ if (!i)
+ printf("Port %03u: Dev %03u, %sM%s\n", d->portnum, d->devnum, d->speed, lanes);
+ else if (i->bInterfaceClass == 9)
printf("Port %03u: Dev %03u, If %u, Class=%s, Driver=%s/%up, %sM%s\n", d->portnum, d->devnum, i->ifnum, subcls,
i->driver, d->maxchild, d->speed, lanes);
else
@@ -686,11 +689,12 @@ static void sort_busses(void)
static void print_tree_dev_interface(struct usbdevice *d, struct usbinterface *i)
{
indent += 3;
- while (i) {
+ do {
printf(" %*s", indent, "|__ ");
print_usbdevice(d, i);
- i = i->next;
- }
+ if (i)
+ i = i->next;
+ } while (i);
indent -= 3;
}
static void print_tree_dev_children(struct usbdevice *d)