Re: [patch/RESEND 2.6.29-rc6] NAND: fix "raw" reads with ECCsyndrome layouts

From: Andrew Morton
Date: Thu Feb 26 2009 - 15:26:34 EST


On Tue, 24 Feb 2009 15:08:13 -0800
David Brownell <david-b@xxxxxxxxxxx> wrote:

> +static void nand_write_page_raw_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
> + const uint8_t *buf)
> +{
> + int eccsize = chip->ecc.size;
> + int eccbytes = chip->ecc.bytes;
> + uint8_t *oob = chip->oob_poi;
> + int temp;

Please don't create variables called "temp" or "tmp".

> + temp = chip->ecc.steps;
> + do {
> + chip->write_buf(mtd, buf, eccsize);
> + buf += eccsize;
> +
> + if (chip->ecc.prepad) {
> + chip->write_buf(mtd, oob, chip->ecc.prepad);
> + oob += chip->ecc.prepad;
> + }
> +
> + chip->read_buf(mtd, oob, eccbytes);
> + oob += eccbytes;
> +
> + if (chip->ecc.postpad) {
> + chip->write_buf(mtd, oob, chip->ecc.postpad);
> + oob += chip->ecc.postpad;
> + }
> + } while (--temp);

It would be clearer to code this as a plain old up-counting for loop.

> + temp = mtd->oobsize - (oob - chip->oob_poi);
> + if (temp)
> + chip->write_buf(mtd, oob, temp);

Here the same woefully-named variable appears to be reemployed for some
semantically quite different purpose.

> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/