 if (bd->options == 0) { /* Memory-based BBT. We may read only needed bytes from the OOB area to * test if block is bad, no need to read the whole page content. */ scanlen	= ooblen = pagelen = 0; 
 if (!(bd->options & NAND_BBT_SCANEMPTY)) { /* We need only read few bytes from the OOB area */ scanlen = ooblen = 0; 
static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip){	struct nand_chip *this = mtd->priv;	int i, j, numblocks, len, scanlen, pagelen;	int startblock;	loff_t from;	size_t readlen, ooblen;	printk (KERN_INFO "Scanning device for bad blocks\n");	if (bd->options & NAND_BBT_SCANALLPAGES)		len = 1 << (this->bbt_erase_shift - this->page_shift);	else {		if (bd->options & NAND_BBT_SCAN2NDPAGE)			len = 2;		else				len = 1;	}		if (bd->options == 0) {		/* Memory-based BBT. We may read only needed bytes from the OOB area to		 * test if block is bad, no need to read the whole page content. */		scanlen	= ooblen = pagelen = 0;		readlen = bd->len;	} else {		scanlen	= mtd->oobblock + mtd->oobsize;		readlen = len * mtd->oobblock;		ooblen = len * mtd->oobsize;		pagelen = mtd->oobblock;	}	if (chip == -1) {		/* Note that numblocks is 2 * (real numblocks) here, see i+=2 below as it		 * makes shifting and masking less painful */		numblocks = mtd->size >> (this->bbt_erase_shift - 1);		startblock = 0;		from = 0;	} else {		if (chip >= this->numchips) {			printk (KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n",				chip + 1, this->numchips);			return -EINVAL;			}		numblocks = this->chipsize >> (this->bbt_erase_shift - 1);		startblock = chip * numblocks;		numblocks += startblock;		from = startblock << (this->bbt_erase_shift - 1);	}		for (i = startblock; i < numblocks;) {		int ret;				if (bd->options == 0) {			size_t retlen;			if ((ret = mtd->read_oob(mtd, from + bd->offs, bd->len, &retlen, &buf[bd->offs])))				return ret;		} else {			if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen)))				return ret;		}		for (j = 0; j < len; j++) {			if (check_pattern (&buf[j * scanlen], scanlen, pagelen, bd)) {				this->bbt[i >> 3] |= 0x03 << (i & 0x6);				printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 					i >> 1, (unsigned int) from);				break;			}		}		i += 2;		from += (1 << this->bbt_erase_shift);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/171650af9cd847964cf69b6bab9009631283293f/nand_bbt.c/buggy/drivers/mtd/nand/nand_bbt.c