mediatek: add support for the new MT7623 Arm SoC
[openwrt/svn-archive/archive.git] / target / linux / mediatek / patches / 0016-thermal-streamline-get_trend-callbacks.patch
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
5
6 The .get_trend callback in struct thermal_zone_device_ops has the prototype:
7
8 int (*get_trend) (struct thermal_zone_device *, int,
9 enum thermal_trend *);
10
11 whereas the .get_trend callback in struct thermal_zone_of_device_ops has:
12
13 int (*get_trend)(void *, long *);
14
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.
17
18 While the OF prototype may be the better one, this should be decided at
19 framework level and not on OF level.
20
21 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
22 ---
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(-)
27
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)
34 {
35 struct __thermal_zone *data = tz->devdata;
36 - long dev_trend;
37 int r;
38
39 if (!data->ops->get_trend)
40 return -EINVAL;
41
42 - r = data->ops->get_trend(data->sensor_data, &dev_trend);
43 + r = data->ops->get_trend(data->sensor_data, trip, trend);
44 if (r)
45 return r;
46
47 - /* TODO: These intervals might have some thresholds, but in core code */
48 - if (dev_trend > 0)
49 - *trend = THERMAL_TREND_RAISING;
50 - else if (dev_trend < 0)
51 - *trend = THERMAL_TREND_DROPPING;
52 - else
53 - *trend = THERMAL_TREND_STABLE;
54 -
55 return 0;
56 }
57
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,
63 return 0;
64 }
65
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)
68 {
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)
72 if (ret)
73 return ret;
74
75 - *trend = tr;
76 -
77 - return 0;
78 -}
79 -
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)
83 -{
84 - int ret;
85 - long tr;
86 -
87 - ret = __ti_thermal_get_trend(thermal->devdata, &tr);
88 - if (ret)
89 - return ret;
90 -
91 if (tr > 0)
92 *trend = THERMAL_TREND_RAISING;
93 else if (tr < 0)
94 @@ -277,6 +261,13 @@ static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
95 return 0;
96 }
97
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)
101 +{
102 + return __ti_thermal_get_trend(thermal->devdata, trip, trend);
103 +}
104 +
105 /* Get critical temperature callback functions for thermal zone */
106 static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
107 int *temp)
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 {
113 */
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);
119 };
120
121 --
122 1.7.10.4
123