Commit e2788c98 authored by Mike Dunn's avatar Mike Dunn Committed by David Woodhouse

mtd: nand: add sanity check of ecc strength to nand_scan_tail()

This patch adds sanity checks that ensure that drivers for controllers with
hardware ECC set the 'strength' element in struct nand_ecc_ctrl.  Also stylistic
changes to the line that calculates strength for software ECC.

This v2 simplifies the check.  Thanks Brian!¹

¹ http://lists.infradead.org/pipermail/linux-mtd/2012-April/040890.htmlSigned-off-by: default avatarMike Dunn <mikedunn@newsguy.com>
Acked-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 3f91e94f
...@@ -3348,8 +3348,13 @@ int nand_scan_tail(struct mtd_info *mtd) ...@@ -3348,8 +3348,13 @@ int nand_scan_tail(struct mtd_info *mtd)
if (!chip->ecc.write_oob) if (!chip->ecc.write_oob)
chip->ecc.write_oob = nand_write_oob_syndrome; chip->ecc.write_oob = nand_write_oob_syndrome;
if (mtd->writesize >= chip->ecc.size) if (mtd->writesize >= chip->ecc.size) {
if (!chip->ecc.strength) {
pr_warn("Driver must set ecc.strength when using hardware ECC\n");
BUG();
}
break; break;
}
pr_warn("%d byte HW ECC not possible on " pr_warn("%d byte HW ECC not possible on "
"%d byte page size, fallback to SW ECC\n", "%d byte page size, fallback to SW ECC\n",
chip->ecc.size, mtd->writesize); chip->ecc.size, mtd->writesize);
...@@ -3404,7 +3409,7 @@ int nand_scan_tail(struct mtd_info *mtd) ...@@ -3404,7 +3409,7 @@ int nand_scan_tail(struct mtd_info *mtd)
BUG(); BUG();
} }
chip->ecc.strength = chip->ecc.strength =
chip->ecc.bytes*8 / fls(8*chip->ecc.size); chip->ecc.bytes * 8 / fls(8 * chip->ecc.size);
break; break;
case NAND_ECC_NONE: case NAND_ECC_NONE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment