]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal: gov_bang_bang: Drop unnecessary cooling device target state checks
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 28 May 2024 16:54:01 +0000 (18:54 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 11 Jun 2024 19:06:44 +0000 (21:06 +0200)
Some cooling device target state checks in bang_bang_control()
done before setting the new target state are not necessary after
recent changes, so drop them.

Also avoid updating the target state before checking it for
unexpected values.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/gov_bang_bang.c

index acb52c9ee10f1a62fea7d47dd3d9002e189d55b0..4a2e869b9538c170112c3b09dc05ee31ac70bcc1 100644 (file)
@@ -57,24 +57,16 @@ static void bang_bang_control(struct thermal_zone_device *tz,
                if (instance->trip != trip)
                        continue;
 
-               if (instance->target == THERMAL_NO_TARGET)
-                       instance->target = 0;
-
-               if (instance->target != 0 && instance->target != 1) {
+               if (instance->target != 0 && instance->target != 1 &&
+                   instance->target != THERMAL_NO_TARGET)
                        pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
                                 instance->target, instance->name);
 
-                       instance->target = 1;
-               }
-
                /*
                 * Enable the fan when the trip is crossed on the way up and
                 * disable it when the trip is crossed on the way down.
                 */
-               if (instance->target == 0 && crossed_up)
-                       instance->target = 1;
-               else if (instance->target == 1 && !crossed_up)
-                       instance->target = 0;
+               instance->target = crossed_up;
 
                dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);