Message ID | 1497619909-29454-16-git-send-email-bmeng.cn@gmail.com |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show |
On 16 June 2017 at 07:31, Bin Meng <bmeng.cn@gmail.com> wrote: > USB 3.0 defines bMaxPacketSize0 field in the device descriptor as > the exponent of 2, so let's print the calculated actual size. > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com> > --- > > cmd/usb.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) Reviewed-by: Simon Glass <sjg@chromium.org> Please see below. > > diff --git a/cmd/usb.c b/cmd/usb.c > index 4fa456e..1bdd391 100644 > --- a/cmd/usb.c > +++ b/cmd/usb.c > @@ -150,6 +150,8 @@ static void usb_display_string(struct usb_device *dev, int index) > > static void usb_display_desc(struct usb_device *dev) > { > + u16 bMaxPacketSize0 = dev->descriptor.bMaxPacketSize0; I suggest uint and also 'normal' variable name like packet_size. > + > if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) { > printf("%d: %s, USB Revision %x.%x\n", dev->devnum, > usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass), > @@ -171,9 +173,10 @@ static void usb_display_desc(struct usb_device *dev) > usb_get_class_desc( > dev->config.if_desc[0].desc.bInterfaceClass)); > } > + if (dev->descriptor.bcdUSB >= cpu_to_le16(0x0300)) > + bMaxPacketSize0 = 1 << bMaxPacketSize0; > printf(" - PacketSize: %d Configurations: %d\n", > - dev->descriptor.bMaxPacketSize0, > - dev->descriptor.bNumConfigurations); > + bMaxPacketSize0, dev->descriptor.bNumConfigurations); > printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n", > dev->descriptor.idVendor, dev->descriptor.idProduct, > (dev->descriptor.bcdDevice>>8) & 0xff, > -- > 2.9.2 > Regards, Simon
diff --git a/cmd/usb.c b/cmd/usb.c index 4fa456e..1bdd391 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -150,6 +150,8 @@ static void usb_display_string(struct usb_device *dev, int index) static void usb_display_desc(struct usb_device *dev) { + u16 bMaxPacketSize0 = dev->descriptor.bMaxPacketSize0; + if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) { printf("%d: %s, USB Revision %x.%x\n", dev->devnum, usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass), @@ -171,9 +173,10 @@ static void usb_display_desc(struct usb_device *dev) usb_get_class_desc( dev->config.if_desc[0].desc.bInterfaceClass)); } + if (dev->descriptor.bcdUSB >= cpu_to_le16(0x0300)) + bMaxPacketSize0 = 1 << bMaxPacketSize0; printf(" - PacketSize: %d Configurations: %d\n", - dev->descriptor.bMaxPacketSize0, - dev->descriptor.bNumConfigurations); + bMaxPacketSize0, dev->descriptor.bNumConfigurations); printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n", dev->descriptor.idVendor, dev->descriptor.idProduct, (dev->descriptor.bcdDevice>>8) & 0xff,
USB 3.0 defines bMaxPacketSize0 field in the device descriptor as the exponent of 2, so let's print the calculated actual size. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> --- cmd/usb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)