net: dsa: call phy_init_eee in DSA layer
All DSA drivers are calling phy_init_eee if eee_enabled is true. Move up this statement in the DSA layer to simplify the DSA drivers. qca8k does not require to cache the ethtool_eee structures from now on. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7f5c6d7cdd
commit
c48f7eb302
|
@ -360,14 +360,7 @@ static int bcm_sf2_sw_set_eee(struct dsa_switch *ds, int port,
|
||||||
struct ethtool_eee *p = &priv->port_sts[port].eee;
|
struct ethtool_eee *p = &priv->port_sts[port].eee;
|
||||||
|
|
||||||
p->eee_enabled = e->eee_enabled;
|
p->eee_enabled = e->eee_enabled;
|
||||||
|
bcm_sf2_eee_enable_set(ds, port, e->eee_enabled);
|
||||||
if (!p->eee_enabled) {
|
|
||||||
bcm_sf2_eee_enable_set(ds, port, false);
|
|
||||||
} else {
|
|
||||||
p->eee_enabled = bcm_sf2_eee_init(ds, port, phydev);
|
|
||||||
if (!p->eee_enabled)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -855,12 +855,6 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
|
||||||
struct mv88e6xxx_chip *chip = ds->priv;
|
struct mv88e6xxx_chip *chip = ds->priv;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (e->eee_enabled) {
|
|
||||||
err = phy_init_eee(phydev, 0);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&chip->reg_lock);
|
mutex_lock(&chip->reg_lock);
|
||||||
err = mv88e6xxx_energy_detect_write(chip, port, e);
|
err = mv88e6xxx_energy_detect_write(chip, port, e);
|
||||||
mutex_unlock(&chip->reg_lock);
|
mutex_unlock(&chip->reg_lock);
|
||||||
|
|
|
@ -654,41 +654,14 @@ qca8k_eee_enable_set(struct dsa_switch *ds, int port, bool enable)
|
||||||
mutex_unlock(&priv->reg_mutex);
|
mutex_unlock(&priv->reg_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
qca8k_eee_init(struct dsa_switch *ds, int port,
|
|
||||||
struct phy_device *phy)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = phy_init_eee(phy, 0);
|
|
||||||
if (ret)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
qca8k_eee_enable_set(ds, port, true);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qca8k_set_eee(struct dsa_switch *ds, int port,
|
qca8k_set_eee(struct dsa_switch *ds, int port,
|
||||||
struct phy_device *phydev,
|
struct phy_device *phydev,
|
||||||
struct ethtool_eee *e)
|
struct ethtool_eee *e)
|
||||||
{
|
{
|
||||||
struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
|
qca8k_eee_enable_set(ds, port, e->eee_enabled);
|
||||||
struct ethtool_eee *p = &priv->port_sts[port].eee;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
p->eee_enabled = e->eee_enabled;
|
return 0;
|
||||||
|
|
||||||
if (!p->eee_enabled) {
|
|
||||||
qca8k_eee_enable_set(ds, port, false);
|
|
||||||
} else {
|
|
||||||
p->eee_enabled = qca8k_eee_init(ds, port, phydev);
|
|
||||||
if (!p->eee_enabled)
|
|
||||||
ret = -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -156,7 +156,6 @@ enum qca8k_fdb_cmd {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ar8xxx_port_status {
|
struct ar8xxx_port_status {
|
||||||
struct ethtool_eee eee;
|
|
||||||
int enabled;
|
int enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -659,6 +659,12 @@ static int dsa_slave_set_eee(struct net_device *dev, struct ethtool_eee *e)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (e->eee_enabled) {
|
||||||
|
ret = phy_init_eee(p->phy, 0);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return phy_ethtool_set_eee(p->phy, e);
|
return phy_ethtool_set_eee(p->phy, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue