mirror of https://github.com/hak5/openwrt-owl.git
102 lines
3.8 KiB
Diff
102 lines
3.8 KiB
Diff
From 4a7069a32c99a81950de035535b0a064dcceaeba Mon Sep 17 00:00:00 2001
|
|
From: Rajendra Nayak <rnayak@codeaurora.org>
|
|
Date: Thu, 5 May 2016 14:21:42 +0530
|
|
Subject: [PATCH] thermal: core: export apis to get slope and offset
|
|
|
|
Add apis for platform thermal drivers to query for slope and offset
|
|
attributes, which might be needed for temperature calculations.
|
|
|
|
Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
|
|
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
|
|
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
|
|
---
|
|
Documentation/thermal/sysfs-api.txt | 12 ++++++++++++
|
|
drivers/thermal/thermal_core.c | 30 ++++++++++++++++++++++++++++++
|
|
include/linux/thermal.h | 8 ++++++++
|
|
3 files changed, 50 insertions(+)
|
|
|
|
--- a/Documentation/thermal/sysfs-api.txt
|
|
+++ b/Documentation/thermal/sysfs-api.txt
|
|
@@ -72,6 +72,18 @@ temperature) and throttle appropriate de
|
|
It deletes the corresponding entry form /sys/class/thermal folder and
|
|
unbind all the thermal cooling devices it uses.
|
|
|
|
+1.1.7 int thermal_zone_get_slope(struct thermal_zone_device *tz)
|
|
+
|
|
+ This interface is used to read the slope attribute value
|
|
+ for the thermal zone device, which might be useful for platform
|
|
+ drivers for temperature calculations.
|
|
+
|
|
+1.1.8 int thermal_zone_get_offset(struct thermal_zone_device *tz)
|
|
+
|
|
+ This interface is used to read the offset attribute value
|
|
+ for the thermal zone device, which might be useful for platform
|
|
+ drivers for temperature calculations.
|
|
+
|
|
1.2 thermal cooling device interface
|
|
1.2.1 struct thermal_cooling_device *thermal_cooling_device_register(char *name,
|
|
void *devdata, struct thermal_cooling_device_ops *)
|
|
--- a/drivers/thermal/thermal_core.c
|
|
+++ b/drivers/thermal/thermal_core.c
|
|
@@ -2061,6 +2061,36 @@ exit:
|
|
}
|
|
EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name);
|
|
|
|
+/**
|
|
+ * thermal_zone_get_slope - return the slope attribute of the thermal zone
|
|
+ * @tz: thermal zone device with the slope attribute
|
|
+ *
|
|
+ * Return: If the thermal zone device has a slope attribute, return it, else
|
|
+ * return 1.
|
|
+ */
|
|
+int thermal_zone_get_slope(struct thermal_zone_device *tz)
|
|
+{
|
|
+ if (tz && tz->tzp)
|
|
+ return tz->tzp->slope;
|
|
+ return 1;
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(thermal_zone_get_slope);
|
|
+
|
|
+/**
|
|
+ * thermal_zone_get_offset - return the offset attribute of the thermal zone
|
|
+ * @tz: thermal zone device with the offset attribute
|
|
+ *
|
|
+ * Return: If the thermal zone device has a offset attribute, return it, else
|
|
+ * return 0.
|
|
+ */
|
|
+int thermal_zone_get_offset(struct thermal_zone_device *tz)
|
|
+{
|
|
+ if (tz && tz->tzp)
|
|
+ return tz->tzp->offset;
|
|
+ return 0;
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
|
|
+
|
|
#ifdef CONFIG_NET
|
|
static const struct genl_multicast_group thermal_event_mcgrps[] = {
|
|
{ .name = THERMAL_GENL_MCAST_GROUP_NAME, },
|
|
--- a/include/linux/thermal.h
|
|
+++ b/include/linux/thermal.h
|
|
@@ -432,6 +432,8 @@ thermal_of_cooling_device_register(struc
|
|
void thermal_cooling_device_unregister(struct thermal_cooling_device *);
|
|
struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
|
|
int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
|
|
+int thermal_zone_get_slope(struct thermal_zone_device *tz);
|
|
+int thermal_zone_get_offset(struct thermal_zone_device *tz);
|
|
|
|
int get_tz_trend(struct thermal_zone_device *, int);
|
|
struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
|
|
@@ -489,6 +491,12 @@ static inline struct thermal_zone_device
|
|
static inline int thermal_zone_get_temp(
|
|
struct thermal_zone_device *tz, int *temp)
|
|
{ return -ENODEV; }
|
|
+static inline int thermal_zone_get_slope(
|
|
+ struct thermal_zone_device *tz)
|
|
+{ return -ENODEV; }
|
|
+static inline int thermal_zone_get_offset(
|
|
+ struct thermal_zone_device *tz)
|
|
+{ return -ENODEV; }
|
|
static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
|
|
{ return -ENODEV; }
|
|
static inline struct thermal_instance *
|