Commit 1fb0a495 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: core: Push code doing params register/unregister into separate helpers

Extract the code calling params register/unregister driver ops into
separate functions. Call publish/unpublish unconditionally.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b79cb787
...@@ -1545,6 +1545,24 @@ static const struct devlink_ops mlxsw_devlink_ops = { ...@@ -1545,6 +1545,24 @@ static const struct devlink_ops mlxsw_devlink_ops = {
.trap_policer_counter_get = mlxsw_devlink_trap_policer_counter_get, .trap_policer_counter_get = mlxsw_devlink_trap_policer_counter_get,
}; };
static int mlxsw_core_params_register(struct mlxsw_core *mlxsw_core)
{
int err;
if (mlxsw_core->driver->params_register) {
err = mlxsw_core->driver->params_register(mlxsw_core);
if (err)
return err;
}
return 0;
}
static void mlxsw_core_params_unregister(struct mlxsw_core *mlxsw_core)
{
if (mlxsw_core->driver->params_register)
mlxsw_core->driver->params_unregister(mlxsw_core);
}
static int static int
__mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
const struct mlxsw_bus *mlxsw_bus, const struct mlxsw_bus *mlxsw_bus,
...@@ -1617,8 +1635,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -1617,8 +1635,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
goto err_devlink_register; goto err_devlink_register;
} }
if (mlxsw_driver->params_register && !reload) { if (!reload) {
err = mlxsw_driver->params_register(mlxsw_core); err = mlxsw_core_params_register(mlxsw_core);
if (err) if (err)
goto err_register_params; goto err_register_params;
} }
...@@ -1643,8 +1661,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -1643,8 +1661,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
if (err) if (err)
goto err_thermal_init; goto err_thermal_init;
if (mlxsw_driver->params_register) devlink_params_publish(devlink);
devlink_params_publish(devlink);
if (!reload) if (!reload)
devlink_reload_enable(devlink); devlink_reload_enable(devlink);
...@@ -1658,8 +1675,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -1658,8 +1675,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
mlxsw_core->driver->fini(mlxsw_core); mlxsw_core->driver->fini(mlxsw_core);
err_driver_init: err_driver_init:
err_fw_rev_validate: err_fw_rev_validate:
if (mlxsw_driver->params_unregister && !reload) if (!reload)
mlxsw_driver->params_unregister(mlxsw_core); mlxsw_core_params_unregister(mlxsw_core);
err_register_params: err_register_params:
if (!reload) if (!reload)
devlink_unregister(devlink); devlink_unregister(devlink);
...@@ -1724,14 +1741,13 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, ...@@ -1724,14 +1741,13 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
return; return;
} }
if (mlxsw_core->driver->params_unregister) devlink_params_unpublish(devlink);
devlink_params_unpublish(devlink);
mlxsw_thermal_fini(mlxsw_core->thermal); mlxsw_thermal_fini(mlxsw_core->thermal);
mlxsw_hwmon_fini(mlxsw_core->hwmon); mlxsw_hwmon_fini(mlxsw_core->hwmon);
if (mlxsw_core->driver->fini) if (mlxsw_core->driver->fini)
mlxsw_core->driver->fini(mlxsw_core); mlxsw_core->driver->fini(mlxsw_core);
if (mlxsw_core->driver->params_unregister && !reload) if (!reload)
mlxsw_core->driver->params_unregister(mlxsw_core); mlxsw_core_params_unregister(mlxsw_core);
if (!reload) if (!reload)
devlink_unregister(devlink); devlink_unregister(devlink);
mlxsw_emad_fini(mlxsw_core); mlxsw_emad_fini(mlxsw_core);
...@@ -1744,8 +1760,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, ...@@ -1744,8 +1760,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
return; return;
reload_fail_deinit: reload_fail_deinit:
if (mlxsw_core->driver->params_unregister) mlxsw_core_params_unregister(mlxsw_core);
mlxsw_core->driver->params_unregister(mlxsw_core);
devlink_unregister(devlink); devlink_unregister(devlink);
devlink_resources_unregister(devlink, NULL); devlink_resources_unregister(devlink, NULL);
devlink_free(devlink); devlink_free(devlink);
......
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