]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
usb: align usb_endpoint_descriptor to 16-bit boundary
authorStefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Thu, 20 Oct 2011 19:25:37 +0000 (22:25 +0300)
committerRemy Bohmer <linux@bohmer.net>
Sun, 11 Dec 2011 13:42:10 +0000 (14:42 +0100)
The usb_endpoint_descriptor struct is 7 bytes large and is
defined as an array (ep_desc[USB_MAXENDPOINTS])
in the usb_interface struct in include/usb.h

This fact will result in that every odd index in that
array will start at an uneven address, this in
turn makes accesses to u16 wMaxPacketSize unaligned.
Such accesses are illegal on the OpenRISC architecture
(as well as other architectures) and will render a bus error.

Setting the aligned(2) attribute on usb_endpoint_descriptor
will force wMaxPacketSize to a 16-bit boundary.

Signed-off-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
include/usbdescriptors.h

index 2dec3b93d65438cfc5c16ec4a1f04ee62a469ac7..392fcf53780162fc87f6fbb58fdcb8496009111f 100644 (file)
@@ -199,7 +199,7 @@ struct usb_endpoint_descriptor {
        u8 bmAttributes;
        u16 wMaxPacketSize;
        u8 bInterval;
-} __attribute__ ((packed));
+} __attribute__ ((packed)) __attribute__ ((aligned(2)));
 
 struct usb_interface_descriptor {
        u8 bLength;