public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: fixup "mtd: nand: erase block before marking bad"
@ 2012-01-16 19:40 Brian Norris
  2012-01-19 21:49 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Norris @ 2012-01-16 19:40 UTC (permalink / raw)
  To: linux-mtd; +Cc: Brian Norris, David Woodhouse, Artem Bityutskiy

The following commit had an incorrect solution:

   mtd: nand: erase block before marking bad
   commit ece080820c9dddf467b6da08a8bfbab66615a03b

When trying to erase a block before writing to its OOB marker, we erase
after we mark the memory BBT. This causes an error like this:

   nand_erase_nand: attempt to erase a bad block at page 0x00000000

This patch is a fixup that moves the erase code block to the correct
location.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/nand_base.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ecc3f52..c6603d4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -400,6 +400,17 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
 	uint8_t buf[2] = { 0, 0 };
 	int block, ret, i = 0;
 
+	if (!(chip->bbt_options & NAND_BBT_USE_FLASH)) {
+		struct erase_info einfo;
+
+		/* Attempt erase before marking OOB */
+		memset(&einfo, 0, sizeof(einfo));
+		einfo.mtd = mtd;
+		einfo.addr = ofs;
+		einfo.len = 1 << chip->phys_erase_shift;
+		nand_erase_nand(mtd, &einfo, 0);
+	}
+
 	if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
 		ofs += mtd->erasesize - mtd->writesize;
 
@@ -413,14 +424,6 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
 		ret = nand_update_bbt(mtd, ofs);
 	else {
 		struct mtd_oob_ops ops;
-		struct erase_info einfo;
-
-		/* Attempt erase before marking OOB */
-		memset(&einfo, 0, sizeof(einfo));
-		einfo.mtd = mtd;
-		einfo.addr = ofs;
-		einfo.len = 1 << chip->phys_erase_shift;
-		nand_erase_nand(mtd, &einfo, 0);
 
 		nand_get_device(chip, mtd, FL_WRITING);
 
-- 
1.7.5.4

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

* Re: [PATCH] mtd: nand: fixup "mtd: nand: erase block before marking bad"
  2012-01-16 19:40 [PATCH] mtd: nand: fixup "mtd: nand: erase block before marking bad" Brian Norris
@ 2012-01-19 21:49 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2012-01-19 21:49 UTC (permalink / raw)
  To: Brian Norris; +Cc: David Woodhouse, linux-mtd

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

On Mon, 2012-01-16 at 11:40 -0800, Brian Norris wrote:
> The following commit had an incorrect solution:
> 
>    mtd: nand: erase block before marking bad
>    commit ece080820c9dddf467b6da08a8bfbab66615a03b

Squashed into, thank you!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

end of thread, other threads:[~2012-01-19 21:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 19:40 [PATCH] mtd: nand: fixup "mtd: nand: erase block before marking bad" Brian Norris
2012-01-19 21:49 ` Artem Bityutskiy

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