]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
clk: Only enable the parent clock if the clock was enabled before reparenting
authorMaksim Kiselev <bigunclemax@gmail.com>
Fri, 29 Aug 2025 08:25:00 +0000 (11:25 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 4 Dec 2025 15:39:26 +0000 (09:39 -0600)
The current implementation of clk_set_parent() unconditionally enables
the new parent clock, even if the target clock was not previously enabled.

To avoid this implicit behavior, this patch adds a check for whether
the target clock has been enabled before parent enabling..

Fixes: ac30d90f336 ("clk: Ensure the parent clocks are enabled while reparenting")
Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/clk/clk-uclass.c

index 3dbe1ce9441ca513d41be90520ff175c96b4253a..ae787b8851036d3f6b07c71a07fdc0be915c0ae6 100644 (file)
@@ -631,10 +631,12 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
        if (!ops->set_parent)
                return -ENOSYS;
 
-       ret = clk_enable(parent);
-       if (ret && ret != -ENOSYS) {
-               printf("Cannot enable parent %s\n", parent->dev->name);
-               return ret;
+       if (clk->enable_count) {
+               ret = clk_enable(parent);
+               if (ret && ret != -ENOSYS) {
+                       printf("Cannot enable parent %s\n", parent->dev->name);
+                       return ret;
+               }
        }
 
        ret = ops->set_parent(clk, parent);