/* Service routine to read status register until ready, or timeout occurs. Returns non-zero if error.  */
static int wait_till_ready(struct m25p_spifi *flash)
/* Service routine to read status register until ready, or timeout occurs. Returns non-zero if error.  */
static int wait_till_ready(struct m25p_spifi *flash)
{
	unsigned long deadline;
	int sr;
	deadline = jiffies + MAX_READY_WAIT_JIFFIES;
	do {
		if ((sr = read_sr(flash)) < 0)
			break;
		if (!(sr & SR_WIP))
			return 0;
		cond_resched();
	} while (!time_after_eq(jiffies, deadline));
	return 1;
}