Skip to content

Commit 860fe1f

Browse files
vladimirolteandavem330
authored andcommitted
net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path
Currently when probing returns an error, the netdev is freed but phylink_disconnect is not called. Create a common function between the unbind path and the error path, call it the opposite of dpaa2_switch_probe_port: dpaa2_switch_remove_port, and call it from both the unbind and the error path. Fixes: 84cba72 ("dpaa2-switch: integrate the MAC endpoint support") Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d52ef12 commit 860fe1f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,6 +2925,18 @@ static int dpaa2_switch_ctrl_if_setup(struct ethsw_core *ethsw)
29252925
return err;
29262926
}
29272927

2928+
static void dpaa2_switch_remove_port(struct ethsw_core *ethsw,
2929+
u16 port_idx)
2930+
{
2931+
struct ethsw_port_priv *port_priv = ethsw->ports[port_idx];
2932+
2933+
rtnl_lock();
2934+
dpaa2_switch_port_disconnect_mac(port_priv);
2935+
rtnl_unlock();
2936+
free_netdev(port_priv->netdev);
2937+
ethsw->ports[port_idx] = NULL;
2938+
}
2939+
29282940
static int dpaa2_switch_init(struct fsl_mc_device *sw_dev)
29292941
{
29302942
struct device *dev = &sw_dev->dev;
@@ -3203,10 +3215,7 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
32033215
for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
32043216
port_priv = ethsw->ports[i];
32053217
unregister_netdev(port_priv->netdev);
3206-
rtnl_lock();
3207-
dpaa2_switch_port_disconnect_mac(port_priv);
3208-
rtnl_unlock();
3209-
free_netdev(port_priv->netdev);
3218+
dpaa2_switch_remove_port(ethsw, i);
32103219
}
32113220

32123221
kfree(ethsw->fdbs);
@@ -3394,7 +3403,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
33943403
dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
33953404
err_free_netdev:
33963405
for (i--; i >= 0; i--)
3397-
free_netdev(ethsw->ports[i]->netdev);
3406+
dpaa2_switch_remove_port(ethsw, i);
33983407
kfree(ethsw->filter_blocks);
33993408
err_free_fdbs:
34003409
kfree(ethsw->fdbs);

0 commit comments

Comments
 (0)