/* mcs7830_phy_emit_wait() - emit PHY read/write access, wait for its execution @udev: network device to talk to @rwflag: PHY_CMD1_READ or PHY_CMD1_WRITE opcode @index: number of the PHY register to read or write Return: zero upon success, negative upon error  */
static int mcs7830_phy_emit_wait(struct usb_device *udev, uint8_t rwflag, uint8_t index)
/* mcs7830_phy_emit_wait() - emit PHY read/write access, wait for its execution @udev: network device to talk to @rwflag: PHY_CMD1_READ or PHY_CMD1_WRITE opcode @index: number of the PHY register to read or write Return: zero upon success, negative upon error  */
static int mcs7830_phy_emit_wait(struct usb_device *udev, uint8_t rwflag, uint8_t index)
{
	int rc;
	int retry;
	uint8_t cmd[2];
	cmd[0] = rwflag | PHY_CMD1_PHYADDR;
	cmd[1] = PHY_CMD2_PEND | (index & 0x1f);
	rc = mcs7830_write_reg(udev, REG_PHY_CMD, sizeof(cmd), cmd);
	if (rc < 0)
		return rc;
	retry = 10;
	do {
		rc = mcs7830_read_reg(udev, REG_PHY_CMD, sizeof(cmd), cmd);
		if (rc < 0)
			return rc;
		if (cmd[1] & PHY_CMD2_READY)
			return 0;
		if (!retry--)
			return -ETIMEDOUT;
		mdelay(1);
	} while (1);
}