/* wait_for_cmd_complete - waits for a command to complete. @sp : private member of the device structure, which is a pointer to the s2io_nic structure. Description: Function that waits for a command to Write into RMAC ADDR DATA registers to be completed and returns either success or error depending on whether the command was complete or not. Return value: SUCCESS on success and FAILURE on failure.  */
static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit, int bit_state)
/* wait_for_cmd_complete - waits for a command to complete. @sp : private member of the device structure, which is a pointer to the s2io_nic structure. Description: Function that waits for a command to Write into RMAC ADDR DATA registers to be completed and returns either success or error depending on whether the command was complete or not. Return value: SUCCESS on success and FAILURE on failure.  */
static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit, int bit_state)
{
	int ret = FAILURE, cnt = 0, delay = 1;
	u64 val64;
	if ((bit_state != S2IO_BIT_RESET) && (bit_state != S2IO_BIT_SET))
		return FAILURE;
	do {
		val64 = readq(addr);
		if (bit_state == S2IO_BIT_RESET) {
			if (!(val64 & busy_bit)) {
				ret = SUCCESS;
				break;
			}
		} else {
			if (val64 & busy_bit) {
				ret = SUCCESS;
				break;
			}
		}
		if (in_interrupt())
			mdelay(delay);
		else
			msleep(delay);
		if (++cnt >= 10)
			delay = 50;
	} while (cnt < 20);
	return ret;
}