net phy: Check for aneg completion before setting state to PHY_RUNNING
authorBalakumaran Kannan <kumaran.4353@gmail.com>
Thu, 24 Apr 2014 02:52:47 +0000 (08:22 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 May 2014 19:50:57 +0000 (15:50 -0400)
phy_state_machine should check whether auto-negotiatin is completed
before changing phydev->state from PHY_NOLINK to PHY_RUNNING. If
auto-negotiation is not completed phydev->state should be set to
PHY_AN.

Signed-off-by: Balakumaran Kannan <kumaran.4353@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy.c

index 1b6d09aef42748bcbba6d4fe88ca68d6ea83c852..a972056b22498c15596a88f6b348e0f066ddb85b 100644 (file)
@@ -765,6 +765,17 @@ void phy_state_machine(struct work_struct *work)
                        break;
 
                if (phydev->link) {
+                       if (AUTONEG_ENABLE == phydev->autoneg) {
+                               err = phy_aneg_done(phydev);
+                               if (err < 0)
+                                       break;
+
+                               if (!err) {
+                                       phydev->state = PHY_AN;
+                                       phydev->link_timeout = PHY_AN_TIMEOUT;
+                                       break;
+                               }
+                       }
                        phydev->state = PHY_RUNNING;
                        netif_carrier_on(phydev->attached_dev);
                        phydev->adjust_link(phydev->attached_dev);