static int mcs7830_init_common(struct usb_device *udev) { int timeout; int have_link; debug("%s()\n", __func__); timeout = 0; do { have_link = mcs7830_read_phy(udev, MII_BMSR) & BMSR_LSTATUS; if (have_link) break; udelay(LINKSTATUS_TIMEOUT_RES * 1000); timeout += LINKSTATUS_TIMEOUT_RES; } while (timeout < LINKSTATUS_TIMEOUT); if (!have_link) { debug("ethernet link is down\n"); return -ETIMEDOUT; } return 0; }
/* * mcs7830_init() - network interface's init callback * @eth: network device to initialize * @bd: board information * Return: zero upon success, negative upon error * * after initial setup during probe() and get_info(), this init() callback * ensures that the link is up and subsequent send() and recv() calls can * exchange ethernet frames */ static int mcs7830_init(struct eth_device *eth, bd_t *bd) { struct ueth_data *dev; int timeout; int have_link; debug("%s()\n", __func__); dev = eth->priv; timeout = 0; do { have_link = mcs7830_read_phy(dev, MII_BMSR) & BMSR_LSTATUS; if (have_link) break; udelay(LINKSTATUS_TIMEOUT_RES * 1000); timeout += LINKSTATUS_TIMEOUT_RES; } while (timeout < LINKSTATUS_TIMEOUT); if (!have_link) { debug("ethernet link is down\n"); return -ETIMEDOUT; } return 0; }