Patchwork [MTD,NAND] Only check one byte for bad block status on 8-bit flash

login
register
mail settings
Submitter Matt Reimer
Date Nov. 18, 2008, 7:30 p.m.
Message ID <f383264b0811181130l54d043edsbf19a9371d53082@mail.gmail.com>
Download mbox | patch
Permalink /patch/9539/
State New, archived
Headers show

Comments

Matt Reimer - Nov. 18, 2008, 7:30 p.m.

Patch

From 3fff4f2507deee7b6bbbd8c8f999f0bf337546af Mon Sep 17 00:00:00 2001
From: Matt Reimer <mreimer@sdgsystems.com>
Date: Tue, 18 Nov 2008 11:16:01 -0800
Subject: [PATCH] [MTD][NAND] Only check one byte for bad block status on 8-bit flash

According to the Samsung NAND flash docs I'm using, the bad-block
indicator is a byte for 8-bit flash, and a word for 16-bit flash. Teach
nand_bbt.c to respect this. An effect of this is that for 8-bit parts
the byte following the bad block indicator is available for use.

Signed-off-by: Matt Reimer <mreimer@sdgsystems.com>
---
 drivers/mtd/nand/nand_bbt.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 5e121ce..6862906 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1081,7 +1081,14 @@  static struct nand_bbt_descr smallpage_memorybased = {
 	.pattern = scan_ff_pattern
 };
 
-static struct nand_bbt_descr largepage_memorybased = {
+static struct nand_bbt_descr largepage_memorybased_8bit = {
+	.options = 0,
+	.offs = 0,
+	.len = 1,
+	.pattern = scan_ff_pattern
+};
+
+static struct nand_bbt_descr largepage_memorybased_16bit = {
 	.options = 0,
 	.offs = 0,
 	.len = 2,
@@ -1095,7 +1102,14 @@  static struct nand_bbt_descr smallpage_flashbased = {
 	.pattern = scan_ff_pattern
 };
 
-static struct nand_bbt_descr largepage_flashbased = {
+static struct nand_bbt_descr largepage_flashbased_8bit = {
+	.options = NAND_BBT_SCAN2NDPAGE,
+	.offs = 0,
+	.len = 1,
+	.pattern = scan_ff_pattern
+};
+
+static struct nand_bbt_descr largepage_flashbased_16bit = {
 	.options = NAND_BBT_SCAN2NDPAGE,
 	.offs = 0,
 	.len = 2,
@@ -1173,14 +1187,21 @@  int nand_default_bbt(struct mtd_info *mtd)
 			this->bbt_md = &bbt_mirror_descr;
 		}
 		if (!this->badblock_pattern) {
-			this->badblock_pattern = (mtd->writesize > 512) ? &largepage_flashbased : &smallpage_flashbased;
+			this->badblock_pattern = (mtd->writesize > 512) ?
+			    (this->options & NAND_BUSWIDTH_16 ?
+				&largepage_flashbased_16bit :
+			        &largepage_flashbased_8bit) :
+			    &smallpage_flashbased;
 		}
 	} else {
 		this->bbt_td = NULL;
 		this->bbt_md = NULL;
 		if (!this->badblock_pattern) {
 			this->badblock_pattern = (mtd->writesize > 512) ?
-			    &largepage_memorybased : &smallpage_memorybased;
+			    (this->options & NAND_BUSWIDTH_16 ?
+				&largepage_memorybased_16bit :
+			        &largepage_memorybased_8bit) :
+			    &smallpage_memorybased;
 		}
 	}
 	return nand_scan_bbt(mtd, this->badblock_pattern);
-- 
1.5.6.3