[PATCH 2/7] mtd/nand: try to erase bad blocks only if scrub flag is provided
mikhail.kshevetskiy at iopsys.eu
mikhail.kshevetskiy at iopsys.eu
Thu Oct 6 05:14:57 CEST 2022
From: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
'mtd erase' command should not erase bad blocks. To force bad block erasing
there is 'mtd erase.dontskipbad' command (this command sets 'scrub' flag
to true in the erase_info structure). Unfortunately nand layer ignore
scrub flag and try to erases bad blocks unconditionally. This is wrong.
Add checks to allow bad block erasing only if scrub flag is set.
Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
---
drivers/mtd/nand/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c
index 99c29670c7..a4fb7602c9 100644
--- a/drivers/mtd/nand/core.c
+++ b/drivers/mtd/nand/core.c
@@ -174,7 +174,10 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo)
nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last);
while (nanddev_pos_cmp(&pos, &last) <= 0) {
schedule();
- ret = nanddev_erase(nand, &pos);
+ if (!einfo->scrub && nanddev_isbad(nand, &pos))
+ ret = -EIO;
+ else
+ ret = nanddev_erase(nand, &pos);
if (ret) {
einfo->fail_addr = nanddev_pos_to_offs(nand, &pos);
--
2.35.1
More information about the U-Boot
mailing list