]> git.karo-electronics.de Git - linux-beck.git/commitdiff
thermal: core: split available_policies_show()
authorEduardo Valentin <edubezval@gmail.com>
Tue, 8 Nov 2016 05:08:56 +0000 (21:08 -0800)
committerZhang Rui <rui.zhang@intel.com>
Wed, 23 Nov 2016 02:06:12 +0000 (10:06 +0800)
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>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h

index 23f138f7eb68b386094e0cec3c46963c132f18a6..3d5118473eb089df61c86cf3e0feed7b2325f8a5 100644 (file)
@@ -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
index db65d3b08cf71cba3a0098d51a64a3e6cccfd311..8994d2a379c317f5745a0e98e9c1952b77d96bdf 100644 (file)
@@ -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);