提交 f83e2102 编写于 作者: J Jiri Pirko 提交者: David S. Miller

mlxsw: spectrum: Move port used check outside port remove function

Be symmentrical with create and do the check outside the remove function.
Signed-off-by: NJiri Pirko <jiri@mellanox.com>
Signed-off-by: NElad Raz <eladr@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 adc4e04a
...@@ -2403,8 +2403,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -2403,8 +2403,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
{ {
struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port];
if (!mlxsw_sp_port)
return;
cancel_delayed_work_sync(&mlxsw_sp_port->hw_stats.update_dw); cancel_delayed_work_sync(&mlxsw_sp_port->hw_stats.update_dw);
mlxsw_core_port_fini(&mlxsw_sp_port->core_port); mlxsw_core_port_fini(&mlxsw_sp_port->core_port);
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
...@@ -2422,11 +2420,17 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -2422,11 +2420,17 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
free_netdev(mlxsw_sp_port->dev); free_netdev(mlxsw_sp_port->dev);
} }
static bool mlxsw_sp_port_created(struct mlxsw_sp *mlxsw_sp, u8 local_port)
{
return mlxsw_sp->ports[local_port] != NULL;
}
static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp) static void mlxsw_sp_ports_remove(struct mlxsw_sp *mlxsw_sp)
{ {
int i; int i;
for (i = 1; i < MLXSW_PORT_MAX_PORTS; i++) for (i = 1; i < MLXSW_PORT_MAX_PORTS; i++)
if (mlxsw_sp_port_created(mlxsw_sp, i))
mlxsw_sp_port_remove(mlxsw_sp, i); mlxsw_sp_port_remove(mlxsw_sp, i);
kfree(mlxsw_sp->ports); kfree(mlxsw_sp->ports);
} }
...@@ -2461,6 +2465,7 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp) ...@@ -2461,6 +2465,7 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
err_port_create: err_port_create:
err_port_module_info_get: err_port_module_info_get:
for (i--; i >= 1; i--) for (i--; i >= 1; i--)
if (mlxsw_sp_port_created(mlxsw_sp, i))
mlxsw_sp_port_remove(mlxsw_sp, i); mlxsw_sp_port_remove(mlxsw_sp, i);
kfree(mlxsw_sp->ports); kfree(mlxsw_sp->ports);
return err; return err;
...@@ -2503,6 +2508,7 @@ static int mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, u8 base_port, ...@@ -2503,6 +2508,7 @@ static int mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, u8 base_port,
err_port_create: err_port_create:
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
if (mlxsw_sp_port_created(mlxsw_sp, base_port + i))
mlxsw_sp_port_remove(mlxsw_sp, base_port + i); mlxsw_sp_port_remove(mlxsw_sp, base_port + i);
i = count; i = count;
err_port_swid_set: err_port_swid_set:
...@@ -2593,6 +2599,7 @@ static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port, ...@@ -2593,6 +2599,7 @@ static int mlxsw_sp_port_split(struct mlxsw_core *mlxsw_core, u8 local_port,
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
if (mlxsw_sp_port_created(mlxsw_sp, base_port + i))
mlxsw_sp_port_remove(mlxsw_sp, base_port + i); mlxsw_sp_port_remove(mlxsw_sp, base_port + i);
err = mlxsw_sp_port_split_create(mlxsw_sp, base_port, module, count); err = mlxsw_sp_port_split_create(mlxsw_sp, base_port, module, count);
...@@ -2638,6 +2645,7 @@ static int mlxsw_sp_port_unsplit(struct mlxsw_core *mlxsw_core, u8 local_port) ...@@ -2638,6 +2645,7 @@ static int mlxsw_sp_port_unsplit(struct mlxsw_core *mlxsw_core, u8 local_port)
base_port = base_port + 2; base_port = base_port + 2;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
if (mlxsw_sp_port_created(mlxsw_sp, base_port + i))
mlxsw_sp_port_remove(mlxsw_sp, base_port + i); mlxsw_sp_port_remove(mlxsw_sp, base_port + i);
mlxsw_sp_port_unsplit_create(mlxsw_sp, base_port, count); mlxsw_sp_port_unsplit_create(mlxsw_sp, base_port, count);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册