]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mtd: rawnand: micron: Update ecc_stats.corrected
authorBoris Brezillon <boris.brezillon@bootlin.com>
Wed, 20 Jun 2018 07:44:43 +0000 (09:44 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 2 Jul 2018 07:01:34 +0000 (09:01 +0200)
Even if we can't update ecc_stats.corrected with an accurate value we
should at least increase the number of bitflips so that MTD users can
know that there was some bitflips.

Just add chip->ecc.strength to mtd->ecc_stats.corrected which should
account for the worst case situation.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/nand_micron.c

index 5ec4c90a637d549a644441461ffc7717c623a4bc..203faba0a9c179104e6f8e951596b1ef05b616d0 100644 (file)
@@ -137,18 +137,19 @@ micron_nand_read_page_on_die_ecc(struct mtd_info *mtd, struct nand_chip *chip,
        if (ret)
                goto out;
 
-       if (status & NAND_STATUS_FAIL)
+       if (status & NAND_STATUS_FAIL) {
                mtd->ecc_stats.failed++;
-
-       /*
-        * The internal ECC doesn't tell us the number of bitflips
-        * that have been corrected, but tells us if it recommends to
-        * rewrite the block. If it's the case, then we pretend we had
-        * a number of bitflips equal to the ECC strength, which will
-        * hint the NAND core to rewrite the block.
-        */
-       else if (status & NAND_STATUS_WRITE_RECOMMENDED)
+       } else if (status & NAND_STATUS_WRITE_RECOMMENDED) {
+               /*
+                * The internal ECC doesn't tell us the number of bitflips
+                * that have been corrected, but tells us if it recommends to
+                * rewrite the block. If it's the case, then we pretend we had
+                * a number of bitflips equal to the ECC strength, which will
+                * hint the NAND core to rewrite the block.
+                */
+               mtd->ecc_stats.corrected += chip->ecc.strength;
                max_bitflips = chip->ecc.strength;
+       }
 
        ret = nand_read_data_op(chip, buf, mtd->writesize, false);
        if (!ret && oob_required)