summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
diff options
context:
space:
mode:
authorHan Xu <han.xu@nxp.com>2022-04-11 21:52:43 -0500
committerMiquel Raynal <miquel.raynal@bootlin.com>2022-04-21 09:34:04 +0200
commitd10af38a2e3b60dc46ca9727dfc24d0ea57136e3 (patch)
tree3f11bb1e78b90d3ee7fe558a545a710fdc8e322b /drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
parent15616c7cfb968d72e614b1ba669467dc373b2582 (diff)
downloadlinux-d10af38a2e3b60dc46ca9727dfc24d0ea57136e3.tar.bz2
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
Diffstat (limited to 'drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c')
-rw-r--r--drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 66ebd569858d..cee39126771e 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -240,7 +240,13 @@ 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)) {
@@ -248,7 +254,14 @@ static inline bool gpmi_check_ecc(struct gpmi_nand_data *this)
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;
}
/*