[MTD] [NAND] fix s3c2410 error correction

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Jan 26 08:59:01 EST 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=d0bf37932ac98cc793da2164ac1a4656fbf34bbc
Commit:     d0bf37932ac98cc793da2164ac1a4656fbf34bbc
Parent:     4fac9f698404a5cd50b978fbdb7e54235353c215
Author:     Matt Reimer <mreimer at vpop.net>
AuthorDate: Thu Oct 18 18:02:43 2007 -0700
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Sat Jan 26 21:11:38 2008 +0800

    [MTD] [NAND] fix s3c2410 error correction
    
    The single-bit error correction was, well, incorrect. For determing which
    bit to correct it was using P1' P2' P4' P8' instead of P1 P2 P4 P8, and
    it was using P16' P32' P64' P128' P256' P512' P1024' P2048' instead of
    P16 P32 P64 P128 P256 P512 P1024 P2048.
    
    Signed-off-by: Matt Reimer <mreimer at vpop.net>
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 drivers/mtd/nand/s3c2410.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 21a2cc8..d31cb7b 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -366,23 +366,21 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
 	    ((diff2 ^ (diff2 >> 1)) & 0x55) == 0x55) {
 		/* calculate the bit position of the error */
 
-		bit  = (diff2 >> 2) & 1;
-		bit |= (diff2 >> 3) & 2;
-		bit |= (diff2 >> 4) & 4;
+		bit  = ((diff2 >> 3) & 1) |
+		       ((diff2 >> 4) & 2) |
+		       ((diff2 >> 5) & 4);
 
 		/* calculate the byte position of the error */
 
-		byte  = (diff1 << 1) & 0x80;
-		byte |= (diff1 << 2) & 0x40;
-		byte |= (diff1 << 3) & 0x20;
-		byte |= (diff1 << 4) & 0x10;
-
-		byte |= (diff0 >> 3) & 0x08;
-		byte |= (diff0 >> 2) & 0x04;
-		byte |= (diff0 >> 1) & 0x02;
-		byte |= (diff0 >> 0) & 0x01;
-
-		byte |= (diff2 << 8) & 0x100;
+		byte = ((diff2 << 7) & 0x100) |
+		       ((diff1 << 0) & 0x80)  |
+		       ((diff1 << 1) & 0x40)  |
+		       ((diff1 << 2) & 0x20)  |
+		       ((diff1 << 3) & 0x10)  |
+		       ((diff0 >> 4) & 0x08)  |
+		       ((diff0 >> 3) & 0x04)  |
+		       ((diff0 >> 2) & 0x02)  |
+		       ((diff0 >> 1) & 0x01);
 
 		dev_dbg(info->device, "correcting error bit %d, byte %d\n",
 			bit, byte);



More information about the linux-mtd-cvs mailing list