u_char	ecc_code[oobsel->eccbytes]; 
u_char	ecc_code[32]; 
static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, 	u_char *oob_buf,  struct nand_oobinfo *oobsel, int cached){	int 	i, status;	u_char	ecc_code[oobsel->eccbytes];	int	eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;	int  	*oob_config = oobsel->eccpos;	int	datidx = 0, eccidx = 0, eccsteps = this->eccsteps;	int	eccbytes = 0;		/* FIXME: Enable cached programming */	cached = 0;		/* Send command to begin auto page programming */	this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page);	/* Write out complete page of data, take care of eccmode */	switch (eccmode) {	/* No ecc, write all */	case NAND_ECC_NONE:		printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");		this->write_buf(mtd, this->data_poi, mtd->oobblock);		break;			/* Software ecc 3/256, write all */	case NAND_ECC_SOFT:		for (; eccsteps; eccsteps--) {			this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code);			for (i = 0; i < 3; i++, eccidx++)				oob_buf[oob_config[eccidx]] = ecc_code[i];			datidx += this->eccsize;		}		this->write_buf(mtd, this->data_poi, mtd->oobblock);		break;	default:		eccbytes = this->eccbytes;		for (; eccsteps; eccsteps--) {			/* enable hardware ecc logic for write */			this->enable_hwecc(mtd, NAND_ECC_WRITE);			this->write_buf(mtd, &this->data_poi[datidx], this->eccsize);			this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code);			for (i = 0; i < eccbytes; i++, eccidx++)				oob_buf[oob_config[eccidx]] = ecc_code[i];			/* If the hardware ecc provides syndromes then			 * the ecc code must be written immidiately after			 * the data bytes (words) */			if (this->options & NAND_HWECC_SYNDROME)				this->write_buf(mtd, ecc_code, eccbytes);			datidx += this->eccsize;		}		break;	}											/* Write out OOB data */	if (this->options & NAND_HWECC_SYNDROME)		this->write_buf(mtd, &oob_buf[oobsel->eccbytes], mtd->oobsize - oobsel->eccbytes);	else 		this->write_buf(mtd, oob_buf, mtd->oobsize);	/* Send command to actually program the data */	this->cmdfunc (mtd, cached ? NAND_CMD_CACHEDPROG : NAND_CMD_PAGEPROG, -1, -1);	if (!cached) {		/* call wait ready function */		status = this->waitfunc (mtd, this, FL_WRITING);		/* See if operation failed and additional status checks are available */		if ((status & NAND_STATUS_FAIL) && (this->errstat)) {			status = this->errstat(mtd, this, FL_WRITING, status, page);		}		/* See if device thinks it succeeded */		if (status & NAND_STATUS_FAIL) {			DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page);			return -EIO;		}	} else {		/* FIXME: Implement cached programming ! */		/* wait until cache is ready*/		// status = this->waitfunc (mtd, this, FL_CACHEDRPG);	}	return 0;	}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/0a18cde60f384d1f7aa012aba004766fb633a31d/nand_base.c/buggy/drivers/mtd/nand/nand_base.c