clk: always pass parent_rate into .round_rate
The parent_rate will likely be used by most .round_rate implementation no matter whether flag CLK_SET_RATE_PARENT is set or not, so let's always pass parent_rate into .round_rate. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
This commit is contained in:
parent
27d545915f
commit
81536e072b
|
@ -67,8 +67,8 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
|
||||||
if (divider->flags & CLK_DIVIDER_ONE_BASED)
|
if (divider->flags & CLK_DIVIDER_ONE_BASED)
|
||||||
maxdiv--;
|
maxdiv--;
|
||||||
|
|
||||||
if (!best_parent_rate) {
|
if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) {
|
||||||
parent_rate = __clk_get_rate(__clk_get_parent(hw->clk));
|
parent_rate = *best_parent_rate;
|
||||||
bestdiv = DIV_ROUND_UP(parent_rate, rate);
|
bestdiv = DIV_ROUND_UP(parent_rate, rate);
|
||||||
bestdiv = bestdiv == 0 ? 1 : bestdiv;
|
bestdiv = bestdiv == 0 ? 1 : bestdiv;
|
||||||
bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv;
|
bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv;
|
||||||
|
@ -108,13 +108,7 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
|
||||||
int div;
|
int div;
|
||||||
div = clk_divider_bestdiv(hw, rate, prate);
|
div = clk_divider_bestdiv(hw, rate, prate);
|
||||||
|
|
||||||
if (prate)
|
return *prate / div;
|
||||||
return *prate / div;
|
|
||||||
else {
|
|
||||||
unsigned long r;
|
|
||||||
r = __clk_get_rate(__clk_get_parent(hw->clk));
|
|
||||||
return r / div;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate)
|
static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate)
|
||||||
|
|
|
@ -582,7 +582,7 @@ EXPORT_SYMBOL_GPL(clk_get_rate);
|
||||||
*/
|
*/
|
||||||
unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
|
unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
|
||||||
{
|
{
|
||||||
unsigned long unused;
|
unsigned long parent_rate = 0;
|
||||||
|
|
||||||
if (!clk)
|
if (!clk)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -590,10 +590,10 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
|
||||||
if (!clk->ops->round_rate)
|
if (!clk->ops->round_rate)
|
||||||
return clk->rate;
|
return clk->rate;
|
||||||
|
|
||||||
if (clk->flags & CLK_SET_RATE_PARENT)
|
if (clk->parent)
|
||||||
return clk->ops->round_rate(clk->hw, rate, &unused);
|
parent_rate = clk->parent->rate;
|
||||||
else
|
|
||||||
return clk->ops->round_rate(clk->hw, rate, NULL);
|
return clk->ops->round_rate(clk->hw, rate, &parent_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -763,7 +763,7 @@ static void clk_calc_subtree(struct clk *clk, unsigned long new_rate)
|
||||||
static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
|
static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
|
||||||
{
|
{
|
||||||
struct clk *top = clk;
|
struct clk *top = clk;
|
||||||
unsigned long best_parent_rate;
|
unsigned long best_parent_rate = 0;
|
||||||
unsigned long new_rate;
|
unsigned long new_rate;
|
||||||
|
|
||||||
/* sanity */
|
/* sanity */
|
||||||
|
@ -775,9 +775,6 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
|
||||||
if (!clk->ops->round_rate) {
|
if (!clk->ops->round_rate) {
|
||||||
clk->new_rate = clk->rate;
|
clk->new_rate = clk->rate;
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
|
||||||
new_rate = clk->ops->round_rate(clk->hw, rate, NULL);
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,6 +791,7 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
best_parent_rate = clk->parent->rate;
|
||||||
new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
|
new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
|
||||||
|
|
||||||
if (best_parent_rate != clk->parent->rate) {
|
if (best_parent_rate != clk->parent->rate) {
|
||||||
|
|
Loading…
Reference in New Issue