From: Grant Grundler Date: Tue, 15 Nov 2011 07:12:40 +0000 (+0000) Subject: net-next:asix:poll in asix_get_phyid in case phy not ready X-Git-Tag: upstream/snapshot3+hdmi~8688^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a77929a278651d4451c872178d4d7aac8908aa8e;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git net-next:asix:poll in asix_get_phyid in case phy not ready Sometimes the phy isn't ready after reset...poll and pray it will be soon. Signed-off-by: Freddy Xin Signed-off-by: Grant Grundler Signed-off-by: David S. Miller --- diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index 873860d..b4675e8 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c @@ -652,9 +652,17 @@ static u32 asix_get_phyid(struct usbnet *dev) { int phy_reg; u32 phy_id; + int i; - phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); - if (phy_reg < 0) + /* Poll for the rare case the FW or phy isn't ready yet. */ + for (i = 0; i < 100; i++) { + phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); + if (phy_reg != 0 && phy_reg != 0xFFFF) + break; + mdelay(1); + } + + if (phy_reg <= 0 || phy_reg == 0xFFFF) return 0; phy_id = (phy_reg & 0xffff) << 16;