|
13 | 13 |
|
14 | 14 | #include "thermal_core.h"
|
15 | 15 |
|
| 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 | + |
16 | 37 | /**
|
17 | 38 | * bang_bang_control - controls devices associated with the given zone
|
18 | 39 | * @tz: thermal_zone_device
|
@@ -54,25 +75,8 @@ static void bang_bang_control(struct thermal_zone_device *tz,
|
54 | 75 | tz->temperature, trip->hysteresis);
|
55 | 76 |
|
56 | 77 | 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); |
76 | 80 | }
|
77 | 81 | }
|
78 | 82 |
|
|
0 commit comments