diff mbox series

[v4,4/5] mtd: rawnand: Introduce a new function nand_check_is_erased_page()

Message ID 20200518135943.11749-5-huobean@gmail.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series Micron SLC NAND filling block | expand

Commit Message

Bean Huo May 18, 2020, 1:59 p.m. UTC
From: Bean Huo <beanhuo@micron.com>

Add a new function nand_check_is_erased_page() in nand_base.c, which is
used to check whether one programmable page is empty or already programmed.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/mtd/nand/raw/nand_base.c | 41 ++++++++++++++++++++++++++++++++
 include/linux/mtd/rawnand.h      |  2 ++
 2 files changed, 43 insertions(+)

Comments

kernel test robot May 18, 2020, 3:11 p.m. UTC | #1
Hi Bean,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.7-rc6 next-20200518]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Bean-Huo/Micron-SLC-NAND-filling-block/20200518-220231
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b9bbe6ed63b2b9f2c9ee5cbd0f2c946a2723f4ce
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

drivers/mtd/nand/raw/nand_base.c: In function 'nand_check_is_erased_page':
>> drivers/mtd/nand/raw/nand_base.c:2611:2: error: 'max_bitflips' undeclared (first use in this function)
2611 |  max_bitflips = 0;
|  ^~~~~~~~~~~~
drivers/mtd/nand/raw/nand_base.c:2611:2: note: each undeclared identifier is reported only once for each function it appears in

vim +/max_bitflips +2611 drivers/mtd/nand/raw/nand_base.c

  2586	
  2587	/**
  2588	 * nand_check_is_erased_page - check if this page is a empty page
  2589	 * @chip: nand chip info structure
  2590	 * @page_data: data buffer containing the data in the page being checked
  2591	 * @oob: indicate if chip->oob_poi points to oob date of the page
  2592	 *
  2593	 * Returns true if this is an un-programmed page, false otherwise.
  2594	 */
  2595	int nand_check_is_erased_page(struct nand_chip *chip, u8 *page_data, bool oob)
  2596	{
  2597		struct mtd_info *mtd = nand_to_mtd(chip);
  2598		int ret, i;
  2599		u8 *databuf, *eccbuf = NULL;
  2600		struct mtd_oob_region oobregion;
  2601		int datasize, eccbytes = 0;
  2602	
  2603		databuf = page_data;
  2604		datasize = chip->ecc.size;
  2605	
  2606		if (oob) {
  2607			mtd_ooblayout_ecc(mtd, 0, &oobregion);
  2608			eccbuf = chip->oob_poi + oobregion.offset;
  2609			eccbytes = chip->ecc.bytes;
  2610		}
> 2611		max_bitflips = 0;
  2612	
  2613		for (i = 0; i < chip->ecc.steps; i++) {
  2614			ret = nand_check_erased_ecc_chunk(databuf, datasize,
  2615							  eccbuf, eccbytes,
  2616							  NULL, 0, chip->ecc.strength);
  2617			if (ret < 0)
  2618				return false;
  2619	
  2620			databuf += chip->ecc.size;
  2621			eccbuf += chip->ecc.bytes;
  2622		}
  2623	
  2624		return ret;
  2625	}
  2626	EXPORT_SYMBOL(nand_check_is_erased_page);
  2627	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 09ee490c08a9..2b9862d9979b 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -2646,6 +2646,47 @@  int nand_check_erased_ecc_chunk(void *data, int datalen,
 }
 EXPORT_SYMBOL(nand_check_erased_ecc_chunk);
 
+/**
+ * nand_check_is_erased_page - check if this page is a empty page
+ * @chip: nand chip info structure
+ * @page_data: data buffer containing the data in the page being checked
+ * @oob: indicate if chip->oob_poi points to oob date of the page
+ *
+ * Returns true if this is an un-programmed page, false otherwise.
+ */
+int nand_check_is_erased_page(struct nand_chip *chip, u8 *page_data, bool oob)
+{
+	struct mtd_info *mtd = nand_to_mtd(chip);
+	int ret, i;
+	u8 *databuf, *eccbuf = NULL;
+	struct mtd_oob_region oobregion;
+	int datasize, eccbytes = 0;
+
+	databuf = page_data;
+	datasize = chip->ecc.size;
+
+	if (oob) {
+		mtd_ooblayout_ecc(mtd, 0, &oobregion);
+		eccbuf = chip->oob_poi + oobregion.offset;
+		eccbytes = chip->ecc.bytes;
+	}
+	max_bitflips = 0;
+
+	for (i = 0; i < chip->ecc.steps; i++) {
+		ret = nand_check_erased_ecc_chunk(databuf, datasize,
+						  eccbuf, eccbytes,
+						  NULL, 0, chip->ecc.strength);
+		if (ret < 0)
+			return false;
+
+		databuf += chip->ecc.size;
+		eccbuf += chip->ecc.bytes;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL(nand_check_is_erased_page);
+
 /**
  * nand_read_page_raw_notsupp - dummy read raw page function
  * @chip: nand chip info structure
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 3d75e50e5b75..718ce81eb111 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -1337,6 +1337,8 @@  int nand_check_erased_ecc_chunk(void *data, int datalen,
 				void *extraoob, int extraooblen,
 				int threshold);
 
+int nand_check_is_erased_page(struct nand_chip *chip, u8 *page_data, bool oob);
+
 int nand_ecc_choose_conf(struct nand_chip *chip,
 			 const struct nand_ecc_caps *caps, int oobavail);