summaryrefslogtreecommitdiff
path: root/drivers/thermal/thermal_core.c
diff options
context:
space:
mode:
authorEduardo Valentin <edubezval@gmail.com>2016-11-07 21:08:56 -0800
committerZhang Rui <rui.zhang@intel.com>2016-11-23 10:06:12 +0800
commit97d2423bd9738bb75cd716d01c4c4e1d6fae8441 (patch)
treecd032fb598591ce3555287a7d5fdf1861cb13195 /drivers/thermal/thermal_core.c
parent6b885202d7c17157a44d5cb42793f795d6d7a58e (diff)
thermal: core: split available_policies_show()
This patch creates a helper to build a list of available governors. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/thermal_core.c')
-rw-r--r--drivers/thermal/thermal_core.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 23f138f7eb68..3d5118473eb0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -779,6 +779,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) \
@@ -1048,21 +1067,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