summaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-07 00:00:29 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 08:11:18 +0100
commit14726fa7f3e5c43ed9ca9c9da503be82c2bccd72 (patch)
treed1cc899c671e9cb87fa79b2aed986f155a7c3539 /drivers/usb/storage/usb.c
parent303f85ddbd08e5fa6ba5507780cfebbdce1053d9 (diff)
downloadbarebox-14726fa7f3e5c43ed9ca9c9da503be82c2bccd72.tar.gz
usb: storage: Use put_unaligned_be* helpers
Replace explicit endianness casts with put_unaligned_be* helpers. 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, 7 insertions, 11 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 5a5d075..06ec1eb 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -26,6 +26,8 @@
#include <usb/usb.h>
#include <usb/usb_defs.h>
+#include <asm/unaligned.h>
+
#include "usb.h"
#include "transport.h"
@@ -111,13 +113,12 @@ static int usb_stor_inquiry(struct us_blk_dev *usb_blkdev)
struct device_d *dev = &usb_blkdev->us->pusb_dev->dev;
int ret;
u8 cmd[6];
- const u32 datalen = 36;
+ const u16 datalen = 36;
u8 *data = xzalloc(datalen);
memset(cmd, 0, sizeof(cmd));
cmd[0] = SCSI_INQUIRY;
- cmd[3] = (u8)(datalen >> 8);
- cmd[4] = (u8)(datalen >> 0);
+ put_unaligned_be16(datalen, &cmd[3]);
ret = usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data, datalen,
3, USB_STOR_NO_REQUEST_SENSE);
@@ -183,19 +184,14 @@ exit:
}
static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
- unsigned long start, u8 *data,
- unsigned short blocks)
+ u32 start, u8 *data, u16 blocks)
{
u8 cmd[10];
memset(cmd, 0, sizeof(cmd));
cmd[0] = opcode;
- cmd[2] = (u8)(start >> 24);
- cmd[3] = (u8)(start >> 16);
- cmd[4] = (u8)(start >> 8);
- cmd[5] = (u8)(start >> 0);
- cmd[7] = (u8)(blocks >> 8);
- cmd[8] = (u8)(blocks >> 0);
+ put_unaligned_be32(start, &cmd[2]);
+ put_unaligned_be16(blocks, &cmd[7]);
return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data,
blocks * SECTOR_SIZE, 2, 0);