Skip to content

Commit 0ae204a

Browse files
committed
thermal: gov_bang_bang: Fold thermal_zone_trip_update() into its caller
Fold thermal_zone_trip_update() into bang_bang_control() which is the only caller of it to reduce code size and make it easier to follow. No functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent 4526c58 commit 0ae204a

File tree

1 file changed

+33
-42
lines changed

1 file changed

+33
-42
lines changed

drivers/thermal/gov_bang_bang.c

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,6 @@
1313

1414
#include "thermal_core.h"
1515

16-
static void thermal_zone_trip_update(struct thermal_zone_device *tz,
17-
const struct thermal_trip *trip,
18-
bool crossed_up)
19-
{
20-
struct thermal_instance *instance;
21-
22-
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
23-
thermal_zone_trip_id(tz, trip), trip->temperature,
24-
tz->temperature, trip->hysteresis);
25-
26-
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
27-
if (instance->trip != trip)
28-
continue;
29-
30-
if (instance->target == THERMAL_NO_TARGET)
31-
instance->target = 0;
32-
33-
if (instance->target != 0 && instance->target != 1) {
34-
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
35-
instance->target, instance->name);
36-
37-
instance->target = 1;
38-
}
39-
40-
/*
41-
* Enable the fan when the trip is crossed on the way up and
42-
* disable it when the trip is crossed on the way down.
43-
*/
44-
if (instance->target == 0 && crossed_up)
45-
instance->target = 1;
46-
else if (instance->target == 1 && !crossed_up)
47-
instance->target = 0;
48-
49-
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
50-
51-
mutex_lock(&instance->cdev->lock);
52-
instance->cdev->updated = false; /* cdev needs update */
53-
mutex_unlock(&instance->cdev->lock);
54-
}
55-
}
56-
5716
/**
5817
* bang_bang_control - controls devices associated with the given zone
5918
* @tz: thermal_zone_device
@@ -90,7 +49,39 @@ static void bang_bang_control(struct thermal_zone_device *tz,
9049

9150
lockdep_assert_held(&tz->lock);
9251

93-
thermal_zone_trip_update(tz, trip, crossed_up);
52+
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
53+
thermal_zone_trip_id(tz, trip), trip->temperature,
54+
tz->temperature, trip->hysteresis);
55+
56+
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
57+
if (instance->trip != trip)
58+
continue;
59+
60+
if (instance->target == THERMAL_NO_TARGET)
61+
instance->target = 0;
62+
63+
if (instance->target != 0 && instance->target != 1) {
64+
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
65+
instance->target, instance->name);
66+
67+
instance->target = 1;
68+
}
69+
70+
/*
71+
* Enable the fan when the trip is crossed on the way up and
72+
* disable it when the trip is crossed on the way down.
73+
*/
74+
if (instance->target == 0 && crossed_up)
75+
instance->target = 1;
76+
else if (instance->target == 1 && !crossed_up)
77+
instance->target = 0;
78+
79+
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
80+
81+
mutex_lock(&instance->cdev->lock);
82+
instance->cdev->updated = false; /* cdev needs update */
83+
mutex_unlock(&instance->cdev->lock);
84+
}
9485

9586
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
9687
thermal_cdev_update(instance->cdev);

0 commit comments

Comments
 (0)