Skip to content

Commit

Permalink
cpufreq: cpufreq-cpu0: use the exact frequency for clk_set_rate()
Browse files Browse the repository at this point in the history
clk_set_rate() isn't supposed to accept approximate frequencies, instead
a supported frequency should be obtained from clk_round_rate() and then
used to set the clock.

Signed-off-by: Guennadi Liakhovetski <[email protected]>
Acked-by: Shawn Guo <[email protected]>
Acked-by: Viresh Kumar <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
lyakh authored and rafaeljw committed Jun 5, 2013
1 parent 2f7021a commit 0ca6843
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/cpufreq/cpufreq-cpu0.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
struct cpufreq_freqs freqs;
struct opp *opp;
unsigned long volt = 0, volt_old = 0, tol = 0;
long freq_Hz;
long freq_Hz, freq_exact;
unsigned int index;
int ret;

Expand All @@ -60,6 +60,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
freq_Hz = clk_round_rate(cpu_clk, freq_table[index].frequency * 1000);
if (freq_Hz < 0)
freq_Hz = freq_table[index].frequency * 1000;
freq_exact = freq_Hz;
freqs.new = freq_Hz / 1000;
freqs.old = clk_get_rate(cpu_clk) / 1000;

Expand Down Expand Up @@ -98,7 +99,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
}
}

ret = clk_set_rate(cpu_clk, freqs.new * 1000);
ret = clk_set_rate(cpu_clk, freq_exact);
if (ret) {
pr_err("failed to set clock rate: %d\n", ret);
if (cpu_reg)
Expand Down

0 comments on commit 0ca6843

Please sign in to comment.