mtd: nand: differentiate 1- vs. 2-byte writes when marking bad blocks

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Mar 26 20:59:03 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=85443319989bb91814504608a6e11d880e156828
Commit:     85443319989bb91814504608a6e11d880e156828
Parent:     cdbec0508699e3346052bf098c5c330a711a86a9
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Fri Jan 13 18:11:49 2012 -0800
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Tue Mar 27 00:12:34 2012 +0100

    mtd: nand: differentiate 1- vs. 2-byte writes when marking bad blocks
    
    It seems that we have developed a bad-block-marking "feature" out of
    pure laziness:
    
      "We write two bytes per location, so we dont have to mess with 16 bit
      access."
    
    It's relatively simple to write a 1 byte at a time on x8 devices and 2
    bytes at a time on x16 devices, so let's do it.
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/nand_base.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7855fd2..c6603d4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -430,13 +430,17 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
 		/*
 		 * Write to first two pages if necessary. If we write to more
 		 * than one location, the first error encountered quits the
-		 * procedure. We write two bytes per location, so we dont have
-		 * to mess with 16 bit access.
+		 * procedure.
 		 */
-		ops.len = ops.ooblen = 2;
 		ops.datbuf = NULL;
 		ops.oobbuf = buf;
-		ops.ooboffs = chip->badblockpos & ~0x01;
+		ops.ooboffs = chip->badblockpos;
+		if (chip->options & NAND_BUSWIDTH_16) {
+			ops.ooboffs &= ~0x01;
+			ops.len = ops.ooblen = 2;
+		} else {
+			ops.len = ops.ooblen = 1;
+		}
 		ops.mode = MTD_OPS_PLACE_OOB;
 		do {
 			ret = nand_do_write_oob(mtd, ofs, &ops);



More information about the linux-mtd-cvs mailing list