mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 02:23:16 +00:00
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
This commit is contained in:
parent
08d8c62164
commit
47b4c8bd5d
@ -1921,6 +1921,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||||||
struct omap_nand_info *info = mtd_to_omap(mtd);
|
struct omap_nand_info *info = mtd_to_omap(mtd);
|
||||||
struct device *dev = &info->pdev->dev;
|
struct device *dev = &info->pdev->dev;
|
||||||
int min_oobbytes = BADBLOCK_MARKER_LENGTH;
|
int min_oobbytes = BADBLOCK_MARKER_LENGTH;
|
||||||
|
int elm_bch_strength = -1;
|
||||||
int oobbytes_per_step;
|
int oobbytes_per_step;
|
||||||
dma_cap_mask_t mask;
|
dma_cap_mask_t mask;
|
||||||
int err;
|
int err;
|
||||||
@ -2074,12 +2075,7 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||||||
chip->ecc.write_subpage = omap_write_subpage_bch;
|
chip->ecc.write_subpage = omap_write_subpage_bch;
|
||||||
mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
|
mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
|
||||||
oobbytes_per_step = chip->ecc.bytes;
|
oobbytes_per_step = chip->ecc.bytes;
|
||||||
|
elm_bch_strength = BCH4_ECC;
|
||||||
err = elm_config(info->elm_dev, BCH4_ECC,
|
|
||||||
mtd->writesize / chip->ecc.size,
|
|
||||||
chip->ecc.size, chip->ecc.bytes);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
|
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;
|
chip->ecc.write_subpage = omap_write_subpage_bch;
|
||||||
mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
|
mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
|
||||||
oobbytes_per_step = chip->ecc.bytes;
|
oobbytes_per_step = chip->ecc.bytes;
|
||||||
|
elm_bch_strength = BCH8_ECC;
|
||||||
err = elm_config(info->elm_dev, BCH8_ECC,
|
|
||||||
mtd->writesize / chip->ecc.size,
|
|
||||||
chip->ecc.size, chip->ecc.bytes);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OMAP_ECC_BCH16_CODE_HW:
|
case OMAP_ECC_BCH16_CODE_HW:
|
||||||
@ -2138,19 +2128,21 @@ static int omap_nand_attach_chip(struct nand_chip *chip)
|
|||||||
chip->ecc.write_subpage = omap_write_subpage_bch;
|
chip->ecc.write_subpage = omap_write_subpage_bch;
|
||||||
mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
|
mtd_set_ooblayout(mtd, &omap_ooblayout_ops);
|
||||||
oobbytes_per_step = chip->ecc.bytes;
|
oobbytes_per_step = chip->ecc.bytes;
|
||||||
|
elm_bch_strength = BCH16_ECC;
|
||||||
err = elm_config(info->elm_dev, BCH16_ECC,
|
|
||||||
mtd->writesize / chip->ecc.size,
|
|
||||||
chip->ecc.size, chip->ecc.bytes);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(dev, "Invalid or unsupported ECC scheme\n");
|
dev_err(dev, "Invalid or unsupported ECC scheme\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if NAND device's OOB is enough to store ECC signatures */
|
/* Check if NAND device's OOB is enough to store ECC signatures */
|
||||||
min_oobbytes += (oobbytes_per_step *
|
min_oobbytes += (oobbytes_per_step *
|
||||||
(mtd->writesize / chip->ecc.size));
|
(mtd->writesize / chip->ecc.size));
|
||||||
|
Loading…
Reference in New Issue
Block a user