/* Wait until an operation is completed by checking a bit in a register up to @attempts times. Returns %0 if the operation completes and %1 otherwise.  */
static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity, int attempts, int delay)
/* Wait until an operation is completed by checking a bit in a register up to @attempts times. Returns %0 if the operation completes and %1 otherwise.  */
static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity, int attempts, int delay)
{
	while (1) {
		u32 val = readl(adapter->regs + reg) & mask;
		if (!!val == polarity)
			return 0;
		if (--attempts == 0)
			return 1;
		if (delay)
			udelay(delay);
	}
}