/* This routine checks for WIP(write in progress)bit in Status register(SMSR-b0) The routine checks for #timeout loops, each at interval of 1 milli-second. If successful the routine returns 0.  */
static int smi_wait_till_ready(int bank, int timeout)
/* This routine checks for WIP(write in progress)bit in Status register(SMSR-b0) The routine checks for #timeout loops, each at interval of 1 milli-second. If successful the routine returns 0.  */
static int smi_wait_till_ready(int bank, int timeout)
{
	int count;
	unsigned int sr;
	for (count = 0; count < timeout; count++) {
		sr = smi_read_sr(bank);
		if (sr < 0)
			break;
		else if (!(sr & WIP_BIT))
			return 0;
		udelay(1000);
	}
	printf("SMI controller is still in wait, timeout=%d\n", timeout);
	return -EIO;
}