[PATCH] USB/ISP1760: Fix for unaligned exceptions

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <bigeasy@...>, <linux-usb@...>
Cc: <linux-kernel@...>, Michael Hennerich <michael.hennerich@...>, Bryan Wu <cooloney@...>
Date: Tuesday, November 18, 2008 - 5:22 am

From: Michael Hennerich <michael.hennerich@analog.com>

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
 drivers/usb/host/isp1760-hcd.c |   67 ++++++++++++++++++++++++++++-----------
 1 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 8017f1c..00bece2 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -136,12 +136,21 @@ static void priv_read_copy(struct isp1760_hcd *priv, u32 *src,
 		return;
 	}
 
-	while (len >= 4) {
-		*src = __raw_readl(dst);
-		len -= 4;
-		src++;
-		dst++;
-	}
+	if (unlikely((u32)src & 0x3)) {
+		while (len >= 4) {
+			put_unaligned(__raw_readl(dst), src);
+			len -= 4;
+			src++;
+			dst++;
+		}
+	} else {
+		while (len >= 4) {
+			*src = __raw_readl(dst);
+			len -= 4;
+			src++;
+			dst++;
+		}
+	} 
 
 	if (!len)
 		return;
@@ -159,25 +168,45 @@ static void priv_read_copy(struct isp1760_hcd *priv, u32 *src,
 		len--;
 		buff8++;
 	}
+
 }
 
 static void priv_write_copy(const struct isp1760_hcd *priv, const u32 *src,
 		__u32 __iomem *dst, u32 len)
 {
-	while (len >= 4) {
-		__raw_writel(*src, dst);
-		len -= 4;
-		src++;
-		dst++;
-	}
 
-	if (!len)
-		return;
-	/* in case we have 3, 2 or 1 by left. The buffer is allocated and the
-	 * extra bytes should not be read by the HW
-	 */
-
-	__raw_writel(*src, dst);
+	if (unlikely((u32)src & 0x3)) {
+		while (len >= 4) {
+			__raw_writel(get_unaligned(src), dst);
+			len -= 4;
+			src++;
+			dst++;
+		}
+	
+		if (!len)
+			return;
+		/* in case we have 3, 2 or 1 by left. The buffer is allocated and the
+		 * extra bytes should not be read by the HW
+		 */
+	
+		__raw_writel(get_unaligned(src), dst);
+	
+	} else{
+		while (len >= 4) {
+			__raw_writel(*src, dst);
+			len -= 4;
+			src++;
+			dst++;
+		}
+	
+		if (!len)
+			return;
+		/* in case we have 3, 2 or 1 by left. The buffer is allocated and the
+		 * extra bytes should not be read by the HW
+		 */
+	
+		__raw_writel(*src, dst);	
+	}
 }
 
 /* memory management of the 60kb on the chip from 0x1000 to 0xffff */
-- 
1.5.6.3
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] USB/ISP1760: Fix for unaligned exceptions, Bryan Wu, (Tue Nov 18, 5:22 am)
Re: [PATCH] USB/ISP1760: Fix for unaligned exceptions, Sebastian Andrzej Siewior..., (Tue Nov 18, 6:52 am)
RE: [PATCH] USB/ISP1760: Fix for unaligned exceptions, Hennerich, Michael, (Tue Nov 18, 11:41 am)
Re: [PATCH] USB/ISP1760: Fix for unaligned exceptions, Sebastian Andrzej Siewior..., (Wed Nov 19, 5:18 am)
RE: [PATCH] USB/ISP1760: Fix for unaligned exceptions, Hennerich, Michael, (Wed Nov 19, 6:30 am)
Re: [PATCH] USB/ISP1760: Fix for unaligned exceptions, Sebastian Andrzej Siewior..., (Wed Nov 19, 6:55 am)