Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Han Xu and committed by
Miquel Raynal
d10af38a 15616c7c

+14 -1
+14 -1
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
··· 240 240 241 241 static inline bool gpmi_check_ecc(struct gpmi_nand_data *this) 242 242 { 243 + struct nand_chip *chip = &this->nand; 243 244 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; 244 250 245 251 /* Do the sanity check. */ 246 252 if (GPMI_IS_MXS(this)) { ··· 254 248 if (geo->gf_len == 14) 255 249 return false; 256 250 } 257 - return geo->ecc_strength <= this->devdata->bch_max_ecc_strength; 251 + 252 + if (geo->ecc_strength > this->devdata->bch_max_ecc_strength) 253 + return false; 254 + 255 + if (!nand_ecc_is_strong_enough(nand)) 256 + return false; 257 + 258 + return true; 258 259 } 259 260 260 261 /*