/* zynq_nand_write_page_swecc -  software ecc based page write function @mtd: mtd info structure @chip: nand chip info structure @buf: data buffer @oob_required: must write chip->oob_poi to OOB  */
static int zynq_nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, const u8 *buf, int oob_required, int page)
/* zynq_nand_write_page_swecc -  software ecc based page write function @mtd: mtd info structure @chip: nand chip info structure @buf: data buffer @oob_required: must write chip->oob_poi to OOB  */
static int zynq_nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, const u8 *buf, int oob_required, int page)
{
	int i, eccsize = chip->ecc.size;
	int eccbytes = chip->ecc.bytes;
	int eccsteps = chip->ecc.steps;
	u8 *ecc_calc = chip->buffers->ecccalc;
	const u8 *p = buf;
	u32 *eccpos = chip->ecc.layout->eccpos;
	for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize)
		chip->ecc.calculate(mtd, p, &ecc_calc[i]);
	for (i = 0; i < chip->ecc.total; i++)
		chip->oob_poi[eccpos[i]] = ecc_calc[i];
	return chip->ecc.write_page_raw(mtd, chip, buf, 1, page);
}