drivers/net/ethernet/ti/am65-cpsw-nuss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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.
Fixes: 7bcffde02152 ("net: ethernet: ti: am65-cpsw-nuss: restore vlan configuration while down/up")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/kernel-janitors/aS_lhMwppbDHoEcX@stanley.mountain/
Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Signed-off-by: Alexander Vassilevski <oss@vassilevski.com>
---
I agree, Christophe.
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 77f59996a0..434a310808 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -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)
@@ -318,7 +318,7 @@ static int am65_cpsw_nuss_ndo_slave_add_vid(struct net_device *ndev,
port_mask = BIT(port->port_id) | ALE_PORT_HOST;
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;
--
2.43.0
Le 17/05/2026 à 17:16, Alexander Vassilevski a écrit :
> 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.
>
> Fixes: 7bcffde02152 ("net: ethernet: ti: am65-cpsw-nuss: restore vlan configuration while down/up")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/kernel-janitors/aS_lhMwppbDHoEcX@stanley.mountain/
> Suggested-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Appreciated, but not really needed. I just made a comment about a tiny
possible improvement.
> Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
This should be placed after Signed-off-by:
> Signed-off-by: Alexander Vassilevski <oss@vassilevski.com>
> ---
> I agree, Christophe.
This part could be more descriptive.
You could for example have:
Changes in v2:
- remove unreg_mcast which is now unneeded.
>
> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 77f59996a0..434a310808 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -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)
> @@ -318,7 +318,7 @@ static int am65_cpsw_nuss_ndo_slave_add_vid(struct net_device *ndev,
> port_mask = BIT(port->port_id) | ALE_PORT_HOST;
> 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;
Patches don't work like that.
When you send a v2, it supersedes the previous v1.
So your dead-code removal, should also be included in the v2.
Otherwise, it is impossible for maintainers to know what to apply.
So, you should send a new cumulative version, as a v3.
CJ
© 2016 - 2026 Red Hat, Inc.