kernel: update kernel 4.1 to version 4.1.20
[openwrt.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 --- a/drivers/thermal/of-thermal.c
29 +++ b/drivers/thermal/of-thermal.c
30 @@ -187,24 +187,15 @@ static int of_thermal_get_trend(struct t
31                                 enum thermal_trend *trend)
32  {
33         struct __thermal_zone *data = tz->devdata;
34 -       long dev_trend;
35         int r;
36  
37         if (!data->ops->get_trend)
38                 return -EINVAL;
39  
40 -       r = data->ops->get_trend(data->sensor_data, &dev_trend);
41 +       r = data->ops->get_trend(data->sensor_data, trip, trend);
42         if (r)
43                 return r;
44  
45 -       /* TODO: These intervals might have some thresholds, but in core code */
46 -       if (dev_trend > 0)
47 -               *trend = THERMAL_TREND_RAISING;
48 -       else if (dev_trend < 0)
49 -               *trend = THERMAL_TREND_DROPPING;
50 -       else
51 -               *trend = THERMAL_TREND_STABLE;
52 -
53         return 0;
54  }
55  
56 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
57 +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
58 @@ -238,7 +238,7 @@ static int ti_thermal_get_trip_temp(stru
59         return 0;
60  }
61  
62 -static int __ti_thermal_get_trend(void *p, long *trend)
63 +static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
64  {
65         struct ti_thermal_data *data = p;
66         struct ti_bandgap *bgp;
67 @@ -251,22 +251,6 @@ static int __ti_thermal_get_trend(void *
68         if (ret)
69                 return ret;
70  
71 -       *trend = tr;
72 -
73 -       return 0;
74 -}
75 -
76 -/* Get the temperature trend callback functions for thermal zone */
77 -static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
78 -                               int trip, enum thermal_trend *trend)
79 -{
80 -       int ret;
81 -       long tr;
82 -
83 -       ret = __ti_thermal_get_trend(thermal->devdata, &tr);
84 -       if (ret)
85 -               return ret;
86 -
87         if (tr > 0)
88                 *trend = THERMAL_TREND_RAISING;
89         else if (tr < 0)
90 @@ -277,6 +261,13 @@ static int ti_thermal_get_trend(struct t
91         return 0;
92  }
93  
94 +/* Get the temperature trend callback functions for thermal zone */
95 +static int ti_thermal_get_trend(struct thermal_zone_device *thermal,
96 +                               int trip, enum thermal_trend *trend)
97 +{
98 +       return __ti_thermal_get_trend(thermal->devdata, trip, trend);
99 +}
100 +
101  /* Get critical temperature callback functions for thermal zone */
102  static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
103                                     int *temp)
104 --- a/include/linux/thermal.h
105 +++ b/include/linux/thermal.h
106 @@ -274,7 +274,7 @@ struct thermal_genl_event {
107   */
108  struct thermal_zone_of_device_ops {
109         int (*get_temp)(void *, int *);
110 -       int (*get_trend)(void *, long *);
111 +       int (*get_trend)(void *, int, enum thermal_trend *);
112         int (*set_emul_temp)(void *, int);
113  };
114