|
@@ -220,6 +220,7 @@ static int _div_round_closest(const struct clk_div_table *table,
|
|
|
unsigned long flags)
|
|
|
{
|
|
|
int up, down, div;
|
|
|
+ unsigned long up_rate, down_rate;
|
|
|
|
|
|
up = down = div = DIV_ROUND_CLOSEST(parent_rate, rate);
|
|
|
|
|
@@ -231,7 +232,10 @@ static int _div_round_closest(const struct clk_div_table *table,
|
|
|
down = _round_down_table(table, div);
|
|
|
}
|
|
|
|
|
|
- return (up - div) <= (div - down) ? up : down;
|
|
|
+ up_rate = DIV_ROUND_UP(parent_rate, up);
|
|
|
+ down_rate = DIV_ROUND_UP(parent_rate, down);
|
|
|
+
|
|
|
+ return (rate - up_rate) <= (down_rate - rate) ? up : down;
|
|
|
}
|
|
|
|
|
|
static int _div_round(const struct clk_div_table *table,
|