[PATCH 3/3] mtd: nand: Make software ECC support optional

Sascha Hauer s.hauer at pengutronix.de
Fri Dec 11 04:58:03 EST 2020


Most NAND controllers use hardware ECC, so make software ECC support
optional to save some binary space.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mtd/nand/Kconfig     | 5 +++++
 drivers/mtd/nand/nand_base.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 339f7a923d..7c93260892 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -7,8 +7,13 @@ menuconfig NAND
 
 if NAND
 
+config MTD_NAND_ECC_SOFT
+	bool
+	prompt "Support software ecc"
+
 config MTD_NAND_ECC_SW_BCH
 	select BCH
+	depends on MTD_NAND_ECC_SOFT
 	bool
 	prompt "Support software BCH ecc"
 
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 0a980e4499..7c325f1f70 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -5053,6 +5053,9 @@ static int nand_set_ecc_soft_ops(struct nand_chip *chip)
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	struct nand_ecc_ctrl *ecc = &chip->ecc;
 
+	if (!IS_ENABLED(CONFIG_MTD_NAND_ECC_SOFT))
+		return -ENOSYS;
+
 	if (WARN_ON(ecc->mode != NAND_ECC_SOFT))
 		return -EINVAL;
 
-- 
2.20.1




More information about the barebox mailing list