summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorTroy Kisky <troy.kisky@boundarydevices.com>2013-09-11 18:24:48 +0800
committerMarek Vasut <marex@denx.de>2013-09-24 17:51:35 +0200
commit898d686eead1df09970757dfd469b659d5a208be (patch)
tree8f7b782bdb5f5726f2183a47a4812bc542890872 /drivers/usb
parent7a813d5b7d7e8dce209999f460d962d41a0b8a3e (diff)
usb: gadget: config: fix unaligned access issues
As seen with codesourcery compiler 2010q1, the buf pointer in usb_request structure is not aligned on 4 bytes boundary causing data aborts in eth_setup -> conf_buf -> usb_gadget_config_buf. Make it as align access to fix this issue. Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> [voice.shen@atmel.com: add commit message] Signed-off-by: Bo Shen <voice.shen@atmel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/config.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index f563afe787..014a6791c1 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <asm/unaligned.h>
#include <asm/errno.h>
#include <linux/list.h>
#include <linux/string.h>
@@ -86,7 +87,8 @@ int usb_gadget_config_buf(
/* config descriptor first */
if (length < USB_DT_CONFIG_SIZE || !desc)
return -EINVAL;
- *cp = *config;
+ /* config need not be aligned */
+ memcpy(cp, config, sizeof(*cp));
/* then interface/endpoint/class/vendor/... */
len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (u8 *)buf,
@@ -100,7 +102,7 @@ int usb_gadget_config_buf(
/* patch up the config descriptor */
cp->bLength = USB_DT_CONFIG_SIZE;
cp->bDescriptorType = USB_DT_CONFIG;
- cp->wTotalLength = cpu_to_le16(len);
+ put_unaligned_le16(len, &cp->wTotalLength);
cp->bmAttributes |= USB_CONFIG_ATT_ONE;
return len;
}