From: amit daniel kachhap <amit.daniel@samsung.com>
To: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org, Gu1 <gu1@aeroxteam.fr>,
Hongbo Zhang <hongbo.zhang@linaro.org>,
amit kachhap <amit.kachhap@gmail.com>
Subject: Re: [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table
Date: Wed, 6 Feb 2013 17:44:05 -0800 [thread overview]
Message-ID: <CADGdYn6hGhFg7gYsw2oLPZo2Kks9c2GCgFttOLLPR96QSTjW2Q@mail.gmail.com> (raw)
In-Reply-To: <CADGdYn4uusfk5gQ+tf8=VvaTLzTHkkfZJ9cLBojTwy8fT7vPoA@mail.gmail.com>
Few comments below,
On Wed, Feb 6, 2013 at 5:41 PM, amit kachhap <amit.kachhap@gmail.com> wrote:
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
> drivers/thermal/cpu_cooling.c | 45 ++++++++---------------------------------
> 1 file changed, 8 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 08f12c7..57bb669 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -186,46 +186,17 @@ get_cpu_cooling_table(unsigned int cpu)
> */
> static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
> {
> - int ret = 0, i = 0;
> - unsigned long level_index;
> - bool descend = false;
> - struct cpufreq_frequency_table *table =
> - cpufreq_frequency_get_table(cpu);
> - if (!table)
> - return ret;
> -
> - while (table[i].frequency != CPUFREQ_TABLE_END) {
> - if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
> - continue;
> -
> - /*check if table in ascending or descending order*/
> - if ((table[i + 1].frequency != CPUFREQ_TABLE_END) &&
> - (table[i + 1].frequency < table[i].frequency)
> - && !descend) {
> - descend = true;
> - }
> + struct cpufreq_frequency_table *table;
> + unsigned int freq;
>
> - /*return if level matched and table in descending order*/
> - if (descend && i == level)
> - return table[i].frequency;
> - i++;
> - }
> - i--;
> + table = get_cpu_cooling_table(cpu);
> + if (IS_ERR(table))
> + return -EINVAL;
>
> - if (level > i || descend)
> - return ret;
> - level_index = i - level;
> + freq = table[level].frequency;
>
> - /*Scan the table in reverse order and match the level*/
> - while (i >= 0) {
> - if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
> - continue;
> - /*return if level matched*/
> - if (i == level_index)
> - return table[i].frequency;
> - i--;
> - }
> - return ret;
> + kfree(table);
> + return 0;
return freq instead of return 0.
> }
>
> /**
> --
> 1.7.9.5
next parent reply other threads:[~2013-02-07 1:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CADGdYn4uusfk5gQ+tf8=VvaTLzTHkkfZJ9cLBojTwy8fT7vPoA@mail.gmail.com>
2013-02-07 1:44 ` amit daniel kachhap [this message]
2013-02-06 4:30 [PATCH 0/5] Thermal: cpu cooling fix Zhang Rui
2013-02-06 4:30 ` [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table 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=CADGdYn6hGhFg7gYsw2oLPZo2Kks9c2GCgFttOLLPR96QSTjW2Q@mail.gmail.com \
--to=amit.daniel@samsung.com \
--cc=amit.kachhap@gmail.com \
--cc=gu1@aeroxteam.fr \
--cc=hongbo.zhang@linaro.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).