net: stmmac: use SPEED_UNKNOWN/DUPLEX_UNKNOWN
authorLABBE Corentin <clabbe.montjoie@gmail.com>
Wed, 15 Feb 2017 09:46:40 +0000 (10:46 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Feb 2017 18:20:54 +0000 (13:20 -0500)
It is better to use DUPLEX_UNKNOWN instead of just "-1".
Using 0 for an invalid speed is bad since 0 is a valid value for speed.
So this patch replace 0 by SPEED_UNKNOWN.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Reviewed-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 511c47cf6aad589dfa744834fb9f1fd1f99c1d59..a87071d0ebfedcef4c925864e8ca80cdcd7a2c0b 100644 (file)
@@ -754,8 +754,8 @@ static void stmmac_adjust_link(struct net_device *dev)
        } else if (priv->oldlink) {
                new_state = 1;
                priv->oldlink = 0;
-               priv->speed = 0;
-               priv->oldduplex = -1;
+               priv->speed = SPEED_UNKNOWN;
+               priv->oldduplex = DUPLEX_UNKNOWN;
        }
 
        if (new_state && netif_msg_link(priv))
@@ -817,8 +817,8 @@ static int stmmac_init_phy(struct net_device *dev)
        int interface = priv->plat->interface;
        int max_speed = priv->plat->max_speed;
        priv->oldlink = 0;
-       priv->speed = 0;
-       priv->oldduplex = -1;
+       priv->speed = SPEED_UNKNOWN;
+       priv->oldduplex = DUPLEX_UNKNOWN;
 
        if (priv->plat->phy_node) {
                phydev = of_phy_connect(dev, priv->plat->phy_node,
@@ -3434,8 +3434,8 @@ int stmmac_suspend(struct device *dev)
        spin_unlock_irqrestore(&priv->lock, flags);
 
        priv->oldlink = 0;
-       priv->speed = 0;
-       priv->oldduplex = -1;
+       priv->speed = SPEED_UNKNOWN;
+       priv->oldduplex = DUPLEX_UNKNOWN;
        return 0;
 }
 EXPORT_SYMBOL_GPL(stmmac_suspend);