Skip to content

Commit 8c12672

Browse files
committed
mtd: rawnand: Use the ECC framework nand_ecc_is_strong_enough() helper
Plus, the new helper has a more "english" name. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20200827085208.16276-19-miquel.raynal@bootlin.com
1 parent 1e3b37a commit 8c12672

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5494,43 +5494,6 @@ int nand_ecc_choose_conf(struct nand_chip *chip,
54945494
}
54955495
EXPORT_SYMBOL_GPL(nand_ecc_choose_conf);
54965496

5497-
/*
5498-
* Check if the chip configuration meet the datasheet requirements.
5499-
5500-
* If our configuration corrects A bits per B bytes and the minimum
5501-
* required correction level is X bits per Y bytes, then we must ensure
5502-
* both of the following are true:
5503-
*
5504-
* (1) A / B >= X / Y
5505-
* (2) A >= X
5506-
*
5507-
* Requirement (1) ensures we can correct for the required bitflip density.
5508-
* Requirement (2) ensures we can correct even when all bitflips are clumped
5509-
* in the same sector.
5510-
*/
5511-
static bool nand_ecc_strength_good(struct nand_chip *chip)
5512-
{
5513-
struct mtd_info *mtd = nand_to_mtd(chip);
5514-
struct nand_ecc_ctrl *ecc = &chip->ecc;
5515-
const struct nand_ecc_props *requirements =
5516-
nanddev_get_ecc_requirements(&chip->base);
5517-
int corr, ds_corr;
5518-
5519-
if (ecc->size == 0 || requirements->step_size == 0)
5520-
/* Not enough information */
5521-
return true;
5522-
5523-
/*
5524-
* We get the number of corrected bits per page to compare
5525-
* the correction density.
5526-
*/
5527-
corr = (mtd->writesize * ecc->strength) / ecc->size;
5528-
ds_corr = (mtd->writesize * requirements->strength) /
5529-
requirements->step_size;
5530-
5531-
return corr >= ds_corr && ecc->strength >= requirements->strength;
5532-
}
5533-
55345497
static int rawnand_erase(struct nand_device *nand, const struct nand_pos *pos)
55355498
{
55365499
struct nand_chip *chip = container_of(nand, struct nand_chip,
@@ -5816,7 +5779,7 @@ static int nand_scan_tail(struct nand_chip *chip)
58165779
mtd->oobavail = ret;
58175780

58185781
/* ECC sanity check: warn if it's too weak */
5819-
if (!nand_ecc_strength_good(chip))
5782+
if (!nand_ecc_is_strong_enough(&chip->base))
58205783
pr_warn("WARNING: %s: the ECC used on your system (%db/%dB) is too weak compared to the one required by the NAND chip (%db/%dB)\n",
58215784
mtd->name, chip->ecc.strength, chip->ecc.size,
58225785
nanddev_get_ecc_requirements(&chip->base)->strength,

0 commit comments

Comments
 (0)