Jassi Brar | 1 Apr 2011 11:38
Picon

Re: [PATCH] usb: gadget: file_storage: don't assume wMaxPacketSize to be 512

On Fri, Apr 1, 2011 at 2:08 PM, Felipe Balbi <balbi@...> wrote:
> we shouldn't assume that value because on SuperSpeed, we have
> 1024 as wMaxPacketSize.
>
> Signed-off-by: Felipe Balbi <balbi@...>
> ---
>
> this was tested with dummy_hcd and a bunch of dd if of
> transfers with different sizes.
>
>  drivers/usb/gadget/file_storage.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
> index a6eacb5..b3c9f29 100644
> --- a/drivers/usb/gadget/file_storage.c
> +++ b/drivers/usb/gadget/file_storage.c
>  <at>  <at>  -1249,6 +1249,7  <at>  <at>  static int do_read(struct fsg_dev *fsg)
>
>  static int do_write(struct fsg_dev *fsg)
>  {
> +       struct usb_ep           *ep = fsg->bulk_out;
>        struct fsg_lun          *curlun = fsg->curlun;
>        u32                     lba;
>        struct fsg_buffhd       *bh;
>  <at>  <at>  -1331,7 +1332,7  <at>  <at>  static int do_write(struct fsg_dev *fsg)
>                                curlun->info_valid = 1;
>                                continue;
>                        }
> -                       amount -= (amount & 511);
> +                       amount -= (amount & (ep->maxpacket - 1));

IMHO,  amount &= ~(ep->maxpacket - 1)  looks better
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@...
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane