aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorMike Dunn <mikedunn@newsguy.com>2012-04-25 15:06:10 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-05-14 00:12:41 -0400
commite2788c98b98269a3131bffd2b57599280d7abd73 (patch)
tree9c2ae016d1a388485a1d1ff2941bc6fa9f3d17a8 /drivers/mtd
parent3f91e94f7f511de74c0d2abe08672ccdbdd1961c (diff)
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.html Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Acked-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand_base.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8718eaf8269f..9f5d339a3610 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3348,8 +3348,13 @@ int nand_scan_tail(struct mtd_info *mtd)
3348 if (!chip->ecc.write_oob) 3348 if (!chip->ecc.write_oob)
3349 chip->ecc.write_oob = nand_write_oob_syndrome; 3349 chip->ecc.write_oob = nand_write_oob_syndrome;
3350 3350
3351 if (mtd->writesize >= chip->ecc.size) 3351 if (mtd->writesize >= chip->ecc.size) {
3352 if (!chip->ecc.strength) {
3353 pr_warn("Driver must set ecc.strength when using hardware ECC\n");
3354 BUG();
3355 }
3352 break; 3356 break;
3357 }
3353 pr_warn("%d byte HW ECC not possible on " 3358 pr_warn("%d byte HW ECC not possible on "
3354 "%d byte page size, fallback to SW ECC\n", 3359 "%d byte page size, fallback to SW ECC\n",
3355 chip->ecc.size, mtd->writesize); 3360 chip->ecc.size, mtd->writesize);
@@ -3404,7 +3409,7 @@ int nand_scan_tail(struct mtd_info *mtd)
3404 BUG(); 3409 BUG();
3405 } 3410 }
3406 chip->ecc.strength = 3411 chip->ecc.strength =
3407 chip->ecc.bytes*8 / fls(8*chip->ecc.size); 3412 chip->ecc.bytes * 8 / fls(8 * chip->ecc.size);
3408 break; 3413 break;
3409 3414
3410 case NAND_ECC_NONE: 3415 case NAND_ECC_NONE: