[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200310203224.410198-1-mikhail.kshevetskiy@oktetlabs.ru>
Date: Tue, 10 Mar 2020 23:32:23 +0300
From: Mikhail Kshevetskiy <mikhail.kshevetskiy@...etlabs.ru>
To: miquel.raynal@...tlin.com, richard@....at
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
Mikhail Kshevetskiy <mikhail.kshevetskiy@...etlabs.ru>
Subject: [PATCH 1/2] mtd: spinand: wait for erase completion before writing bad block maker
SPI flash will discard any write operation while it is busy with block
erasing. As result bad block marker will not be writed to a flash.
To fix it just wait for completion of erase operation.
The erasing code is almost the same as in spinand_erase(). The only
difference is: we ignore ERASE_FAILED status.
This patch also improve error handling a bit.
Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@...etlabs.ru>
---
drivers/mtd/nand/spi/core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 89f6beefb01c..bb4eac400b0f 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -610,6 +610,7 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
.oobbuf.out = spinand->oobbuf,
};
int ret;
+ u8 status;
/* Erase block before marking it bad. */
ret = spinand_select_target(spinand, pos->target);
@@ -620,7 +621,14 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
if (ret)
return ret;
- spinand_erase_op(spinand, pos);
+ ret = spinand_erase_op(spinand, pos);
+ if (ret)
+ return ret;
+
+ /* ignore status as erase may fail for bad blocks */
+ spinand_wait(spinand, &status);
+ if (ret)
+ return ret;
memset(spinand->oobbuf, 0, 2);
return spinand_write_page(spinand, &req);
--
2.25.0
Powered by blists - more mailing lists