Lines Matching +full:thermal +full:- +full:zone
1 // SPDX-License-Identifier: GPL-2.0
3 * thermal_helpers.c - helper functions to handle thermal devices
29 if (tz->emul_temperature || !tz->ops.get_trend || in get_tz_trend()
30 tz->ops.get_trend(tz, trip, &trend)) { in get_tz_trend()
31 if (tz->temperature > tz->last_temperature) in get_tz_trend()
33 else if (tz->temperature < tz->last_temperature) in get_tz_trend()
49 list_for_each_entry(ti, &td->thermal_instances, trip_node) { in thermal_instance_present()
50 if (ti->cdev == cdev) in thermal_instance_present()
69 * __thermal_zone_get_temp() - returns the temperature of a thermal zone
73 * When a valid thermal zone reference is passed, it will fetch its
76 * Both tz and tz->ops must be valid pointers when calling this function,
77 * and the tz->ops.get_temp callback must be provided.
78 * The function must be called under tz->lock.
86 int ret = -EINVAL; in __thermal_zone_get_temp()
88 lockdep_assert_held(&tz->lock); in __thermal_zone_get_temp()
90 ret = tz->ops.get_temp(tz, temp); in __thermal_zone_get_temp()
92 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { in __thermal_zone_get_temp()
94 const struct thermal_trip *trip = &td->trip; in __thermal_zone_get_temp()
96 if (trip->type == THERMAL_TRIP_CRITICAL) { in __thermal_zone_get_temp()
97 crit_temp = trip->temperature; in __thermal_zone_get_temp()
108 *temp = tz->emul_temperature; in __thermal_zone_get_temp()
112 dev_dbg(&tz->device, "Failed to get temperature: %d\n", ret); in __thermal_zone_get_temp()
118 * thermal_zone_get_temp() - returns the temperature of a thermal zone
122 * When a valid thermal zone reference is passed, it will fetch its
132 return -EINVAL; in thermal_zone_get_temp()
136 if (!tz->ops.get_temp) in thermal_zone_get_temp()
137 return -EINVAL; in thermal_zone_get_temp()
141 return -ENODATA; in thermal_zone_get_temp()
152 * No check is needed for the ops->set_cur_state as the in thermal_cdev_set_cur_state()
155 ret = cdev->ops->set_cur_state(cdev, state); in thermal_cdev_set_cur_state()
172 list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) { in __thermal_cdev_update()
173 if (instance->target == THERMAL_NO_TARGET) in __thermal_cdev_update()
175 if (instance->target > target) in __thermal_cdev_update()
176 target = instance->target; in __thermal_cdev_update()
182 dev_dbg(&cdev->device, "set to state %lu\n", target); in __thermal_cdev_update()
186 * thermal_cdev_update - update cooling device state if needed
195 if (!cdev->updated) { in thermal_cdev_update()
197 cdev->updated = true; in thermal_cdev_update()
202 * thermal_cdev_update_nocheck() - Unconditionally update cooling device state
213 * thermal_zone_get_slope - return the slope attribute of the thermal zone
214 * @tz: thermal zone device with the slope attribute
216 * Return: If the thermal zone device has a slope attribute, return it, else
221 if (tz && tz->tzp) in thermal_zone_get_slope()
222 return tz->tzp->slope; in thermal_zone_get_slope()
228 * thermal_zone_get_offset - return the offset attribute of the thermal zone
229 * @tz: thermal zone device with the offset attribute
231 * Return: If the thermal zone device has a offset attribute, return it, else
236 if (tz && tz->tzp) in thermal_zone_get_offset()
237 return tz->tzp->offset; in thermal_zone_get_offset()