/* Verify buffer against the FCM Controller Data Buffer  */
static int fsl_elbc_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
/* Verify buffer against the FCM Controller Data Buffer  */
static int fsl_elbc_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
{
	struct nand_chip *chip = mtd->priv;
	struct fsl_elbc_mtd *priv = chip->priv;
	struct fsl_elbc_ctrl *ctrl = priv->ctrl;
	int i;
	if (len < 0) {
		printf("write_buf of %d bytes", len);
		return -EINVAL;
	}
	if ((unsigned int)len > ctrl->read_bytes - ctrl->index) {
		printf("verify_buf beyond end of buffer "
		       "(%d requested, %u available)\n",
		       len, ctrl->read_bytes - ctrl->index);
		ctrl->index = ctrl->read_bytes;
		return -EINVAL;
	}
	for (i = 0; i < len; i++)
		if (in_8(&ctrl->addr[ctrl->index + i]) != buf[i])
			break;
	ctrl->index += len;
	return i == len && ctrl->status == LTESR_CC ? 0 : -EIO;
}