From: Madalin Bucur <madalin.bucur@freescale.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>
Cc: <afleming@freescale.com>, Madalin Bucur <madalin.bucur@freescale.com>
Subject: [PATCH 3/3] net/phy: abort genphy_read_status when link changes during speed and duplex reading
Date: Thu, 6 Oct 2011 19:48:57 +0300 [thread overview]
Message-ID: <1317919737-25893-1-git-send-email-madalin.bucur@freescale.com> (raw)
If the link changes during speed and duplex reading the values may be out of sync;
abort the update if the link state changes during the read
Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
---
drivers/net/phy/phy_device.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index a1e132c..e88f49a 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -824,6 +824,16 @@ int genphy_read_status(struct phy_device *phydev)
lpa &= adv;
+ err = phy_read(phydev, MII_BMSR);
+
+ if (err < 0)
+ return err;
+
+ /* if the link changed while reading speed and duplex
+ * abort the speed and duplex update */
+ if (((err & BMSR_LSTATUS) == 0) != (phydev->link == 0))
+ return 0;
+
phydev->speed = SPEED_10;
phydev->duplex = DUPLEX_HALF;
phydev->pause = phydev->asym_pause = 0;
--
1.7.0.1
reply other threads:[~2011-10-06 16:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1317919737-25893-1-git-send-email-madalin.bucur@freescale.com \
--to=madalin.bucur@freescale.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox