|
@@ -4037,22 +4037,24 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
ecc->read_oob = nand_read_oob_std;
|
|
|
ecc->write_oob = nand_write_oob_std;
|
|
|
/*
|
|
|
- * Board driver should supply ecc.size and ecc.bytes values to
|
|
|
- * select how many bits are correctable; see nand_bch_init()
|
|
|
- * for details. Otherwise, default to 4 bits for large page
|
|
|
- * devices.
|
|
|
+ * Board driver should supply ecc.size and ecc.strength values
|
|
|
+ * to select how many bits are correctable. Otherwise, default
|
|
|
+ * to 4 bits for large page devices.
|
|
|
*/
|
|
|
if (!ecc->size && (mtd->oobsize >= 64)) {
|
|
|
ecc->size = 512;
|
|
|
- ecc->bytes = DIV_ROUND_UP(13 * ecc->strength, 8);
|
|
|
+ ecc->strength = 4;
|
|
|
}
|
|
|
+
|
|
|
+ /* See nand_bch_init() for details. */
|
|
|
+ ecc->bytes = DIV_ROUND_UP(
|
|
|
+ ecc->strength * fls(8 * ecc->size), 8);
|
|
|
ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes,
|
|
|
&ecc->layout);
|
|
|
if (!ecc->priv) {
|
|
|
pr_warn("BCH ECC initialization failed!\n");
|
|
|
BUG();
|
|
|
}
|
|
|
- ecc->strength = ecc->bytes * 8 / fls(8 * ecc->size);
|
|
|
break;
|
|
|
|
|
|
case NAND_ECC_NONE:
|