/* The controller does not check for bitflips in erased pages, therefore software must check instead.  */
static int check_erased_page(struct nand_chip *chip, u8 *buf, struct mtd_info *mtd)
/* The controller does not check for bitflips in erased pages, therefore software must check instead.  */
static int check_erased_page(struct nand_chip *chip, u8 *buf, struct mtd_info *mtd)
{
	u8 *ecc = chip->oob_poi;
	const int ecc_size = chip->ecc.bytes;
	const int pkt_size = chip->ecc.size;
	int i, res, bitflips;
	ecc += 8;
	bitflips = 0;
	for (i = 0; i < chip->ecc.steps; i++) {
		res = nand_check_erased_ecc_chunk(buf, pkt_size, ecc, ecc_size,
						  NULL, 0, chip->ecc.strength);
		if (res < 0) {
			printf("fsl-ifc: NAND Flash ECC Uncorrectable Error\n");
			mtd->ecc_stats.failed++;
		} else if (res > 0) {
			mtd->ecc_stats.corrected += res;
		}
		bitflips = max(res, bitflips);
		buf += pkt_size;
		ecc += ecc_size;
	}
	return bitflips;
}