/* Perform a single write to an MII 16bit register. Returns zero on success or -ETIMEDOUT if the PHY did not respond.  */
static int velocity_mii_write(struct mac_regs __iomem *regs, u8 mii_addr, u16 data)
/* Perform a single write to an MII 16bit register. Returns zero on success or -ETIMEDOUT if the PHY did not respond.  */
static int velocity_mii_write(struct mac_regs __iomem *regs, u8 mii_addr, u16 data)
{
	u16 ww;
	safe_disable_mii_autopoll(regs);
	writeb(mii_addr, &regs->MIIADR);
	writew(data, &regs->MIIDATA);
	BYTE_REG_BITS_ON(MIICR_WCMD, &regs->MIICR);
	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
		udelay(5);
		if (!(readb(&regs->MIICR) & MIICR_WCMD))
			break;
	}
	enable_mii_autopoll(regs);
	if (ww == W_MAX_TIMEOUT)
		return -ETIMEDOUT;
	return 0;
}