linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: dbx500: Round to closest available freq
@ 2013-04-10 13:06 Ulf Hansson
  2013-04-11 20:33 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2013-04-10 13:06 UTC (permalink / raw)
  To: linux-arm-kernel

From: Mats Fagerstrom <mats.fagerstrom@stericsson.com>

When reading the cpu speed, round it to the closest available
frequency from the table.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
---
 drivers/cpufreq/dbx500-cpufreq.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c
index 15ed367..6ec6539 100644
--- a/drivers/cpufreq/dbx500-cpufreq.c
+++ b/drivers/cpufreq/dbx500-cpufreq.c
@@ -71,15 +71,15 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
 	int i = 0;
 	unsigned long freq = clk_get_rate(armss_clk) / 1000;
 
-	while (freq_table[i].frequency != CPUFREQ_TABLE_END) {
-		if (freq <= freq_table[i].frequency)
+	/* The value is rounded to closest frequency in the defined table. */
+	while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) {
+		if (freq < freq_table[i].frequency +
+		   (freq_table[i + 1].frequency - freq_table[i].frequency) / 2)
 			return freq_table[i].frequency;
 		i++;
 	}
 
-	/* We could not find a corresponding frequency. */
-	pr_err("dbx500-cpufreq: Failed to find cpufreq speed\n");
-	return 0;
+	return freq_table[i].frequency;
 }
 
 static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy)
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] cpufreq: dbx500: Round to closest available freq
  2013-04-10 13:06 [PATCH] cpufreq: dbx500: Round to closest available freq Ulf Hansson
@ 2013-04-11 20:33 ` Linus Walleij
  2013-04-11 21:33   ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2013-04-11 20:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 10, 2013 at 3:06 PM, Ulf Hansson <ulf.hansson@stericsson.com> wrote:

> From: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
>
> When reading the cpu speed, round it to the closest available
> frequency from the table.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> Signed-off-by: Mats Fagerstrom <mats.fagerstrom@stericsson.com>

(...)
> +       /* The value is rounded to closest frequency in the defined table. */
> +       while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) {
> +               if (freq < freq_table[i].frequency +
> +                  (freq_table[i + 1].frequency - freq_table[i].frequency) / 2)
>                         return freq_table[i].frequency;

Oh that works, clever.

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] cpufreq: dbx500: Round to closest available freq
  2013-04-11 20:33 ` Linus Walleij
@ 2013-04-11 21:33   ` Rafael J. Wysocki
  2013-04-11 21:52     ` Troy Kisky
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-04-11 21:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Thursday, April 11, 2013 10:33:07 PM Linus Walleij wrote:
> On Wed, Apr 10, 2013 at 3:06 PM, Ulf Hansson <ulf.hansson@stericsson.com> wrote:
> 
> > From: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
> >
> > When reading the cpu speed, round it to the closest available
> > frequency from the table.
> >
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > Signed-off-by: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
> 
> (...)
> > +       /* The value is rounded to closest frequency in the defined table. */
> > +       while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) {
> > +               if (freq < freq_table[i].frequency +
> > +                  (freq_table[i + 1].frequency - freq_table[i].frequency) / 2)
> >                         return freq_table[i].frequency;
> 
> Oh that works, clever.
> 
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks, applied.

Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] cpufreq: dbx500: Round to closest available freq
  2013-04-11 21:33   ` Rafael J. Wysocki
@ 2013-04-11 21:52     ` Troy Kisky
  0 siblings, 0 replies; 4+ messages in thread
From: Troy Kisky @ 2013-04-11 21:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 4/11/2013 2:33 PM, Rafael J. Wysocki wrote:
> On Thursday, April 11, 2013 10:33:07 PM Linus Walleij wrote:
>> On Wed, Apr 10, 2013 at 3:06 PM, Ulf Hansson <ulf.hansson@stericsson.com> wrote:
>>
>>> From: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
>>>
>>> When reading the cpu speed, round it to the closest available
>>> frequency from the table.
>>>
>>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>>> Signed-off-by: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
>> (...)
>>> +       /* The value is rounded to closest frequency in the defined table. */
>>> +       while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) {
>>> +               if (freq < freq_table[i].frequency +
>>> +                  (freq_table[i + 1].frequency - freq_table[i].frequency) / 2)

if (freq < (freq_table[i].frequency + freq_table[i + 1].frequency) / 2)

is easier to read.



>>>                          return freq_table[i].frequency;
>> Oh that works, clever.
>>
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Thanks, applied.
>
> Rafael
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-11 21:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-10 13:06 [PATCH] cpufreq: dbx500: Round to closest available freq Ulf Hansson
2013-04-11 20:33 ` Linus Walleij
2013-04-11 21:33   ` Rafael J. Wysocki
2013-04-11 21:52     ` Troy Kisky

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).