[PATCH] cpufreq: dbx500: Round to closest available freq

Linus Walleij linus.walleij at linaro.org
Thu Apr 11 16:33:07 EDT 2013


On Wed, Apr 10, 2013 at 3:06 PM, Ulf Hansson <ulf.hansson at stericsson.com> wrote:

> From: Mats Fagerstrom <mats.fagerstrom at stericsson.com>
>
> When reading the cpu speed, round it to the closest available
> frequency from the table.
>
> Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>
> Signed-off-by: Mats Fagerstrom <mats.fagerstrom at stericsson.com>

(...)
> +       /* 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;

Oh that works, clever.

Acked-by: Linus Walleij <linus.walleij at linaro.org>

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list