/* Returns 0 on success, a negative error code otherwise.  */
int nand_write_data_op(struct nand_chip *chip, const void *buf, unsigned int len, bool force_8bit)
/* Returns 0 on success, a negative error code otherwise.  */
int nand_write_data_op(struct nand_chip *chip, const void *buf, unsigned int len, bool force_8bit)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	if (!len || !buf)
		return -EINVAL;
	if (force_8bit) {
		const u8 *p = buf;
		unsigned int i;
		for (i = 0; i < len; i++)
			chip->write_byte(mtd, p[i]);
	} else {
		chip->write_buf(mtd, buf, len);
	}
	return 0;
}