From: Eduardo Valentin <eduardo.valentin@ti.com>
To: Eduardo Valentin <eduardo.valentin@ti.com>
Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] thermal: fix cpu_cooling max_level behavior
Date: Wed, 13 Nov 2013 14:31:41 -0400 [thread overview]
Message-ID: <5283C58D.10800@ti.com> (raw)
In-Reply-To: <1384366269-1655-1-git-send-email-eduardo.valentin@ti.com>
[-- Attachment #1: Type: text/plain, Size: 1940 bytes --]
On 13-11-2013 14:11, Eduardo Valentin wrote:
> As per Documentation/thermal/sysfs-api.txt, max_level
> is an index, not a counter. Thus, in case a CPU has
> 3 valid frequencies, max_level is expected to be 2, for instance.
>
> The current code makes max_level == number of valid frequencies,
> which is bogus. This patch fix the cpu_cooling device by
> ranging max_level properly.
>
> Reported-by: Carlos Hernandez <ceh@ti.com>
> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Rui,
This fix is applicable even on 3.12.
> ---
> drivers/thermal/cpu_cooling.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index d179028..d0f8f8b5 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -173,6 +173,8 @@ static int get_property(unsigned int cpu, unsigned long input,
> freq = table[i].frequency;
> max_level++;
> }
> + /* max_level is an index, not a counter */
> + max_level--;
>
> /* get max level */
> if (property == GET_MAXL) {
> @@ -181,7 +183,7 @@ static int get_property(unsigned int cpu, unsigned long input,
> }
>
> if (property == GET_FREQ)
> - level = descend ? input : (max_level - input - 1);
> + level = descend ? input : (max_level - input);
>
> for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
> /* ignore invalid entry */
> @@ -197,7 +199,7 @@ static int get_property(unsigned int cpu, unsigned long input,
>
> if (property == GET_LEVEL && (unsigned int)input == freq) {
> /* get level by frequency */
> - *output = descend ? j : (max_level - j - 1);
> + *output = descend ? j : (max_level - j);
> return 0;
> }
> if (property == GET_FREQ && level == j) {
>
--
You have got to be excited about what you are doing. (L. Lamport)
Eduardo Valentin
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 295 bytes --]
next prev parent reply other threads:[~2013-11-13 18:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 18:11 [PATCH 1/1] thermal: fix cpu_cooling max_level behavior Eduardo Valentin
2013-11-13 18:31 ` Eduardo Valentin [this message]
2013-12-06 13:52 ` Eduardo Valentin
2014-01-02 4:02 ` Zhang Rui
2014-01-04 13:53 ` Eduardo Valentin
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=5283C58D.10800@ti.com \
--to=eduardo.valentin@ti.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).