From patchwork Wed Dec 30 10:38:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 59075 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2768236lbb; Wed, 30 Dec 2015 02:38:51 -0800 (PST) X-Received: by 10.66.140.79 with SMTP id re15mr90147673pab.127.1451471931678; Wed, 30 Dec 2015 02:38:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sm10si12262821pab.78.2015.12.30.02.38.51; Wed, 30 Dec 2015 02:38:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754417AbbL3Kiu (ORCPT + 11 others); Wed, 30 Dec 2015 05:38:50 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:36573 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754019AbbL3Kit (ORCPT ); Wed, 30 Dec 2015 05:38:49 -0500 Received: by mail-pf0-f176.google.com with SMTP id 65so95848168pff.3 for ; Wed, 30 Dec 2015 02:38:49 -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=jdQUEeQzqPCn5VnaT8/umRdThoue77F25zmpJSkdr3c=; b=TWEFl1VMCXpYhw6kvCpeRdPFXf0yXwswy49t/6XaZ+RBNPegtew1b0fzicRFvyilBr 5K26YMNFUsTXVYsZS/ddo1Wwef0wSZjp8XqonT3IgGMIwKyn/cAgDGKYFSZ1nOlhvjEO yfLp9iv20UX/EhKwqEy7LQf+sHub/LrNETwcA= 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=jdQUEeQzqPCn5VnaT8/umRdThoue77F25zmpJSkdr3c=; b=WkUaJHF3PAQ+qw1jqksaBdCs54tAMitfmIX13kybpOEueoBMcXr4EwOyT39KsXFsmY 5toqwq2R41J5nmXiPPA8cehr2c/UH9OZsQZ8Q2udeojpuP6Bw/uuFd/qMJJKxU3PNFHz QaXoqn+Ak63Yg2GZk5FRCBgsLK4fWICm6DPJ0EZ4h4BXAr6IysrDJmzDZrBJ6d0R8o+z ePOn6g1uR8Skd7CO5KfI+52m6iqz6gac6Eu9wXjAklOG3+0Eeht5kYgISTdsbaEL7m54 yPXVjsy5zmKDj4Og18paUp8OGgrHlU9zZPacn438C4alU2k/E5JFwF13xjoL8ageO0AB BfTg== X-Gm-Message-State: ALoCoQnYMxHhr5NMbw7JkOQtKOaO1bWj9yOWlecMIf+OFLEjDyi0dGaaD0xQw9Gk7XhEx4MyoBycl9r9JyCKaMJLcq5kGmtSIw== X-Received: by 10.98.65.219 with SMTP id g88mr78174717pfd.63.1451471928887; Wed, 30 Dec 2015 02:38:48 -0800 (PST) Received: from localhost.localdomain (v17.blockcn.net. [192.241.236.26]) by smtp.gmail.com with ESMTPSA id y26sm22333526pfi.89.2015.12.30.02.38.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Dec 2015 02:38:47 -0800 (PST) From: Leo Yan To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, javi.merino@arm.com Cc: Leo Yan Subject: [PATCH v2] thermal: re-calculate k_po/k_pu when update sustainable power Date: Wed, 30 Dec 2015 18:38:40 +0800 Message-Id: <1451471920-2148-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 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(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d9e525c..223f8df 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->k_po * sustainable_power) / old_val; + tz->tzp->k_pu = (tz->tzp->k_pu * sustainable_power) / old_val; return count; } static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show,