mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2025-03-01 05:41:22 +00:00
131 lines
4.0 KiB
Diff
131 lines
4.0 KiB
Diff
From 61aea8433aba4b8b40dfc777b59afc157a8fd32a Mon Sep 17 00:00:00 2001
|
|
From: Lukasz Luba <l.luba@partner.samsung.com>
|
|
Date: Wed, 7 Nov 2018 18:09:45 +0100
|
|
Subject: [PATCH 17/25] MEMEKA: thermal: add new sysfs file for irq-mode
|
|
|
|
Patch adds show functions for irq-mode feature.
|
|
It allocates new attributes and extends the old list.
|
|
|
|
Cc: Zhang Rui <rui.zhang@intel.com>
|
|
Cc: Eduardo Valentin <edubezval@gmail.com>
|
|
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
|
|
Signed-off-by: memeka <mihailescu2m@gmail.com>
|
|
---
|
|
drivers/thermal/thermal_sysfs.c | 53 +++++++++++++++++++++++++++++++--
|
|
1 file changed, 51 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
|
|
index aa99edb4dff7..e3ede8af79cc 100644
|
|
--- a/drivers/thermal/thermal_sysfs.c
|
|
+++ b/drivers/thermal/thermal_sysfs.c
|
|
@@ -21,6 +21,8 @@
|
|
|
|
#include "thermal_core.h"
|
|
|
|
+#define TRIP_ATTR_NUM 4
|
|
+
|
|
/* sys I/F for thermal zone */
|
|
|
|
static ssize_t
|
|
@@ -166,6 +168,28 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,
|
|
return sprintf(buf, "%d\n", temperature);
|
|
}
|
|
|
|
+static ssize_t
|
|
+trip_point_irq_mode_show(struct device *dev, struct device_attribute *attr,
|
|
+ char *buf)
|
|
+{
|
|
+ struct thermal_zone_device *tz = to_thermal_zone(dev);
|
|
+ int trip, ret;
|
|
+ bool mode;
|
|
+
|
|
+ if (!tz->ops->get_trip_irq_mode)
|
|
+ return -EPERM;
|
|
+
|
|
+ if (sscanf(attr->attr.name, "trip_point_%d_irq", &trip) != 1)
|
|
+ return -EINVAL;
|
|
+
|
|
+ ret = tz->ops->get_trip_irq_mode(tz, trip, &mode);
|
|
+
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return sprintf(buf, "%d\n", mode);
|
|
+}
|
|
+
|
|
static ssize_t
|
|
trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
|
|
const char *buf, size_t count)
|
|
@@ -520,10 +544,19 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
|
|
if (!tz->trip_type_attrs)
|
|
return -ENOMEM;
|
|
|
|
+ tz->trip_irq_mode_attrs = kcalloc(tz->trips,
|
|
+ sizeof(*tz->trip_irq_mode_attrs),
|
|
+ GFP_KERNEL);
|
|
+ if (!tz->trip_irq_mode_attrs) {
|
|
+ kfree(tz->trip_type_attrs);
|
|
+ return -ENOMEM;
|
|
+ }
|
|
+
|
|
tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs),
|
|
GFP_KERNEL);
|
|
if (!tz->trip_temp_attrs) {
|
|
kfree(tz->trip_type_attrs);
|
|
+ kfree(tz->trip_irq_mode_attrs);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
@@ -533,14 +566,17 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
|
|
GFP_KERNEL);
|
|
if (!tz->trip_hyst_attrs) {
|
|
kfree(tz->trip_type_attrs);
|
|
+ kfree(tz->trip_irq_mode_attrs);
|
|
kfree(tz->trip_temp_attrs);
|
|
return -ENOMEM;
|
|
}
|
|
}
|
|
|
|
- attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL);
|
|
+ attrs = kcalloc(tz->trips * TRIP_ATTR_NUM + 1, sizeof(*attrs),
|
|
+ GFP_KERNEL);
|
|
if (!attrs) {
|
|
kfree(tz->trip_type_attrs);
|
|
+ kfree(tz->trip_irq_mode_attrs);
|
|
kfree(tz->trip_temp_attrs);
|
|
if (tz->ops->get_trip_hyst)
|
|
kfree(tz->trip_hyst_attrs);
|
|
@@ -559,6 +595,19 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
|
|
tz->trip_type_attrs[indx].attr.show = trip_point_type_show;
|
|
attrs[indx] = &tz->trip_type_attrs[indx].attr.attr;
|
|
|
|
+ /* create trip irq_mode attribute */
|
|
+ snprintf(tz->trip_irq_mode_attrs[indx].name,
|
|
+ THERMAL_NAME_LENGTH, "trip_point_%d_irq", indx);
|
|
+
|
|
+ sysfs_attr_init(&tz->trip_irq_mode_attrs[indx].attr.attr);
|
|
+ tz->trip_irq_mode_attrs[indx].attr.attr.name =
|
|
+ tz->trip_irq_mode_attrs[indx].name;
|
|
+ tz->trip_irq_mode_attrs[indx].attr.attr.mode = S_IRUGO;
|
|
+ tz->trip_irq_mode_attrs[indx].attr.show =
|
|
+ trip_point_irq_mode_show;
|
|
+ attrs[indx + tz->trips * 3] =
|
|
+ &tz->trip_irq_mode_attrs[indx].attr.attr;
|
|
+
|
|
/* create trip temp attribute */
|
|
snprintf(tz->trip_temp_attrs[indx].name, THERMAL_NAME_LENGTH,
|
|
"trip_point_%d_temp", indx);
|
|
@@ -595,7 +644,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
|
|
attrs[indx + tz->trips * 2] =
|
|
&tz->trip_hyst_attrs[indx].attr.attr;
|
|
}
|
|
- attrs[tz->trips * 3] = NULL;
|
|
+ attrs[tz->trips * TRIP_ATTR_NUM] = NULL;
|
|
|
|
tz->trips_attribute_group.attrs = attrs;
|
|
|
|
--
|
|
2.17.1
|
|
|