diff options
author | Miquel Raynal <miquel.raynal@bootlin.com> | 2021-06-10 16:49:02 +0300 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2021-06-18 10:45:21 +0300 |
commit | 47b4c8bd5db1c986c8b4b7189791701fe5c1897e (patch) | |
tree | 96a498050ec82870c5d467f91bd8ca8eaf4c5143 /drivers/mtd/nand | |
parent | 08d8c62164a322eb923034acacf25246b775593a (diff) | |
download | linux-47b4c8bd5db1c986c8b4b7189791701fe5c1897e.tar.xz |
mtd: rawnand: omap: Aggregate the HW configuration of the ELM
Instead of calling elm_config() for each possible BCH configuration,
just save the BCH configuration that must be applied and use it in a
single call at the bottom.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210610134906.3503303-2-miquel.raynal@bootlin.com
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/raw/omap2.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c index c75e7a0b101f..a36c4e7e5bc1 100644 --- a/drivers/mtd/nand/raw/omap2.c +++ b/drivers/mtd/nand/raw/omap2.c @@ -1921,6 +1921,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip) struct omap_nand_info *info = mtd_to_omap(mtd); struct device *dev = &info->pdev->dev; int min_oobbytes = BADBLOCK_MARKER_LENGTH; + int elm_bch_strength = -1; int oobbytes_per_step; dma_cap_mask_t mask; int err; @@ -2074,12 +2075,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip) chip->ecc.write_subpage = omap_write_subpage_bch; mtd_set_ooblayout(mtd, &omap_ooblayout_ops); oobbytes_per_step = chip->ecc.bytes; - - err = elm_config(info->elm_dev, BCH4_ECC, - mtd->writesize / chip->ecc.size, - chip->ecc.size, chip->ecc.bytes); - if (err < 0) - return err; + elm_bch_strength = BCH4_ECC; break; case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW: @@ -2116,13 +2112,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip) chip->ecc.write_subpage = omap_write_subpage_bch; mtd_set_ooblayout(mtd, &omap_ooblayout_ops); oobbytes_per_step = chip->ecc.bytes; - - err = elm_config(info->elm_dev, BCH8_ECC, - mtd->writesize / chip->ecc.size, - chip->ecc.size, chip->ecc.bytes); - if (err < 0) - return err; - + elm_bch_strength = BCH8_ECC; break; case OMAP_ECC_BCH16_CODE_HW: @@ -2138,17 +2128,19 @@ static int omap_nand_attach_chip(struct nand_chip *chip) chip->ecc.write_subpage = omap_write_subpage_bch; mtd_set_ooblayout(mtd, &omap_ooblayout_ops); oobbytes_per_step = chip->ecc.bytes; + elm_bch_strength = BCH16_ECC; + break; + default: + dev_err(dev, "Invalid or unsupported ECC scheme\n"); + return -EINVAL; + } - err = elm_config(info->elm_dev, BCH16_ECC, + if (elm_bch_strength >= 0) { + err = elm_config(info->elm_dev, elm_bch_strength, mtd->writesize / chip->ecc.size, chip->ecc.size, chip->ecc.bytes); if (err < 0) return err; - - break; - default: - dev_err(dev, "Invalid or unsupported ECC scheme\n"); - return -EINVAL; } /* Check if NAND device's OOB is enough to store ECC signatures */ |