[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1464646584-14322-19-git-send-email-edubezval@gmail.com>
Date: Mon, 30 May 2016 15:15:54 -0700
From: Eduardo Valentin <edubezval@...il.com>
To: Rui Zhang <rui.zhang@...el.com>
Cc: Linux PM <linux-pm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Eduardo Valentin <edubezval@...il.com>
Subject: [PATCHv3 18/48] thermal: core: split available_policies_show()
This patch creates a helper to build a list of available governors.
Cc: Zhang Rui <rui.zhang@...el.com>
Cc: linux-pm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@...il.com>
---
drivers/thermal/thermal_core.c | 35 ++++++++++++++++++++---------------
drivers/thermal/thermal_core.h | 1 +
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 078b260..d3f7124 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -722,6 +722,25 @@ exit:
return ret;
}
+int thermal_build_list_of_policies(char *buf)
+{
+ struct thermal_governor *pos;
+ ssize_t count = 0;
+ ssize_t size = PAGE_SIZE;
+
+ mutex_lock(&thermal_governor_lock);
+
+ list_for_each_entry(pos, &thermal_governor_list, governor_list) {
+ size = PAGE_SIZE - count;
+ count += scnprintf(buf + count, size, "%s ", pos->name);
+ }
+ count += scnprintf(buf + count, size, "\n");
+
+ mutex_unlock(&thermal_governor_lock);
+
+ return count;
+}
+
/* sys I/F for thermal zone */
#define to_thermal_zone(_dev) \
@@ -988,21 +1007,7 @@ static ssize_t
available_policies_show(struct device *dev, struct device_attribute *devattr,
char *buf)
{
- struct thermal_governor *pos;
- ssize_t count = 0;
- ssize_t size = PAGE_SIZE;
-
- mutex_lock(&thermal_governor_lock);
-
- list_for_each_entry(pos, &thermal_governor_list, governor_list) {
- size = PAGE_SIZE - count;
- count += scnprintf(buf + count, size, "%s ", pos->name);
- }
- count += scnprintf(buf + count, size, "\n");
-
- mutex_unlock(&thermal_governor_lock);
-
- return count;
+ return thermal_build_list_of_policies(buf);
}
static ssize_t
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index db65d3b..8994d2a 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -61,6 +61,7 @@ void thermal_zone_device_rebind_exception(struct thermal_zone_device *,
void thermal_zone_device_unbind_exception(struct thermal_zone_device *,
const char *, size_t);
int thermal_zone_device_set_policy(struct thermal_zone_device *, char *);
+int thermal_build_list_of_policies(char *buf);
#ifdef CONFIG_THERMAL_GOV_STEP_WISE
int thermal_gov_step_wise_register(void);
--
2.1.4
Powered by blists - more mailing lists