Skip to content

Commit

Permalink
sh: clkfwk: modify for_each_frequency end condition
Browse files Browse the repository at this point in the history
The end condition of for_each_frequency should care about
both clk_rate_table_round and clk_rate_div_range_round,
and using "correct max size" is a natural idea in later function.
To avoid data over flow, this patch didn't modify
clk_rate_div_range_round side as .max = div_max + 1.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Kuninori Morimoto authored and Paul Mundt committed Oct 18, 2010
1 parent 56ea510 commit c2590f4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/sh/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct clk_rate_round_data {

#define for_each_frequency(pos, r, freq) \
for (pos = r->min, freq = r->func(pos, r); \
pos < r->max; pos++, freq = r->func(pos, r)) \
pos <= r->max; pos++, freq = r->func(pos, r)) \
if (unlikely(freq == 0)) \
; \
else
Expand Down Expand Up @@ -139,12 +139,15 @@ long clk_rate_table_round(struct clk *clk,
{
struct clk_rate_round_data table_round = {
.min = 0,
.max = clk->nr_freqs,
.max = clk->nr_freqs - 1,
.func = clk_rate_table_iter,
.arg = freq_table,
.rate = rate,
};

if (clk->nr_freqs < 1)
return 0;

return clk_rate_round_helper(&table_round);
}

Expand Down

0 comments on commit c2590f4

Please sign in to comment.