Commit c7789669 authored by Mats Fagerstrom's avatar Mats Fagerstrom Committed by Rafael J. Wysocki

cpufreq: dbx500: Round to closest available freq

When reading the cpu speed, round it to the closest available
frequency from the table.
Signed-off-by: default avatarMats Fagerstrom <mats.fagerstrom@stericsson.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent e4969eba
...@@ -71,15 +71,15 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) ...@@ -71,15 +71,15 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
int i = 0; int i = 0;
unsigned long freq = clk_get_rate(armss_clk) / 1000; unsigned long freq = clk_get_rate(armss_clk) / 1000;
while (freq_table[i].frequency != CPUFREQ_TABLE_END) { /* The value is rounded to closest frequency in the defined table. */
if (freq <= freq_table[i].frequency) 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; return freq_table[i].frequency;
i++; i++;
} }
/* We could not find a corresponding frequency. */ return freq_table[i].frequency;
pr_err("dbx500-cpufreq: Failed to find cpufreq speed\n");
return 0;
} }
static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment