From patchwork Wed Dec 30 06:12:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 7931981 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4B546BEEE5 for ; Wed, 30 Dec 2015 06:13:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71E74202EB for ; Wed, 30 Dec 2015 06:13:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D055F202F2 for ; Wed, 30 Dec 2015 06:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751043AbbL3GMm (ORCPT ); Wed, 30 Dec 2015 01:12:42 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33742 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbbL3GMk (ORCPT ); Wed, 30 Dec 2015 01:12:40 -0500 Received: by mail-pa0-f44.google.com with SMTP id cy9so134166586pac.0 for ; Tue, 29 Dec 2015 22:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ER+YTXHdHVBjbMP3d/IR32Pc26Og+UHW7ulMI5aV/KA=; b=XLHHZNfANaEyDJphtKc0xzKntFDLzwBf8j4TdVqBwNYU1rMOXdiA/5ItXK0JvAnlRq ngnGUBZt4mNHbA7V5MSoC+n2kZtALNcd1SrcNyvKQvSORFVXCkBklv74BJkdFznqo/qV U+GlWrHxf7hcjjXdeHgwx2ukWiQlg8AourgNE= 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; bh=ER+YTXHdHVBjbMP3d/IR32Pc26Og+UHW7ulMI5aV/KA=; b=NJp3jFbDjJqVBvdvp7ZOfCtHd7/r3oiXoC/GuWiG4n4XRu8NkuPCyyTinckaDlNxHL uYE3pPQ+M59AzlRtr08Pa2LzitNfRfoqmP1vu7CxthGWgt3t17FzPjmUWqneZDmkRggd WEES/smt+jsOKZt8T0N4pdEjnd4g4mUIbooyvBHW9Q5d7qt9qLk5dfuRYZ01Isdh8ha8 lcm3cbttzLRuKep4iAz0YXqP5hrtIAy3WLos8YEsIi6ExIzrjFQ7g1hDN5a/im6X5W/y azJSD8p2QOjP6qretoF5RsY8/FQxwHfLYSbBCpjuNGRjLYwtOeUA/PLJuVBMI4TgZzPv kSAA== X-Gm-Message-State: ALoCoQmgBnII7Mx7Rvfn0qw0CbAKZ2WNdU6GT+sOYcLg6sQYf2ywxQWZa0LqQ9yY1qTLhMn1OA1EYPSkEuDd+P5MyRkH1S5Mig== X-Received: by 10.66.144.65 with SMTP id sk1mr89430154pab.126.1451455959750; Tue, 29 Dec 2015 22:12:39 -0800 (PST) Received: from localhost.localdomain (v17.blockcn.net. [192.241.236.26]) by smtp.gmail.com with ESMTPSA id fi16sm18589135pac.12.2015.12.29.22.12.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Dec 2015 22:12:38 -0800 (PST) From: Leo Yan To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Javi Merino Cc: Leo Yan Subject: [PATCH] thermal: re-calculate k_po/k_pu when update sustainable power Date: Wed, 30 Dec 2015 14:12:30 +0800 Message-Id: <1451455950-23633-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 k_po/k_pu are in essence ratio values compared with sustainable power. So when update sustainable power, we can recalculate k_po/k_pu simply with below formula: sustainable_power(new) k_p(new) = ---------------------- * k_p(old) sustainable_power(old) Signed-off-by: Leo Yan --- drivers/thermal/thermal_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d9e525c..212688a 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -908,7 +908,7 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct thermal_zone_device *tz = to_thermal_zone(dev); - u32 sustainable_power; + u32 sustainable_power, old_val; if (!tz->tzp) return -EIO; @@ -916,8 +916,12 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr, if (kstrtou32(buf, 10, &sustainable_power)) return -EINVAL; + old_val = tz->tzp->sustainable_power; + tz->tzp->sustainable_power = sustainable_power; + tz->tzp->k_po = (tz->tzp->kpo * sustainable_power) / old_val; + tz->tzp->k_pu = (tz->tzp->kpu * sustainable_power) / old_val; return count; } static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show,