mtd: nand/fsmc: Flip the bit only if the error index is < 4096

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Mar 26 20:59:18 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b533f8d84f4f0807bf1bcf52017c6a267c8c4405
Commit:     b533f8d84f4f0807bf1bcf52017c6a267c8c4405
Parent:     aea686b47c0cf97e0c6941799b523b6df87fc234
Author:     Vipin Kumar <vipin.kumar at st.com>
AuthorDate: Wed Mar 14 11:47:11 2012 +0530
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Tue Mar 27 00:58:43 2012 +0100

    mtd: nand/fsmc: Flip the bit only if the error index is < 4096
    
    ECC can correct up to 8 bits in 512 bytes data + 13 bytes ecc. This means that
    the algorithm can correct a max of 8 bits in 4200 bits ie the error indices can
    be from 0 to 4199. Of these 0 to 4095 are for data and 4096 to 4199 for ecc.
    
    The driver flips the bit only if the index is <= 4096. This is a bug since the
    data bits are only from 0 to 4095.
    
    This patch modifies the check as < 4096
    
    Signed-off-by: Vipin Kumar <vipin.kumar at st.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/fsmc_nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index bd42339..6a0bca1 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -654,7 +654,7 @@ static int fsmc_bch8_correct_data(struct mtd_info *mtd, uint8_t *dat,
 		change_bit(0, (unsigned long *)&err_idx[i]);
 		change_bit(1, (unsigned long *)&err_idx[i]);
 
-		if (err_idx[i] <= chip->ecc.size * 8) {
+		if (err_idx[i] < chip->ecc.size * 8) {
 			change_bit(err_idx[i], (unsigned long *)dat);
 			i++;
 		}



More information about the linux-mtd-cvs mailing list