mediatek: add support for the new MT7623 Arm SoC
[openwrt/staging/yousong.git] / target / linux / mediatek / patches / 0021-thermal-of-implement-.set_trips-for-device-tree-ther.patch
1 From 525f68bb9d9f6334dbcd2b5ec99f9d797ff53618 Mon Sep 17 00:00:00 2001
2 From: Sascha Hauer <s.hauer@pengutronix.de>
3 Date: Wed, 13 May 2015 10:52:40 +0200
4 Subject: [PATCH 21/76] thermal: of: implement .set_trips for device tree
5 thermal zones
6
7 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
8 ---
9 drivers/thermal/of-thermal.c | 12 ++++++++++++
10 include/linux/thermal.h | 3 +++
11 2 files changed, 15 insertions(+)
12
13 diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
14 index bd3185e..f8dd847 100644
15 --- a/drivers/thermal/of-thermal.c
16 +++ b/drivers/thermal/of-thermal.c
17 @@ -97,6 +97,17 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
18 return data->ops->get_temp(data->sensor_data, temp);
19 }
20
21 +static int of_thermal_set_trips(struct thermal_zone_device *tz,
22 + int low, int high)
23 +{
24 + struct __thermal_zone *data = tz->devdata;
25 +
26 + if (!data->ops || !data->ops->set_trips)
27 + return -ENOSYS;
28 +
29 + return data->ops->set_trips(data->sensor_data, low, high);
30 +}
31 +
32 /**
33 * of_thermal_get_ntrips - function to export number of available trip
34 * points.
35 @@ -367,6 +378,7 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
36
37 static const struct thermal_zone_device_ops of_thermal_ops = {
38 .get_temp = of_thermal_get_temp,
39 + .set_trips = of_thermal_set_trips,
40 .get_trend = of_thermal_get_trend,
41 .set_emul_temp = of_thermal_set_emul_temp,
42
43 diff --git a/include/linux/thermal.h b/include/linux/thermal.h
44 index aef6e13..b751f6b 100644
45 --- a/include/linux/thermal.h
46 +++ b/include/linux/thermal.h
47 @@ -267,12 +267,15 @@ struct thermal_genl_event {
48 *
49 * Optional:
50 * @get_trend: a pointer to a function that reads the sensor temperature trend.
51 + * @set_trips: a pointer to a function that sets a temperature window which shall
52 + * trigger an interrupt when it is left.
53 * @set_emul_temp: a pointer to a function that sets sensor emulated
54 * temperature.
55 */
56 struct thermal_zone_of_device_ops {
57 int (*get_temp)(void *, int *);
58 int (*get_trend)(void *, int, enum thermal_trend *);
59 + int (*set_trips)(void *, int, int);
60 int (*set_emul_temp)(void *, int);
61 };
62
63 --
64 1.7.10.4
65