diff options
author | Mats Fagerstrom <mats.fagerstrom@stericsson.com> | 2013-04-11 17:23:57 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-04-11 17:23:57 -0400 |
commit | c77896693da9ad75bd999fd86dd81a3da747e267 (patch) | |
tree | 7b13b479e7e38598afa47c292fc1d35a991c4f05 /drivers/cpufreq/dbx500-cpufreq.c | |
parent | e4969ebac83fdea78d89c779331396728a4e6199 (diff) |
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: 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>
Diffstat (limited to 'drivers/cpufreq/dbx500-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/dbx500-cpufreq.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 15ed367139a6..6ec6539ae041 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) | |||
71 | int i = 0; | 71 | int i = 0; |
72 | unsigned long freq = clk_get_rate(armss_clk) / 1000; | 72 | unsigned long freq = clk_get_rate(armss_clk) / 1000; |
73 | 73 | ||
74 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { | 74 | /* The value is rounded to closest frequency in the defined table. */ |
75 | if (freq <= freq_table[i].frequency) | 75 | while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) { |
76 | if (freq < freq_table[i].frequency + | ||
77 | (freq_table[i + 1].frequency - freq_table[i].frequency) / 2) | ||
76 | return freq_table[i].frequency; | 78 | return freq_table[i].frequency; |
77 | i++; | 79 | i++; |
78 | } | 80 | } |
79 | 81 | ||
80 | /* We could not find a corresponding frequency. */ | 82 | return freq_table[i].frequency; |
81 | pr_err("dbx500-cpufreq: Failed to find cpufreq speed\n"); | ||
82 | return 0; | ||
83 | } | 83 | } |
84 | 84 | ||
85 | static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) | 85 | static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) |