/* NAND write with ECC. Used when performing writes in interrupt context, this may for example be called by mtdoops when writing an oops while in panic.  */
static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf)
/* NAND write with ECC. Used when performing writes in interrupt context, this may for example be called by mtdoops when writing an oops while in panic.  */
static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf)
{
	struct nand_chip *chip = mtd->priv;
	int ret;
	if ((to + len) > mtd->size)
		return -EINVAL;
	if (!len)
		return 0;
	panic_nand_wait(mtd, chip, 400);
	panic_nand_get_device(chip, mtd, FL_WRITING);
	chip->ops.len = len;
	chip->ops.datbuf = (uint8_t *)buf;
	chip->ops.oobbuf = NULL;
	ret = nand_do_write_ops(mtd, to, &chip->ops);
	*retlen = chip->ops.retlen;
	return ret;
}