/* Poll the DataFlash device until it is READY. This usually takes 5-20 msec or so; more for sector erase. ready: return > 0  */
static int dataflash_waitready(struct spi_slave *spi)
/* Poll the DataFlash device until it is READY. This usually takes 5-20 msec or so; more for sector erase. ready: return > 0  */
static int dataflash_waitready(struct spi_slave *spi)
{
	int status;
	int timeout = 2 * CONFIG_SYS_HZ;
	int timebase;
	timebase = get_timer(0);
	do {
		status = dataflash_status(spi);
		if (status < 0)
			status = 0;
		if (status & (1 << 7))
			return status;
		mdelay(3);
	} while (get_timer(timebase) < timeout);
	return -ETIME;
}