]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ethernet: ti: am65-cpsw-nuss: remove dead vid check in slave_add_vid()
authorAlexander Vassilevski <oss@vassilevski.com>
Sun, 17 May 2026 22:07:57 +0000 (15:07 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 21 May 2026 00:00:44 +0000 (17:00 -0700)
am65_cpsw_nuss_ndo_slave_add_vid() returns early at the top with:

     if (!netif_running(ndev) || !vid)
         return 0;

so vid is guaranteed to be non-zero in the rest of the function. The
subsequent

     if (!vid)
         unreg_mcast = port_mask;

is therefore unreachable. Drop the dead branch.

With that branch gone, unreg_mcast is only ever its initializer value
of zero, so drop the variable and pass 0 directly to
cpsw_ale_vlan_add_modify().

No functional change.

Found by Smatch.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/aS_lhMwppbDHoEcX@stanley.mountain
Signed-off-by: Alexander Vassilevski <oss@vassilevski.com>
Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Link: https://patch.msgid.link/20260517220757.2679458-1-oss@vassilevski.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ti/am65-cpsw-nuss.c

index 7ac75fc8cdcf4d7ff9ead468731d740a936c8178..434a31080855a78e3ea5dfc528d3e59d8766dbd5 100644 (file)
@@ -302,7 +302,7 @@ static int am65_cpsw_nuss_ndo_slave_add_vid(struct net_device *ndev,
 {
        struct am65_cpsw_common *common = am65_ndev_to_common(ndev);
        struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
-       u32 port_mask, unreg_mcast = 0;
+       u32 port_mask;
        int ret;
 
        if (!common->is_emac_mode)
@@ -316,11 +316,9 @@ static int am65_cpsw_nuss_ndo_slave_add_vid(struct net_device *ndev,
                return ret;
 
        port_mask = BIT(port->port_id) | ALE_PORT_HOST;
-       if (!vid)
-               unreg_mcast = port_mask;
        dev_info(common->dev, "Adding vlan %d to vlan filter\n", vid);
        ret = cpsw_ale_vlan_add_modify(common->ale, vid, port_mask,
-                                      unreg_mcast, port_mask, 0);
+                                      0, port_mask, 0);
 
        pm_runtime_put(common->dev);
        return ret;