Skip to content

Commit 84248e3

Browse files
committed
thermal: gov_bang_bang: Split bang_bang_control()
Move the setting of the thermal instance target state from bang_bang_control() into a separate function that will be also called in a different place going forward. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Peter Kästle <[email protected]> Reviewed-by: Zhang Rui <[email protected]> Cc: 6.10+ <[email protected]> # 6.10+ Link: https://patch.msgid.link/[email protected]
1 parent b9b6ee6 commit 84248e3

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

drivers/thermal/gov_bang_bang.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@
1313

1414
#include "thermal_core.h"
1515

16+
static void bang_bang_set_instance_target(struct thermal_instance *instance,
17+
unsigned int target)
18+
{
19+
if (instance->target != 0 && instance->target != 1 &&
20+
instance->target != THERMAL_NO_TARGET)
21+
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
22+
instance->target, instance->name);
23+
24+
/*
25+
* Enable the fan when the trip is crossed on the way up and disable it
26+
* when the trip is crossed on the way down.
27+
*/
28+
instance->target = target;
29+
30+
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
31+
32+
mutex_lock(&instance->cdev->lock);
33+
__thermal_cdev_update(instance->cdev);
34+
mutex_unlock(&instance->cdev->lock);
35+
}
36+
1637
/**
1738
* bang_bang_control - controls devices associated with the given zone
1839
* @tz: thermal_zone_device
@@ -54,25 +75,8 @@ static void bang_bang_control(struct thermal_zone_device *tz,
5475
tz->temperature, trip->hysteresis);
5576

5677
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
57-
if (instance->trip != trip)
58-
continue;
59-
60-
if (instance->target != 0 && instance->target != 1 &&
61-
instance->target != THERMAL_NO_TARGET)
62-
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
63-
instance->target, instance->name);
64-
65-
/*
66-
* Enable the fan when the trip is crossed on the way up and
67-
* disable it when the trip is crossed on the way down.
68-
*/
69-
instance->target = crossed_up;
70-
71-
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
72-
73-
mutex_lock(&instance->cdev->lock);
74-
__thermal_cdev_update(instance->cdev);
75-
mutex_unlock(&instance->cdev->lock);
78+
if (instance->trip == trip)
79+
bang_bang_set_instance_target(instance, crossed_up);
7680
}
7781
}
7882

0 commit comments

Comments
 (0)