diff options
-rw-r--r-- | drivers/clk/clk-divider.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index c57294563a98..b3c83966be18 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c | |||
@@ -240,6 +240,18 @@ static bool _is_best_div(struct clk_divider *divider, | |||
240 | return now <= rate && now > best; | 240 | return now <= rate && now > best; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int _next_div(struct clk_divider *divider, int div) | ||
244 | { | ||
245 | div++; | ||
246 | |||
247 | if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) | ||
248 | return __roundup_pow_of_two(div); | ||
249 | if (divider->table) | ||
250 | return _round_up_table(divider->table, div); | ||
251 | |||
252 | return div; | ||
253 | } | ||
254 | |||
243 | static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, | 255 | static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, |
244 | unsigned long *best_parent_rate) | 256 | unsigned long *best_parent_rate) |
245 | { | 257 | { |
@@ -267,7 +279,7 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate, | |||
267 | */ | 279 | */ |
268 | maxdiv = min(ULONG_MAX / rate, maxdiv); | 280 | maxdiv = min(ULONG_MAX / rate, maxdiv); |
269 | 281 | ||
270 | for (i = 1; i <= maxdiv; i++) { | 282 | for (i = 1; i <= maxdiv; i = _next_div(divider, i)) { |
271 | if (!_is_valid_div(divider, i)) | 283 | if (!_is_valid_div(divider, i)) |
272 | continue; | 284 | continue; |
273 | if (rate * i == parent_rate_saved) { | 285 | if (rate * i == parent_rate_saved) { |