thermal/drivers/int340x: Do not check the thermal zone state
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Fri, 7 Jul 2023 20:37:31 +0000 (22:37 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 14 Jul 2023 18:46:02 +0000 (20:46 +0200)
The driver is accessing the thermal zone state to ensure the state is
different from the one we want to set.

We don't want the driver to access the thermal zone device internals.

Actually, the thermal core code already checks if the thermal zone's
state is different before calling this function, thus this check is
duplicate.

Remove it.

Acked-by: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/intel/int340x_thermal/int3400_thermal.c

index 6aadfd72d91051459597bc49acb9873cdb952f7e..ddd600820f683e25e4345e04c02f09dd60648b6f 100644 (file)
@@ -503,32 +503,28 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,
 {
        struct int3400_thermal_priv *priv = thermal_zone_device_priv(thermal);
        int result = 0;
+       int enabled;
 
        if (!priv)
                return -EINVAL;
 
-       if (mode != thermal->mode) {
-               int enabled;
+       enabled = mode == THERMAL_DEVICE_ENABLED;
 
-               enabled = mode == THERMAL_DEVICE_ENABLED;
-
-               if (priv->os_uuid_mask) {
-                       if (!enabled) {
-                               priv->os_uuid_mask = 0;
-                               result = set_os_uuid_mask(priv, priv->os_uuid_mask);
-                       }
-                       goto eval_odvp;
+       if (priv->os_uuid_mask) {
+               if (!enabled) {
+                       priv->os_uuid_mask = 0;
+                       result = set_os_uuid_mask(priv, priv->os_uuid_mask);
                }
-
-               if (priv->current_uuid_index < 0 ||
-                   priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID)
-                       return -EINVAL;
-
-               result = int3400_thermal_run_osc(priv->adev->handle,
-                                                int3400_thermal_uuids[priv->current_uuid_index],
-                                                &enabled);
+               goto eval_odvp;
        }
 
+       if (priv->current_uuid_index < 0 ||
+           priv->current_uuid_index >= INT3400_THERMAL_MAXIMUM_UUID)
+               return -EINVAL;
+
+       result = int3400_thermal_run_osc(priv->adev->handle,
+                                        int3400_thermal_uuids[priv->current_uuid_index],
+                                        &enabled);
 eval_odvp:
        evaluate_odvp(priv);