[U-Boot] [PATCH 2/5] mtd: davinci_nand: Use common read function instead of verify_buf()

Peter Tyser ptyser at xes-inc.com
Mon Jan 26 23:24:48 CET 2015


The driver-specific verify_buf() function can be replaced with the
standard read_page_raw() function to verify writes.  This will allow
verify_buf() to be removed.  verify_buf() is no longer supported in
mainline Linux, so it is a pain to continue supporting.

Signed-off-by: Peter Tyser <ptyser at xes-inc.com>
---
I don't have davinci hardware to test on, but the change should
mirror the nand_base.c change.

 drivers/mtd/nand/davinci_nand.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 41689b5..b4e22d1 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -370,6 +370,7 @@ static int nand_davinci_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 	int status;
 	int ret = 0;
 	struct nand_ecclayout *saved_ecc_layout;
+	__maybe_unused uint8_t *vfy_buf;
 
 	/* save current ECC layout and assign Keystone RBL ECC layout */
 	if (page < CONFIG_KEYSTONE_NAND_MAX_RBL_PAGE) {
@@ -406,16 +407,24 @@ static int nand_davinci_write_page(struct mtd_info *mtd, struct nand_chip *chip,
 	}
 
 #ifdef CONFIG_MTD_NAND_VERIFY_WRITE
+	vfy_buf = malloc(mtd->writesize);
+	if (!vfy_buf) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	/* Send command to read back the data */
 	chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+	chip->ecc.read_page_raw(mtd, chip, vfy_buf, oob_required, page);
 
-	if (chip->verify_buf(mtd, buf, mtd->writesize)) {
+	if (memcmp(buf, vfy_buf, mtd->writesize))
 		ret = -EIO;
-		goto err;
-	}
+
+	free(vfy_buf);
 
 	/* Make sure the next page prog is preceded by a status read */
-	chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
+	if (!ret)
+		chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
 #endif
 err:
 	/* restore ECC layout */
-- 
1.9.1



More information about the U-Boot mailing list