[PATCH 03/12] mtd: nand_bbt: add new API definitions

From: Peter Pan 潘栋 (peterpandong)
Date: Fri Sep 25 2015 - 02:39:40 EST


Add new API definitions for nand_bbt to replace old ones without
any users. These API includes:
int nand_bbt_init(struct nand_bbt *bbt);
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);

Signed-off-by: Brian Norris <computersforpeace@xxxxxxxxx>
---
drivers/mtd/nand/nand_bbt.c | 71 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/nand_bbt.h | 6 ++++
2 files changed, 77 insertions(+)

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 63a1a36..3b7d1e1 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1375,3 +1375,74 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
}

EXPORT_SYMBOL(nand_scan_bbt);
+
+/**
+ * nand_bbt_init - [NAND BBT Interface] Initialize and locate/create a bad block
+ * table
+ * @bbt: NAND BBT structure
+ *
+ * This function selects the default bad block table support for the device and
+ * scans for an existing table, or else creates one.
+ */
+int nand_bbt_init(struct nand_bbt *bbt)
+{
+ /*
+ * FIXME: For now, we call nand_default_bbt() directly. It will change
+ * when we use struct nand_bbt instead of struct nand_chip.
+ */
+ return nand_default_bbt(bbt->mtd);
+}
+EXPORT_SYMBOL(nand_bbt_init);
+
+void nand_bbt_release(struct nand_bbt *bbt)
+{
+ kfree(bbt->bbt);
+}
+EXPORT_SYMBOL(nand_bbt_release);
+
+/**
+ * nand_bbt_isreserved - [NAND BBT Interface] Check if a block is reserved
+ * @bbt: NAND BBT structure
+ * @offs: offset in the device
+ */
+int nand_bbt_isreserved(struct nand_bbt *bbt, loff_t offs)
+{
+ /*
+ * FIXME: For now, we call nand_isreserved_bbt() directly. It will
+ * change when we use struct nand_bbt instead of struct nand_chip.
+ */
+ return nand_isreserved_bbt(bbt->mtd, offs);
+}
+EXPORT_SYMBOL(nand_bbt_isreserved);
+
+/**
+ * nand_bbt_isbad - [NAND BBT Interface] Check if a block is bad
+ * @bbt: NAND BBT structure
+ * @offs: offset in the device
+ */
+int nand_bbt_isbad(struct nand_bbt *bbt, loff_t offs)
+{
+ /*
+ * FIXME: For now, we call nand_isbad_bbt() directly. It will change
+ * when we use struct nand_bbt instead of struct nand_chip.
+ * Since we already have nand_bbt_isreserved(), we don't need to
+ * check pass down allow_bbt.
+ */
+ return nand_isbad_bbt(bbt->mtd, offs, 1);
+}
+EXPORT_SYMBOL(nand_bbt_isbad);
+
+/**
+ * nand_bbt_markbad - [NAND BBT Interface] Mark a block bad in the BBT
+ * @bbt: NAND BBT structure
+ * @offs: offset of the bad block
+ */
+int nand_bbt_markbad(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_markbad_bbt(bbt->mtd, offs);
+}
+EXPORT_SYMBOL(nand_bbt_markbad);
diff --git a/include/linux/mtd/nand_bbt.h b/include/linux/mtd/nand_bbt.h
index e468571..150c49a 100644
--- a/include/linux/mtd/nand_bbt.h
+++ b/include/linux/mtd/nand_bbt.h
@@ -174,4 +174,10 @@ struct nand_bbt {
u8 *bbt;
};

+int nand_bbt_init(struct nand_bbt *bbt);
+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);
+
#endif /* __LINUX_MTD_NAND_BBT_H */
--
1.9.1
N?叉??y??b??千v??藓{.n???{?赙zXФ?塄}?财??j:+v???赙zZ+€?zf"?????i????ア??璀??撷f?^j谦y??@A?囤?0鹅h??i