From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Tyser Date: Mon, 26 Jan 2015 16:24:48 -0600 Subject: [U-Boot] [PATCH 2/5] mtd: davinci_nand: Use common read function instead of verify_buf() In-Reply-To: <1422311091-4110-1-git-send-email-ptyser@xes-inc.com> References: <1422311091-4110-1-git-send-email-ptyser@xes-inc.com> Message-ID: <1422311091-4110-2-git-send-email-ptyser@xes-inc.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- 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