Commit 97d2423b authored by Eduardo Valentin's avatar Eduardo Valentin Committed by Zhang Rui

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: default avatarEduardo Valentin <edubezval@gmail.com>
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
parent 6b885202
...@@ -779,6 +779,25 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz, ...@@ -779,6 +779,25 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
return ret; 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 */ /* sys I/F for thermal zone */
#define to_thermal_zone(_dev) \ #define to_thermal_zone(_dev) \
...@@ -1048,21 +1067,7 @@ static ssize_t ...@@ -1048,21 +1067,7 @@ static ssize_t
available_policies_show(struct device *dev, struct device_attribute *devattr, available_policies_show(struct device *dev, struct device_attribute *devattr,
char *buf) char *buf)
{ {
struct thermal_governor *pos; return thermal_build_list_of_policies(buf);
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;
} }
static ssize_t static ssize_t
......
...@@ -61,6 +61,7 @@ void thermal_zone_device_rebind_exception(struct thermal_zone_device *, ...@@ -61,6 +61,7 @@ void thermal_zone_device_rebind_exception(struct thermal_zone_device *,
void thermal_zone_device_unbind_exception(struct thermal_zone_device *, void thermal_zone_device_unbind_exception(struct thermal_zone_device *,
const char *, size_t); const char *, size_t);
int thermal_zone_device_set_policy(struct thermal_zone_device *, char *); 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 #ifdef CONFIG_THERMAL_GOV_STEP_WISE
int thermal_gov_step_wise_register(void); int thermal_gov_step_wise_register(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment