summaryrefslogtreecommitdiff
path: root/drivers/net/usb/asix.c
diff options
context:
space:
mode:
authorGrant Grundler <grundler@google.com>2011-11-15 11:12:40 +0400
committerDavid S. Miller <davem@davemloft.net>2011-11-16 01:26:06 +0400
commita77929a278651d4451c872178d4d7aac8908aa8e (patch)
treee80174550dcea0e16d6555cbd8c9097dfc15d6f2 /drivers/net/usb/asix.c
parent3486140e30fcc16c0b8cd9545fbe5e2e66bf6941 (diff)
downloadlinux-a77929a278651d4451c872178d4d7aac8908aa8e.tar.xz
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 <freddy@asix.com.tw> Signed-off-by: Grant Grundler <grundler@chromium.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/asix.c')
-rw-r--r--drivers/net/usb/asix.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 873860d46e9e..b4675e89e42c 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;