Skip to content

Commit d10af38

Browse files
hanxu-nxpmiquelraynal
authored andcommitted
mtd: rawnand: gpmi: Add strict ecc strength check
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
1 parent 15616c7 commit d10af38

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,28 @@ static void gpmi_dump_info(struct gpmi_nand_data *this)
240240

241241
static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
242242
{
243+
struct nand_chip *chip = &this->nand;
243244
struct bch_geometry *geo = &this->bch_geometry;
245+
struct nand_device *nand = &chip->base;
246+
struct nand_ecc_props *conf = &nand->ecc.ctx.conf;
247+
248+
conf->step_size = geo->eccn_chunk_size;
249+
conf->strength = geo->ecc_strength;
244250

245251
/* Do the sanity check. */
246252
if (GPMI_IS_MXS(this)) {
247253
/* The mx23/mx28 only support the GF13. */
248254
if (geo->gf_len == 14)
249255
return false;
250256
}
251-
return geo->ecc_strength <= this->devdata->bch_max_ecc_strength;
257+
258+
if (geo->ecc_strength > this->devdata->bch_max_ecc_strength)
259+
return false;
260+
261+
if (!nand_ecc_is_strong_enough(nand))
262+
return false;
263+
264+
return true;
252265
}
253266

254267
/*

0 commit comments

Comments
 (0)