Skip to content
/ linux Public

Commit 3d7a6f6

Browse files
idoschdavem330
authored andcommitted
mlxsw: core: Initialize switch driver last
Commit 961cf99 ("mlxsw: core: Re-order initialization sequence") changed the initialization sequence so that the switch driver (e.g., mlxsw_spectrum) is initialized before registration with the hwmon and thermal subsystems. This was done in order to avoid situations where hwmon/thermal code uses features not supported by current firmware version, which is only validated as part of switch driver initialization. Later, commit b79cb78 ("mlxsw: Move fw flashing code into core.c") moved firmware validation and flashing code from the switch driver to mlxsw_core so that it is performed before driver initialization. Therefore, change the initialization sequence back to its original form. In addition to being more straightforward, it will allow us to simplify parts of the code in subsequent patches and future patchsets. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0013522 commit 3d7a6f6

File tree

1 file changed

+10
-11
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+10
-11
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,12 +1995,6 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
19951995
if (err)
19961996
goto err_health_init;
19971997

1998-
if (mlxsw_driver->init) {
1999-
err = mlxsw_driver->init(mlxsw_core, mlxsw_bus_info, extack);
2000-
if (err)
2001-
goto err_driver_init;
2002-
}
2003-
20041998
err = mlxsw_hwmon_init(mlxsw_core, mlxsw_bus_info, &mlxsw_core->hwmon);
20051999
if (err)
20062000
goto err_hwmon_init;
@@ -2014,6 +2008,12 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
20142008
if (err)
20152009
goto err_env_init;
20162010

2011+
if (mlxsw_driver->init) {
2012+
err = mlxsw_driver->init(mlxsw_core, mlxsw_bus_info, extack);
2013+
if (err)
2014+
goto err_driver_init;
2015+
}
2016+
20172017
mlxsw_core->is_initialized = true;
20182018
devlink_params_publish(devlink);
20192019

@@ -2022,14 +2022,13 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
20222022

20232023
return 0;
20242024

2025+
err_driver_init:
2026+
mlxsw_env_fini(mlxsw_core->env);
20252027
err_env_init:
20262028
mlxsw_thermal_fini(mlxsw_core->thermal);
20272029
err_thermal_init:
20282030
mlxsw_hwmon_fini(mlxsw_core->hwmon);
20292031
err_hwmon_init:
2030-
if (mlxsw_core->driver->fini)
2031-
mlxsw_core->driver->fini(mlxsw_core);
2032-
err_driver_init:
20332032
mlxsw_core_health_fini(mlxsw_core);
20342033
err_health_init:
20352034
err_fw_rev_validate:
@@ -2101,11 +2100,11 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
21012100

21022101
devlink_params_unpublish(devlink);
21032102
mlxsw_core->is_initialized = false;
2103+
if (mlxsw_core->driver->fini)
2104+
mlxsw_core->driver->fini(mlxsw_core);
21042105
mlxsw_env_fini(mlxsw_core->env);
21052106
mlxsw_thermal_fini(mlxsw_core->thermal);
21062107
mlxsw_hwmon_fini(mlxsw_core->hwmon);
2107-
if (mlxsw_core->driver->fini)
2108-
mlxsw_core->driver->fini(mlxsw_core);
21092108
mlxsw_core_health_fini(mlxsw_core);
21102109
if (!reload)
21112110
mlxsw_core_params_unregister(mlxsw_core);

0 commit comments

Comments
 (0)