diff options
author | Shiraz Hashim <shiraz.hashim@st.com> | 2012-03-06 23:39:41 (GMT) |
---|---|---|
committer | Marek Vasut <marek.vasut@gmail.com> | 2012-03-18 23:08:17 (GMT) |
commit | f50dcd60a03a3fe7bbb7d43d6fe070602bda6989 (patch) | |
tree | bb262d7f2a14b45321c114e66abc02f6d3a2c1ee /drivers | |
parent | 4df4f3c9a2121a7b49c5b2acc73706c16e42c173 (diff) | |
download | u-boot-f50dcd60a03a3fe7bbb7d43d6fe070602bda6989.tar.xz |
USB:gadget:designware Fix memory nonalignment issue
While receiving packets from FIFO sometimes the buffer provided was
nonaligned. Fix this by taking a temporary aligned buffer and then
copying the content to nonaligned buffer.
Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/designware_udc.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c index 67cdb29..7e9ccde 100644 --- a/drivers/usb/gadget/designware_udc.c +++ b/drivers/usb/gadget/designware_udc.c @@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len) u32 i, nw, nb; u32 *wrdp; u8 *bytp; + u32 tmp[128]; if (readl(&udc_regs_p->dev_stat) & DEV_STAT_RXFIFO_EMPTY) return -1; @@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len) nw = len / sizeof(u32); nb = len % sizeof(u32); - wrdp = (u32 *)bufp; + /* use tmp buf if bufp is not word aligned */ + if ((int)bufp & 0x3) + wrdp = (u32 *)&tmp[0]; + else + wrdp = (u32 *)bufp; + for (i = 0; i < nw; i++) { writel(readl(fifo_ptr), wrdp); wrdp++; @@ -223,6 +229,10 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len) } readl(&outep_regs_p[epNum].write_done); + /* copy back tmp buffer to bufp if bufp is not word aligned */ + if ((int)bufp & 0x3) + memcpy(bufp, tmp, len); + return 0; } |