/* Returns 0 for success or negative error code otherwise  */
int nand_reset(struct nand_chip *chip, int chipnr)
/* Returns 0 for success or negative error code otherwise  */
int nand_reset(struct nand_chip *chip, int chipnr)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	int ret;
	ret = nand_reset_data_interface(chip, chipnr);
	if (ret)
		return ret;
	chip->select_chip(mtd, chipnr);
	ret = nand_reset_op(chip);
	chip->select_chip(mtd, -1);
	if (ret)
		return ret;
	chip->select_chip(mtd, chipnr);
	ret = nand_setup_data_interface(chip, chipnr);
	chip->select_chip(mtd, -1);
	if (ret)
		return ret;
	return 0;
}