aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/clk/clk-divider.c12
-rw-r--r--drivers/clk/clk.c16
2 files changed, 10 insertions, 18 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 5fc541d017f1..03b127c0313b 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -67,8 +67,8 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
67 if (divider->flags & CLK_DIVIDER_ONE_BASED) 67 if (divider->flags & CLK_DIVIDER_ONE_BASED)
68 maxdiv--; 68 maxdiv--;
69 69
70 if (!best_parent_rate) { 70 if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) {
71 parent_rate = __clk_get_rate(__clk_get_parent(hw->clk)); 71 parent_rate = *best_parent_rate;
72 bestdiv = DIV_ROUND_UP(parent_rate, rate); 72 bestdiv = DIV_ROUND_UP(parent_rate, rate);
73 bestdiv = bestdiv == 0 ? 1 : bestdiv; 73 bestdiv = bestdiv == 0 ? 1 : bestdiv;
74 bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv; 74 bestdiv = bestdiv > maxdiv ? maxdiv : bestdiv;
@@ -108,13 +108,7 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate,
108 int div; 108 int div;
109 div = clk_divider_bestdiv(hw, rate, prate); 109 div = clk_divider_bestdiv(hw, rate, prate);
110 110
111 if (prate) 111 return *prate / div;
112 return *prate / div;
113 else {
114 unsigned long r;
115 r = __clk_get_rate(__clk_get_parent(hw->clk));
116 return r / div;
117 }
118} 112}
119 113
120static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate) 114static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 8f7c3849c8f6..1ab4f7e5c7ef 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -582,7 +582,7 @@ EXPORT_SYMBOL_GPL(clk_get_rate);
582 */ 582 */
583unsigned long __clk_round_rate(struct clk *clk, unsigned long rate) 583unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
584{ 584{
585 unsigned long unused; 585 unsigned long parent_rate = 0;
586 586
587 if (!clk) 587 if (!clk)
588 return -EINVAL; 588 return -EINVAL;
@@ -590,10 +590,10 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
590 if (!clk->ops->round_rate) 590 if (!clk->ops->round_rate)
591 return clk->rate; 591 return clk->rate;
592 592
593 if (clk->flags & CLK_SET_RATE_PARENT) 593 if (clk->parent)
594 return clk->ops->round_rate(clk->hw, rate, &unused); 594 parent_rate = clk->parent->rate;
595 else 595
596 return clk->ops->round_rate(clk->hw, rate, NULL); 596 return clk->ops->round_rate(clk->hw, rate, &parent_rate);
597} 597}
598 598
599/** 599/**
@@ -763,7 +763,7 @@ static void clk_calc_subtree(struct clk *clk, unsigned long new_rate)
763static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) 763static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
764{ 764{
765 struct clk *top = clk; 765 struct clk *top = clk;
766 unsigned long best_parent_rate; 766 unsigned long best_parent_rate = 0;
767 unsigned long new_rate; 767 unsigned long new_rate;
768 768
769 /* sanity */ 769 /* sanity */
@@ -775,9 +775,6 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
775 if (!clk->ops->round_rate) { 775 if (!clk->ops->round_rate) {
776 clk->new_rate = clk->rate; 776 clk->new_rate = clk->rate;
777 return NULL; 777 return NULL;
778 } else {
779 new_rate = clk->ops->round_rate(clk->hw, rate, NULL);
780 goto out;
781 } 778 }
782 } 779 }
783 780
@@ -794,6 +791,7 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
794 goto out; 791 goto out;
795 } 792 }
796 793
794 best_parent_rate = clk->parent->rate;
797 new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate); 795 new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
798 796
799 if (best_parent_rate != clk->parent->rate) { 797 if (best_parent_rate != clk->parent->rate) {