Skip to content

Commit

Permalink
cpufreq: dbx500: Round to closest available freq
Browse files Browse the repository at this point in the history
When reading the cpu speed, round it to the closest available
frequency from the table.

Signed-off-by: Mats Fagerstrom <mats.fagerstrom@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Mats Fagerstrom authored and Rafael J. Wysocki committed Apr 11, 2013
1 parent e4969eb commit c778966
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/cpufreq/dbx500-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c778966

Please sign in to comment.