aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk-multiplier.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk/clk-multiplier.c')
-rw-r--r--drivers/clk/clk-multiplier.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/clk/clk-multiplier.c b/drivers/clk/clk-multiplier.c
index 9e449c7b751c..dc037c957acd 100644
--- a/drivers/clk/clk-multiplier.c
+++ b/drivers/clk/clk-multiplier.c
@@ -52,14 +52,28 @@ static unsigned long __bestmult(struct clk_hw *hw, unsigned long rate,
52 unsigned long *best_parent_rate, 52 unsigned long *best_parent_rate,
53 u8 width, unsigned long flags) 53 u8 width, unsigned long flags)
54{ 54{
55 struct clk_multiplier *mult = to_clk_multiplier(hw);
55 unsigned long orig_parent_rate = *best_parent_rate; 56 unsigned long orig_parent_rate = *best_parent_rate;
56 unsigned long parent_rate, current_rate, best_rate = ~0; 57 unsigned long parent_rate, current_rate, best_rate = ~0;
57 unsigned int i, bestmult = 0; 58 unsigned int i, bestmult = 0;
59 unsigned int maxmult = (1 << width) - 1;
60
61 if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
62 bestmult = rate / orig_parent_rate;
63
64 /* Make sure we don't end up with a 0 multiplier */
65 if ((bestmult == 0) &&
66 !(mult->flags & CLK_MULTIPLIER_ZERO_BYPASS))
67 bestmult = 1;
58 68
59 if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) 69 /* Make sure we don't overflow the multiplier */
60 return rate / *best_parent_rate; 70 if (bestmult > maxmult)
71 bestmult = maxmult;
72
73 return bestmult;
74 }
61 75
62 for (i = 1; i < ((1 << width) - 1); i++) { 76 for (i = 1; i < maxmult; i++) {
63 if (rate == orig_parent_rate * i) { 77 if (rate == orig_parent_rate * i) {
64 /* 78 /*
65 * This is the best case for us if we have a 79 * This is the best case for us if we have a