* [PATCH] usbutils: lsusb-t: print entries for devices with no interfaces
@ 2023-10-13 15:22 Alan Stern
2023-10-16 18:05 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Alan Stern @ 2023-10-13 15:22 UTC (permalink / raw)
To: Greg KH; +Cc: Douglas Gilbert, USB mailing list
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/
---
lsusb-t.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
Index: usbutils-master/lsusb-t.c
===================================================================
--- usbutils-master.orig/lsusb-t.c
+++ usbutils-master/lsusb-t.c
@@ -183,9 +183,12 @@ static void print_usbdevice(struct usbde
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
@@ -690,11 +693,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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] usbutils: lsusb-t: print entries for devices with no interfaces
2023-10-13 15:22 [PATCH] usbutils: lsusb-t: print entries for devices with no interfaces Alan Stern
@ 2023-10-16 18:05 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-10-16 18:05 UTC (permalink / raw)
To: Alan Stern; +Cc: Douglas Gilbert, USB mailing list
On Fri, Oct 13, 2023 at 11:22:12AM -0400, Alan Stern wrote:
> 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/
Now applied, thanks! I'll do a new release in a few days to get this
out to the world.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-16 18:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 15:22 [PATCH] usbutils: lsusb-t: print entries for devices with no interfaces Alan Stern
2023-10-16 18:05 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox