[PATCH] [MTD] NAND: Wrong calculation of page number in nand_block_bad()

Thomas Gleixner tglx at linutronix.de
Fri Apr 27 13:03:51 EDT 2007


On Fri, 2007-04-27 at 13:19 +0200, Knobloch, Thomas wrote:
> In case that there is no memory based bad block table available the
> function nand_block_checkbad() in drivers/mtd/nand/nand_base.c will call
> nand_block_bad() directly. When parameter 'getchip' is set to zero,
> nand_block_bad() will not right shift the offset to calculate the
> correct page number.
> 
> Signed-off-by: Thomas Knobloch <knobloch at siemens.com>
>
> diff -uNr a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> --- a/drivers/mtd/nand/nand_base.c	2007-04-27 12:44:23.345198284
> +0200
> +++ b/drivers/mtd/nand/nand_base.c	2007-04-27 12:46:57.916226928
> +0200
> @@ -312,7 +312,7 @@
>  		/* Select the NAND device */
>  		chip->select_chip(mtd, chipnr);
>  	} else
> -		page = (int)ofs;
> +		page = (int)(ofs >> chip->page_shift);

Can you please make this outside the else path, so we can remove same
code in the if (getchip) path.

Please also apply the pagemask right there so we don't have it in both
cmdfunc() calls.

	tglx







More information about the linux-mtd mailing list