[U-Boot] USB mass storage gadget patch

victor
2012-11-02T11:43:16Z

>> I attach the file for your reference. Please kindly advise me. Thanks.

The changes of file_storage.c:

--- file_storage.c 2012-11-02 18:27:41.072702402 +0800
+++ file_storage.orig.c 2012-11-02 19:36:37.992528292 +0800

@@ -746,10 +745,6 @@
struct fsg_dev *fsg = ep->driver_data;
struct fsg_buffhd *bh = req->context;

-ga_bh = bh;
-ga_tag = fsg->tag;
-
dump_msg(fsg, "bulk-out", req->buf, req->actual);
if (req->status || req->actual != bh->bulk_out_intended_length)
DBG(fsg, "%s --> %d, %u/%u\n", __func__,

@@ -1185,9 +1174,6 @@
return rc;
}

-bh->inreq->buf = bh->buf;
-
/* If we were asked to read past the end of file,
* end with an empty buffer. */
if (amount == 0) {
@@ -1575,8 +1560,6 @@
static char vendor_id[] = "Linux ";
static char product_cdrom_id[] = "File-CD Gadget ";

-bh->inreq->buf = bh->buf;

if (!fsg->curlun) { // Unsupported LUNs are okay
fsg->bad_lun_okay = 1;
@@ -1667,15 +1649,12 @@
int pmi = fsg->cmnd[8];
u8 *buf = (u8 *) bh->buf;

-bh->inreq->buf = bh->buf;
/* Check the PMI and LBA fields */
if (pmi > 1 || (pmi == 0 && lba != 0)) {
curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
return -EINVAL;
}

@@ -1755,8 +1734,6 @@
curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED;
return -EINVAL;
}
-printf("C %s %x ", __func__, (u8 *)bh->buf);
-bh->inreq->buf = bh->buf;

changeable_values = (pc == 1);
all_pages = (page_code == 0x3f);
@@ -1865,8 +1842,6 @@
struct fsg_lun *curlun = fsg->curlun;
u8 *buf = (u8 *) bh->buf;

-printf("%s\n",__func__);
-bh->inreq->buf = bh->buf;
buf[0] = buf[1] = buf[2] = 0;
buf[3] = 8; // Only the Current/Maximum Capacity
Descriptor
buf += 4;
@@ -1956,9 +1931,8 @@

nsend = min(fsg->usb_amount_left, (u32) mod_data.buflen);
memset(bh->buf + nkeep, 0, nsend - nkeep);
- //bh->inreq->length = nsend;
+ bh->inreq->length = nsend;
bh->inreq->zero = 0;
-printf("%s %x %d %d\n", __func__, (u8 *)bh, bh->inreq->length, nsend);
start_transfer(fsg, fsg->bulk_in, bh->inreq,
&bh->inreq_busy, &bh->state);
bh = fsg->next_buffhd_to_fill = bh->next;

@@ -2137,13 +2107,7 @@

/* Wait for the next buffer to become available */
bh = fsg->next_buffhd_to_fill;
-printf("%s %x %d\n", __func__, (u8 *)bh, bh->state);
while (bh->state != BUF_STATE_EMPTY) {
-if (bh->state == BUF_STATE_FULL)
-{
- bh->state = BUF_STATE_EMPTY;
- break;
-}
rc = sleep_thread(fsg, __LINE__);
if (rc)
return rc;
@@ -2180,8 +2144,6 @@

bh->inreq->length = USB_BULK_CS_WRAP_LEN;
bh->inreq->zero = 0;
-bh->inreq->buf = bh->buf;
-printf("bbb %s %x %d\n", __func__, (u8 *)bh, bh->state);
start_transfer(fsg, fsg->bulk_in, bh->inreq,
&bh->inreq_busy, &bh->state);

@@ -2362,12 +2320,9 @@
for (i = 1; i < cmnd_size; ++i) {
if (fsg->cmnd[i] && !(mask & (1 << i))) {

if (curlun)
curlun->sense_data =
SS_INVALID_FIELD_IN_CDB;
//return -EINVAL;

}
}

@@ -2669,8 +2620,6 @@

ga_bh->inreq->length = USB_BULK_CS_WRAP_LEN;
ga_bh->inreq->zero = 0;
-ga_bh->inreq->buf = ga_bh->buf;
-printf("bbb %s %x %d\n", __func__, (u8 *)ga_bh, ga_bh->state);
start_transfer(fsg, fsg->bulk_in, ga_bh->inreq,
&(ga_bh->inreq_busy), &(ga_bh->state));

@@ -2732,26 +2679,20 @@
/* 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;
-printf("call start_transfer, %x %x\n", (u8 *)bh, (u8 *)(fsg->bulk_out));
-bh->outreq->context = bh;
start_transfer(fsg, fsg->bulk_out, bh->outreq,
&bh->outreq_busy, &bh->state);

@@ -3468,8 +3406,6 @@
ep->driver_data = fsg; // claim the endpoint
fsg->bulk_out = ep;

-if (fsg_fs_bulk_out_desc.bEndpointAddress != 0x1)
- fsg_fs_bulk_out_desc.bEndpointAddress = 0x1;

if (transport_is_cbi()) {
ep = usb_ep_autoconfig(gadget, &fsg_fs_intr_in_desc);