From patchwork Fri Aug 10 17:15:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 176551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A16862C00C7 for ; Sat, 11 Aug 2012 03:17:44 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SzsoB-0005RM-Lk; Fri, 10 Aug 2012 17:15:35 +0000 Received: from mail-ob0-f177.google.com ([209.85.214.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Szso6-0005R5-LW; Fri, 10 Aug 2012 17:15:33 +0000 Received: by obbta17 with SMTP id ta17so2543730obb.36 for ; Fri, 10 Aug 2012 10:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8gxMjgDJJAjGeFF69us04qBZpEuMavzQA0gb1llIyNU=; b=TExTT9bNEbnNLrWK2I64eGE/FqhG9872wYvprpp+eoaVIMWA3eZsxGLifp+I/KZ9nU kwJYs9nHzs88IrzT2SZHqgaRGbB9gDhz/ozsOWBtBJTlDKzJEJLtZuKrT+yTWfXorW3m xCJmWyGxxp7GpszX5ZlowWAo1GPY0TL52+ZqwhhKk9xPdCPX8vP+fwNIVfcs/I5INtim N6dboHm2Oxe9bgemXFZuaPov3zRYb2fNauPqU25J2QtnjUwdxnEptG+Qncq0k2uY/fOy Kfj5p3RM91wl9r2Hncwd3pmGJxLDbtbzbKE9oRbSndLp/Bsk14rvpcQEDnkqEp5C9TE3 1oXg== MIME-Version: 1.0 Received: by 10.60.2.42 with SMTP id 10mr5306490oer.9.1344618928308; Fri, 10 Aug 2012 10:15:28 -0700 (PDT) Received: by 10.76.7.113 with HTTP; Fri, 10 Aug 2012 10:15:28 -0700 (PDT) In-Reply-To: <201208101704.44984.marex@denx.de> References: <1344568737-902-1-git-send-email-b32955@freescale.com> <201208101325.23075.marex@denx.de> <201208101704.44984.marex@denx.de> Date: Fri, 10 Aug 2012 14:15:28 -0300 Message-ID: Subject: Re: [PATCH] mtd: gpmi: add NAND write verify support From: Fabio Estevam To: Marek Vasut X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (festevam[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: fabio.estevam@freescale.com, dedekind1@gmail.com, dwmw2@infradead.org, Huang Shijie , linux-mtd@lists.infradead.org, shawn.guo@linaro.org, Huang Shijie , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hi Marek, On Fri, Aug 10, 2012 at 12:04 PM, Marek Vasut wrote: >> Even there are two nand chips, there is only one gpmi controller. > > For now ... yes. Does this look better? and then I can also send this separate change to allow multi-instances: @@ -1630,7 +1646,7 @@ static int __devinit gpmi_nand_probe(struct platform_devic return -ENOMEM; } - this = kzalloc(sizeof(*this), GFP_KERNEL); + this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL); if (!this) { pr_err("Failed to allocate per-device memory\n"); return -ENOMEM; diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand index 8c0d2f0..5262ef3 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -1533,6 +1533,21 @@ void gpmi_nfc_exit(struct gpmi_nand_data *this) gpmi_free_dma_buffer(this); } +static int gpmi_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len) +{ + struct nand_chip *nand = mtd->priv; + struct gpmi_nand_data *data = container_of(mtd, struct gpmi_nand_data, + mtd); + int ret; + + ret = gpmi_ecc_read_page(mtd, nand, data->verify_buf, 0, 0); + if (ret) + return -EFAULT; + if (memcmp(buf, data->verify_buf, len)) + return -EFAULT; + return 0; +} + static int __devinit gpmi_nfc_init(struct gpmi_nand_data *this) { struct mtd_info *mtd = &this->mtd; @@ -1555,6 +1570,7 @@ static int __devinit gpmi_nfc_init(struct gpmi_nand_data * chip->dev_ready = gpmi_dev_ready; chip->read_byte = gpmi_read_byte; chip->read_buf = gpmi_read_buf; + chip->verify_buf = gpmi_verify_buf; chip->write_buf = gpmi_write_buf; chip->ecc.read_page = gpmi_ecc_read_page; chip->ecc.write_page = gpmi_ecc_write_page; diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/gpmi-nand index 1547a60..cd9bdf7 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.h @@ -148,6 +148,7 @@ struct gpmi_nand_data { /* General-use Variables */ int current_chip; unsigned int command_length; + uint8_t verify_buf[NAND_MAX_PAGESIZE]; /* passed from upper layer */ uint8_t *upper_buf;