aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@gmail.com>2019-08-19 16:00:49 -0400
committerDavid S. Miller <davem@davemloft.net>2019-08-20 15:33:49 -0400
commit74be4babe72fd1ed1bba6b52d0bdc0d1e13f7af8 (patch)
tree1e0bf529fdcd8013cc0c88fcd214002e0587ca04
parent955222ca5281ee7ded6b899605c055b147a15c73 (diff)
net: dsa: do not enable or disable non user ports
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>
-rw-r--r--drivers/net/dsa/b53/b53_common.c7
-rw-r--r--drivers/net/dsa/bcm_sf2.c3
-rw-r--r--drivers/net/dsa/lan9303-core.c6
-rw-r--r--drivers/net/dsa/lantiq_gswip.c6
-rw-r--r--drivers/net/dsa/microchip/ksz_common.c6
-rw-r--r--drivers/net/dsa/mt7530.c6
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c6
7 files changed, 39 insertions, 1 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 907af62846ba..7d328a5f0161 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -510,10 +510,15 @@ EXPORT_SYMBOL(b53_imp_vlan_setup);
510int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) 510int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
511{ 511{
512 struct b53_device *dev = ds->priv; 512 struct b53_device *dev = ds->priv;
513 unsigned int cpu_port = ds->ports[port].cpu_dp->index; 513 unsigned int cpu_port;
514 int ret = 0; 514 int ret = 0;
515 u16 pvlan; 515 u16 pvlan;
516 516
517 if (!dsa_is_user_port(ds, port))
518 return 0;
519
520 cpu_port = ds->ports[port].cpu_dp->index;
521
517 if (dev->ops->irq_enable) 522 if (dev->ops->irq_enable)
518 ret = dev->ops->irq_enable(dev, port); 523 ret = dev->ops->irq_enable(dev, port);
519 if (ret) 524 if (ret)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 49f99436018a..4f839348011d 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -157,6 +157,9 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port,
157 unsigned int i; 157 unsigned int i;
158 u32 reg; 158 u32 reg;
159 159
160 if (!dsa_is_user_port(ds, port))
161 return 0;
162
160 /* Clear the memory power down */ 163 /* Clear the memory power down */
161 reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL); 164 reg = core_readl(priv, CORE_MEM_PSM_VDD_CTRL);
162 reg &= ~P_TXQ_PSM_VDD(port); 165 reg &= ~P_TXQ_PSM_VDD(port);
diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 7a2063e7737a..bbec86b9418e 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -1079,6 +1079,9 @@ static int lan9303_port_enable(struct dsa_switch *ds, int port,
1079{ 1079{
1080 struct lan9303 *chip = ds->priv; 1080 struct lan9303 *chip = ds->priv;
1081 1081
1082 if (!dsa_is_user_port(ds, port))
1083 return 0;
1084
1082 return lan9303_enable_processing_port(chip, port); 1085 return lan9303_enable_processing_port(chip, port);
1083} 1086}
1084 1087
@@ -1086,6 +1089,9 @@ static void lan9303_port_disable(struct dsa_switch *ds, int port)
1086{ 1089{
1087 struct lan9303 *chip = ds->priv; 1090 struct lan9303 *chip = ds->priv;
1088 1091
1092 if (!dsa_is_user_port(ds, port))
1093 return;
1094
1089 lan9303_disable_processing_port(chip, port); 1095 lan9303_disable_processing_port(chip, port);
1090 lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN); 1096 lan9303_phy_write(ds, chip->phy_addr_base + port, MII_BMCR, BMCR_PDOWN);
1091} 1097}
diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 2175ec13bb2c..a69c9b9878b7 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -642,6 +642,9 @@ static int gswip_port_enable(struct dsa_switch *ds, int port,
642 struct gswip_priv *priv = ds->priv; 642 struct gswip_priv *priv = ds->priv;
643 int err; 643 int err;
644 644
645 if (!dsa_is_user_port(ds, port))
646 return 0;
647
645 if (!dsa_is_cpu_port(ds, port)) { 648 if (!dsa_is_cpu_port(ds, port)) {
646 err = gswip_add_single_port_br(priv, port, true); 649 err = gswip_add_single_port_br(priv, port, true);
647 if (err) 650 if (err)
@@ -678,6 +681,9 @@ static void gswip_port_disable(struct dsa_switch *ds, int port)
678{ 681{
679 struct gswip_priv *priv = ds->priv; 682 struct gswip_priv *priv = ds->priv;
680 683
684 if (!dsa_is_user_port(ds, port))
685 return;
686
681 if (!dsa_is_cpu_port(ds, port)) { 687 if (!dsa_is_cpu_port(ds, port)) {
682 gswip_mdio_mask(priv, GSWIP_MDIO_PHY_LINK_DOWN, 688 gswip_mdio_mask(priv, GSWIP_MDIO_PHY_LINK_DOWN,
683 GSWIP_MDIO_PHY_LINK_MASK, 689 GSWIP_MDIO_PHY_LINK_MASK,
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index b45c7b972cec..b0b870f0c252 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -361,6 +361,9 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
361{ 361{
362 struct ksz_device *dev = ds->priv; 362 struct ksz_device *dev = ds->priv;
363 363
364 if (!dsa_is_user_port(ds, port))
365 return 0;
366
364 /* setup slave port */ 367 /* setup slave port */
365 dev->dev_ops->port_setup(dev, port, false); 368 dev->dev_ops->port_setup(dev, port, false);
366 if (dev->dev_ops->phy_setup) 369 if (dev->dev_ops->phy_setup)
@@ -378,6 +381,9 @@ void ksz_disable_port(struct dsa_switch *ds, int port)
378{ 381{
379 struct ksz_device *dev = ds->priv; 382 struct ksz_device *dev = ds->priv;
380 383
384 if (!dsa_is_user_port(ds, port))
385 return;
386
381 dev->on_ports &= ~(1 << port); 387 dev->on_ports &= ~(1 << port);
382 dev->live_ports &= ~(1 << port); 388 dev->live_ports &= ~(1 << port);
383 389
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 3181e95586d6..c48e29486b10 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -726,6 +726,9 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
726{ 726{
727 struct mt7530_priv *priv = ds->priv; 727 struct mt7530_priv *priv = ds->priv;
728 728
729 if (!dsa_is_user_port(ds, port))
730 return 0;
731
729 mutex_lock(&priv->reg_mutex); 732 mutex_lock(&priv->reg_mutex);
730 733
731 /* Setup the MAC for the user port */ 734 /* Setup the MAC for the user port */
@@ -751,6 +754,9 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
751{ 754{
752 struct mt7530_priv *priv = ds->priv; 755 struct mt7530_priv *priv = ds->priv;
753 756
757 if (!dsa_is_user_port(ds, port))
758 return;
759
754 mutex_lock(&priv->reg_mutex); 760 mutex_lock(&priv->reg_mutex);
755 761
756 /* Clear up all port matrix which could be restored in the next 762 /* Clear up all port matrix which could be restored in the next
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 9b3ad22a5b98..5e557545df6d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2267,6 +2267,9 @@ static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2267 struct mv88e6xxx_chip *chip = ds->priv; 2267 struct mv88e6xxx_chip *chip = ds->priv;
2268 int err; 2268 int err;
2269 2269
2270 if (!dsa_is_user_port(ds, port))
2271 return 0;
2272
2270 mv88e6xxx_reg_lock(chip); 2273 mv88e6xxx_reg_lock(chip);
2271 2274
2272 err = mv88e6xxx_serdes_power(chip, port, true); 2275 err = mv88e6xxx_serdes_power(chip, port, true);
@@ -2283,6 +2286,9 @@ static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
2283{ 2286{
2284 struct mv88e6xxx_chip *chip = ds->priv; 2287 struct mv88e6xxx_chip *chip = ds->priv;
2285 2288
2289 if (!dsa_is_user_port(ds, port))
2290 return;
2291
2286 mv88e6xxx_reg_lock(chip); 2292 mv88e6xxx_reg_lock(chip);
2287 2293
2288 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED)) 2294 if (mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED))