aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/file_storage.c
diff options
context:
space:
mode:
authorMian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>2011-03-24 12:20:13 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-13 16:24:04 -0700
commit806e8f8fcc27e1753947bd9f059ba2316cf8f92a (patch)
tree939324f5fa4041bb9d66642e1b6df842d93f4d59 /drivers/usb/gadget/file_storage.c
parent088c64f812847b3623b03d167ed329f90f3e38a4 (diff)
usb: usb_storage: do not align length of request for CBW to maxp size
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. It is incorrect to set short_not_ok when preparing the request to receive CBW. CBW will be a short-packet so short_not_ok must not be set. This makes bh->bulk_out_intended_length unnecessary so it is also removed. Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/file_storage.c')
-rw-r--r--drivers/usb/gadget/file_storage.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index a6eacb59571..d04e0e6b019 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -497,19 +497,6 @@ 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;
-}
-
static struct fsg_dev *the_fsg;
static struct usb_gadget_driver fsg_driver;
@@ -730,10 +717,9 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
struct fsg_buffhd *bh = req->context;
dump_msg(fsg, "bulk-out", req->buf, req->actual);
- if (req->status || req->actual != bh->bulk_out_intended_length)
+ if (req->status || req->actual != req->length)
DBG(fsg, "%s --> %d, %u/%u\n", __func__,
- req->status, req->actual,
- bh->bulk_out_intended_length);
+ req->status, req->actual, req->length);
if (req->status == -ECONNRESET) // Request was cancelled
usb_ep_fifo_flush(ep);
@@ -1349,8 +1335,7 @@ static int do_write(struct fsg_dev *fsg)
/* amount is always divisible by 512, hence by
* the bulk-out maxpacket size */
- bh->outreq->length = bh->bulk_out_intended_length =
- amount;
+ bh->outreq->length = amount;
bh->outreq->short_not_ok = 1;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);
@@ -2010,8 +1995,7 @@ static int throw_away_data(struct fsg_dev *fsg)
/* amount is always divisible by 512, hence by
* the bulk-out maxpacket size */
- bh->outreq->length = bh->bulk_out_intended_length =
- amount;
+ bh->outreq->length = amount;
bh->outreq->short_not_ok = 1;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);
@@ -2688,8 +2672,8 @@ static int get_next_command(struct fsg_dev *fsg)
}
/* Queue a request to read a Bulk-only CBW */
- set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN);
- bh->outreq->short_not_ok = 1;
+ bh->outreq->length = USB_BULK_CB_WRAP_LEN;
+ bh->outreq->short_not_ok = 0;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);