summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-08-01 16:32:31 -0400
committerDavid S. Miller <davem@davemloft.net>2017-08-01 20:09:09 -0700
commit7b9cc73843e89ea1ac215511c13c259a70d1b4f7 (patch)
tree16918a70db9b489ff179ac8418c5079361aa7e12 /net
parent13e6be2d22aea327c541c6784deba3db5ecfae8d (diff)
net: dsa: PHY device is mandatory for EEE
The port's PHY and MAC are both implied in EEE. The current code does not call the PHY operations if the related device is NULL. Change that by returning -ENODEV if there's no PHY device attached to the interface. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dsa/slave.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 9507bd38cf04..7df55d597740 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -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,7 @@ 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);
-
- 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 +668,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 +679,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