From: Florian Fainelli <florian@openwrt.org>
To: "Fleming Andy-AFLEMING" <afleming@freescale.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>
Subject: Re: mii_bus->read return checking in phy_device.c
Date: Mon, 7 Mar 2011 10:43:56 +0100 [thread overview]
Message-ID: <201103071043.57023.florian@openwrt.org> (raw)
In-Reply-To: <BB72AC9C-654E-43CE-9361-255767DCFC31@freescale.com>
On Friday 04 March 2011 19:19:10 Fleming Andy-AFLEMING wrote:
> On Mar 4, 2011, at 12:10, "Florian Fainelli" <florian@openwrt.org> wrote:
> > On Friday 04 March 2011 19:06:20 Fleming Andy-AFLEMING wrote:
> >> On Mar 4, 2011, at 11:24, "Florian Fainelli" <florian@openwrt.org> wrote:
> >>> Hello Andy,
> >>>
> >>> While debugging a PHY probing issue with the au1000_eth, I stumbled
> >>> upon this
> >>>
> >>> in drivers/net/phy/phy_device.c:
> >>> phy_reg = bus->read(bus, addr, MII_PHYSID1);
> >>>
> >>> if (phy_reg < 0)
> >>>
> >>> return -EIO;
> >>>
> >>> most drivers implement phylib's mdio_read callback by simply returning
> >>> the contents of their MDIO register after a readl, ioread ... which is
> >>> unsigned. Would not it rather make sense to check for phy_reg <= 0
> >>> instead?
> >>
> >> That isn't a check for a non-existent PHY. PHY registers are unsigned
> >> 16-bit quantities. The negative 32-bit return value would be the result
> >> of something going wrong in the bus transaction.
> >
> > Ok, but 0 is not an acceptable value either for both ID1 and ID2.
>
> I don't remember the exact details, but i recall we had a discussion about
> this several years ago, and decided that 0 should not be interpreted as a
> non-existent PHY. I know I have a part that has an internal PHY which
> doesnt have anything in the ID registers. If your driver is aware that it
> did not get a response from the PHY, it should return 0xffff. Otherwise,
> you can return 0, and just be aware that the PHY subsystem will believe
> there's a PHY there.
Allright, thanks for the clarification, I have sorted this in platform code
registering the particular ethernet driver.
--
Florian
prev parent reply other threads:[~2011-03-07 9:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-04 17:25 mii_bus->read return checking in phy_device.c Florian Fainelli
2011-03-04 18:06 ` Fleming Andy-AFLEMING
2011-03-04 18:12 ` Florian Fainelli
2011-03-04 18:19 ` Fleming Andy-AFLEMING
2011-03-07 9:43 ` Florian Fainelli [this message]
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=201103071043.57023.florian@openwrt.org \
--to=florian@openwrt.org \
--cc=afleming@freescale.com \
--cc=davem@davemloft.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.