{
struct mt7621_nfc *nfc = nand_get_controller_data(nand);
struct mtd_info *mtd = nand_to_mtd(nand);
- int bitflips = 0;
+ int bitflips = 0, ret = 0;
int rc, i;
nand_read_page_op(nand, page, 0, NULL, 0);
mt7621_nfc_read_sector_fdm(nfc, i);
if (rc < 0) {
- bitflips = -EIO;
+ ret = -EIO;
continue;
}
dev_dbg(nfc->dev,
"Uncorrectable ECC error at page %d.%d\n",
page, i);
- bitflips = -EBADMSG;
+ bitflips = nand->ecc.strength + 1;
mtd->ecc_stats.failed++;
- } else if (bitflips >= 0) {
- bitflips += rc;
+ } else {
+ if (rc > bitflips)
+ bitflips = rc;
mtd->ecc_stats.corrected += rc;
}
}
nfi_write16(nfc, NFI_CON, 0);
+ if (ret < 0)
+ return ret;
+
return bitflips;
}