public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: align usb_endpoint_descriptor to 16-bit boundary
@ 2011-10-20 19:25 Stefan Kristiansson
  2011-11-26 22:33 ` Remy Bohmer
  2011-12-13 13:29 ` [U-Boot] OMAP4 u-boot broken (was [PATCH] usb: align usb_endpoint_descriptor to 16-bit boundary) Aneesh V
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Kristiansson @ 2011-10-20 19:25 UTC (permalink / raw)
  To: u-boot

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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/usbdescriptors.h b/include/usbdescriptors.h
index 2dec3b9..392fcf5 100644
--- a/include/usbdescriptors.h
+++ b/include/usbdescriptors.h
@@ -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;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-14 20:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-20 19:25 [U-Boot] [PATCH] usb: align usb_endpoint_descriptor to 16-bit boundary Stefan Kristiansson
2011-11-26 22:33 ` Remy Bohmer
2011-12-13 13:29 ` [U-Boot] OMAP4 u-boot broken (was [PATCH] usb: align usb_endpoint_descriptor to 16-bit boundary) Aneesh V
2011-12-13 20:15   ` Stefan Kristiansson
2011-12-14 10:24     ` Aneesh V
2011-12-14 14:24       ` Tom Rini
2011-12-14 20:25     ` Tom Rini
2011-12-14 10:12   ` Michael Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox