mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-10 12:39:22 -04:00
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>
This commit is contained in:
parent
4df4f3c9a2
commit
f50dcd60a0
@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
|
|||||||
u32 i, nw, nb;
|
u32 i, nw, nb;
|
||||||
u32 *wrdp;
|
u32 *wrdp;
|
||||||
u8 *bytp;
|
u8 *bytp;
|
||||||
|
u32 tmp[128];
|
||||||
|
|
||||||
if (readl(&udc_regs_p->dev_stat) & DEV_STAT_RXFIFO_EMPTY)
|
if (readl(&udc_regs_p->dev_stat) & DEV_STAT_RXFIFO_EMPTY)
|
||||||
return -1;
|
return -1;
|
||||||
@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
|
|||||||
nw = len / sizeof(u32);
|
nw = len / sizeof(u32);
|
||||||
nb = len % sizeof(u32);
|
nb = len % sizeof(u32);
|
||||||
|
|
||||||
|
/* use tmp buf if bufp is not word aligned */
|
||||||
|
if ((int)bufp & 0x3)
|
||||||
|
wrdp = (u32 *)&tmp[0];
|
||||||
|
else
|
||||||
wrdp = (u32 *)bufp;
|
wrdp = (u32 *)bufp;
|
||||||
|
|
||||||
for (i = 0; i < nw; i++) {
|
for (i = 0; i < nw; i++) {
|
||||||
writel(readl(fifo_ptr), wrdp);
|
writel(readl(fifo_ptr), wrdp);
|
||||||
wrdp++;
|
wrdp++;
|
||||||
@ -223,6 +229,10 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
|
|||||||
}
|
}
|
||||||
readl(&outep_regs_p[epNum].write_done);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user