[PATCH] clk: divider: fix divider setting with CLK_SET_RATE_PARENT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When CLK_SET_RATE_PARENT is set for a divider then clk_divider_bestdiv()
is called which returns the best parent rate. This best parent rate must
be fed into divider_get_val(), not the unchanged original parent rate.

Fixes: 47b432c697 ("clk: divider: export clk_div_mask() helper")
Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/clk/clk-divider.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 9c2e50e4a5..7119dd4e59 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -265,19 +265,17 @@ static int clk_divider_set_rate(struct clk *clk, unsigned long rate,
 		unsigned long parent_rate)
 {
 	struct clk_divider *divider = container_of(clk, struct clk_divider, clk);
-	unsigned int div, value;
+	unsigned int value;
 	u32 val;
 
 	if (divider->flags & CLK_DIVIDER_READ_ONLY)
 		return 0;
 
 	if (clk->flags & CLK_SET_RATE_PARENT) {
-		unsigned long best_parent_rate = parent_rate;
-		div = clk_divider_bestdiv(clk, rate, &best_parent_rate,
-				divider->table, divider->width, divider->flags);
-		clk_set_rate(clk_get_parent(clk), best_parent_rate);
-	} else {
-		div = DIV_ROUND_UP(parent_rate, rate);
+		clk_divider_bestdiv(clk, rate, &parent_rate,
+				    divider->table, divider->width,
+				    divider->flags);
+		clk_set_rate(clk_get_parent(clk), parent_rate);
 	}
 
 	value = divider_get_val(rate, parent_rate, divider->table,
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux