summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2010-10-18 03:50:29 +0000
committerPaul Mundt <lethal@linux-sh.org>2010-10-18 20:33:10 +0900
commitc2590f4a8ddf461d33ac2085d966432b2a6a09f2 (patch)
treec0302f29a328b6200517c933db2cb4a94e96be58
parent56ea510962ec690ede2be2064de72e51a33011d9 (diff)
sh: clkfwk: modify for_each_frequency end condition
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>
-rw-r--r--drivers/sh/clk.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/sh/clk.c b/drivers/sh/clk.c
index c76f972db69a..dae64ee9ecc5 100644
--- a/drivers/sh/clk.c
+++ b/drivers/sh/clk.c
@@ -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
@@ -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);
}