aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2011-02-28 07:12:46 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-03-11 09:22:48 -0500
commit74f1b7244e502c5a98906a5dcc5ec389aacd25e6 (patch)
tree44dd8f5b51431beb27dd628c245dab2a32b4a0fc /drivers/mtd/nand
parentbea9312839c51853a2837336405c829b0bf18f88 (diff)
mtd: omap3: nand: report corrected ecc errors
The number of corrected ECC errors should be reported since other MTD systems make use of this information (such as UBI data scrubbing). Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/omap2.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 28af71c61834..d7a4e2550b13 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -517,6 +517,8 @@ static void gen_true_ecc(u8 *ecc_buf)
517 * 517 *
518 * This function compares two ECC's and indicates if there is an error. 518 * This function compares two ECC's and indicates if there is an error.
519 * If the error can be corrected it will be corrected to the buffer. 519 * If the error can be corrected it will be corrected to the buffer.
520 * If there is no error, %0 is returned. If there is an error but it
521 * was corrected, %1 is returned. Otherwise, %-1 is returned.
520 */ 522 */
521static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */ 523static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
522 u8 *ecc_data2, /* read from register */ 524 u8 *ecc_data2, /* read from register */
@@ -622,7 +624,7 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
622 624
623 page_data[find_byte] ^= (1 << find_bit); 625 page_data[find_byte] ^= (1 << find_bit);
624 626
625 return 0; 627 return 1;
626 default: 628 default:
627 if (isEccFF) { 629 if (isEccFF) {
628 if (ecc_data2[0] == 0 && 630 if (ecc_data2[0] == 0 &&
@@ -643,8 +645,11 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */
643 * @calc_ecc: ecc read from HW ECC registers 645 * @calc_ecc: ecc read from HW ECC registers
644 * 646 *
645 * Compares the ecc read from nand spare area with ECC registers values 647 * Compares the ecc read from nand spare area with ECC registers values
646 * and if ECC's mismached, it will call 'omap_compare_ecc' for error detection 648 * and if ECC's mismatched, it will call 'omap_compare_ecc' for error
647 * and correction. 649 * detection and correction. If there are no errors, %0 is returned. If
650 * there were errors and all of the errors were corrected, the number of
651 * corrected errors is returned. If uncorrectable errors exist, %-1 is
652 * returned.
648 */ 653 */
649static int omap_correct_data(struct mtd_info *mtd, u_char *dat, 654static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
650 u_char *read_ecc, u_char *calc_ecc) 655 u_char *read_ecc, u_char *calc_ecc)
@@ -652,6 +657,7 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
652 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 657 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
653 mtd); 658 mtd);
654 int blockCnt = 0, i = 0, ret = 0; 659 int blockCnt = 0, i = 0, ret = 0;
660 int stat = 0;
655 661
656 /* Ex NAND_ECC_HW12_2048 */ 662 /* Ex NAND_ECC_HW12_2048 */
657 if ((info->nand.ecc.mode == NAND_ECC_HW) && 663 if ((info->nand.ecc.mode == NAND_ECC_HW) &&
@@ -665,12 +671,14 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
665 ret = omap_compare_ecc(read_ecc, calc_ecc, dat); 671 ret = omap_compare_ecc(read_ecc, calc_ecc, dat);
666 if (ret < 0) 672 if (ret < 0)
667 return ret; 673 return ret;
674 /* keep track of the number of corrected errors */
675 stat += ret;
668 } 676 }
669 read_ecc += 3; 677 read_ecc += 3;
670 calc_ecc += 3; 678 calc_ecc += 3;
671 dat += 512; 679 dat += 512;
672 } 680 }
673 return 0; 681 return stat;
674} 682}
675 683
676/** 684/**