]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/dsa/slave.c
net: dsa: call phy_init_eee in DSA layer
[linux.git] / net / dsa / slave.c
index 9507bd38cf0441578de213178e23a692d8aed072..ad5caaf384d79671f509437ae43f6be2954bca93 100644 (file)
@@ -648,6 +648,10 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
        struct dsa_switch *ds = p->dp->ds;
        int ret;
 
+       /* Port's PHY and MAC both need to be EEE capable */
+       if (!p->phy)
+               return -ENODEV;
+
        if (!ds->ops->set_eee)
                return -EOPNOTSUPP;
 
@@ -655,10 +659,13 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
        if (ret)
                return ret;
 
-       if (p->phy)
-               ret = phy_ethtool_set_eee(p->phy, e);
+       if (e->eee_enabled) {
+               ret = phy_init_eee(p->phy, 0);
+               if (ret)
+                       return ret;
+       }
 
-       return ret;
+       return phy_ethtool_set_eee(p->phy, e);
 }
 
 static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
@@ -667,6 +674,10 @@ static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
        struct dsa_switch *ds = p->dp->ds;
        int ret;
 
+       /* Port's PHY and MAC both need to be EEE capable */
+       if (!p->phy)
+               return -ENODEV;
+
        if (!ds->ops->get_eee)
                return -EOPNOTSUPP;
 
@@ -674,10 +685,7 @@ static int dsa_slave_get_eee(struct net_device *dev, struct ethtool_eee *e)
        if (ret)
                return ret;
 
-       if (p->phy)
-               ret = phy_ethtool_get_eee(p->phy, e);
-
-       return ret;
+       return phy_ethtool_get_eee(p->phy, e);
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER