diff options
author | Eduardo Valentin <edubezval@gmail.com> | 2016-11-08 08:08:55 +0300 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2016-11-23 05:06:12 +0300 |
commit | 6b885202d7c17157a44d5cb42793f795d6d7a58e (patch) | |
tree | 0da2e2247a5e3f85d02f61ebe984ea1b0c1efdaa /drivers/thermal/thermal_core.c | |
parent | 3d0055d2b252d9bbae8c064b37dd444b77f4c4c1 (diff) | |
download | linux-6b885202d7c17157a44d5cb42793f795d6d7a58e.tar.xz |
thermal: core: split policy_store
Similarly to passive_store, policy_store now is split
between thermal core data structure handling and sysfs handling.
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.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 4e315c979f89..23f138f7eb68 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -757,6 +757,28 @@ void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz, mutex_unlock(&thermal_list_lock); } +int thermal_zone_device_set_policy(struct thermal_zone_device *tz, + char *policy) +{ + struct thermal_governor *gov; + int ret = -EINVAL; + + mutex_lock(&thermal_governor_lock); + mutex_lock(&tz->lock); + + gov = __find_governor(strim(policy)); + if (!gov) + goto exit; + + ret = thermal_set_governor(tz, gov); + +exit: + mutex_unlock(&tz->lock); + mutex_unlock(&thermal_governor_lock); + + return ret; +} + /* sys I/F for thermal zone */ #define to_thermal_zone(_dev) \ @@ -1001,27 +1023,16 @@ static ssize_t policy_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret = -EINVAL; struct thermal_zone_device *tz = to_thermal_zone(dev); - struct thermal_governor *gov; char name[THERMAL_NAME_LENGTH]; + int ret; snprintf(name, sizeof(name), "%s", buf); - mutex_lock(&thermal_governor_lock); - mutex_lock(&tz->lock); - - gov = __find_governor(strim(name)); - if (!gov) - goto exit; - - ret = thermal_set_governor(tz, gov); + ret = thermal_zone_device_set_policy(tz, name); if (!ret) ret = count; -exit: - mutex_unlock(&tz->lock); - mutex_unlock(&thermal_governor_lock); return ret; } |