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>
This commit is contained in:
Родитель
3d0055d2b2
Коммит
6b885202d7
|
@ -757,6 +757,28 @@ void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz,
|
||||||
mutex_unlock(&thermal_list_lock);
|
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 */
|
/* sys I/F for thermal zone */
|
||||||
|
|
||||||
#define to_thermal_zone(_dev) \
|
#define to_thermal_zone(_dev) \
|
||||||
|
@ -1001,27 +1023,16 @@ static ssize_t
|
||||||
policy_store(struct device *dev, struct device_attribute *attr,
|
policy_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
int ret = -EINVAL;
|
|
||||||
struct thermal_zone_device *tz = to_thermal_zone(dev);
|
struct thermal_zone_device *tz = to_thermal_zone(dev);
|
||||||
struct thermal_governor *gov;
|
|
||||||
char name[THERMAL_NAME_LENGTH];
|
char name[THERMAL_NAME_LENGTH];
|
||||||
|
int ret;
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s", buf);
|
snprintf(name, sizeof(name), "%s", buf);
|
||||||
|
|
||||||
mutex_lock(&thermal_governor_lock);
|
ret = thermal_zone_device_set_policy(tz, name);
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
|
|
||||||
gov = __find_governor(strim(name));
|
|
||||||
if (!gov)
|
|
||||||
goto exit;
|
|
||||||
|
|
||||||
ret = thermal_set_governor(tz, gov);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = count;
|
ret = count;
|
||||||
|
|
||||||
exit:
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
mutex_unlock(&thermal_governor_lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ void thermal_zone_device_rebind_exception(struct thermal_zone_device *,
|
||||||
const char *, size_t);
|
const char *, size_t);
|
||||||
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 *);
|
||||||
|
|
||||||
#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);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче