thermal: gov_step_wise: Adjust code logic to match comment
authorZhang Rui <rui.zhang@intel.com>
Tue, 21 Mar 2023 05:47:14 +0000 (13:47 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 27 Apr 2023 17:17:11 +0000 (19:17 +0200)
For the algorithm of choosing the next target state in step_wise
governor, the code does the right thing but is implemented in a
way different from what the comment describes. And this hurts the code
readability.

As the logic in the comment is simpler, adjust the code logic to align
with the comment.

No functional change.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[ rjw: Subject edit ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/gov_step_wise.c

index 3f72a8eaf2f75d2cb87f8ea4ba96db87f54516c1..1050fb4d94c2d46856ea22daa881bd37f15b27a4 100644 (file)
@@ -53,24 +53,16 @@ static unsigned long get_target_state(struct thermal_instance *instance,
                return next_target;
        }
 
-       switch (trend) {
-       case THERMAL_TREND_RAISING:
-               if (throttle) {
+       if (throttle) {
+               if (trend == THERMAL_TREND_RAISING)
                        next_target = clamp((cur_state + 1), instance->lower, instance->upper);
-               }
-               break;
-       case THERMAL_TREND_DROPPING:
-               if (cur_state <= instance->lower) {
-                       if (!throttle)
+       } else {
+               if (trend == THERMAL_TREND_DROPPING) {
+                       if (cur_state <= instance->lower)
                                next_target = THERMAL_NO_TARGET;
-               } else {
-                       if (!throttle) {
+                       else
                                next_target = clamp((cur_state - 1), instance->lower, instance->upper);
-                       }
                }
-               break;
-       default:
-               break;
        }
 
        return next_target;