netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: netdev@vger.kernel.org
Subject: Doubts about the get_phy_id function.
Date: Wed, 29 Oct 2008 10:12:22 +0100	[thread overview]
Message-ID: <490828F6.4000307@st.com> (raw)

Hi All,
Using a bad PHY address, the physical device is erroneously attached to 
the MAC device driver.
This happens because the get_phy_id function reads zero from the 
PHYIR1/2 regs and never fails.
I'm facing this problem on some PHY devices (*) but I've not clear 
enough if this can actually depend on an HW issue (e.g.invalid  phy 
addresses have been left floating) or we need to apply the patch below. 
Indeed, it helps me to catch the problem and, as final result, the 
phy_connect always fails on wrong PHY address and the network interface 
cannot be opened.

(*) on other ones, the get_phy_id function reads 0xffff from PHYIR1/2 
regs and fails (as expected results) when I try to attach a wrong PHY 
address.

Welcome advice.
Best Regards,
Peppe

PS: if it makes sense for you, I can rework the patch and send it to the 
ML again.

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8ad602c..8a1baf9 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -192,7 +192,7 @@ int get_phy_id(struct mii_bus *bus, int addr, u32 
*phy_id)
         * in the upper half */
        phy_reg = bus->read(bus, addr, MII_PHYSID1);
 
-       if (phy_reg < 0)
+       if (phy_reg <= 0)
                return -EIO;
 
        *phy_id = (phy_reg & 0xffff) << 16;
@@ -200,7 +200,7 @@ int get_phy_id(struct mii_bus *bus, int addr, u32 
*phy_id)
        /* Grab the bits from PHYIR2, and put them in the lower half */
        phy_reg = bus->read(bus, addr, MII_PHYSID2);
 
-       if (phy_reg < 0)
+       if (phy_reg <= 0)
                return -EIO;
 
        *phy_id |= (phy_reg & 0xffff);

             reply	other threads:[~2008-10-29  9:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-29  9:12 Giuseppe CAVALLARO [this message]
2008-11-03 20:24 ` Doubts about the get_phy_id function Andy Fleming

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=490828F6.4000307@st.com \
    --to=peppe.cavallaro@st.com \
    --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).