/* Returns 0 for success or negative error code otherwise.  */
static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
/* Returns 0 for success or negative error code otherwise.  */
static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
{
	struct mtd_info *mtd = nand_to_mtd(chip);
	int ret;
	if (!chip->setup_data_interface || !chip->data_interface)
		return 0;
	if (chip->onfi_version) {
		u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
			chip->onfi_timing_mode_default,
		};
		ret = chip->onfi_set_features(mtd, chip,
				ONFI_FEATURE_ADDR_TIMING_MODE,
				tmode_param);
		if (ret)
			goto err;
	}
	ret = chip->setup_data_interface(mtd, chipnr, chip->data_interface);
err:
	return ret;
}