summaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-07 00:00:33 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 08:11:18 +0100
commit0f2ee3101423367a0a913d3ed65815c18dfa6ab3 (patch)
treeaf83ab5480b8642d8267ccefae8ee127618ac2a7 /drivers/usb/storage/usb.c
parent3119a8bfa583deab7794cc06db8fd1a13f7cdf3d (diff)
downloadbarebox-0f2ee3101423367a0a913d3ed65815c18dfa6ab3.tar.gz
usb: storage: Use simple boolean to speficy read vs. write operation
Use simple boolean to speficy read vs. write operation usb_stor_blk_io() instead of having a custom anonymous enum. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r--drivers/usb/storage/usb.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 0ab20f1..dc63e8a 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -203,11 +203,10 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
#define US_MAX_IO_BLK 32
-enum { io_rd, io_wr };
-
/* Read / write a chunk of sectors on media */
-static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
- int sector_start, int sector_count, void *buffer)
+static int usb_stor_blk_io(struct block_device *disk_dev,
+ int sector_start, int sector_count, void *buffer,
+ bool read)
{
struct us_blk_dev *pblk_dev = container_of(disk_dev,
struct us_blk_dev,
@@ -225,8 +224,8 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
/* read / write the requested data */
dev_dbg(dev, "%s %u block(s), starting from %d\n",
- (io_op == io_rd) ? "Read" : "Write",
- sector_count, sector_start);
+ read ? "Read" : "Write",
+ sector_count, sector_start);
sectors_done = 0;
while (sector_count > 0) {
int result;
@@ -234,8 +233,7 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
u8 *data = buffer + (sectors_done * SECTOR_SIZE);
result = usb_stor_io_10(pblk_dev,
- (io_op == io_rd) ?
- SCSI_READ10 : SCSI_WRITE10,
+ read ? SCSI_READ10 : SCSI_WRITE10,
(ulong)sector_start,
data, n);
if (result != 0) {
@@ -256,14 +254,14 @@ static int usb_stor_blk_io(int io_op, struct block_device *disk_dev,
static int __maybe_unused usb_stor_blk_write(struct block_device *blk,
const void *buffer, int block, int num_blocks)
{
- return usb_stor_blk_io(io_wr, blk, block, num_blocks, (void *)buffer);
+ return usb_stor_blk_io(blk, block, num_blocks, (void *)buffer, false);
}
/* Read a chunk of sectors from media */
static int usb_stor_blk_read(struct block_device *blk, void *buffer, int block,
int num_blocks)
{
- return usb_stor_blk_io(io_rd, blk, block, num_blocks, buffer);
+ return usb_stor_blk_io(blk, block, num_blocks, buffer, true);
}
static struct block_device_ops usb_mass_storage_ops = {