Skip to content

Commit

Permalink
net: dsa: do not enable or disable non user ports
Browse files Browse the repository at this point in the history
The .port_enable and .port_disable operations are currently only
called for user ports, hence assuming they have a slave device. In
preparation for using these operations for other port types as well,
simply guard all implementations against non user ports and return
directly in such case.

Note that bcm_sf2_sw_suspend() currently calls bcm_sf2_port_disable()
(and thus b53_disable_port()) against the user and CPU ports, so do
not guards those functions. They will be called for unused ports in
the future, but that was expected by those drivers anyway.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vivien Didelot authored and David S. Miller committed Aug 20, 2019
1 parent 955222c commit 74be4ba
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/net/dsa/b53/b53_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,15 @@ EXPORT_SYMBOL(b53_imp_vlan_setup);
int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
{
struct b53_device *dev = ds->priv;
unsigned int cpu_port = ds->ports[port].cpu_dp->index;
unsigned int cpu_port;
int ret = 0;
u16 pvlan;

if (!dsa_is_user_port(ds, port))
return 0;

cpu_port = ds->ports[port].cpu_dp->index;

if (dev->ops->irq_enable)
ret = dev->ops->irq_enable(dev, port);
if (ret)
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/dsa/bcm_sf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
unsigned int i;
u32 reg;

if (!dsa_is_user_port(ds, port))
return 0;

/* Clear the memory power down */
reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
reg &= ~P_TXQ_PSM_VDD(port);
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/dsa/lan9303-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,13 +1079,19 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
{
struct lan9303 *chip = ds->priv;

if (!dsa_is_user_port(ds, port))
return 0;

return lan9303_enable_processing_port(chip, port);
}

static void lan9303_port_disable(struct dsa_switch *ds, int port)
{
struct lan9303 *chip = ds->priv;

if (!dsa_is_user_port(ds, port))
return;

lan9303_disable_processing_port(chip, port);
lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN);
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/dsa/lantiq_gswip.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ static int gswip_port_enable(struct dsa_switch *ds, int port,
struct gswip_priv *priv = ds->priv;
int err;

if (!dsa_is_user_port(ds, port))
return 0;

if (!dsa_is_cpu_port(ds, port)) {
err = gswip_add_single_port_br(priv, port, true);
if (err)
Expand Down Expand Up @@ -678,6 +681,9 @@ static void gswip_port_disable(struct dsa_switch *ds, int port)
{
struct gswip_priv *priv = ds->priv;

if (!dsa_is_user_port(ds, port))
return;

if (!dsa_is_cpu_port(ds, port)) {
gswip_mdio_mask(priv, GSWIP_MDIO_PHY_LINK_DOWN,
GSWIP_MDIO_PHY_LINK_MASK,
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/dsa/microchip/ksz_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
{
struct ksz_device *dev = ds->priv;

if (!dsa_is_user_port(ds, port))
return 0;

/* setup slave port */
dev->dev_ops->port_setup(dev, port, false);
if (dev->dev_ops->phy_setup)
Expand All @@ -378,6 +381,9 @@ void ksz_disable_port(struct dsa_switch *ds, int port)
{
struct ksz_device *dev = ds->priv;

if (!dsa_is_user_port(ds, port))
return;

dev->on_ports &= ~(1 << port);
dev->live_ports &= ~(1 << port);

Expand Down
6 changes: 6 additions & 0 deletions drivers/net/dsa/mt7530.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
{
struct mt7530_priv *priv = ds->priv;

if (!dsa_is_user_port(ds, port))
return 0;

mutex_lock(&priv->reg_mutex);

/* Setup the MAC for the user port */
Expand All @@ -751,6 +754,9 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
{
struct mt7530_priv *priv = ds->priv;

if (!dsa_is_user_port(ds, port))
return;

mutex_lock(&priv->reg_mutex);

/* Clear up all port matrix which could be restored in the next
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,9 @@ static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
struct mv88e6xxx_chip *chip = ds->priv;
int err;

if (!dsa_is_user_port(ds, port))
return 0;

mv88e6xxx_reg_lock(chip);

err = mv88e6xxx_serdes_power(chip, port, true);
Expand All @@ -2283,6 +2286,9 @@ static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
{
struct mv88e6xxx_chip *chip = ds->priv;

if (!dsa_is_user_port(ds, port))
return;

mv88e6xxx_reg_lock(chip);

if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))
Expand Down

0 comments on commit 74be4ba

Please sign in to comment.