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
6 Add apis for platform thermal drivers to query for slope and offset
7 attributes, which might be needed for temperature calculations.
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>
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(+)
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.
24 +1.1.7 int thermal_zone_get_slope(struct thermal_zone_device *tz)
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.
30 +1.1.8 int thermal_zone_get_offset(struct thermal_zone_device *tz)
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.
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:
43 EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);
46 + * thermal_zone_get_slope - return the slope attribute of the thermal zone
47 + * @tz: thermal zone device with the slope attribute
49 + * Return: If the thermal zone device has a slope attribute, return it, else
52 +int thermal_zone_get_slope(struct thermal_zone_device *tz)
55 + return tz->tzp->slope;
58 +EXPORT_SYMBOL_GPL(thermal_zone_get_slope);
61 + * thermal_zone_get_offset - return the offset attribute of the thermal zone
62 + * @tz: thermal zone device with the offset attribute
64 + * Return: If the thermal zone device has a offset attribute, return it, else
67 +int thermal_zone_get_offset(struct thermal_zone_device *tz)
70 + return tz->tzp->offset;
73 +EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
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);
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)
93 +static inline int thermal_zone_get_slope(
94 + struct thermal_zone_device *tz)
96 +static inline int thermal_zone_get_offset(
97 + struct thermal_zone_device *tz)
99 static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
101 static inline struct thermal_instance *