unsigned char buffer[mtd->oobblock], *pbuf; 
unsigned char buffer[MAX_ONENAND_PAGESIZE], *pbuf; 
static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,	unsigned long count, loff_t to, size_t *retlen,	u_char *eccbuf, struct nand_oobinfo *oobsel){	struct onenand_chip *this = mtd->priv;	unsigned char buffer[mtd->oobblock], *pbuf;	size_t total_len, len;	int i, written = 0;	int ret = 0;	/* Preset written len for early exit */	*retlen = 0;	/* Calculate total length of data */	total_len = 0;	for (i = 0; i < count; i++)		total_len += vecs[i].iov_len;	DEBUG(MTD_DEBUG_LEVEL3, "onenand_writev_ecc: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);	/* Do not allow write past end of the device */	if (unlikely((to + total_len) > mtd->size)) {		DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempted write past end of device\n");		return -EINVAL;	}	/* Reject writes, which are not page aligned */        if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(total_len))) {                DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempt to write not page aligned data\n");                return -EINVAL;        }	/* Grab the lock and see if the device is available */	onenand_get_device(mtd, FL_WRITING);	/* TODO handling oob */		/* Loop until all keve's data has been written */	len = 0;	while (count) {		pbuf = buffer;		/* 		 * If the given tuple is >= pagesize then		 * write it out from the iov		 */		if ((vecs->iov_len - len) >= mtd->oobblock) {			pbuf = vecs->iov_base + len;			len += mtd->oobblock;			/* Check, if we have to switch to the next tuple */			if (len >= (int) vecs->iov_len) {				vecs++;				len = 0;				count--;			}		} else {			int cnt = 0, thislen;			while (cnt < mtd->oobblock) {				thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len);				memcpy(buffer + cnt, vecs->iov_base + len, thislen);				cnt += thislen;				len += thislen;				/* Check, if we have to switch to the next tuple */				if (len >= (int) vecs->iov_len) {					vecs++;					len = 0;					count--;				}			}		}		this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock);		this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->oobblock);		this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);		this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock);		onenand_update_bufferram(mtd, to, 1);		ret = this->wait(mtd, FL_WRITING);		if (ret) {			DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: write failed %d\n", ret);			goto out;		}		/* Only check verify write turn on */		ret = onenand_verify_page(mtd, (u_char *) pbuf, to, block, page);		if (ret) {			DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: verify failed %d\n", ret);			goto out;		}		written += mtd->oobblock;		to += mtd->oobblock;	}out:	/* Deselect and wakt up anyone waiting on the device */	onenand_release_device(mtd);	*retlen = written;	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/d36d63d404b75ddf231da0dbd3640e6d1722b4ab/onenand_base.c/clean/drivers/mtd/onenand/onenand_base.c