mlxsw: core_thermal: Fold two loops into one
authorIdo Schimmel <idosch@nvidia.com>
Tue, 30 Jul 2024 13:58:15 +0000 (15:58 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Aug 2024 01:38:28 +0000 (18:38 -0700)
There is no need to traverse the same array twice. Do it once by folding
both loops into one.

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/81756744ed532aaa9249a83fc08757accfe8b07c.1722345311.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

index afd8fe85a94dba7d211f5e9a77a159497d0e715c..b2a4eea859d1bb8da1f3fdda12dc45d6aa2b7ea3 100644 (file)
@@ -500,10 +500,8 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
        if (!area->tz_module_arr)
                return -ENOMEM;
 
-       for (i = 0; i < area->tz_module_num; i++)
-               mlxsw_thermal_module_init(dev, core, thermal, area, i);
-
        for (i = 0; i < area->tz_module_num; i++) {
+               mlxsw_thermal_module_init(dev, core, thermal, area, i);
                module_tz = &area->tz_module_arr[i];
                err = mlxsw_thermal_module_tz_init(module_tz);
                if (err)