[PATCH 9/9] s3c2410: improve NAND partial reads avoiding false ECC errors/corrections

Nelson Castillo arhuaco at freaks-unidos.net
Tue Mar 31 20:07:53 CEST 2009


With the introduction of optimized OOB reads in nand_read_subpage,
  the length of the data requested may not be a multiple of four bytes.

  This caused a partial read on the 2440, leading to false ECC errors
  and, worse, attempts to "correct" them.

  Note that there is a similar issue in s3c2440_nand_write_buf, which
  doesn't seem to cause trouble yet.

Signed-off-by: Werner Almesberger <werner at openmoko.org>
---

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

diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 0024f10..3c90449 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -530,7 +530,14 @@ static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
 static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
 {
 	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
+
 	readsl(info->regs + S3C2440_NFDATA, buf, len / 4);
+	if (unlikely(len & 3)) {
+		u32 data;
+
+		data = readl(info->regs + S3C2440_NFDATA);
+		memcpy(buf + (len & ~3), &data, len & 3);
+	}
 }
 
 static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)




More information about the openmoko-kernel mailing list