Skip to content

Commit

Permalink
mtd: rawnand: gpmi: Add strict ecc strength check
Browse files Browse the repository at this point in the history
Add nand_ecc_is_strong_enough() check in gpmi_check_ecc() function to
make sure ecc strength can meet chip requirement.

Signed-off-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220412025246.24269-3-han.xu@nxp.com
  • Loading branch information
Han Xu authored and Miquel Raynal committed Apr 21, 2022
1 parent 15616c7 commit d10af38
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,28 @@ static void gpmi_dump_info(struct gpmi_nand_data *this)

static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
{
struct nand_chip *chip = &this->nand;
struct bch_geometry *geo = &this->bch_geometry;
struct nand_device *nand = &chip->base;
struct nand_ecc_props *conf = &nand->ecc.ctx.conf;

conf->step_size = geo->eccn_chunk_size;
conf->strength = geo->ecc_strength;

/* Do the sanity check. */
if (GPMI_IS_MXS(this)) {
/* The mx23/mx28 only support the GF13. */
if (geo->gf_len == 14)
return false;
}
return geo->ecc_strength <= this->devdata->bch_max_ecc_strength;

if (geo->ecc_strength > this->devdata->bch_max_ecc_strength)
return false;

if (!nand_ecc_is_strong_enough(nand))
return false;

return true;
}

/*
Expand Down

0 comments on commit d10af38

Please sign in to comment.