From patchwork Wed May 4 06:02:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9010471 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2426D9F1C1 for ; Wed, 4 May 2016 06:07:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FCB7202EC for ; Wed, 4 May 2016 06:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 188A8202B8 for ; Wed, 4 May 2016 06:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757219AbcEDGDQ (ORCPT ); Wed, 4 May 2016 02:03:16 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33610 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757187AbcEDGDO (ORCPT ); Wed, 4 May 2016 02:03:14 -0400 Received: by mail-pa0-f50.google.com with SMTP id xk12so20285791pac.0; Tue, 03 May 2016 23:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4EjvQZFzAOdl6S/XDNn7UlNcBa1AymDh9ZxD/bk6pII=; b=SR13vCIg1+PEotHt6dccwhKhC/Ryrk+IgLNWaBKzeC7himybMb2t85rvNMcSCtlkiI QSGplGH5q0/QXSfkZs+GU+//BzmtcKbt1PtdpyKKRAZzCEjBKNGbCUOGGMn1fnyFBG/o wx5gWUBLQA8l2a0eTjJUQUtRqPQeFf/spJ40vuts1Jb+uIlnvq4E5wbDarcPWSbyFSeu An1dkkNJDogWSy+dUF03qGLgB+A8WfrKn9yTIz5aI9iw/g3iPJnSl+uIvO0PAptAHTBK ahDiSfkX6UlpUN8rTRgwI3d1vfZy9z+eT+JcKfqR4DVil/MzijnrshOtbnf4T3rsVuDL waGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4EjvQZFzAOdl6S/XDNn7UlNcBa1AymDh9ZxD/bk6pII=; b=Bf5HXIy7w2NpYy9/HVK764/3mG0BPI9fjBCwfVDniPs/D4yvWoDU2csR6p6Akgy1BM C500P5WTRHLy6de+DluO4hzhVVl6+AOs04Sjy8/V0mqB67CJeUHpb/ev+0s2VBinCFLY T853ouDvAdcg2AVZYIU9pLoP7a8FftriPNI48iRf1OF51A7VD9jH8XBv2f/rYQFYIy6c +ESKAUwK4br7JjQl1Ve2jTmlCtTO8H5n9RkWLOJYzt8O3SaxXhYHH0wtepNSDum4vlgR 9pjbagdvBTf235bCioLwr0mSRzLr1s2Zhhrl83PqYRMx1MBNEsDvQn9h1Ef3Vb+RNq63 U3Mg== X-Gm-Message-State: AOPr4FWLQTuY2CHc1LaA9mgUXMK+7wb6C54D/7pJE4h1X/Snr2w77qHQh5a2I3wYyKIeQQ== X-Received: by 10.66.26.43 with SMTP id i11mr9689642pag.58.1462341793588; Tue, 03 May 2016 23:03:13 -0700 (PDT) Received: from localhost ([2601:647:4203:c8e0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id zn12sm2647244pab.14.2016.05.03.23.03.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 May 2016 23:03:12 -0700 (PDT) From: Eduardo Valentin To: Rui Zhang Cc: Linux PM , LKML , Eduardo Valentin Subject: [PATCH 14/31] thermal: core: split policy_store Date: Tue, 3 May 2016 23:02:28 -0700 Message-Id: <1462341765-13268-15-git-send-email-edubezval@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462341765-13268-1-git-send-email-edubezval@gmail.com> References: <1462341765-13268-1-git-send-email-edubezval@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 6042ea2..b4772e7 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -699,6 +699,28 @@ void thermal_zone_device_passive_update(struct thermal_zone_device *tz, thermal_zone_device_update(tz); } +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) \ @@ -927,27 +949,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 da53693..5bb5101 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -57,6 +57,7 @@ struct thermal_instance { int thermal_register_governor(struct thermal_governor *); void thermal_unregister_governor(struct thermal_governor *); void thermal_zone_device_passive_update(struct thermal_zone_device *, int); +int thermal_zone_device_set_policy(struct thermal_zone_device *, char *); #ifdef CONFIG_THERMAL_GOV_STEP_WISE int thermal_gov_step_wise_register(void);