/* Read hardware ECC value and pack into three bytes  */
static int nand_davinci_calculate_1bit(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
/* Read hardware ECC value and pack into three bytes  */
static int nand_davinci_calculate_1bit(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
{
	unsigned int ecc_val = nand_davinci_readecc_1bit(mtd);
	unsigned int ecc24 = (ecc_val & 0x0fff) | ((ecc_val & 0x0fff0000) >> 4);
	ecc24 = ~ecc24;
	ecc_code[0] = (u_char)(ecc24);
	ecc_code[1] = (u_char)(ecc24 >> 8);
	ecc_code[2] = (u_char)(ecc24 >> 16);
	return 0;
}