Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248732
b: refs/heads/master
c: 98346f7
h: refs/heads/master
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Apr 14, 2011
1 parent 13f1517 commit e026932
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: db8fa2852ed5b46c05148db87be135300f17b8ce
refs/heads/master: 98346f7db014614a4814eb60639f651f8bbc591d
24 changes: 20 additions & 4 deletions trunk/drivers/usb/gadget/f_mass_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,20 @@ static int exception_in_progress(struct fsg_common *common)
return common->state > FSG_STATE_IDLE;
}

/* Make bulk-out requests be divisible by the maxpacket size */
static void set_bulk_out_req_length(struct fsg_common *common,
struct fsg_buffhd *bh, unsigned int length)
{
unsigned int rem;

bh->bulk_out_intended_length = length;
rem = length % common->bulk_out_maxpacket;
if (rem > 0)
length += common->bulk_out_maxpacket - rem;
bh->outreq->length = length;
}


/*-------------------------------------------------------------------------*/

static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
Expand Down Expand Up @@ -572,9 +586,9 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
struct fsg_buffhd *bh = req->context;

dump_msg(common, "bulk-out", req->buf, req->actual);
if (req->status || req->actual != req->length)
if (req->status || req->actual != bh->bulk_out_intended_length)
DBG(common, "%s --> %d, %u/%u\n", __func__,
req->status, req->actual, req->length);
req->status, req->actual, bh->bulk_out_intended_length);
if (req->status == -ECONNRESET) /* Request was cancelled */
usb_ep_fifo_flush(ep);

Expand Down Expand Up @@ -966,6 +980,7 @@ static int do_write(struct fsg_common *common)
* the bulk-out maxpacket size
*/
bh->outreq->length = amount;
bh->bulk_out_intended_length = amount;
bh->outreq->short_not_ok = 1;
if (!start_out_transfer(common, bh))
/* Dunno what to do if common->fsg is NULL */
Expand Down Expand Up @@ -1611,6 +1626,7 @@ static int throw_away_data(struct fsg_common *common)
* the bulk-out maxpacket size.
*/
bh->outreq->length = amount;
bh->bulk_out_intended_length = amount;
bh->outreq->short_not_ok = 1;
if (!start_out_transfer(common, bh))
/* Dunno what to do if common->fsg is NULL */
Expand Down Expand Up @@ -2279,8 +2295,8 @@ static int get_next_command(struct fsg_common *common)
}

/* Queue a request to read a Bulk-only CBW */
bh->outreq->length = USB_BULK_CB_WRAP_LEN;
bh->outreq->short_not_ok = 0;
set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN);
bh->outreq->short_not_ok = 1;
if (!start_out_transfer(common, bh))
/* Don't know what to do if common->fsg is NULL */
return -EIO;
Expand Down
28 changes: 22 additions & 6 deletions trunk/drivers/usb/gadget/file_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,19 @@ 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;

Expand Down Expand Up @@ -717,9 +730,10 @@ 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 != req->length)
if (req->status || req->actual != bh->bulk_out_intended_length)
DBG(fsg, "%s --> %d, %u/%u\n", __func__,
req->status, req->actual, req->length);
req->status, req->actual,
bh->bulk_out_intended_length);
if (req->status == -ECONNRESET) // Request was cancelled
usb_ep_fifo_flush(ep);

Expand Down Expand Up @@ -1335,7 +1349,8 @@ static int do_write(struct fsg_dev *fsg)

/* amount is always divisible by 512, hence by
* the bulk-out maxpacket size */
bh->outreq->length = amount;
bh->outreq->length = bh->bulk_out_intended_length =
amount;
bh->outreq->short_not_ok = 1;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);
Expand Down Expand Up @@ -1964,7 +1979,8 @@ 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 = amount;
bh->outreq->length = bh->bulk_out_intended_length =
amount;
bh->outreq->short_not_ok = 1;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);
Expand Down Expand Up @@ -2643,8 +2659,8 @@ static int get_next_command(struct fsg_dev *fsg)
}

/* Queue a request to read a Bulk-only CBW */
bh->outreq->length = USB_BULK_CB_WRAP_LEN;
bh->outreq->short_not_ok = 0;
set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN);
bh->outreq->short_not_ok = 1;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);

Expand Down
7 changes: 7 additions & 0 deletions trunk/drivers/usb/gadget/storage_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ struct fsg_buffhd {
enum fsg_buffer_state state;
struct fsg_buffhd *next;

/*
* The NetChip 2280 is faster, and handles some protocol faults
* better, if we don't submit any short bulk-out read requests.
* So we will record the intended request length here.
*/
unsigned int bulk_out_intended_length;

struct usb_request *inreq;
int inreq_busy;
struct usb_request *outreq;
Expand Down

0 comments on commit e026932

Please sign in to comment.