mtd: nand: fix ECC Correction bug for SMC ordering for NDFC driver

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 19 17:59:04 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=76c23c32e3b3ad48e07e07897075ab19ae1ef117
Commit:     76c23c32e3b3ad48e07e07897075ab19ae1ef117
Parent:     ebd5a74db74ee2db833d43ea35108a4be9cab42f
Author:     Feng Kan <fkan at amcc.com>
AuthorDate: Tue Aug 25 11:27:20 2009 -0700
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sat Sep 19 14:15:00 2009 -0700

    mtd: nand: fix ECC Correction bug for SMC ordering for NDFC driver
    
    Fix ECC Correction bug where the byte offset location were double
    fliped causing correction routine to toggle the wrong byte location
    in the ECC segment. The ndfc_calculate_ecc routine change the order
    of getting the ECC code.
            /* The NDFC uses Smart Media (SMC) bytes order */
            ecc_code[0] = p[2];
            ecc_code[1] = p[1];
            ecc_code[2] = p[3];
    But in the Correction algorithm when calculating the byte offset
    location, the b1 is used as the upper part of the address. Which
    again reverse the order making the final byte offset address
    location incorrect.
    	byte_addr = (addressbits[b1] << 4) + addressbits[b0];
    The order is change to read it in straight and let the correction
    function to revert it to SMC order.
    
    Cc: stable at kernel.org
    Signed-off-by: Feng Kan <fkan at amcc.com>
    Acked-by: Victor Gallardo <vgallardo at amcc.com>
    Acked-by: Prodyut Hazarika <phazarika at amcc.com>
    Acked-by: Stefan Roese <sr at denx.de>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/ndfc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 89bf85a..40b5658 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -102,8 +102,8 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
 	wmb();
 	ecc = in_be32(ndfc->ndfcbase + NDFC_ECC);
 	/* The NDFC uses Smart Media (SMC) bytes order */
-	ecc_code[0] = p[2];
-	ecc_code[1] = p[1];
+	ecc_code[0] = p[1];
+	ecc_code[1] = p[2];
 	ecc_code[2] = p[3];
 
 	return 0;



More information about the linux-mtd-cvs mailing list