[<prev] [next>] [day] [month] [year] [list]
Message-ID: <87F60714EC601C4C83DFF1D2E3D390A0326CC882@NTXXIAMBX02.xacn.micron.com>
Date: Fri, 25 Sep 2015 06:39:37 +0000
From: Peter Pan 潘栋 (peterpandong)
<peterpandong@...ron.com>
To: "dwmw2@...radead.org" <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
"fransklaver@...il.com" <fransklaver@...il.com>,
"wsa@...-dreams.de" <wsa@...-dreams.de>,
"zajec5@...il.com" <zajec5@...il.com>,
"boris.brezillon@...e-electrons.com"
<boris.brezillon@...e-electrons.com>,
"baruch@...s.co.il" <baruch@...s.co.il>,
"ezequiel.garcia@...e-electrons.com"
<ezequiel.garcia@...e-electrons.com>,
"kdasu.kdev@...il.com" <kdasu.kdev@...il.com>,
"rogerq@...com" <rogerq@...com>,
"asierra@...-inc.com" <asierra@...-inc.com>, bpqw <bpqw@...ron.com>
CC: "linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Frank Liu 刘群 (frankliu)
<frankliu@...ron.com>,
Peter Pan 潘栋 (peterpandong)
<peterpandong@...ron.com>, Kamil Debski <Kamil.Debski@...tec.com>,
"Ionela Voinescu" <Ionela.Voinescu@...tec.com>,
Bean Huo 霍斌斌 (beanhuo)
<beanhuo@...ron.com>
Subject: [PATCH 04/12] mtd: nand_bbt: add nand_bbt_markbad_factory()
interface
Some nand controller drivers(like docg4.c) mark factory bad block
mark by accessing bbt buffer directly, so create this API to avoid
breaking layer.
Signed-off-by: Peter Pan <peterpandong@...ron.com>
---
drivers/mtd/nand/nand_bbt.c | 32 +++++++++++++++++++++++++++++---
include/linux/mtd/nand_bbt.h | 1 +
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 3b7d1e1..26a3cd9 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1353,11 +1353,12 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
}
/**
- * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT
+ * nand_bbt_update_mark - update mark in the BBT
* @mtd: MTD device structure
* @offs: offset of the bad block
+ * @mark: block type mark
*/
-int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
+static int nand_bbt_update_mark(struct mtd_info *mtd, loff_t offs, uint8_t mark)
{
struct nand_chip *this = mtd->priv;
int block, ret = 0;
@@ -1365,7 +1366,7 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
block = (int)(offs >> this->bbt_erase_shift);
/* Mark bad block in memory */
- bbt_mark_entry(this, block, BBT_BLOCK_WORN);
+ bbt_mark_entry(this, block, mark);
/* Update flash-based bad block table */
if (this->bbt_options & NAND_BBT_USE_FLASH)
@@ -1374,6 +1375,15 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
return ret;
}
+/**
+ * nand_markbad_bbt - [NAND Interface] Mark a block bad in the BBT
+ * @mtd: MTD device structure
+ * @offs: offset of the bad block
+ */
+int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
+{
+ return nand_bbt_update_mark(mtd, offs, BBT_BLOCK_WORN);
+}
EXPORT_SYMBOL(nand_scan_bbt);
/**
@@ -1446,3 +1456,19 @@ int nand_bbt_markbad(struct nand_bbt *bbt, loff_t offs)
return nand_markbad_bbt(bbt->mtd, offs);
}
EXPORT_SYMBOL(nand_bbt_markbad);
+
+/**
+ * nand_bbt_markbad_factory - [NAND BBT Interface] Mark a block as factory bad
+ * in the BBT
+ * @bbt: NAND BBT structure
+ * @offs: offset of the bad block
+ */
+int nand_bbt_markbad_factory(struct nand_bbt *bbt, loff_t offs)
+{
+ /*
+ * FIXME: For now, we call nand_markbad_bbt() directly. It will change
+ * when we use struct nand_bbt instead of struct nand_chip.
+ */
+ return nand_bbt_update_mark(bbt->mtd, offs, BBT_BLOCK_FACTORY_BAD);
+}
+EXPORT_SYMBOL(nand_bbt_markbad_factory);
diff --git a/include/linux/mtd/nand_bbt.h b/include/linux/mtd/nand_bbt.h
index 150c49a..48a0620 100644
--- a/include/linux/mtd/nand_bbt.h
+++ b/include/linux/mtd/nand_bbt.h
@@ -179,5 +179,6 @@ void nand_bbt_release(struct nand_bbt *bbt);
int nand_bbt_markbad(struct nand_bbt *bbt, loff_t offs);
int nand_bbt_isreserved(struct nand_bbt *bbt, loff_t offs);
int nand_bbt_isbad(struct nand_bbt *bbt, loff_t offs);
+int nand_bbt_markbad_factory(struct nand_bbt *bbt, loff_t offs);
#endif /* __LINUX_MTD_NAND_BBT_H */
--
1.9.1
Powered by blists - more mailing lists