Lines Matching refs:tz
12 int for_each_thermal_trip(struct thermal_zone_device *tz,
18 lockdep_assert_held(&tz->lock);
20 for (i = 0; i < tz->num_trips; i++) {
21 ret = cb(&tz->trips[i], data);
30 int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
32 return tz->num_trips;
38 * @tz: a pointer to a thermal zone device structure
46 * This function must be called with tz->lock held. Both tz and tz->ops
51 void __thermal_zone_set_trips(struct thermal_zone_device *tz)
58 lockdep_assert_held(&tz->lock);
60 if (!tz->ops->set_trips)
63 for (i = 0; i < tz->num_trips; i++) {
67 ret = __thermal_zone_get_trip(tz, i , &trip);
73 if (trip_low < tz->temperature && trip_low > low) {
79 if (trip.temperature > tz->temperature &&
87 if (tz->prev_low_trip == low && tz->prev_high_trip == high)
94 if (same_trip && (tz->prev_low_trip != -INT_MAX ||
95 tz->prev_high_trip != INT_MAX))
98 tz->prev_low_trip = low;
99 tz->prev_high_trip = high;
101 dev_dbg(&tz->device,
108 ret = tz->ops->set_trips(tz, low, high);
110 dev_err(&tz->device, "Failed to set trips: %d\n", ret);
113 int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
116 if (!tz || !tz->trips || trip_id < 0 || trip_id >= tz->num_trips || !trip)
119 *trip = tz->trips[trip_id];
124 int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
129 mutex_lock(&tz->lock);
130 ret = __thermal_zone_get_trip(tz, trip_id, trip);
131 mutex_unlock(&tz->lock);
137 int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id,
143 if (!tz->ops->set_trip_temp && !tz->ops->set_trip_hyst && !tz->trips)
146 ret = __thermal_zone_get_trip(tz, trip_id, &t);
153 if (t.temperature != trip->temperature && tz->ops->set_trip_temp) {
154 ret = tz->ops->set_trip_temp(tz, trip_id, trip->temperature);
159 if (t.hysteresis != trip->hysteresis && tz->ops->set_trip_hyst) {
160 ret = tz->ops->set_trip_hyst(tz, trip_id, trip->hysteresis);
165 if (tz->trips && (t.temperature != trip->temperature || t.hysteresis != trip->hysteresis))
166 tz->trips[trip_id] = *trip;
168 thermal_notify_tz_trip_change(tz->id, trip_id, trip->type,
171 __thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED);
176 int thermal_zone_trip_id(struct thermal_zone_device *tz,
181 for (i = 0; i < tz->num_trips; i++) {
182 if (&tz->trips[i] == trip)