diff mbox

[03/11] mtd: nand_bbt: add new API definitions

Message ID 1457923684-13505-4-git-send-email-peterpandong@micron.com
State Superseded
Headers show

Commit Message

Peter Pan March 14, 2016, 2:47 a.m. UTC
Add new API definitions for nand_bbt to replace old ones without
any users. These API includes:
	struct nand_bbt_create(struct mtd_info *mtd);
	struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
				const struct nand_bbt_ops *ops,
				struct nand_chip_layout_info *info,
				unsigned int options,
				struct nand_bbt_descr *bbt_td,
				struct nand_bbt_descr *bbt_md);
	void nand_bbt_destroy(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@gmail.com>
Signed-off-by: Peter Pan <peterpandong@micron.com>
---
 drivers/mtd/nand/nand_bbt.c  | 113 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/nand_bbt.h |  11 +++++
 2 files changed, 124 insertions(+)

Comments

kernel test robot March 14, 2016, 3:47 a.m. UTC | #1
Hi Peter,

[auto build test WARNING on next-20160311]
[cannot apply to mtd/master v4.5-rc7 v4.5-rc6 v4.5-rc5 v4.5-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Peter-Pan/mtd-nand_bbt-introduce-independent-nand-BBT/20160314-105725
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   drivers/mtd/nand/nand_base.c:321: warning: Excess function parameter 'getchip' description in 'nand_block_bad'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'ops'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'info'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'options'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'bbt_td'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'bbt_md'
   drivers/mtd/nand/nand_base.c:321: warning: Excess function parameter 'getchip' description in 'nand_block_bad'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'ops'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'info'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'options'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'bbt_td'
>> drivers/mtd/nand/nand_bbt.c:1409: warning: No description found for parameter 'bbt_md'

vim +/ops +1409 drivers/mtd/nand/nand_bbt.c

  1393	static void nand_bbt_release(struct nand_bbt *bbt)
  1394	{
  1395		kfree(bbt->bbt);
  1396	}
  1397	
  1398	/**
  1399	 * nand_bbt_create - [NAND BBT Interface] create BBT structures for certain
  1400	 * MTD device
  1401	 * @mtd: MTD structure
  1402	 */
  1403	struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
  1404				const struct nand_bbt_ops *ops,
  1405				struct nand_chip_layout_info *info,
  1406				unsigned int options,
  1407				struct nand_bbt_descr *bbt_td,
  1408				struct nand_bbt_descr *bbt_md)
> 1409	{
  1410		struct nand_bbt *bbt = kzalloc(sizeof(struct nand_bbt),
  1411						GFP_KERNEL);
  1412		int ret;
  1413	
  1414		if (!bbt)
  1415			return ERR_PTR(-ENOMEM);
  1416	
  1417		bbt->mtd = mtd;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Boris Brezillon March 25, 2016, 8:49 a.m. UTC | #2
On Mon, 14 Mar 2016 02:47:56 +0000
Peter Pan <peterpansjtu@gmail.com> wrote:

> Add new API definitions for nand_bbt to replace old ones without
> any users. These API includes:
> 	struct nand_bbt_create(struct mtd_info *mtd);
> 	struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
> 				const struct nand_bbt_ops *ops,
> 				struct nand_chip_layout_info *info,
> 				unsigned int options,
> 				struct nand_bbt_descr *bbt_td,
> 				struct nand_bbt_descr *bbt_md);
> 	void nand_bbt_destroy(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@gmail.com>
> Signed-off-by: Peter Pan <peterpandong@micron.com>
> ---
>  drivers/mtd/nand/nand_bbt.c  | 113 +++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mtd/nand_bbt.h |  11 +++++
>  2 files changed, 124 insertions(+)
> 

>  
> +struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
> +		const struct nand_bbt_ops *ops,
> +		struct nand_chip_layout_info *info,

Should be const struct nand_chip_layout_info *.
Peter Pan March 28, 2016, 7:56 a.m. UTC | #3
On Fri, Mar 25, 2016 at 4:49 PM, Boris Brezillon
<boris.brezillon@free-electrons.com> wrote:
> On Mon, 14 Mar 2016 02:47:56 +0000
> Peter Pan <peterpansjtu@gmail.com> wrote:
>
>> Add new API definitions for nand_bbt to replace old ones without
>> any users. These API includes:
>>       struct nand_bbt_create(struct mtd_info *mtd);
>>       struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
>>                               const struct nand_bbt_ops *ops,
>>                               struct nand_chip_layout_info *info,
>>                               unsigned int options,
>>                               struct nand_bbt_descr *bbt_td,
>>                               struct nand_bbt_descr *bbt_md);
>>       void nand_bbt_destroy(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@gmail.com>
>> Signed-off-by: Peter Pan <peterpandong@micron.com>
>> ---
>>  drivers/mtd/nand/nand_bbt.c  | 113 +++++++++++++++++++++++++++++++++++++++++++
>>  include/linux/mtd/nand_bbt.h |  11 +++++
>>  2 files changed, 124 insertions(+)
>>
>
>>
>> +struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
>> +             const struct nand_bbt_ops *ops,
>> +             struct nand_chip_layout_info *info,
>
> Should be const struct nand_chip_layout_info *.

Fix this in v4

Thanks,
Peter Pan
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 2fbb523..aab734e 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1373,3 +1373,116 @@  int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
 
 	return ret;
 }
+
+/**
+ * nand_bbt_init - 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.
+ */
+static 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);
+}
+
+static void nand_bbt_release(struct nand_bbt *bbt)
+{
+	kfree(bbt->bbt);
+}
+
+/**
+ * nand_bbt_create - [NAND BBT Interface] create BBT structures for certain
+ * MTD device
+ * @mtd: MTD structure
+ */
+struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
+			const struct nand_bbt_ops *ops,
+			struct nand_chip_layout_info *info,
+			unsigned int options,
+			struct nand_bbt_descr *bbt_td,
+			struct nand_bbt_descr *bbt_md)
+{
+	struct nand_bbt *bbt = kzalloc(sizeof(struct nand_bbt),
+					GFP_KERNEL);
+	int ret;
+
+	if (!bbt)
+		return ERR_PTR(-ENOMEM);
+
+	bbt->mtd = mtd;
+	bbt->bbt_options = options;
+	bbt->bbt_ops = ops;
+	bbt->info = info;
+	bbt->bbt_td = bbt_td;
+	bbt->bbt_md = bbt_md;
+
+	ret = nand_bbt_init(bbt);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return bbt;
+}
+EXPORT_SYMBOL(nand_bbt_create);
+
+/**
+ * nand_bbt_destroy - [NAND BBT Interface] Destroy BBT structures
+ * @bbt: NAND BBT structure
+ */
+void nand_bbt_destroy(struct nand_bbt *bbt)
+{
+	nand_bbt_release(bbt);
+	kfree(bbt);
+}
+EXPORT_SYMBOL(nand_bbt_destroy);
+
+/**
+ * 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 cfb22c8..c651d95 100644
--- a/include/linux/mtd/nand_bbt.h
+++ b/include/linux/mtd/nand_bbt.h
@@ -182,4 +182,15 @@  struct nand_bbt {
 	u8 *bbt;
 };
 
+struct nand_bbt *nand_bbt_create(struct mtd_info *mtd,
+		const struct nand_bbt_ops *ops,
+		struct nand_chip_layout_info *info,
+		unsigned int options,
+		struct nand_bbt_descr *bbt_td,
+		struct nand_bbt_descr *bbt_md);
+void nand_bbt_destroy(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 */