From 048c2b85c12ac4aa8cd82201e1ade332557e4380 Mon Sep 17 00:00:00 2001
From: Charles Manning <manningc2@actrix.gen.nz>
Date: Thu, 16 Dec 2010 20:35:56 -0800
Subject: [PATCH 26/32] mtd: nand: omap2: Force all buffer reads to u32 alignment

---
 drivers/mtd/nand/omap2.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index bb89c65..832f111 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -247,6 +247,18 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char *buf, int len)
 	int ret = 0;
 	u32 *p = (u32 *)buf;
 
+	/* u32 align the buffer and read */
+	/* NB: This assumes the buf ptr can be aligned *down* which is a valid.
+	* Assumption when dealing with ecc buffers etc.
+	*/
+	u32 addr = (u32)p;
+
+	int diff = addr & 3;
+	addr -= diff;
+	len += diff;
+	len = (len + 3) & ~3;
+	p = (u32 *)addr;
+
 	/* take care of subpage reads */
 	if (len % 4) {
 		if (info->nand.options & NAND_BUSWIDTH_16)
-- 
1.6.6.1

