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

Andrew Morton akpm at linux-foundation.org
Thu Feb 26 15:25:43 EST 2009


On Tue, 24 Feb 2009 15:08:13 -0800
David Brownell <david-b at pacbell.net> 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.

> +}



More information about the linux-mtd mailing list