Re: [PATCH v2] usb: gadget: storage: add superspeed support

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

 



On Fri, 19 Aug 2011, Felipe Balbi wrote:

> > I think the best value would be FSG_BUFLEN / the bulk maxpacket size 
> > (always 1024 for SuperSpeed) -- but no more than the maximum allowed 
> > value (either 15 or 16, I forget which).
> > 
> > We also need to figure out whether the UDC driver should pay attention 
> > to the bMaxBurst value.  If it doesn't support bursting, it would have 
> > to set that field to 0.
> 
> ok... how about the below:
> 
> From c7176d97fe781f7fe0b21ca15ef7f449e5a7598e Mon Sep 17 00:00:00 2001
> From: Felipe Balbi <balbi@xxxxxx>
> Date: Wed, 3 Aug 2011 14:33:27 +0300
> Subject: [PATCH] usb: gadget: storage: add superspeed support
> Organization: Texas Instruments\n

When did TI add the \n to the end of their name?  :-)

> this patch adds superspeed descriptors for the
> storage gadgets.
> 
> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
>  drivers/usb/gadget/f_mass_storage.c |   24 ++++++++++
>  drivers/usb/gadget/file_storage.c   |   29 +++++++++++-
>  drivers/usb/gadget/mass_storage.c   |    2 +-
>  drivers/usb/gadget/storage_common.c |   85 ++++++++++++++++++++++++++++++++++-
>  4 files changed, 134 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index 5b93395..9c12234 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -3019,6 +3019,30 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
>  		}
>  	}
>  
> +	if (gadget_is_superspeed(gadget)) {
> +		u8		max_burst;

Why not just int, or unsigned?

> +		/* Calculate bMaxBurst, we know packet size is 1024 */
> +		max_burst = (FSG_BUFLEN << (FSG_NUM_BUFFERS - 1) >>
> +				(__ffs(1024)));

There's no reason to do a bit-shift by FSG_NUM_BUFFERS - 1.  This
should simply be:

		max_burst = FSG_BUFLEN / 1024;

You can trust the compiler to do the division at compile time, and 
don't bother worrying about right shifts.

> +		max_burst = min_t(u8, max_burst, 15);

In fact, you could even do:

		max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15);

Since FSG_BUFLEN is 16384, this will always come out to 15 anyway.

Alan Stern

P.S.: Just in case you weren't aware, the patch you posted was 
incomplete: It made some changes to g_file_storage and other changes to 
g_mass_storage, but it didn't make all changes to both.

--
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