summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers/usb/usbmsc.c
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2013-01-15 16:22:04 -0800
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-03-12 23:56:16 +0100
commit2c2c4fae2221f87aeff88162fa3216f3a91af793 (patch)
treebcbca2817987c5dd0bb73b2e90e43cff722debd0 /payloads/libpayload/drivers/usb/usbmsc.c
parentee5c111755ac4acc6dfb6e10a4e271211e149a39 (diff)
downloadcoreboot-2c2c4fae2221f87aeff88162fa3216f3a91af793.tar.xz
libpayload: In the USBMSC read_capacity function, make buf an array of u32.
That way when it's treated as a u32 when its value is extracted for numblocks and blocksize below, it doesn't make the compiler unhappy, and it ensures that the buffer will be properly aligned on architectures where that sort of thing matters. Built and saw warnings about type punning go away. Change-Id: I254e0b5e70847112d660675b7df0ac9cb52e4051 Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://review.coreboot.org/2653 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'payloads/libpayload/drivers/usb/usbmsc.c')
-rw-r--r--payloads/libpayload/drivers/usb/usbmsc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/payloads/libpayload/drivers/usb/usbmsc.c b/payloads/libpayload/drivers/usb/usbmsc.c
index 0032f581bb..16af44888e 100644
--- a/payloads/libpayload/drivers/usb/usbmsc.c
+++ b/payloads/libpayload/drivers/usb/usbmsc.c
@@ -375,14 +375,14 @@ read_capacity (usbdev_t *dev)
cmdblock_t cb;
memset (&cb, 0, sizeof (cb));
cb.command = 0x25; // read capacity
- u8 buf[8];
+ u32 buf[2];
usb_debug ("Reading capacity of mass storage device.\n");
int count = 0, ret;
while (count++ < 20) {
switch (ret = execute_command
(dev, cbw_direction_data_in, (u8 *) &cb,
- sizeof (cb), buf, 8, 0)) {
+ sizeof (cb), (u8 *)buf, 8, 0)) {
case MSC_COMMAND_OK:
break;
case MSC_COMMAND_FAIL:
@@ -398,8 +398,8 @@ read_capacity (usbdev_t *dev)
MSC_INST (dev)->numblocks = 0xffffffff;
MSC_INST (dev)->blocksize = 512;
} else {
- MSC_INST (dev)->numblocks = ntohl (*(u32 *) buf) + 1;
- MSC_INST (dev)->blocksize = ntohl (*(u32 *) (buf + 4));
+ MSC_INST (dev)->numblocks = ntohl(buf[0]) + 1;
+ MSC_INST (dev)->blocksize = ntohl(buf[1]);
}
usb_debug (" %d %d-byte sectors (%d MB)\n", MSC_INST (dev)->numblocks,
MSC_INST (dev)->blocksize,