diff options
| -rw-r--r-- | drivers/clk/clk-divider.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 78b2e656ff6a..25006a8bb8e6 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c | |||
| @@ -219,17 +219,18 @@ static int _div_round_closest(const struct clk_div_table *table, | |||
| 219 | unsigned long parent_rate, unsigned long rate, | 219 | unsigned long parent_rate, unsigned long rate, |
| 220 | unsigned long flags) | 220 | unsigned long flags) |
| 221 | { | 221 | { |
| 222 | int up, down, div; | 222 | int up, down; |
| 223 | unsigned long up_rate, down_rate; | 223 | unsigned long up_rate, down_rate; |
| 224 | 224 | ||
| 225 | up = down = div = DIV_ROUND_CLOSEST(parent_rate, rate); | 225 | up = DIV_ROUND_UP(parent_rate, rate); |
| 226 | down = parent_rate / rate; | ||
| 226 | 227 | ||
| 227 | if (flags & CLK_DIVIDER_POWER_OF_TWO) { | 228 | if (flags & CLK_DIVIDER_POWER_OF_TWO) { |
| 228 | up = __roundup_pow_of_two(div); | 229 | up = __roundup_pow_of_two(up); |
| 229 | down = __rounddown_pow_of_two(div); | 230 | down = __rounddown_pow_of_two(down); |
| 230 | } else if (table) { | 231 | } else if (table) { |
| 231 | up = _round_up_table(table, div); | 232 | up = _round_up_table(table, up); |
| 232 | down = _round_down_table(table, div); | 233 | down = _round_down_table(table, down); |
| 233 | } | 234 | } |
| 234 | 235 | ||
| 235 | up_rate = DIV_ROUND_UP(parent_rate, up); | 236 | up_rate = DIV_ROUND_UP(parent_rate, up); |
