diff options
author | Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com> | 2011-03-24 07:20:13 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-13 19:24:04 -0400 |
commit | 806e8f8fcc27e1753947bd9f059ba2316cf8f92a (patch) | |
tree | 939324f5fa4041bb9d66642e1b6df842d93f4d59 /drivers/usb | |
parent | 088c64f812847b3623b03d167ed329f90f3e38a4 (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')
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 24 | ||||
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 28 | ||||
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 7 |
3 files changed, 10 insertions, 49 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 6d8e533949eb..125587ac5d0b 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -474,20 +474,6 @@ static int exception_in_progress(struct fsg_common *common) | |||
474 | return common->state > FSG_STATE_IDLE; | 474 | return common->state > FSG_STATE_IDLE; |
475 | } | 475 | } |
476 | 476 | ||
477 | /* Make bulk-out requests be divisible by the maxpacket size */ | ||
478 | static void set_bulk_out_req_length(struct fsg_common *common, | ||
479 | struct fsg_buffhd *bh, unsigned int length) | ||
480 | { | ||
481 | unsigned int rem; | ||
482 | |||
483 | bh->bulk_out_intended_length = length; | ||
484 | rem = length % common->bulk_out_maxpacket; | ||
485 | if (rem > 0) | ||
486 | length += common->bulk_out_maxpacket - rem; | ||
487 | bh->outreq->length = length; | ||
488 | } | ||
489 | |||
490 | |||
491 | /*-------------------------------------------------------------------------*/ | 477 | /*-------------------------------------------------------------------------*/ |
492 | 478 | ||
493 | static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) | 479 | static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) |
@@ -586,9 +572,9 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) | |||
586 | struct fsg_buffhd *bh = req->context; | 572 | struct fsg_buffhd *bh = req->context; |
587 | 573 | ||
588 | dump_msg(common, "bulk-out", req->buf, req->actual); | 574 | dump_msg(common, "bulk-out", req->buf, req->actual); |
589 | if (req->status || req->actual != bh->bulk_out_intended_length) | 575 | if (req->status || req->actual != req->length) |
590 | DBG(common, "%s --> %d, %u/%u\n", __func__, | 576 | DBG(common, "%s --> %d, %u/%u\n", __func__, |
591 | req->status, req->actual, bh->bulk_out_intended_length); | 577 | req->status, req->actual, req->length); |
592 | if (req->status == -ECONNRESET) /* Request was cancelled */ | 578 | if (req->status == -ECONNRESET) /* Request was cancelled */ |
593 | usb_ep_fifo_flush(ep); | 579 | usb_ep_fifo_flush(ep); |
594 | 580 | ||
@@ -975,7 +961,6 @@ static int do_write(struct fsg_common *common) | |||
975 | * the bulk-out maxpacket size | 961 | * the bulk-out maxpacket size |
976 | */ | 962 | */ |
977 | bh->outreq->length = amount; | 963 | bh->outreq->length = amount; |
978 | bh->bulk_out_intended_length = amount; | ||
979 | bh->outreq->short_not_ok = 1; | 964 | bh->outreq->short_not_ok = 1; |
980 | if (!start_out_transfer(common, bh)) | 965 | if (!start_out_transfer(common, bh)) |
981 | /* Dunno what to do if common->fsg is NULL */ | 966 | /* Dunno what to do if common->fsg is NULL */ |
@@ -1652,7 +1637,6 @@ static int throw_away_data(struct fsg_common *common) | |||
1652 | * the bulk-out maxpacket size. | 1637 | * the bulk-out maxpacket size. |
1653 | */ | 1638 | */ |
1654 | bh->outreq->length = amount; | 1639 | bh->outreq->length = amount; |
1655 | bh->bulk_out_intended_length = amount; | ||
1656 | bh->outreq->short_not_ok = 1; | 1640 | bh->outreq->short_not_ok = 1; |
1657 | if (!start_out_transfer(common, bh)) | 1641 | if (!start_out_transfer(common, bh)) |
1658 | /* Dunno what to do if common->fsg is NULL */ | 1642 | /* Dunno what to do if common->fsg is NULL */ |
@@ -2322,8 +2306,8 @@ static int get_next_command(struct fsg_common *common) | |||
2322 | } | 2306 | } |
2323 | 2307 | ||
2324 | /* Queue a request to read a Bulk-only CBW */ | 2308 | /* Queue a request to read a Bulk-only CBW */ |
2325 | set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN); | 2309 | bh->outreq->length = USB_BULK_CB_WRAP_LEN; |
2326 | bh->outreq->short_not_ok = 1; | 2310 | bh->outreq->short_not_ok = 0; |
2327 | if (!start_out_transfer(common, bh)) | 2311 | if (!start_out_transfer(common, bh)) |
2328 | /* Don't know what to do if common->fsg is NULL */ | 2312 | /* Don't know what to do if common->fsg is NULL */ |
2329 | return -EIO; | 2313 | return -EIO; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index a6eacb59571b..d04e0e6b019d 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) | |||
497 | return (fsg->state > FSG_STATE_IDLE); | 497 | return (fsg->state > FSG_STATE_IDLE); |
498 | } | 498 | } |
499 | 499 | ||
500 | /* Make bulk-out requests be divisible by the maxpacket size */ | ||
501 | static void set_bulk_out_req_length(struct fsg_dev *fsg, | ||
502 | struct fsg_buffhd *bh, unsigned int length) | ||
503 | { | ||
504 | unsigned int rem; | ||
505 | |||
506 | bh->bulk_out_intended_length = length; | ||
507 | rem = length % fsg->bulk_out_maxpacket; | ||
508 | if (rem > 0) | ||
509 | length += fsg->bulk_out_maxpacket - rem; | ||
510 | bh->outreq->length = length; | ||
511 | } | ||
512 | |||
513 | static struct fsg_dev *the_fsg; | 500 | static struct fsg_dev *the_fsg; |
514 | static struct usb_gadget_driver fsg_driver; | 501 | static struct usb_gadget_driver fsg_driver; |
515 | 502 | ||
@@ -730,10 +717,9 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) | |||
730 | struct fsg_buffhd *bh = req->context; | 717 | struct fsg_buffhd *bh = req->context; |
731 | 718 | ||
732 | dump_msg(fsg, "bulk-out", req->buf, req->actual); | 719 | dump_msg(fsg, "bulk-out", req->buf, req->actual); |
733 | if (req->status || req->actual != bh->bulk_out_intended_length) | 720 | if (req->status || req->actual != req->length) |
734 | DBG(fsg, "%s --> %d, %u/%u\n", __func__, | 721 | DBG(fsg, "%s --> %d, %u/%u\n", __func__, |
735 | req->status, req->actual, | 722 | req->status, req->actual, req->length); |
736 | bh->bulk_out_intended_length); | ||
737 | if (req->status == -ECONNRESET) // Request was cancelled | 723 | if (req->status == -ECONNRESET) // Request was cancelled |
738 | usb_ep_fifo_flush(ep); | 724 | usb_ep_fifo_flush(ep); |
739 | 725 | ||
@@ -1349,8 +1335,7 @@ static int do_write(struct fsg_dev *fsg) | |||
1349 | 1335 | ||
1350 | /* amount is always divisible by 512, hence by | 1336 | /* amount is always divisible by 512, hence by |
1351 | * the bulk-out maxpacket size */ | 1337 | * the bulk-out maxpacket size */ |
1352 | bh->outreq->length = bh->bulk_out_intended_length = | 1338 | bh->outreq->length = amount; |
1353 | amount; | ||
1354 | bh->outreq->short_not_ok = 1; | 1339 | bh->outreq->short_not_ok = 1; |
1355 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 1340 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
1356 | &bh->outreq_busy, &bh->state); | 1341 | &bh->outreq_busy, &bh->state); |
@@ -2010,8 +1995,7 @@ static int throw_away_data(struct fsg_dev *fsg) | |||
2010 | 1995 | ||
2011 | /* amount is always divisible by 512, hence by | 1996 | /* amount is always divisible by 512, hence by |
2012 | * the bulk-out maxpacket size */ | 1997 | * the bulk-out maxpacket size */ |
2013 | bh->outreq->length = bh->bulk_out_intended_length = | 1998 | bh->outreq->length = amount; |
2014 | amount; | ||
2015 | bh->outreq->short_not_ok = 1; | 1999 | bh->outreq->short_not_ok = 1; |
2016 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 2000 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
2017 | &bh->outreq_busy, &bh->state); | 2001 | &bh->outreq_busy, &bh->state); |
@@ -2688,8 +2672,8 @@ static int get_next_command(struct fsg_dev *fsg) | |||
2688 | } | 2672 | } |
2689 | 2673 | ||
2690 | /* Queue a request to read a Bulk-only CBW */ | 2674 | /* Queue a request to read a Bulk-only CBW */ |
2691 | set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN); | 2675 | bh->outreq->length = USB_BULK_CB_WRAP_LEN; |
2692 | bh->outreq->short_not_ok = 1; | 2676 | bh->outreq->short_not_ok = 0; |
2693 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 2677 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
2694 | &bh->outreq_busy, &bh->state); | 2678 | &bh->outreq_busy, &bh->state); |
2695 | 2679 | ||
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index b015561fd602..3179b8bb6ced 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -286,13 +286,6 @@ struct fsg_buffhd { | |||
286 | enum fsg_buffer_state state; | 286 | enum fsg_buffer_state state; |
287 | struct fsg_buffhd *next; | 287 | struct fsg_buffhd *next; |
288 | 288 | ||
289 | /* | ||
290 | * The NetChip 2280 is faster, and handles some protocol faults | ||
291 | * better, if we don't submit any short bulk-out read requests. | ||
292 | * So we will record the intended request length here. | ||
293 | */ | ||
294 | unsigned int bulk_out_intended_length; | ||
295 | |||
296 | struct usb_request *inreq; | 289 | struct usb_request *inreq; |
297 | int inreq_busy; | 290 | int inreq_busy; |
298 | struct usb_request *outreq; | 291 | struct usb_request *outreq; |