[PATCH 1/1] clk: fix clk_enable() parent enable

Maxim Kochetkov fido_max at inbox.ru
Fri Jul 26 14:03:09 CEST 2024


Move clkp->enable_count++ after clk_enable(clkp->dev->parent).
It allows the parent clock increment its enable counters for proper
disable sequence.

Signed-off-by: Maxim Kochetkov <fido_max at inbox.ru>
---
 drivers/clk/clk-uclass.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index c48a62ba09..d56001c0b7 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -618,10 +618,6 @@ int clk_enable(struct clk *clk)
 		/* Take id 0 as a non-valid clk, such as dummy */
 		if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
 			ops = clk_dev_ops(clkp->dev);
-			if (clkp->enable_count) {
-				clkp->enable_count++;
-				return 0;
-			}
 			if (clkp->dev->parent &&
 			    device_get_uclass_id(clkp->dev->parent) == UCLASS_CLK) {
 				ret = clk_enable(dev_get_clk_ptr(clkp->dev->parent));
@@ -631,6 +627,11 @@ int clk_enable(struct clk *clk)
 					return ret;
 				}
 			}
+
+			if (clkp->enable_count) {
+				clkp->enable_count++;
+				return 0;
+			}
 		}
 
 		if (ops->enable) {
-- 
2.45.2



More information about the U-Boot mailing list