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>
This commit is contained in:
Gabe Black 2013-01-15 16:22:04 -08:00 committed by Stefan Reinauer
parent ee5c111755
commit 2c2c4fae22
1 changed files with 4 additions and 4 deletions

View File

@ -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,