/* Verify a page of NAND flash, including the OOB. Reads page of NAND and verifies the contents and OOB against the values in ops. */
int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops, loff_t ofs)
/* Verify a page of NAND flash, including the OOB. Reads page of NAND and verifies the contents and OOB against the values in ops. */
int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops, loff_t ofs)
{
	int rval;
	struct mtd_oob_ops vops;
	size_t verlen = mtd->writesize + mtd->oobsize;
	memcpy(&vops, ops, sizeof(vops));
	vops.datbuf = memalign(ARCH_DMA_MINALIGN, verlen);
	if (!vops.datbuf)
		return -ENOMEM;
	vops.oobbuf = vops.datbuf + mtd->writesize;
	rval = mtd_read_oob(mtd, ofs, &vops);
	if (!rval)
		rval = memcmp(ops->datbuf, vops.datbuf, vops.len);
	if (!rval)
		rval = memcmp(ops->oobbuf, vops.oobbuf, vops.ooblen);
	free(vops.datbuf);
	return rval ? -EIO : 0;
}