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: 59072 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2667961lbb; Tue, 29 Dec 2015 22:13:33 -0800 (PST) X-Received: by 10.98.86.75 with SMTP id k72mr55088536pfb.156.1451456012931; Tue, 29 Dec 2015 22:13:32 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q79si32720891pfi.220.2015.12.29.22.13.32; Tue, 29 Dec 2015 22:13:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1751041AbbL3GMl (ORCPT + 29 others); Wed, 30 Dec 2015 01:12:41 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36280 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750814AbbL3GMk (ORCPT ); Wed, 30 Dec 2015 01:12:40 -0500 Received: by mail-pa0-f50.google.com with SMTP id yy13so41720146pab.3 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=ITd6We0Xf5ZwDQ7f6nagh9BrgAokaIOCzMGiqnboNNiLzx9UVJWAr3hbrXUE123xAW KbjtDXEI+YQ7q1WJbfoxSGcyE3o1uQUORZJa89UM1CXCE7+fY7l3rKmSV0KKZ0UqDYhx W1MgvzNGhWM0A7ZNcFg2iNimwYdysDcR9fnZXnKmeJM461ijLGEFJ3mDGSJIvf6A5LsN Cpoz4eD5abrM5QW55FCscnGTNAqBpNBcVwPDnDmFKNU+kI2MJ0EmjkldHyBevNLJZENU 27gFR/dyAkJhyrU3dPAFQxuiPObf4X02e1XfRlBy/w5T4nge8dxL0Uyg/hcuUt7Z5sj0 3kEw== X-Gm-Message-State: ALoCoQkv4hN/bvJmVHQ3qoP7LG9KZFgaKWp5qt/sC+ugxb2qSxw96vH/FsDLu4LyLFzBH3vxHM5oM3dhsXOhaErzO4V0jSTsEg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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,