From b2fb47f1873ae812ce33129996a22b11a36d0aa9 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 15 Dec 2011 08:40:51 -0700 Subject: USB: Use (get|put)_unaligned for accessing wMaxPacketSize In 9792987721c7980453fe6447c3fa6593b44f8458 Stefan describes a usecase where the previous behavior of leaving wMaxPacketSize be unaligned caused fatal problems. The initial fix for this problem was incomplete however as it showed another cases of non-aligned access that previously worked implicitly. This switches to making sure that all access of wMaxPacketSize are done via (get|put)_unaligned. In order to maintain a level of readability to the code in some cases we now use a variable for the value of wMaxPacketSize and in others, a macro. Cc: Minkyu Kang Cc: Remy Bohmer OpenRISC: Tested-by: Stefan Kristiansson Beagleboard xM, Pandaboard run-tested, s5p_goni build-tested. Signed-off-by: Tom Rini --- common/cmd_usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common/cmd_usb.c') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index d4ec2a291c..320667f5fb 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -240,7 +241,7 @@ void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc) printf("Interrupt"); break; } - printf(" MaxPacket %d", epdesc->wMaxPacketSize); + printf(" MaxPacket %d", get_unaligned(&epdesc->wMaxPacketSize)); if ((epdesc->bmAttributes & 0x03) == 0x3) printf(" Interval %dms", epdesc->bInterval); printf("\n"); -- cgit v1.2.1