diff options
author | Durgadoss R <durgadoss.r@intel.com> | 2012-09-18 01:34:54 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2012-11-05 00:56:32 -0500 |
commit | 9b4298a088907811a4fe5a5d7cd2454da60708c5 (patch) | |
tree | 77d598b92fae403b5cc1c558a9f52d69da4a072b | |
parent | 71350db43b4c5c4da59b729c805f00ff6675b99d (diff) |
Thermal: Add get trend, get instance API's to thermal_sys
This patch adds the following API's to thermal_sys.c, that
can be used by other Thermal drivers.
* get_tz_trend: obtain the trend of the given thermal zone
* get_thermal_instance: obtain the instance corresponding
to the given tz, cdev and the trip point.
Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r-- | drivers/thermal/thermal_sys.c | 40 | ||||
-rw-r--r-- | include/linux/thermal.h | 4 |
2 files changed, 44 insertions, 0 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index bbc834625f7f..1f98c560a88e 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
@@ -82,6 +82,46 @@ static void release_idr(struct idr *idr, struct mutex *lock, int id) | |||
82 | mutex_unlock(lock); | 82 | mutex_unlock(lock); |
83 | } | 83 | } |
84 | 84 | ||
85 | int get_tz_trend(struct thermal_zone_device *tz, int trip) | ||
86 | { | ||
87 | enum thermal_trend trend; | ||
88 | |||
89 | if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) { | ||
90 | if (tz->temperature > tz->last_temperature) | ||
91 | trend = THERMAL_TREND_RAISING; | ||
92 | else if (tz->temperature < tz->last_temperature) | ||
93 | trend = THERMAL_TREND_DROPPING; | ||
94 | else | ||
95 | trend = THERMAL_TREND_STABLE; | ||
96 | } | ||
97 | |||
98 | return trend; | ||
99 | } | ||
100 | EXPORT_SYMBOL(get_tz_trend); | ||
101 | |||
102 | struct thermal_instance *get_thermal_instance(struct thermal_zone_device *tz, | ||
103 | struct thermal_cooling_device *cdev, int trip) | ||
104 | { | ||
105 | struct thermal_instance *pos = NULL; | ||
106 | struct thermal_instance *target_instance = NULL; | ||
107 | |||
108 | mutex_lock(&tz->lock); | ||
109 | mutex_lock(&cdev->lock); | ||
110 | |||
111 | list_for_each_entry(pos, &tz->thermal_instances, tz_node) { | ||
112 | if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) { | ||
113 | target_instance = pos; | ||
114 | break; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | mutex_unlock(&cdev->lock); | ||
119 | mutex_unlock(&tz->lock); | ||
120 | |||
121 | return target_instance; | ||
122 | } | ||
123 | EXPORT_SYMBOL(get_thermal_instance); | ||
124 | |||
85 | /* sys I/F for thermal zone */ | 125 | /* sys I/F for thermal zone */ |
86 | 126 | ||
87 | #define to_thermal_zone(_dev) \ | 127 | #define to_thermal_zone(_dev) \ |
diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 8611e3eba60c..32af124d23cd 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h | |||
@@ -185,6 +185,10 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, | |||
185 | const struct thermal_cooling_device_ops *); | 185 | const struct thermal_cooling_device_ops *); |
186 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); | 186 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); |
187 | 187 | ||
188 | int get_tz_trend(struct thermal_zone_device *, int); | ||
189 | struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, | ||
190 | struct thermal_cooling_device *, int); | ||
191 | |||
188 | #ifdef CONFIG_NET | 192 | #ifdef CONFIG_NET |
189 | extern int thermal_generate_netlink_event(u32 orig, enum events event); | 193 | extern int thermal_generate_netlink_event(u32 orig, enum events event); |
190 | #else | 194 | #else |