mlxsw: core_thermal: Simplify rollback
authorIdo Schimmel <idosch@nvidia.com>
Tue, 30 Jul 2024 13:58:18 +0000 (15:58 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Aug 2024 01:38:28 +0000 (18:38 -0700)
During rollback, instead of calling mlxsw_thermal_module_fini() for all
the modules, only call it for modules that were successfully
initialized. This is not a bug fix since mlxsw_thermal_module_fini()
first checks that the module was initialized.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Link: https://patch.msgid.link/905bebc45f6e246031f0c5c177bba8efe11e05f5.1722345311.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

index 36b883a..e9bf11a 100644 (file)
@@ -509,7 +509,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
        return 0;
 
 err_thermal_module_init:
-       for (i = area->tz_module_num - 1; i >= 0; i--)
+       for (i--; i >= 0; i--)
                mlxsw_thermal_module_fini(&area->tz_module_arr[i]);
        kfree(area->tz_module_arr);
        return err;