* [PATCH] clk: divider: fix divider setting with CLK_SET_RATE_PARENT
@ 2021-04-13 9:01 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2021-04-13 9:01 UTC (permalink / raw)
To: Barebox List
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@pengutronix.de>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-13 9:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 9:01 [PATCH] clk: divider: fix divider setting with CLK_SET_RATE_PARENT Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox