aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu, Josh <Josh.wu@atmel.com>2015-01-13 22:50:46 -0500
committerBrian Norris <computersforpeace@gmail.com>2015-01-20 15:42:33 -0500
commit267d46e635c575e9c8b2932d9617266e6e67ee99 (patch)
tree7acf1da8a55f2285f5bd85d785fbfb6cccd55306
parentcfe4af3aac3bd63e9caf548157805ca46ad7b073 (diff)
mtd: atmel_nand: return max bitflips in all sectors in pmecc_correction()
atmel_nand_pmecc_read_page() will return the total bitflips in this page. This is incorrect. As one nand page includes multiple ecc sectors, that will cause the returned total bitflips exceed ecc capablity. So this patch will make pmecc_correct() return the max bitflips of all sectors in the page. That also makes atmel_nand_pmecc_read_page() return the max bitflips. Signed-off-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/atmel_nand.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index a345e7b2463a..7346d16cf61a 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -847,7 +847,7 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
847 struct atmel_nand_host *host = nand_chip->priv; 847 struct atmel_nand_host *host = nand_chip->priv;
848 int i, err_nbr; 848 int i, err_nbr;
849 uint8_t *buf_pos; 849 uint8_t *buf_pos;
850 int total_err = 0; 850 int max_bitflips = 0;
851 851
852 for (i = 0; i < nand_chip->ecc.total; i++) 852 for (i = 0; i < nand_chip->ecc.total; i++)
853 if (ecc[i] != 0xff) 853 if (ecc[i] != 0xff)
@@ -874,13 +874,13 @@ normal_check:
874 pmecc_correct_data(mtd, buf_pos, ecc, i, 874 pmecc_correct_data(mtd, buf_pos, ecc, i,
875 nand_chip->ecc.bytes, err_nbr); 875 nand_chip->ecc.bytes, err_nbr);
876 mtd->ecc_stats.corrected += err_nbr; 876 mtd->ecc_stats.corrected += err_nbr;
877 total_err += err_nbr; 877 max_bitflips = max_t(int, max_bitflips, err_nbr);
878 } 878 }
879 } 879 }
880 pmecc_stat >>= 1; 880 pmecc_stat >>= 1;
881 } 881 }
882 882
883 return total_err; 883 return max_bitflips;
884} 884}
885 885
886static void pmecc_enable(struct atmel_nand_host *host, int ecc_op) 886static void pmecc_enable(struct atmel_nand_host *host, int ecc_op)