libubox: update to the latest version
[openwrt/openwrt.git] / target / linux / generic / pending-4.4 / 086-0002-thermal-core-export-apis-to-get-slope-and-offset.patch
1 From 4a7069a32c99a81950de035535b0a064dcceaeba Mon Sep 17 00:00:00 2001
2 From: Rajendra Nayak <rnayak@codeaurora.org>
3 Date: Thu, 5 May 2016 14:21:42 +0530
4 Subject: [PATCH] thermal: core: export apis to get slope and offset
5
6 Add apis for platform thermal drivers to query for slope and offset
7 attributes, which might be needed for temperature calculations.
8
9 Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
10 Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
11 Signed-off-by: Zhang Rui <rui.zhang@intel.com>
12 ---
13 Documentation/thermal/sysfs-api.txt | 12 ++++++++++++
14 drivers/thermal/thermal_core.c | 30 ++++++++++++++++++++++++++++++
15 include/linux/thermal.h | 8 ++++++++
16 3 files changed, 50 insertions(+)
17
18 --- a/Documentation/thermal/sysfs-api.txt
19 +++ b/Documentation/thermal/sysfs-api.txt
20 @@ -72,6 +72,18 @@ temperature) and throttle appropriate de
21 It deletes the corresponding entry form /sys/class/thermal folder and
22 unbind all the thermal cooling devices it uses.
23
24 +1.1.7 int thermal_zone_get_slope(struct thermal_zone_device *tz)
25 +
26 + This interface is used to read the slope attribute value
27 + for the thermal zone device, which might be useful for platform
28 + drivers for temperature calculations.
29 +
30 +1.1.8 int thermal_zone_get_offset(struct thermal_zone_device *tz)
31 +
32 + This interface is used to read the offset attribute value
33 + for the thermal zone device, which might be useful for platform
34 + drivers for temperature calculations.
35 +
36 1.2 thermal cooling device interface
37 1.2.1 struct thermal_cooling_device *thermal_cooling_device_register(char *name,
38 void *devdata, struct thermal_cooling_device_ops *)
39 --- a/drivers/thermal/thermal_core.c
40 +++ b/drivers/thermal/thermal_core.c
41 @@ -2061,6 +2061,36 @@ exit:
42 }
43 EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);
44
45 +/**
46 + * thermal_zone_get_slope - return the slope attribute of the thermal zone
47 + * @tz: thermal zone device with the slope attribute
48 + *
49 + * Return: If the thermal zone device has a slope attribute, return it, else
50 + * return 1.
51 + */
52 +int thermal_zone_get_slope(struct thermal_zone_device *tz)
53 +{
54 + if (tz && tz->tzp)
55 + return tz->tzp->slope;
56 + return 1;
57 +}
58 +EXPORT_SYMBOL_GPL(thermal_zone_get_slope);
59 +
60 +/**
61 + * thermal_zone_get_offset - return the offset attribute of the thermal zone
62 + * @tz: thermal zone device with the offset attribute
63 + *
64 + * Return: If the thermal zone device has a offset attribute, return it, else
65 + * return 0.
66 + */
67 +int thermal_zone_get_offset(struct thermal_zone_device *tz)
68 +{
69 + if (tz && tz->tzp)
70 + return tz->tzp->offset;
71 + return 0;
72 +}
73 +EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
74 +
75 #ifdef CONFIG_NET
76 static const struct genl_multicast_group thermal_event_mcgrps[] = {
77 { .name = THERMAL_GENL_MCAST_GROUP_NAME, },
78 --- a/include/linux/thermal.h
79 +++ b/include/linux/thermal.h
80 @@ -432,6 +432,8 @@ thermal_of_cooling_device_register(struc
81 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
82 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
83 int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
84 +int thermal_zone_get_slope(struct thermal_zone_device *tz);
85 +int thermal_zone_get_offset(struct thermal_zone_device *tz);
86
87 int get_tz_trend(struct thermal_zone_device *, int);
88 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
89 @@ -489,6 +491,12 @@ static inline struct thermal_zone_device
90 static inline int thermal_zone_get_temp(
91 struct thermal_zone_device *tz, int *temp)
92 { return -ENODEV; }
93 +static inline int thermal_zone_get_slope(
94 + struct thermal_zone_device *tz)
95 +{ return -ENODEV; }
96 +static inline int thermal_zone_get_offset(
97 + struct thermal_zone_device *tz)
98 +{ return -ENODEV; }
99 static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
100 { return -ENODEV; }
101 static inline struct thermal_instance *