Commit f9801fda authored by Abhishek Sahu's avatar Abhishek Sahu Committed by Miquel Raynal

mtd: rawnand: denali: use helper function for ecc setup

Use the NAND core helper function nand_ecc_choose_conf to tune
the ECC parameters instead of the function locally defined.
Signed-off-by: default avatarAbhishek Sahu <absahu@codeaurora.org>
Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 181ace9e
...@@ -1120,33 +1120,6 @@ int denali_calc_ecc_bytes(int step_size, int strength) ...@@ -1120,33 +1120,6 @@ int denali_calc_ecc_bytes(int step_size, int strength)
} }
EXPORT_SYMBOL(denali_calc_ecc_bytes); EXPORT_SYMBOL(denali_calc_ecc_bytes);
static int denali_ecc_setup(struct mtd_info *mtd, struct nand_chip *chip,
struct denali_nand_info *denali)
{
int oobavail = mtd->oobsize - denali->oob_skip_bytes;
int ret;
/*
* If .size and .strength are already set (usually by DT),
* check if they are supported by this controller.
*/
if (chip->ecc.size && chip->ecc.strength)
return nand_check_ecc_caps(chip, denali->ecc_caps, oobavail);
/*
* We want .size and .strength closest to the chip's requirement
* unless NAND_ECC_MAXIMIZE is requested.
*/
if (!(chip->ecc.options & NAND_ECC_MAXIMIZE)) {
ret = nand_match_ecc_req(chip, denali->ecc_caps, oobavail);
if (!ret)
return 0;
}
/* Max ECC strength is the last thing we can do */
return nand_maximize_ecc(chip, denali->ecc_caps, oobavail);
}
static int denali_ooblayout_ecc(struct mtd_info *mtd, int section, static int denali_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion) struct mtd_oob_region *oobregion)
{ {
...@@ -1317,7 +1290,8 @@ int denali_init(struct denali_nand_info *denali) ...@@ -1317,7 +1290,8 @@ int denali_init(struct denali_nand_info *denali)
chip->ecc.mode = NAND_ECC_HW_SYNDROME; chip->ecc.mode = NAND_ECC_HW_SYNDROME;
chip->options |= NAND_NO_SUBPAGE_WRITE; chip->options |= NAND_NO_SUBPAGE_WRITE;
ret = denali_ecc_setup(mtd, chip, denali); ret = nand_ecc_choose_conf(chip, denali->ecc_caps,
mtd->oobsize - denali->oob_skip_bytes);
if (ret) { if (ret) {
dev_err(denali->dev, "Failed to setup ECC settings.\n"); dev_err(denali->dev, "Failed to setup ECC settings.\n");
goto disable_irq; goto disable_irq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment