[PATCH 3/3] cpufreq: ppc: Fix handling of non-existent clocks
viresh.kumar at linaro.org
Mon Apr 21 16:01:05 EST 2014
On 17 April 2014 15:23, Geert Uytterhoeven <geert+renesas at glider.be> wrote:
> If the clock doesn't exist, clk_get_rate() returns -EINVAL
You clk_get_rate() isn't written well then, it should return zero.
@Mike: I didn't see this clearly mentioned in clk.h, should we fix
>, which becomes
> a large number (freq is u32), failing the "freq < min_cpufreq" test.
> Explicitly test for "(u32)-EINVAL" to fix this.
That's a bad check. We should have done this instead:
(s32)freq < 0; but that would be true for high values of clock. And that's
why clk_get_rate() must return zero for errors.
> Update the comment, and fix a grammer issue while we're at it.
> Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
> drivers/cpufreq/ppc-corenet-cpufreq.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
> diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
> index 53881d78a931..7027eab814ce 100644
> --- a/drivers/cpufreq/ppc-corenet-cpufreq.c
> +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
> @@ -179,10 +179,11 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
> clk = of_clk_get(data->parent, i);
> freq = clk_get_rate(clk);
> - * the clock is valid if its frequency is not masked
> - * and large than minimum allowed frequency.
> + * the clock is valid if it exists, its frequency is not
> + * masked, and larger than minimum allowed frequency.
> - if (freq < min_cpufreq || (mask & (1 << i)))
> + if (freq == (u32)-EINVAL || freq < min_cpufreq ||
> + (mask & (1 << i)))
> table[i].frequency = CPUFREQ_ENTRY_INVALID;
> table[i].frequency = freq / 1000;
More information about the Linuxppc-dev