From patchwork Fri Feb 27 03:28:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Brownell X-Patchwork-Id: 23808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C223CDDD04 for ; Fri, 27 Feb 2009 14:31:05 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LctPA-0004Gx-3j; Fri, 27 Feb 2009 03:28:52 +0000 Received: from n17.bullet.mail.mud.yahoo.com ([68.142.206.144]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1LctP4-0004Gg-HI for linux-mtd@lists.infradead.org; Fri, 27 Feb 2009 03:28:49 +0000 Received: from [209.191.108.97] by n17.bullet.mail.mud.yahoo.com with NNFMP; 27 Feb 2009 03:28:45 -0000 Received: from [68.142.201.242] by t4.bullet.mud.yahoo.com with NNFMP; 27 Feb 2009 03:28:45 -0000 Received: from [127.0.0.1] by omp403.mail.mud.yahoo.com with NNFMP; 27 Feb 2009 03:28:45 -0000 X-Yahoo-Newman-Id: 548577.77095.bm@omp403.mail.mud.yahoo.com Received: (qmail 45873 invoked from network); 27 Feb 2009 03:28:45 -0000 Received: from unknown (HELO pogo) (david-b@69.226.224.20 with plain) by smtp103.sbc.mail.sp1.yahoo.com with SMTP; 27 Feb 2009 03:28:44 -0000 X-YMail-OSG: tB7raAYVM1naE5NmkIIz.P.RCylaqWofqfEEGEulVkSg.fX7SgULnznPTiiHfNh0vQJJ07.n0N63J9A7C_wVnTByP2ff4XqN9hH7jGTOS.j9cF0hh.W1vGIOgzdRitGwbpTz0xBCWnhZu_RE6eGUk242midHsjP9JmFazFUBrQFGpxurMd8beNfeYYsr5QOmerGZveAeRwiehOCau2AgVzZ19ubnvVVopVmyXA-- X-Yahoo-Newman-Property: ymail-3 From: David Brownell To: Andrew Morton Subject: Re: [patch/RESEND 2.6.29-rc6] NAND: fix "raw" reads with ECC syndrome layouts Date: Thu, 26 Feb 2009 19:28:43 -0800 User-Agent: KMail/1.9.10 References: <200902241508.13835.david-b@pacbell.net> <20090226122543.797eac77.akpm@linux-foundation.org> In-Reply-To: <20090226122543.797eac77.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200902261928.43642.david-b@pacbell.net> X-Spam-Score: 0.0 (/) Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 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 On Thursday 26 February 2009, Andrew Morton wrote: > > +     temp = chip->ecc.steps; > > +     do { > > +             ... > > +     } while (--temp); > > It would be clearer to code this as a plain old up-counting for loop. Downside: GCC adds a pointless jump-to-loop-test instruction at the top of the loop ... but we know there's at least one step, so there's no need to do that. And up-counting needs an extra variable, with initialization etc. ======== CUT HERE From: David Brownell Cosmetic fixes to the patch fixing raw HW_SYNDROME read/write. Signed-off-by: David Brownell --- drivers/mtd/nand/nand_base.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -773,10 +773,9 @@ static int nand_read_page_raw_syndrome(s int eccsize = chip->ecc.size; int eccbytes = chip->ecc.bytes; uint8_t *oob = chip->oob_poi; - int temp; + int steps, size; - temp = chip->ecc.steps; - do { + for (steps = chip->ecc.steps; steps > 0; steps--) { chip->read_buf(mtd, buf, eccsize); buf += eccsize; @@ -792,11 +791,11 @@ static int nand_read_page_raw_syndrome(s chip->read_buf(mtd, oob, chip->ecc.postpad); oob += chip->ecc.postpad; } - } while (--temp); + } - temp = mtd->oobsize - (oob - chip->oob_poi); - if (temp) - chip->read_buf(mtd, oob, temp); + size = mtd->oobsize - (oob - chip->oob_poi); + if (size) + chip->read_buf(mtd, oob, size); return 0; } @@ -1542,7 +1541,7 @@ static void nand_write_page_raw(struct m * @chip: nand chip info structure * @buf: data buffer * - * We need a special oob layout and handling even when ECC isn't used. + * We need a special oob layout and handling even when ECC isn't checked. */ static void nand_write_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf) @@ -1550,10 +1549,9 @@ static void nand_write_page_raw_syndrome int eccsize = chip->ecc.size; int eccbytes = chip->ecc.bytes; uint8_t *oob = chip->oob_poi; - int temp; + int steps, size; - temp = chip->ecc.steps; - do { + for (steps = chip->ecc.steps; steps > 0; steps--) { chip->write_buf(mtd, buf, eccsize); buf += eccsize; @@ -1569,11 +1567,11 @@ static void nand_write_page_raw_syndrome chip->write_buf(mtd, oob, chip->ecc.postpad); oob += chip->ecc.postpad; } - } while (--temp); + } - temp = mtd->oobsize - (oob - chip->oob_poi); - if (temp) - chip->write_buf(mtd, oob, temp); + size = mtd->oobsize - (oob - chip->oob_poi); + if (size) + chip->write_buf(mtd, oob, size); } /** * nand_write_page_swecc - [REPLACABLE] software ecc based page write function