1 From 5da86f6a2b4c2c318e153649dc8fd34fe73f8292 Mon Sep 17 00:00:00 2001
2 From: Sascha Hauer <s.hauer@pengutronix.de>
3 Date: Wed, 13 May 2015 10:52:35 +0200
4 Subject: [PATCH 16/76] thermal: streamline get_trend callbacks
6 The .get_trend callback in struct thermal_zone_device_ops has the prototype:
8 int (*get_trend) (struct thermal_zone_device *, int,
11 whereas the .get_trend callback in struct thermal_zone_of_device_ops has:
13 int (*get_trend)(void *, long *);
15 Streamline both prototypes and add the trip argument to the OF callback
16 aswell and use enum thermal_trend * instead of an integer pointer.
18 While the OF prototype may be the better one, this should be decided at
19 framework level and not on OF level.
21 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
23 drivers/thermal/of-thermal.c | 11 +--------
24 drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 25 +++++++-------------
25 include/linux/thermal.h | 2 +-
26 3 files changed, 10 insertions(+), 28 deletions(-)
28 diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
29 index 03839df..c84404d 100644
30 --- a/drivers/thermal/of-thermal.c
31 +++ b/drivers/thermal/of-thermal.c
32 @@ -187,24 +187,15 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
33 enum thermal_trend *trend)
35 struct __thermal_zone *data = tz->devdata;
39 if (!data->ops->get_trend)
42 - r = data->ops->get_trend(data->sensor_data, &dev_trend);
43 + r = data->ops->get_trend(data->sensor_data, trip, trend);
47 - /* TODO: These intervals might have some thresholds, but in core code */
49 - *trend = THERMAL_TREND_RAISING;
50 - else if (dev_trend < 0)
51 - *trend = THERMAL_TREND_DROPPING;
53 - *trend = THERMAL_TREND_STABLE;
58 diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
59 index d3a42bf..ade78eb 100644
60 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
61 +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
62 @@ -238,7 +238,7 @@ static int ti_thermal_get_trip_temp(struct thermal_zone_device *thermal,
66 -static int __ti_thermal_get_trend(void *p, long *trend)
67 +static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
69 struct ti_thermal_data *data = p;
70 struct ti_bandgap *bgp;
71 @@ -251,22 +251,6 @@ static int __ti_thermal_get_trend(void *p, long *trend)
80 -/* Get the temperature trend callback functions for thermal zone */
81 -static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
82 - int trip, enum thermal_trend *trend)
87 - ret = __ti_thermal_get_trend(thermal->devdata, &tr);
92 *trend = THERMAL_TREND_RAISING;
94 @@ -277,6 +261,13 @@ static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
98 +/* Get the temperature trend callback functions for thermal zone */
99 +static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
100 + int trip, enum thermal_trend *trend)
102 + return __ti_thermal_get_trend(thermal->devdata, trip, trend);
105 /* Get critical temperature callback functions for thermal zone */
106 static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
108 diff --git a/include/linux/thermal.h b/include/linux/thermal.h
109 index e9f2863..5c6a589 100644
110 --- a/include/linux/thermal.h
111 +++ b/include/linux/thermal.h
112 @@ -269,7 +269,7 @@ struct thermal_genl_event {
114 struct thermal_zone_of_device_ops {
115 int (*get_temp)(void *, int *);
116 - int (*get_trend)(void *, long *);
117 + int (*get_trend)(void *, int, enum thermal_trend *);
118 int (*set_emul_temp)(void *, int);