summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-07 00:00:34 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 08:11:18 +0100
commit39dfaf95d20aa7173182843a8e14cb44253e921a (patch)
tree4ed0d84050ac159467ec7ba33d260f3d2fba3a65
parent0f2ee3101423367a0a913d3ed65815c18dfa6ab3 (diff)
downloadbarebox-39dfaf95d20aa7173182843a8e14cb44253e921a.tar.gz
usb: storage: Simplify I/O loop in usb_stor_blk_io()
Simplify I/O loop a bit, by re-arranging things and dropping "sectors_done", "result" and "data" local variables. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/usb/storage/usb.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index dc63e8a..7df8a52 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -213,7 +213,6 @@ static int usb_stor_blk_io(struct block_device *disk_dev,
blk);
struct us_data *us = pblk_dev->us;
struct device_d *dev = &us->pusb_dev->dev;
- unsigned sectors_done;
/* ensure unit ready */
dev_dbg(dev, "Testing for unit ready\n");
@@ -226,28 +225,23 @@ static int usb_stor_blk_io(struct block_device *disk_dev,
dev_dbg(dev, "%s %u block(s), starting from %d\n",
read ? "Read" : "Write",
sector_count, sector_start);
- sectors_done = 0;
+
while (sector_count > 0) {
- int result;
unsigned n = min(sector_count, US_MAX_IO_BLK);
- u8 *data = buffer + (sectors_done * SECTOR_SIZE);
- result = usb_stor_io_10(pblk_dev,
- read ? SCSI_READ10 : SCSI_WRITE10,
- (ulong)sector_start,
- data, n);
- if (result != 0) {
+ if (usb_stor_io_10(pblk_dev,
+ read ? SCSI_READ10 : SCSI_WRITE10,
+ sector_start,
+ buffer, n)) {
dev_dbg(dev, "I/O error at sector %d\n", sector_start);
break;
}
sector_start += n;
sector_count -= n;
- sectors_done += n;
+ buffer += n * SECTOR_SIZE;
}
- dev_dbg(dev, "Successful I/O of %d blocks\n", sectors_done);
-
- return (sector_count != 0) ? -EIO : 0;
+ return sector_count ? -EIO : 0;
}
/* Write a chunk of sectors to media */