From: David Brownell <david-b@pacbell.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
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 [thread overview]
Message-ID: <200902261928.43642.david-b@pacbell.net> (raw)
In-Reply-To: <20090226122543.797eac77.akpm@linux-foundation.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 <dbrownell@users.sourceforge.net>
Cosmetic fixes to the patch fixing raw HW_SYNDROME read/write.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
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
prev parent reply other threads:[~2009-02-27 3:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 23:08 [patch/RESEND 2.6.29-rc6] NAND: fix "raw" reads with ECC syndrome layouts David Brownell
2009-02-26 20:25 ` Andrew Morton
2009-02-27 3:28 ` David Brownell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200902261928.43642.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox