From patchwork Tue Nov 8 05:08:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 9416531 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8BA860512 for ; Tue, 8 Nov 2016 05:14:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9961828B99 for ; Tue, 8 Nov 2016 05:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DC9E28B9B; Tue, 8 Nov 2016 05:14:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4321928B99 for ; Tue, 8 Nov 2016 05:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753327AbcKHFK0 (ORCPT ); Tue, 8 Nov 2016 00:10:26 -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 Received: by mail-pf0-f195.google.com with SMTP id i88so18052412pfk.2; Mon, 07 Nov 2016 21:10:24 -0800 (PST) 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=3mQfbbkhmSad6tWd8XIC8vmYU4iVxZHUpKbHQ2jsuNs=; b=doDT1BQFKHJBCb11s/aSRDlDUQbcGclt4nW/84V8henAAZGNcNln05Wrf7p6dwJ7A7 bSGpDeMsSyoUySx2ovzlV2Ay92t96d/Kx3ZWq45fS0Mr4KVnlMZfemyrsrC6p0gJLMHX DoieyWQKvwGJ7o0uzWNUOU79kP0qRYFFks9tCOLQPhGw6Ky4eSUUBDzJEKq8E/doWuwO 0gufZZR+LZ7uw/pCksWvnXGOhaBDe6a10/u+KaauyAahaHGmzEak69neNVNYzK6GXYn5 63zdpjEW+25hJTH2ngBABOIl3IX90U+IC5C6ZVBULl14ksyv6+NmG/rYGeAC8k3f9RCq RoCQ== 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=3mQfbbkhmSad6tWd8XIC8vmYU4iVxZHUpKbHQ2jsuNs=; b=TZih+0bzvgS18KOUVWDqUxa5xtcVRn4p8ZpzfsrgogvHJ+7kTMVwmNTPPMMp8G34M9 J1h2qtjR5Gwx9JeU6uaBiPQD8Hr12apBDwWjcOPq9/zm3ooijIQ3TVYxMvorhmCI7nQk vxzsGHzZ2dUBE9AHHpYGmT+c0a2KzB+tX742n54MzObZcJ3SOChrEPXq7YrXacWpNa/h DManuvzLWIo8t42QEwgkMMRYsPbG8YO4m8iuTO2c+0AZmYuBCeQTEjFqDJGaUMqjB5Z/ qq1rWHLkDYvrGBnMqToWwElrNql0L4Su9Kwk+9M4eWb+rB/6wCkolVpcAXe1U9eTG7Ia jJLg== X-Gm-Message-State: ABUngvcGovlUAesZiz44m6634LH26vuHh1HBFgdP/aeZHK/X7NkpwP5tcNUGh6dyTey5lQ== X-Received: by 10.99.167.15 with SMTP id d15mr4124166pgf.104.1478581823703; Mon, 07 Nov 2016 21:10:23 -0800 (PST) Received: from localhost ([2601:647:4401:a2f0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id s3sm44405755pfe.27.2016.11.07.21.10.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2016 21:10:23 -0800 (PST) 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.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 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);