Skip to content

Commit

Permalink
mips: lemote 2f: Use cpufreq_for_each_entry macro for iteration
Browse files Browse the repository at this point in the history
The cpufreq core now supports the cpufreq_for_each_entry macro helper
for iteration over the cpufreq_frequency_table, so use it.

It should have no functional changes.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Stratos Karafotis authored and Rafael J. Wysocki committed Apr 29, 2014
1 parent fdb56c4 commit 4966ee4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions arch/mips/loongson/lemote-2f/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ EXPORT_SYMBOL(clk_put);

int clk_set_rate(struct clk *clk, unsigned long rate)
{
struct cpufreq_frequency_table *pos;
int ret = 0;
int regval;
int i;

if (likely(clk->ops && clk->ops->set_rate)) {
unsigned long flags;
Expand All @@ -106,22 +106,16 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
propagate_rate(clk);

for (i = 0; loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END;
i++) {
if (loongson2_clockmod_table[i].frequency ==
CPUFREQ_ENTRY_INVALID)
continue;
if (rate == loongson2_clockmod_table[i].frequency)
cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table)
if (rate == pos->frequency)
break;
}
if (rate != loongson2_clockmod_table[i].frequency)
if (rate != pos->frequency)
return -ENOTSUPP;

clk->rate = rate;

regval = LOONGSON_CHIPCFG0;
regval = (regval & ~0x7) |
(loongson2_clockmod_table[i].driver_data - 1);
regval = (regval & ~0x7) | (pos->driver_data - 1);
LOONGSON_CHIPCFG0 = regval;

return ret;
Expand Down

0 comments on commit 4966ee4

Please sign in to comment.