linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Grundler <grundler@chromium.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Allan Chou <allan@asix.com.tw>, Freddy Xin <freddy@asix.com.tw>,
	Grant Grundler <grundler@chromium.org>
Subject: [PATCH 2/5] net-next:asix: poll in asix_get_phyid in case phy not ready
Date: Mon, 14 Nov 2011 15:21:58 -0800	[thread overview]
Message-ID: <1321312921-7748-2-git-send-email-grundler@chromium.org> (raw)
In-Reply-To: <1321312921-7748-1-git-send-email-grundler@chromium.org>

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>
---
 drivers/net/usb/asix.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

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;
-- 
1.7.3.1


  reply	other threads:[~2011-11-14 23:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14 23:21 [PATCH 1/5] net-next:asix: PHY_MODE_RTL8211CL should be 0xC Grant Grundler
2011-11-14 23:21 ` Grant Grundler [this message]
2011-11-14 23:21 ` [PATCH 3/5] net-next:asix: reduce AX88772 init time by about 2 seconds Grant Grundler
2011-11-14 23:22 ` [PATCH 4/5] net-next:asix: more fixes for ax88178 phy init sequence Grant Grundler
2011-11-14 23:22 ` [PATCH 5/5] net-next:asix: update VERSION and white space changes Grant Grundler
2011-11-14 23:42   ` David Miller
2011-11-15  0:39     ` Grant Grundler
2011-11-15  0:54     ` Grant Grundler
2011-11-15  2:32       ` David Miller
2011-11-15  2:41         ` David Miller
2011-11-15  2:45           ` David Miller
2011-11-15 15:19             ` Mark Lord
2011-11-15 21:41               ` David Miller
2011-11-15 15:58             ` Grant Grundler
2011-11-15 17:12 [PATCH 1/5] net-next:asix:PHY_MODE_RTL8211CL should be 0xC Grant Grundler
2011-11-15 17:12 ` [PATCH 2/5] net-next:asix:poll in asix_get_phyid in case phy not ready Grant Grundler
2011-11-15 21:41   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321312921-7748-2-git-send-email-grundler@chromium.org \
    --to=grundler@chromium.org \
    --cc=allan@asix.com.tw \
    --cc=davem@davemloft.net \
    --cc=freddy@asix.com.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).