From patchwork Mon Apr 16 22:35:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 153004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [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 D37C1B700F for ; Tue, 17 Apr 2012 08:38:10 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SJuXc-0001qJ-HR; Mon, 16 Apr 2012 22:37:00 +0000 Received: from mail-pz0-f43.google.com ([209.85.210.43]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SJuXW-0001pd-NQ for linux-mtd@lists.infradead.org; Mon, 16 Apr 2012 22:36:56 +0000 Received: by dadn15 with SMTP id n15so9114789dad.16 for ; Mon, 16 Apr 2012 15:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=0ni08f7wvCiNrMpVhzZUX6SLeHWaIWV1SEU4+YnUIpc=; b=pv9ztU+D7JN4ExF84hDhOnfBvHeQqdhlJHYzAX9kGJM4RRVPCYVP/d15OXU6uyqaWn 4up/nc8IS4ZUMQLw0trlkpLf7xYeWFPLnOwYUGoNLN43EwzUpC/2vVxvL2AclO9r6KLw PAoZ9JkXZUfM2fTaxkHE4qmPmhoQz2JdAMZC0BH1vEzLvkyjPLdcBcszlTZ+sXmaeaXM rtrmILkPpE8D9+jVhyZ/uCp3A45h4W6CWk50fcWOSticny0pmfaSbPxWY0Az8PwtIrvi +jwcFZpt+HZVGpQvwdFUIoQNMwMauvNpV3f+49u8i46f45XXKhg5YehdOtP7vCcCWMdu qyzQ== Received: by 10.68.238.4 with SMTP id vg4mr24683673pbc.125.1334615813917; Mon, 16 Apr 2012 15:36:53 -0700 (PDT) Received: from localhost.localdomain (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPS id wf6sm1010758pbc.8.2012.04.16.15.36.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Apr 2012 15:36:53 -0700 (PDT) From: Brian Norris To: Subject: [PATCH 2/2] mtd: nand: nand_do_{read, write}_ops - pass OOB buffer through Date: Mon, 16 Apr 2012 15:35:55 -0700 Message-Id: <1334615755-15418-3-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.5.4.2.g519b1 In-Reply-To: <1334615755-15418-1-git-send-email-computersforpeace@gmail.com> References: <1334615755-15418-1-git-send-email-computersforpeace@gmail.com> 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.210.43 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[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: Viresh Kumar , Artem Bityutskiy , Nicolas Ferre , Vipin Kumar , Laurent Pinchart , Florian Fainelli , Jamie Iles , Mike Dunn , Bastian Hecht , Dmitry Eremin-Solenikov , Kevin Cernekee , Lei Wen , Axel Lin , Li Yang , Jean-Christophe PLAGNIOL-VILLARD , Armando Visconti , Liu Shuo , Thomas Gleixner , Scott Branden , Artem Bityutskiy , Wolfram Sang , Huang Shijie , Shmulik Ladkani , Jiandong Zheng , Brian Norris , David Woodhouse 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: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Now that we have a function parameter for the OOB buffer, we can pass the OOB buffer as an argument to the nand_ecc_ctrl functions. This allows drivers to know when OOB data must be returned to the upper layers and when it is simply needed for internal calculations, potentially saving time for NAND HW/SW that can simply avoid reading the OOB data. Signed-off-by: Brian Norris --- drivers/mtd/nand/nand_base.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 95ba987..a206f43 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1475,7 +1475,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, uint32_t max_oobsize = ops->mode == MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; - uint8_t *bufpoi, *oob, *buf; + uint8_t *bufpoi, *oobpoi, *oob, *buf; stats = mtd->ecc_stats; @@ -1489,6 +1489,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, buf = ops->datbuf; oob = ops->oobbuf; + oobpoi = oob ? chip->oob_poi : NULL; while (1) { bytes = min(mtd->writesize - col, readlen); @@ -1506,13 +1507,13 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, /* Now read the page into the buffer */ if (unlikely(ops->mode == MTD_OPS_RAW)) ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, - NULL, page); + oobpoi, page); else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob) ret = chip->ecc.read_subpage(mtd, chip, col, bytes, bufpoi); else ret = chip->ecc.read_page(mtd, chip, bufpoi, - NULL, page); + oobpoi, page); if (ret < 0) { if (!aligned) /* Invalidate page cache */ @@ -1535,7 +1536,6 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, buf += bytes; if (unlikely(oob)) { - int toread = min(oobreadlen, max_oobsize); if (toread) { @@ -2256,7 +2256,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, while (1) { int bytes = mtd->writesize; int cached = writelen > bytes && page != blockmask; - uint8_t *wbuf = buf; + uint8_t *wbuf = buf, *oobpoi; /* Partial page write? */ if (unlikely(column || writelen < (mtd->writesize - 1))) { @@ -2272,12 +2272,14 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, size_t len = min(oobwritelen, oobmaxlen); oob = nand_fill_oob(mtd, oob, len, ops); oobwritelen -= len; + oobpoi = chip->oob_poi; } else { + oobpoi = NULL; /* We still need to erase leftover OOB data */ memset(chip->oob_poi, 0xff, mtd->oobsize); } - ret = chip->write_page(mtd, chip, wbuf, NULL, page, cached, + ret = chip->write_page(mtd, chip, wbuf, oobpoi, page, cached, (ops->mode == MTD_OPS_RAW)); if (ret) break;