On Fri, 01 Apr 2011 12:19:59 +0200, Felipe Balbi <balbi@xxxxxx> wrote:
we shouldn't assume that value because on SuperSpeed, we have
1024 as wMaxPacketSize.
The more I look at the code, the more I wonder whether this 511
constant is a consequence of wMaxPacketSize being 512 or mass
storage using 512-byte blocks when reading/writing data from/to
backing file.
Signed-off-by: Felipe Balbi <balbi@xxxxxx>
---
drivers/usb/gadget/f_mass_storage.c | 3 ++-
drivers/usb/gadget/file_storage.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/f_mass_storage.c
b/drivers/usb/gadget/f_mass_storage.c
index 6d8e533..9edcd8a 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -864,6 +864,7 @@ static int do_read(struct fsg_common *common)
static int do_write(struct fsg_common *common)
{
+ struct usb_ep *ep = common->fsg->bulk_out;
struct fsg_lun *curlun = common->curlun;
u32 lba;
struct fsg_buffhd *bh;
@@ -952,7 +953,7 @@ static int do_write(struct fsg_common *common)
curlun->info_valid = 1;
continue;
}
- amount -= amount & 511;
+ amount &= ~(ep->maxpacket - 1);
if (amount == 0) {
/*
diff --git a/drivers/usb/gadget/file_storage.c
b/drivers/usb/gadget/file_storage.c
index a6eacb5..fe59944 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1249,6 +1249,7 @@ static int do_read(struct fsg_dev *fsg)
static int do_write(struct fsg_dev *fsg)
{
+ struct usb_ep *ep = fsg->bulk_out;
struct fsg_lun *curlun = fsg->curlun;
u32 lba;
struct fsg_buffhd *bh;
@@ -1331,7 +1332,7 @@ static int do_write(struct fsg_dev *fsg)
curlun->info_valid = 1;
continue;
}
- amount -= (amount & 511);
+ amount &= ~(ep->maxpacket - 1);
if (amount == 0) {
/* Why were we were asked to transfer a
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +-----<email/xmpp: mnazarewicz@xxxxxxxxxx>-----ooO--(_)--Ooo--
--
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