/* Polls a register every delay_usec microseconds. Returns 0 when the mask bits have the value done. Returns -ETIMEDOUT if this condition is not true after wait_usec microseconds have passed.  */
static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait_usec, int delay_usec)
/* Polls a register every delay_usec microseconds. Returns 0 when the mask bits have the value done. Returns -ETIMEDOUT if this condition is not true after wait_usec microseconds have passed.  */
static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait_usec, int delay_usec)
{
	u32	result;
	do {
		result = readl(ptr);
		result &= mask;
		if (result == done)
			return 0;
		udelay(delay_usec);
		wait_usec -= delay_usec;
	} while (wait_usec > 0);
	return -ETIMEDOUT;
}