mtd: nand: ecc-hamming: Let the software Hamming ECC engine be unselected
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 29 Sep 2020 23:01:22 +0000 (01:01 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 10 Dec 2020 21:37:30 +0000 (22:37 +0100)
There is no reason to always embed the software Hamming ECC engine
implementation. By default it is (with raw NAND), but we can let the
user decide.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200929230124.31491-19-miquel.raynal@bootlin.com
drivers/mtd/nand/Kconfig
drivers/mtd/nand/raw/Kconfig
include/linux/mtd/nand-ecc-sw-hamming.h

index 306c33ca3448ca24a6d96ae2db5811fdbb8651b1..15ffe1a1b86313527a7b9744339777605bf568e0 100644 (file)
@@ -16,7 +16,16 @@ config MTD_NAND_ECC
        depends on MTD_NAND_CORE
 
 config MTD_NAND_ECC_SW_HAMMING
-       bool
+       bool "Software Hamming ECC engine"
+       default y if MTD_RAW_NAND
+       select MTD_NAND_ECC
+       help
+         This enables support for software Hamming error
+         correction. This correction can correct up to 1 bit error
+         per chunk and detect up to 2 bit errors. While it used to be
+         widely used with old parts, newer NAND chips usually require
+         more strength correction and in this case BCH or RS will be
+         preferred.
 
 config MTD_NAND_ECC_SW_HAMMING_SMC
        bool "NAND ECC Smart Media byte order"
index 6149096e32cb64c34823b16ad93b58e24aa0364f..cc86d6e4e04221c09c11f88a725d97cae8b54c52 100644 (file)
@@ -3,7 +3,6 @@ menuconfig MTD_RAW_NAND
        tristate "Raw/Parallel NAND Device Support"
        select MTD_NAND_CORE
        select MTD_NAND_ECC
-       select MTD_NAND_ECC_SW_HAMMING
        help
          This enables support for accessing all type of raw/parallel
          NAND flash devices. For further information see
@@ -72,6 +71,7 @@ config MTD_NAND_AU1550
 config MTD_NAND_NDFC
        tristate "IBM/MCC 4xx NAND controller"
        depends on 4xx
+       select MTD_NAND_ECC_SW_HAMMING
        select MTD_NAND_ECC_SW_HAMMING_SMC
        help
          NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
index 9d4b4d623741d9fe319ae561e5fa2ef89827d33b..5a39e96c3546e068decfcd9a00556c371eb9e7a3 100644 (file)
@@ -32,6 +32,8 @@ struct nand_ecc_sw_hamming_conf {
        unsigned int sm_order;
 };
 
+#if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_HAMMING)
+
 int ecc_sw_hamming_calculate(const unsigned char *buf, unsigned int step_size,
                             unsigned char *code, bool sm_order);
 int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
@@ -44,4 +46,38 @@ int nand_ecc_sw_hamming_correct(struct nand_device *nand, unsigned char *buf,
                                unsigned char *read_ecc,
                                unsigned char *calc_ecc);
 
+#else /* !CONFIG_MTD_NAND_ECC_SW_HAMMING */
+
+static inline int ecc_sw_hamming_calculate(const unsigned char *buf,
+                                          unsigned int step_size,
+                                          unsigned char *code, bool sm_order)
+{
+       return -ENOTSUPP;
+}
+
+static inline int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
+                                               const unsigned char *buf,
+                                               unsigned char *code)
+{
+       return -ENOTSUPP;
+}
+
+static inline int ecc_sw_hamming_correct(unsigned char *buf,
+                                        unsigned char *read_ecc,
+                                        unsigned char *calc_ecc,
+                                        unsigned int step_size, bool sm_order)
+{
+       return -ENOTSUPP;
+}
+
+static inline int nand_ecc_sw_hamming_correct(struct nand_device *nand,
+                                             unsigned char *buf,
+                                             unsigned char *read_ecc,
+                                             unsigned char *calc_ecc)
+{
+       return -ENOTSUPP;
+}
+
+#endif /* CONFIG_MTD_NAND_ECC_SW_HAMMING */
+
 #endif /* __MTD_NAND_ECC_SW_HAMMING_H__ */