From: Yuxuan Shui <yshuiv7@gmail.com>
To: rui.zhang@intel.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuxuan Shui <yshuiv7@gmail.com>
Subject: [PATCH] Thermal: Don't resolve THERMAL_NO_LIMIT to max_state.
Date: Tue, 26 Mar 2013 21:29:49 +0800 [thread overview]
Message-ID: <1364304589-24335-1-git-send-email-yshuiv7@gmail.com> (raw)
max_state may change at runtime, for example, when loading/unloading
cpufreq policy.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
---
drivers/thermal/step_wise.c | 11 ++++++++---
drivers/thermal/thermal_sys.c | 5 ++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 407cde3..2edb7e9 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -54,18 +54,23 @@ static unsigned long get_target_state(struct thermal_instance *instance,
{
struct thermal_cooling_device *cdev = instance->cdev;
unsigned long cur_state;
+ unsigned long max_state;
+ int upper;
cdev->ops->get_cur_state(cdev, &cur_state);
+ cdev->ops->get_max_state(cdev, &max_state);
+
+ upper = instance->upper == THERMAL_NO_LIMIT ? max_state : instance->upper;
switch (trend) {
case THERMAL_TREND_RAISING:
if (throttle)
- cur_state = cur_state < instance->upper ?
- (cur_state + 1) : instance->upper;
+ cur_state = cur_state < upper ?
+ (cur_state + 1) : upper;
break;
case THERMAL_TREND_RAISE_FULL:
if (throttle)
- cur_state = instance->upper;
+ cur_state = upper;
break;
case THERMAL_TREND_DROPPING:
if (cur_state == instance->lower) {
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 5b7863a..f02e4d4 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -1134,11 +1134,10 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
cdev->ops->get_max_state(cdev, &max_state);
- /* lower default 0, upper default max_state */
+ /* lower default 0 */
lower = lower == THERMAL_NO_LIMIT ? 0 : lower;
- upper = upper == THERMAL_NO_LIMIT ? max_state : upper;
- if (lower > upper || upper > max_state)
+ if (lower > upper || (upper != THERMAL_NO_LIMIT && upper > max_state))
return -EINVAL;
dev =
--
1.8.2
next reply other threads:[~2013-03-26 13:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-26 13:29 Yuxuan Shui [this message]
2013-04-12 1:38 ` [PATCH] Thermal: Don't resolve THERMAL_NO_LIMIT to max_state Zhang Rui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1364304589-24335-1-git-send-email-yshuiv7@gmail.com \
--to=yshuiv7@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).