/* mtd: MTD block structure dat: raw data (unused) ecc_code: buffer for ECC  */
static int atmel_nand_calculate(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code)
/* mtd: MTD block structure dat: raw data (unused) ecc_code: buffer for ECC  */
static int atmel_nand_calculate(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code)
{
	struct nand_chip *nand_chip = mtd->priv;
	struct atmel_nand_host *host = nand_chip->priv;
	unsigned int ecc_value;
	ecc_value = ecc_readl(host->ecc, PR);
	ecc_code[0] = ecc_value & 0xFF;
	ecc_code[1] = (ecc_value >> 8) & 0xFF;
	ecc_value = ecc_readl(host->ecc, NPR) & ATMEL_ECC_NPARITY;
	ecc_code[2] = ecc_value & 0xFF;
	ecc_code[3] = (ecc_value >> 8) & 0xFF;
	return 0;
}