Re: [PATCH 3/4] usbutils: Print MaxStreams and Mult for USB 3.0 devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 1 Sep 2010, Sarah Sharp wrote:

> Add the ability to print the MaxStreams and Mult fields from the
> SuperSpeed Endpoint Companion Descriptors.  Only print them for the
> correct endpoint types (MaxStreams is only valid for bulk endpoints, and
> Mult is only valid for isochronous endpoints).

> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -29,7 +29,7 @@ lsusb_CPPFLAGS = \
>  	-DDATADIR=\"$(datadir)\"
>  
>  lsusb_LDADD = \
> -	$(LIBUSB_LIBS)
> +	$(LIBUSB_LIBS) -lm
>  
>  man_MANS = \
>  	lsusb.8	\
> diff --git a/lsusb.c b/lsusb.c
> index a25ad69..a6c64c5 100644
> --- a/lsusb.c
> +++ b/lsusb.c
> @@ -34,6 +34,7 @@
>  #include <stdarg.h>
>  #include <byteswap.h>
>  #include <usb.h>
> +#include <math.h>
>  
>  #include "names.h"
>  #include "devtree.h"
> @@ -770,6 +771,15 @@ static void dump_endpoint(struct usb_dev_handle *dev, struct usb_interface_descr
>  				break;
>  			case USB_DT_SS_ENDPOINT_COMP:
>  				printf("        bMaxBurst %15u\n", buf[2] + 1);
> +				/* Print bulk streams info or isoc "Mult" */
> +				if ((endpoint->bmAttributes & 3) == 2 &&
> +						(buf[3] & 0x1f))
> +					printf("        MaxStreams %14u\n",
> +							(unsigned) pow(2, buf[3]));

You've got to be kidding.  Use a floating-point exponentiation function 
from the math library to compute an integer power of 2?

What's wrong with "1 << buf[3]"?

Alan Stern


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux