Skip to content

Commit e4006bf

Browse files
zhang-ruirafaeljw
authored andcommitted
thermal: gov_step_wise: Adjust code logic to match comment
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>
1 parent cead266 commit e4006bf

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

drivers/thermal/gov_step_wise.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,16 @@ static unsigned long get_target_state(struct thermal_instance *instance,
5353
return next_target;
5454
}
5555

56-
switch (trend) {
57-
case THERMAL_TREND_RAISING:
58-
if (throttle) {
56+
if (throttle) {
57+
if (trend == THERMAL_TREND_RAISING)
5958
next_target = clamp((cur_state + 1), instance->lower, instance->upper);
60-
}
61-
break;
62-
case THERMAL_TREND_DROPPING:
63-
if (cur_state <= instance->lower) {
64-
if (!throttle)
59+
} else {
60+
if (trend == THERMAL_TREND_DROPPING) {
61+
if (cur_state <= instance->lower)
6562
next_target = THERMAL_NO_TARGET;
66-
} else {
67-
if (!throttle) {
63+
else
6864
next_target = clamp((cur_state - 1), instance->lower, instance->upper);
69-
}
7065
}
71-
break;
72-
default:
73-
break;
7466
}
7567

7668
return next_target;

0 commit comments

Comments
 (0)