Commit b244143a authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

mlxsw: core: Move port module events enablement to a separate function

Use a separate function for enablement of port module events such
plug/unplug and temperature threshold crossing. The motivation is to
reuse the function for line cards.
Signed-off-by: default avatarVadim Pasternak <vadimp@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5b6a5ba
......@@ -1148,6 +1148,28 @@ static void mlxsw_env_line_cards_free(struct mlxsw_env *env)
kfree(env->line_cards[i]);
}
static int
mlxsw_env_module_event_enable(struct mlxsw_env *mlxsw_env, u8 slot_index)
{
int err;
err = mlxsw_env_module_oper_state_event_enable(mlxsw_env->core,
slot_index);
if (err)
return err;
err = mlxsw_env_module_temp_event_enable(mlxsw_env->core, slot_index);
if (err)
return err;
return 0;
}
static void
mlxsw_env_module_event_disable(struct mlxsw_env *mlxsw_env, u8 slot_index)
{
}
static int
mlxsw_env_module_type_set(struct mlxsw_core *mlxsw_core, u8 slot_index)
{
......@@ -1220,13 +1242,13 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
* is to be set after line card is activated.
*/
env->line_cards[0]->module_count = num_of_slots ? 0 : module_count;
err = mlxsw_env_module_oper_state_event_enable(mlxsw_core, 0);
if (err)
goto err_oper_state_event_enable;
err = mlxsw_env_module_temp_event_enable(mlxsw_core, 0);
/* Enable events only for main board. Line card events are to be
* configured only after line card is activated. Before that, access to
* modules on line cards is not allowed.
*/
err = mlxsw_env_module_event_enable(env, 0);
if (err)
goto err_temp_event_enable;
goto err_mlxsw_env_module_event_enable;
err = mlxsw_env_module_type_set(mlxsw_core, 0);
if (err)
......@@ -1235,8 +1257,8 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
return 0;
err_type_set:
err_temp_event_enable:
err_oper_state_event_enable:
mlxsw_env_module_event_disable(env, 0);
err_mlxsw_env_module_event_enable:
mlxsw_env_module_plug_event_unregister(env);
err_module_plug_event_register:
mlxsw_env_temp_warn_event_unregister(env);
......@@ -1250,6 +1272,7 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core, struct mlxsw_env **p_env)
void mlxsw_env_fini(struct mlxsw_env *env)
{
mlxsw_env_module_event_disable(env, 0);
mlxsw_env_module_plug_event_unregister(env);
/* Make sure there is no more event work scheduled. */
mlxsw_core_flush_owq();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment