diff options
Diffstat (limited to 'drivers/sh')
-rw-r--r-- | drivers/sh/clk.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/sh/clk.c b/drivers/sh/clk.c index cede14e34507..b9c57a640c24 100644 --- a/drivers/sh/clk.c +++ b/drivers/sh/clk.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/sh/clk.c - SuperH clock framework | 2 | * drivers/sh/clk.c - SuperH clock framework |
3 | * | 3 | * |
4 | * Copyright (C) 2005 - 2009 Paul Mundt | 4 | * Copyright (C) 2005 - 2010 Paul Mundt |
5 | * | 5 | * |
6 | * This clock framework is derived from the OMAP version by: | 6 | * This clock framework is derived from the OMAP version by: |
7 | * | 7 | * |
@@ -73,14 +73,23 @@ long clk_rate_table_round(struct clk *clk, | |||
73 | { | 73 | { |
74 | unsigned long rate_error, rate_error_prev = ~0UL; | 74 | unsigned long rate_error, rate_error_prev = ~0UL; |
75 | unsigned long rate_best_fit = rate; | 75 | unsigned long rate_best_fit = rate; |
76 | unsigned long highest, lowest; | ||
76 | int i; | 77 | int i; |
77 | 78 | ||
79 | highest = 0; | ||
80 | lowest = ~0UL; | ||
81 | |||
78 | for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { | 82 | for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { |
79 | unsigned long freq = freq_table[i].frequency; | 83 | unsigned long freq = freq_table[i].frequency; |
80 | 84 | ||
81 | if (freq == CPUFREQ_ENTRY_INVALID) | 85 | if (freq == CPUFREQ_ENTRY_INVALID) |
82 | continue; | 86 | continue; |
83 | 87 | ||
88 | if (freq > highest) | ||
89 | highest = freq; | ||
90 | if (freq < lowest) | ||
91 | lowest = freq; | ||
92 | |||
84 | rate_error = abs(freq - rate); | 93 | rate_error = abs(freq - rate); |
85 | if (rate_error < rate_error_prev) { | 94 | if (rate_error < rate_error_prev) { |
86 | rate_best_fit = freq; | 95 | rate_best_fit = freq; |
@@ -91,6 +100,11 @@ long clk_rate_table_round(struct clk *clk, | |||
91 | break; | 100 | break; |
92 | } | 101 | } |
93 | 102 | ||
103 | if (rate >= highest) | ||
104 | rate_best_fit = highest; | ||
105 | if (rate <= lowest) | ||
106 | rate_best_fit = lowest; | ||
107 | |||
94 | return rate_best_fit; | 108 | return rate_best_fit; |
95 | } | 109 | } |
96 | 110 | ||