Re: [PATCH 1/2] usb: usb_storage: do not align length of request for CBW to maxp size

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

 



On Tue, 22 Mar 2011, Mian Yousaf Kaukab wrote:

> Mass-storage and file-storage gadgets align the length to maximum-packet-size
> when preparing the request to receive CBW. This is unnecessary and prevents the
> controller driver from knowing that a short-packet is expected.

This code was written more than seven years ago, and I don't really
remember the reason for it.  Perhaps because the net2880 driver worked
better with it -- maybe receiving a short packet was generally better
than specifying an exact length and then getting an overflow error if
the host sent extra data.

But it's not a big deal either way.  Since I can't remember the reason
for putting it in, removing it should be okay.

However...  Please resubmit this after combining 1/2 and 2/2 into a
single patch.  After all, together they only make a single change.  
You should not have separated this change into two patches, because the
intermediate state is broken.

> Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@xxxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/f_mass_storage.c |    6 ------
>  drivers/usb/gadget/file_storage.c   |    6 ------
>  2 files changed, 0 insertions(+), 12 deletions(-)

> diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
> index a6eacb5..9ecd3ac 100644
> --- a/drivers/usb/gadget/file_storage.c
> +++ b/drivers/usb/gadget/file_storage.c
> @@ -497,16 +497,10 @@ static int exception_in_progress(struct fsg_dev *fsg)
>  	return (fsg->state > FSG_STATE_IDLE);
>  }
>  
> -/* Make bulk-out requests be divisible by the maxpacket size */
>  static void set_bulk_out_req_length(struct fsg_dev *fsg,
>  		struct fsg_buffhd *bh, unsigned int length)
>  {
> -	unsigned int	rem;
> -
>  	bh->bulk_out_intended_length = length;
> -	rem = length % fsg->bulk_out_maxpacket;
> -	if (rem > 0)
> -		length += fsg->bulk_out_maxpacket - rem;
>  	bh->outreq->length = length;
>  }

Don't do this.  Just get rid of the function entirely, and move the 
part you want to keep to the single place where the function was 
called.

At the same time, you should get rid of bh->bulk_out_intended_length.  
There is no longer any need for it; it will always be equal to
bh->outreq->length.

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