From: Ana Bobillo <[email protected]>
When READ CAPACITY fails, usb_stor_get_info() makes up a reply of its own
for a 1.44MB floppy, 2880 blocks of 512 bytes. But it sets the values in
host byte order, while the reply is read back as big endian, so on a
little-endian host the device gets 0x400b0001 blocks (about 1G) of 128KiB
rather than 2880 of 512 bytes. It also puts 2880 where READ CAPACITY
returns the last LBA, so even on a big-endian host the device gets 2881
blocks.
Set the reply in big endian like the one it stands in for, with 2879 as
the last LBA, so that such a device has 2880 blocks of 512 bytes on any
host.
Fixes: 149dded2b178 ("* Add support for USB Mass Storage Devices (BBB)
(tested with USB memory sticks only)")
Signed-off-by: Ana Bobillo <[email protected]>
---
Changes in v2:
- New patch, split out of v1 patch 2, with a Fixes: tag (Simon)
- Give 2879 as the last LBA, so that the device has 2880 blocks (Simon)
common/usb_storage.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index ac331f1c1b0..f7c96195b59 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1496,8 +1496,9 @@ int usb_stor_get_info(struct usb_device *dev, struct
us_data *ss,
if (usb_read_capacity(pccb, ss) != 0) {
printf("READ_CAP ERROR\n");
ss->flags &= ~USB_READY;
- cap[0] = 2880;
- cap[1] = 0x200;
+ /* a 1.44MB floppy, as READ CAPACITY gives it: last LBA, size */
+ cap[0] = cpu_to_be32(2880 - 1);
+ cap[1] = cpu_to_be32(0x200);
}
debug("Read Capacity returns: 0x%08x, 0x%08x\n", cap[0], cap[1]);
#if 0