mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally
authorIdo Schimmel <idosch@nvidia.com>
Tue, 30 Jul 2024 13:58:12 +0000 (15:58 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Aug 2024 01:38:27 +0000 (18:38 -0700)
The function returns immediately if the thermal zone pointer is NULL so
there is no need to check it before calling the function.

Remove the check.

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

index d61478c..0b38bab 100644 (file)
@@ -821,10 +821,7 @@ err_linecards_event_ops_register:
 err_thermal_gearboxes_init:
        mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
 err_thermal_modules_init:
-       if (thermal->tzdev) {
-               thermal_zone_device_unregister(thermal->tzdev);
-               thermal->tzdev = NULL;
-       }
+       thermal_zone_device_unregister(thermal->tzdev);
 err_thermal_zone_device_register:
 err_thermal_cooling_device_register:
        for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
@@ -845,10 +842,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
                                             thermal);
        mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]);
        mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
-       if (thermal->tzdev) {
-               thermal_zone_device_unregister(thermal->tzdev);
-               thermal->tzdev = NULL;
-       }
+       thermal_zone_device_unregister(thermal->tzdev);
 
        for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
                thermal_cooling_device_unregister(thermal->cdevs[i].cdev);