|
@@ -82,6 +82,46 @@ static void release_idr(struct idr *idr, struct mutex *lock, int id)
|
|
|
mutex_unlock(lock);
|
|
|
}
|
|
|
|
|
|
+int get_tz_trend(struct thermal_zone_device *tz, int trip)
|
|
|
+{
|
|
|
+ enum thermal_trend trend;
|
|
|
+
|
|
|
+ if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) {
|
|
|
+ if (tz->temperature > tz->last_temperature)
|
|
|
+ trend = THERMAL_TREND_RAISING;
|
|
|
+ else if (tz->temperature < tz->last_temperature)
|
|
|
+ trend = THERMAL_TREND_DROPPING;
|
|
|
+ else
|
|
|
+ trend = THERMAL_TREND_STABLE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return trend;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(get_tz_trend);
|
|
|
+
|
|
|
+struct thermal_instance *get_thermal_instance(struct thermal_zone_device *tz,
|
|
|
+ struct thermal_cooling_device *cdev, int trip)
|
|
|
+{
|
|
|
+ struct thermal_instance *pos = NULL;
|
|
|
+ struct thermal_instance *target_instance = NULL;
|
|
|
+
|
|
|
+ mutex_lock(&tz->lock);
|
|
|
+ mutex_lock(&cdev->lock);
|
|
|
+
|
|
|
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
|
|
|
+ if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
|
|
|
+ target_instance = pos;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mutex_unlock(&cdev->lock);
|
|
|
+ mutex_unlock(&tz->lock);
|
|
|
+
|
|
|
+ return target_instance;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(get_thermal_instance);
|
|
|
+
|
|
|
/* sys I/F for thermal zone */
|
|
|
|
|
|
#define to_thermal_zone(_dev) \
|