Lines Matching +full:- +full:temperature
1 // SPDX-License-Identifier: GPL-2.0
18 INIT_LIST_HEAD(&tz->user_thresholds); in thermal_thresholds_init()
25 struct list_head *thresholds = &tz->user_thresholds; in __thermal_thresholds_flush()
29 list_del(&entry->list_node); in __thermal_thresholds_flush()
36 lockdep_assert_held(&tz->lock); in thermal_thresholds_flush()
57 return t1->temperature - t2->temperature; in __thermal_thresholds_cmp()
61 int temperature) in __thermal_thresholds_find() argument
66 if (t->temperature == temperature) in __thermal_thresholds_find()
72 static bool thermal_thresholds_handle_raising(struct list_head *thresholds, int temperature, in thermal_thresholds_handle_raising() argument
79 if (!(t->direction & THERMAL_THRESHOLD_WAY_UP)) in thermal_thresholds_handle_raising()
82 if (temperature >= t->temperature && in thermal_thresholds_handle_raising()
83 last_temperature < t->temperature) in thermal_thresholds_handle_raising()
90 static bool thermal_thresholds_handle_dropping(struct list_head *thresholds, int temperature, in thermal_thresholds_handle_dropping() argument
97 if (!(t->direction & THERMAL_THRESHOLD_WAY_DOWN)) in thermal_thresholds_handle_dropping()
100 if (temperature <= t->temperature && in thermal_thresholds_handle_dropping()
101 last_temperature > t->temperature) in thermal_thresholds_handle_dropping()
108 static void thermal_threshold_find_boundaries(struct list_head *thresholds, int temperature, in thermal_threshold_find_boundaries() argument
114 if (temperature < t->temperature && in thermal_threshold_find_boundaries()
115 (t->direction & THERMAL_THRESHOLD_WAY_UP) && in thermal_threshold_find_boundaries()
116 *high > t->temperature) in thermal_threshold_find_boundaries()
117 *high = t->temperature; in thermal_threshold_find_boundaries()
121 if (temperature > t->temperature && in thermal_threshold_find_boundaries()
122 (t->direction & THERMAL_THRESHOLD_WAY_DOWN) && in thermal_threshold_find_boundaries()
123 *low < t->temperature) in thermal_threshold_find_boundaries()
124 *low = t->temperature; in thermal_threshold_find_boundaries()
130 struct list_head *thresholds = &tz->user_thresholds; in thermal_thresholds_handle()
132 int temperature = tz->temperature; in thermal_thresholds_handle() local
133 int last_temperature = tz->last_temperature; in thermal_thresholds_handle()
135 lockdep_assert_held(&tz->lock); in thermal_thresholds_handle()
137 thermal_threshold_find_boundaries(thresholds, temperature, low, high); in thermal_thresholds_handle()
146 * The temperature is stable, so obviously we can not have in thermal_thresholds_handle()
149 if (last_temperature == temperature) in thermal_thresholds_handle()
153 * Since last update the temperature: in thermal_thresholds_handle()
154 * - increased : thresholds are crossed the way up in thermal_thresholds_handle()
155 * - decreased : thresholds are crossed the way down in thermal_thresholds_handle()
157 if (temperature > last_temperature) { in thermal_thresholds_handle()
159 temperature, last_temperature)) in thermal_thresholds_handle()
163 temperature, last_temperature)) in thermal_thresholds_handle()
169 int temperature, int direction) in thermal_thresholds_add() argument
171 struct list_head *thresholds = &tz->user_thresholds; in thermal_thresholds_add()
174 lockdep_assert_held(&tz->lock); in thermal_thresholds_add()
176 t = __thermal_thresholds_find(thresholds, temperature); in thermal_thresholds_add()
178 if (t->direction == direction) in thermal_thresholds_add()
179 return -EEXIST; in thermal_thresholds_add()
181 t->direction |= direction; in thermal_thresholds_add()
186 return -ENOMEM; in thermal_thresholds_add()
188 INIT_LIST_HEAD(&t->list_node); in thermal_thresholds_add()
189 t->temperature = temperature; in thermal_thresholds_add()
190 t->direction = direction; in thermal_thresholds_add()
191 list_add(&t->list_node, thresholds); in thermal_thresholds_add()
195 thermal_notify_threshold_add(tz, temperature, direction); in thermal_thresholds_add()
203 int temperature, int direction) in thermal_thresholds_delete() argument
205 struct list_head *thresholds = &tz->user_thresholds; in thermal_thresholds_delete()
208 lockdep_assert_held(&tz->lock); in thermal_thresholds_delete()
210 t = __thermal_thresholds_find(thresholds, temperature); in thermal_thresholds_delete()
212 return -ENOENT; in thermal_thresholds_delete()
214 if (t->direction == direction) { in thermal_thresholds_delete()
215 list_del(&t->list_node); in thermal_thresholds_delete()
218 t->direction &= ~direction; in thermal_thresholds_delete()
221 thermal_notify_threshold_delete(tz, temperature, direction); in thermal_thresholds_delete()
231 struct list_head *thresholds = &tz->user_thresholds; in thermal_thresholds_for_each()