[PATCH v2 2/2] mtd/nand: More BB Detection, dynamic scan options

Brian Norris norris at broadcom.com
Tue Jul 13 19:56:58 EDT 2010


I have a few comments/questions about the following sections.

On 07/13/2010 03:13 PM, Brian Norris wrote:
> Added new flag for scanning of both bytes 1 and 6 of the OOB for
> a BB marker (instead of simply one or the other).

<snip>

> diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
> index ec1700e..474ff66 100644
> --- a/drivers/mtd/nand/nand_bbt.c
> +++ b/drivers/mtd/nand/nand_bbt.c

<snip>

> @@ -447,6 +445,24 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
>   		if (ret<  0)
>   			return ret;
>
> +		/* Check if we need a second scan for the 6th byte
> +		 * Perhaps there is a more efficient way of doing this?
> +		 */
> +		if (!ret&&  bd->options&  NAND_BBT_SCANBYTE1AND6) {
> +			bd->offs = NAND_SMALL_BADBLOCK_POS;
> +			if (bd->options&  NAND_BBT_SCANALLPAGES)
> +				ret = scan_block_full(mtd, bd, from, buf,
> +						readlen, scanlen, len);
> +			else
> +				ret = scan_block_fast(mtd, bd, from, buf, len);
> +
> +			/* Reset offset for future scans */
> +			bd->offs = NAND_LARGE_BADBLOCK_POS;
> +
> +			if (ret<  0)
> +				return ret;
> +		}
> +
>   		if (ret) {
>   			this->bbt[i>>  3] |= 0x03<<  (i&  0x6);
>   			printk(KERN_WARNING "Bad eraseblock %d at 0x%012llx\n",

I realize it's probably not the best practice to just duplicate/modify 
the detection code as I did above. I am trying to find the best place to 
implement the scanning of both bytes 1 and 6 of the OOB. Perhaps 
nand_bbt.c:check_pattern() and check_short_pattern()?

Also, it seems to me that in addition to the main scanning routines, I 
should update the nand_default_block_markbad() function in nand_base.c 
so that it writes its BB marker to the proper bytes in the OOB. Does 
this sound reasonable?

Comments/corrections are appreciated!

Brian




More information about the linux-mtd mailing list