mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: nand_bbt: Skip bad blocks when searching for the BBT in NAND
@ 2020-05-04 13:44 Yunus Bas
  2020-05-04 14:30 ` Yunus Bas
  0 siblings, 1 reply; 2+ messages in thread
From: Yunus Bas @ 2020-05-04 13:44 UTC (permalink / raw)
  To: barebox

From: Stefan Riedmueller <s.riedmueller@phytec.de>

The blocks containing the bad block table can become bad as well. So
make sure to skip any blocks that are marked bad when searching for the
bad block table.

Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Signed-off-by: Christian Hemp <c.hemp@phytec.de>
Signed-off-by: Yunus Bas <y.bas@phytec.de>
---
 drivers/mtd/nand/nand_bbt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 435a06f..403c0ae 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -560,8 +560,14 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
 			int actblock = startblock + dir * block;
 			loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
 
-			/* Read first page */
-			scan_read(mtd, buf, offs, mtd->writesize, td);
+			/* Read first page including oob */
+			scan_read_oob(mtd, buf, offs, scanlen);
+
+			/* Skip blocks which are marked bad */
+			if (buf[mtd->writesize] == 0x00) {
+				continue;
+			}
+
 			if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
 				td->pages[i] = actblock << blocktopage;
 				if (td->options & NAND_BBT_VERSION) {
-- 
2.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-04 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 13:44 [PATCH] mtd: nand_bbt: Skip bad blocks when searching for the BBT in NAND Yunus Bas
2020-05-04 14:30 ` Yunus Bas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox