aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-06-22 04:42:03 -0400
committerZhang Rui <rui.zhang@intel.com>2016-09-27 02:02:16 -0400
commite78eaf45993a51e5d7120de48aa01f059ffe8d37 (patch)
tree13604f5d5bcfceb290f84f6df7a34fd44582cb91
parent826386e73193e0b58c6d797fbbab409bc98b1d9c (diff)
thermal: streamline get_trend callbacks
The .get_trend callback in struct thermal_zone_device_ops has the prototype: int (*get_trend) (struct thermal_zone_device *, int, enum thermal_trend *); whereas the .get_trend callback in struct thermal_zone_of_device_ops has: int (*get_trend)(void *, long *); Streamline both prototypes and add the trip argument to the OF callback aswell and use enum thermal_trend * instead of an integer pointer. While the OF prototype may be the better one, this should be decided at framework level and not on OF level. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Caesar Wang <wxt@rock-chips.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: linux-pm@vger.kernel.org Reviewed-by: Keerthy <j-keerthy@ti.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r--drivers/thermal/of-thermal.c16
-rw-r--r--drivers/thermal/qcom/tsens.c6
-rw-r--r--drivers/thermal/qcom/tsens.h4
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-thermal-common.c25
-rw-r--r--include/linux/thermal.h2
5 files changed, 16 insertions, 37 deletions
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 2d2a06f155e2..20822abc6682 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -202,25 +202,11 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
202 enum thermal_trend *trend) 202 enum thermal_trend *trend)
203{ 203{
204 struct __thermal_zone *data = tz->devdata; 204 struct __thermal_zone *data = tz->devdata;
205 long dev_trend;
206 int r;
207 205
208 if (!data->ops->get_trend) 206 if (!data->ops->get_trend)
209 return -EINVAL; 207 return -EINVAL;
210 208
211 r = data->ops->get_trend(data->sensor_data, &dev_trend); 209 return data->ops->get_trend(data->sensor_data, trip, trend);
212 if (r)
213 return r;
214
215 /* TODO: These intervals might have some thresholds, but in core code */
216 if (dev_trend > 0)
217 *trend = THERMAL_TREND_RAISING;
218 else if (dev_trend < 0)
219 *trend = THERMAL_TREND_DROPPING;
220 else
221 *trend = THERMAL_TREND_STABLE;
222
223 return 0;
224} 210}
225 211
226static int of_thermal_bind(struct thermal_zone_device *thermal, 212static int of_thermal_bind(struct thermal_zone_device *thermal,
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index b18227269286..446f70b5dbb2 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -29,13 +29,13 @@ static int tsens_get_temp(void *data, int *temp)
29 return tmdev->ops->get_temp(tmdev, s->id, temp); 29 return tmdev->ops->get_temp(tmdev, s->id, temp);
30} 30}
31 31
32static int tsens_get_trend(void *data, long *temp) 32static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
33{ 33{
34 const struct tsens_sensor *s = data; 34 const struct tsens_sensor *s = p;
35 struct tsens_device *tmdev = s->tmdev; 35 struct tsens_device *tmdev = s->tmdev;
36 36
37 if (tmdev->ops->get_trend) 37 if (tmdev->ops->get_trend)
38 return tmdev->ops->get_trend(tmdev, s->id, temp); 38 return tmdev->ops->get_trend(tmdev, s->id, trend);
39 39
40 return -ENOTSUPP; 40 return -ENOTSUPP;
41} 41}
diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h
index b0f8c47ff9e2..911c1978892b 100644
--- a/drivers/thermal/qcom/tsens.h
+++ b/drivers/thermal/qcom/tsens.h
@@ -17,6 +17,8 @@
17#define ONE_PT_CALIB2 0x2 17#define ONE_PT_CALIB2 0x2
18#define TWO_PT_CALIB 0x3 18#define TWO_PT_CALIB 0x3
19 19
20#include <linux/thermal.h>
21
20struct tsens_device; 22struct tsens_device;
21 23
22struct tsens_sensor { 24struct tsens_sensor {
@@ -50,7 +52,7 @@ struct tsens_ops {
50 void (*disable)(struct tsens_device *); 52 void (*disable)(struct tsens_device *);
51 int (*suspend)(struct tsens_device *); 53 int (*suspend)(struct tsens_device *);
52 int (*resume)(struct tsens_device *); 54 int (*resume)(struct tsens_device *);
53 int (*get_trend)(struct tsens_device *, int, long *); 55 int (*get_trend)(struct tsens_device *, int, enum thermal_trend *);
54}; 56};
55 57
56/** 58/**
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 15c0a9ac2209..4a6757ca78f0 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -239,7 +239,7 @@ static int ti_thermal_get_trip_temp(struct thermal_zone_device *thermal,
239 return 0; 239 return 0;
240} 240}
241 241
242static int __ti_thermal_get_trend(void *p, long *trend) 242static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
243{ 243{
244 struct ti_thermal_data *data = p; 244 struct ti_thermal_data *data = p;
245 struct ti_bandgap *bgp; 245 struct ti_bandgap *bgp;
@@ -252,22 +252,6 @@ static int __ti_thermal_get_trend(void *p, long *trend)
252 if (ret) 252 if (ret)
253 return ret; 253 return ret;
254 254
255 *trend = tr;
256
257 return 0;
258}
259
260/* Get the temperature trend callback functions for thermal zone */
261static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
262 int trip, enum thermal_trend *trend)
263{
264 int ret;
265 long tr;
266
267 ret = __ti_thermal_get_trend(thermal->devdata, &tr);
268 if (ret)
269 return ret;
270
271 if (tr > 0) 255 if (tr > 0)
272 *trend = THERMAL_TREND_RAISING; 256 *trend = THERMAL_TREND_RAISING;
273 else if (tr < 0) 257 else if (tr < 0)
@@ -278,6 +262,13 @@ static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
278 return 0; 262 return 0;
279} 263}
280 264
265/* Get the temperature trend callback functions for thermal zone */
266static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
267 int trip, enum thermal_trend *trend)
268{
269 return __ti_thermal_get_trend(thermal->devdata, trip, trend);
270}
271
281/* Get critical temperature callback functions for thermal zone */ 272/* Get critical temperature callback functions for thermal zone */
282static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal, 273static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
283 int *temp) 274 int *temp)
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 20118b9ebeb7..b3c16f06fdc4 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -350,7 +350,7 @@ struct thermal_genl_event {
350 */ 350 */
351struct thermal_zone_of_device_ops { 351struct thermal_zone_of_device_ops {
352 int (*get_temp)(void *, int *); 352 int (*get_temp)(void *, int *);
353 int (*get_trend)(void *, long *); 353 int (*get_trend)(void *, int, enum thermal_trend *);
354 int (*set_trips)(void *, int, int); 354 int (*set_trips)(void *, int, int);
355 int (*set_emul_temp)(void *, int); 355 int (*set_emul_temp)(void *, int);
356 int (*set_trip_temp)(void *, int, int); 356 int (*set_trip_temp)(void *, int, int);