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
This commit is contained in:
parent
1e3b37aab9
commit
8c126720fe
1 changed files with 1 additions and 38 deletions
|
@ -5494,43 +5494,6 @@ int nand_ecc_choose_conf(struct nand_chip *chip,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(nand_ecc_choose_conf);
|
EXPORT_SYMBOL_GPL(nand_ecc_choose_conf);
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if the chip configuration meet the datasheet requirements.
|
|
||||||
|
|
||||||
* If our configuration corrects A bits per B bytes and the minimum
|
|
||||||
* required correction level is X bits per Y bytes, then we must ensure
|
|
||||||
* both of the following are true:
|
|
||||||
*
|
|
||||||
* (1) A / B >= X / Y
|
|
||||||
* (2) A >= X
|
|
||||||
*
|
|
||||||
* Requirement (1) ensures we can correct for the required bitflip density.
|
|
||||||
* Requirement (2) ensures we can correct even when all bitflips are clumped
|
|
||||||
* in the same sector.
|
|
||||||
*/
|
|
||||||
static bool nand_ecc_strength_good(struct nand_chip *chip)
|
|
||||||
{
|
|
||||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
|
||||||
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
|
||||||
const struct nand_ecc_props *requirements =
|
|
||||||
nanddev_get_ecc_requirements(&chip->base);
|
|
||||||
int corr, ds_corr;
|
|
||||||
|
|
||||||
if (ecc->size == 0 || requirements->step_size == 0)
|
|
||||||
/* Not enough information */
|
|
||||||
return true;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We get the number of corrected bits per page to compare
|
|
||||||
* the correction density.
|
|
||||||
*/
|
|
||||||
corr = (mtd->writesize * ecc->strength) / ecc->size;
|
|
||||||
ds_corr = (mtd->writesize * requirements->strength) /
|
|
||||||
requirements->step_size;
|
|
||||||
|
|
||||||
return corr >= ds_corr && ecc->strength >= requirements->strength;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rawnand_erase(struct nand_device *nand, const struct nand_pos *pos)
|
static int rawnand_erase(struct nand_device *nand, const struct nand_pos *pos)
|
||||||
{
|
{
|
||||||
struct nand_chip *chip = container_of(nand, struct nand_chip,
|
struct nand_chip *chip = container_of(nand, struct nand_chip,
|
||||||
|
@ -5816,7 +5779,7 @@ static int nand_scan_tail(struct nand_chip *chip)
|
||||||
mtd->oobavail = ret;
|
mtd->oobavail = ret;
|
||||||
|
|
||||||
/* ECC sanity check: warn if it's too weak */
|
/* ECC sanity check: warn if it's too weak */
|
||||||
if (!nand_ecc_strength_good(chip))
|
if (!nand_ecc_is_strong_enough(&chip->base))
|
||||||
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",
|
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",
|
||||||
mtd->name, chip->ecc.strength, chip->ecc.size,
|
mtd->name, chip->ecc.strength, chip->ecc.size,
|
||||||
nanddev_get_ecc_requirements(&chip->base)->strength,
|
nanddev_get_ecc_requirements(&chip->base)->strength,
|
||||||
|
|
Loading…
Add table
Reference in a new issue