* [PATCH 1/3] mtd: spi-nor: Make write support optional
@ 2020-12-11 9:58 Sascha Hauer
2020-12-11 9:58 ` [PATCH 2/3] mtd: nand: Make support for syndrome hardware ecc optional Sascha Hauer
2020-12-11 9:58 ` [PATCH 3/3] mtd: nand: Make software ECC support optional Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-12-11 9:58 UTC (permalink / raw)
To: Barebox List
Write support is optional with the CONFIG_MTD_WRITE option. Bail out
early in the write functions to save some binary space.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/spi-nor/spi-nor.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 350b82a6be..bd748ff5b4 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -470,6 +470,9 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
uint32_t rem;
int ret;
+ if (!IS_ENABLED(CONFIG_MTD_WRITE))
+ return -ENOSYS;
+
dev_dbg(nor->dev, "at 0x%llx, len %lld\n", (long long)instr->addr,
(long long)instr->len);
@@ -928,6 +931,9 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t actual;
int ret;
+ if (!IS_ENABLED(CONFIG_MTD_WRITE))
+ return -ENOSYS;
+
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_WRITE);
@@ -1000,6 +1006,9 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t retval;
int ret;
+ if (!IS_ENABLED(CONFIG_MTD_WRITE))
+ return -ENOSYS;
+
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_WRITE);
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] mtd: nand: Make support for syndrome hardware ecc optional
2020-12-11 9:58 [PATCH 1/3] mtd: spi-nor: Make write support optional Sascha Hauer
@ 2020-12-11 9:58 ` Sascha Hauer
2020-12-11 9:58 ` [PATCH 3/3] mtd: nand: Make software ECC support optional Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-12-11 9:58 UTC (permalink / raw)
To: Barebox List
NAND_ECC_HW_SYNDROME is currently not needed by the drivers in barebox,
so make support for it optional again. This has been optional before the
last NAND layer update, just re-add the option. This time drop the
"default y", as this option shouldn't be needed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/nand/Kconfig | 4 ++++
drivers/mtd/nand/nand_base.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 97819e5c0b..339f7a923d 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -12,6 +12,10 @@ config MTD_NAND_ECC_SW_BCH
bool
prompt "Support software BCH ecc"
+config NAND_ECC_HW_SYNDROME
+ bool
+ prompt "Support syndrome hardware ecc controllers"
+
config NAND_ALLOW_ERASE_BAD
bool
depends on MTD_WRITE
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 2c3c0b360f..0a980e4499 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -5574,6 +5574,10 @@ int nand_scan_tail(struct nand_chip *chip)
if (!ecc->write_subpage && ecc->hwctl && ecc->calculate)
ecc->write_subpage = nand_write_subpage_hwecc;
case NAND_ECC_HW_SYNDROME:
+ if (!IS_ENABLED(CONFIG_NAND_ECC_HW_SYNDROME)) {
+ ret = -ENOSYS;
+ goto err_nand_manuf_cleanup;
+ }
if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&
(!ecc->read_page ||
ecc->read_page == nand_read_page_hwecc ||
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] mtd: nand: Make software ECC support optional
2020-12-11 9:58 [PATCH 1/3] mtd: spi-nor: Make write support optional Sascha Hauer
2020-12-11 9:58 ` [PATCH 2/3] mtd: nand: Make support for syndrome hardware ecc optional Sascha Hauer
@ 2020-12-11 9:58 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-12-11 9:58 UTC (permalink / raw)
To: Barebox List
Most NAND controllers use hardware ECC, so make software ECC support
optional to save some binary space.
Signed-off-by: Sascha Hauer <s.hauer@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-11 9:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 9:58 [PATCH 1/3] mtd: spi-nor: Make write support optional Sascha Hauer
2020-12-11 9:58 ` [PATCH 2/3] mtd: nand: Make support for syndrome hardware ecc optional Sascha Hauer
2020-12-11 9:58 ` [PATCH 3/3] mtd: nand: Make software ECC support optional Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox