[PATCH v2 6/6] realtek: remove redundant is_lagmember checks

Jan Hoffmann jan at 3e8.eu
Sat May 6 16:05:35 PDT 2023


All callers of the rtl83xx_mc_group_* functions already do the same
check, so these aren't needed.

For rtl83xx_mc_group_alloc, this branch also incorrectly returned 0
instead of a negative value. If the branch wasn't effectively dead code
anyway, this could potentially have caused bugs, as 0 is a valid
multicast group entry index.

Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast")
Signed-off-by: Jan Hoffmann <jan at 3e8.eu>
---
 .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c      | 15 ++-------------
 .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c      | 15 ++-------------
 2 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
index 7661ecd8f21a..5dd69c8d6541 100644
--- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
@@ -981,11 +981,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port)
 	if (mc_group >= MAX_MC_GROUPS - 1)
 		return -1;
 
-	if (priv->is_lagmember[port]) {
-		pr_info("%s: %d is lag slave. ignore\n", __func__, port);
-		return 0;
-	}
-
 	set_bit(mc_group, priv->mc_group_bm);
 	portmask = BIT_ULL(port);
 	priv->r->write_mcast_pmask(mc_group, portmask);
@@ -998,10 +993,7 @@ static u64 rtl83xx_mc_group_add_port(struct rtl838x_switch_priv *priv, int mc_gr
 	u64 portmask = priv->r->read_mcast_pmask(mc_group);
 
 	pr_debug("%s: %d\n", __func__, port);
-	if (priv->is_lagmember[port]) {
-		pr_info("%s: %d is lag slave. ignore\n", __func__, port);
-		return portmask;
-	}
+
 	portmask |= BIT_ULL(port);
 	priv->r->write_mcast_pmask(mc_group, portmask);
 
@@ -1013,10 +1005,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr
 	u64 portmask = priv->r->read_mcast_pmask(mc_group);
 
 	pr_debug("%s: %d\n", __func__, port);
-	if (priv->is_lagmember[port]) {
-		pr_info("%s: %d is lag slave. ignore\n", __func__, port);
-		return portmask;
-	}
+
 	portmask &= ~BIT_ULL(port);
 	priv->r->write_mcast_pmask(mc_group, portmask);
 	if (!portmask)
diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
index ad2ad6e8f72a..b6a21f611fdf 100644
--- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
+++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c
@@ -968,11 +968,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port)
 	if (mc_group >= MAX_MC_GROUPS - 1)
 		return -1;
 
-	if (priv->is_lagmember[port]) {
-		pr_info("%s: %d is lag slave. ignore\n", __func__, port);
-		return 0;
-	}
-
 	set_bit(mc_group, priv->mc_group_bm);
 	portmask = BIT_ULL(port);
 	priv->r->write_mcast_pmask(mc_group, portmask);
@@ -985,10 +980,7 @@ static u64 rtl83xx_mc_group_add_port(struct rtl838x_switch_priv *priv, int mc_gr
 	u64 portmask = priv->r->read_mcast_pmask(mc_group);
 
 	pr_debug("%s: %d\n", __func__, port);
-	if (priv->is_lagmember[port]) {
-		pr_info("%s: %d is lag slave. ignore\n", __func__, port);
-		return portmask;
-	}
+
 	portmask |= BIT_ULL(port);
 	priv->r->write_mcast_pmask(mc_group, portmask);
 
@@ -1000,10 +992,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr
 	u64 portmask = priv->r->read_mcast_pmask(mc_group);
 
 	pr_debug("%s: %d\n", __func__, port);
-	if (priv->is_lagmember[port]) {
-		pr_info("%s: %d is lag slave. ignore\n", __func__, port);
-		return portmask;
-	}
+
 	portmask &= ~BIT_ULL(port);
 	priv->r->write_mcast_pmask(mc_group, portmask);
 	if (!portmask)
-- 
2.40.0




More information about the openwrt-devel mailing list