Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wu, Josh and committed by
Brian Norris
267d46e6 cfe4af3a

+3 -3
+3 -3
drivers/mtd/nand/atmel_nand.c
··· 847 847 struct atmel_nand_host *host = nand_chip->priv; 848 848 int i, err_nbr; 849 849 uint8_t *buf_pos; 850 - int total_err = 0; 850 + int max_bitflips = 0; 851 851 852 852 for (i = 0; i < nand_chip->ecc.total; i++) 853 853 if (ecc[i] != 0xff) ··· 874 874 pmecc_correct_data(mtd, buf_pos, ecc, i, 875 875 nand_chip->ecc.bytes, err_nbr); 876 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 880 pmecc_stat >>= 1; 881 881 } 882 882 883 - return total_err; 883 + return max_bitflips; 884 884 } 885 885 886 886 static void pmecc_enable(struct atmel_nand_host *host, int ecc_op)