From: Ido Schimmel Date: Tue, 30 Jul 2024 13:58:15 +0000 (+0200) Subject: mlxsw: core_thermal: Fold two loops into one X-Git-Tag: v6.12-rc1~232^2~349^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d81d71434036642882b55cf93432bf4a1720a481;p=thirdparty%2Fkernel%2Flinux.git mlxsw: core_thermal: Fold two loops into one There is no need to traverse the same array twice. Do it once by folding both loops into one. Signed-off-by: Ido Schimmel Reviewed-by: Vadim Pasternak Signed-off-by: Petr Machata Reviewed-by: Wojciech Drewek Link: https://patch.msgid.link/81756744ed532aaa9249a83fc08757accfe8b07c.1722345311.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index afd8fe85a94db..b2a4eea859d1b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -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)