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