/* Write buf to the FCM Controller Data Buffer  */
static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
/* Write buf to the FCM Controller Data Buffer  */
static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
{
	struct nand_chip *chip = mtd->priv;
	struct fsl_elbc_mtd *priv = chip->priv;
	struct fsl_elbc_ctrl *ctrl = priv->ctrl;
	unsigned int bufsize = mtd->writesize + mtd->oobsize;
	if (len <= 0) {
		printf("write_buf of %d bytes", len);
		ctrl->status = 0;
		return;
	}
	if ((unsigned int)len > bufsize - ctrl->index) {
		printf("write_buf beyond end of buffer "
		       "(%d requested, %u available)\n",
		       len, bufsize - ctrl->index);
		len = bufsize - ctrl->index;
	}
	memcpy_toio(&ctrl->addr[ctrl->index], buf, len);
	in_8(&ctrl->addr[ctrl->index] + len - 1);
	ctrl->index += len;
}