Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932132AbcKHFK1 (ORCPT ); Tue, 8 Nov 2016 00:10:27 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35242 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753076AbcKHFKY (ORCPT ); Tue, 8 Nov 2016 00:10:24 -0500 From: Eduardo Valentin To: Rui Zhang Cc: LKML , Linux PM , Eduardo Valentin Subject: [PATCHv2 17/49] thermal: core: split policy_store Date: Mon, 7 Nov 2016 21:08:55 -0800 Message-Id: <1478581767-7009-18-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1478581767-7009-1-git-send-email-edubezval@gmail.com> References: <1478581767-7009-1-git-send-email-edubezval@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2507 Lines: 89 Similarly to passive_store, policy_store now is split between thermal core data structure handling and sysfs handling. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_core.c | 37 ++++++++++++++++++++++++------------- drivers/thermal/thermal_core.h | 1 + 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 4e315c9..23f138f 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; } diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index a765c75..db65d3b 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -60,6 +60,7 @@ void thermal_zone_device_rebind_exception(struct thermal_zone_device *, const char *, size_t); 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 *); #ifdef CONFIG_THERMAL_GOV_STEP_WISE int thermal_gov_step_wise_register(void); -- 2.1.4