]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: bcm235xx: update clock framework
authorSteve Rae <srae@broadcom.com>
Tue, 21 Jun 2016 23:43:07 +0000 (16:43 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 24 Jun 2016 21:24:38 +0000 (17:24 -0400)
The handling of the "usage counter" is incorrect, and the clock should
only be disabled when transitioning from 1 to 0.

Reported-by: Chris Brand <chris.brand@broadcom.com>
Signed-off-by: Steve Rae <srae@broadcom.com>
arch/arm/cpu/armv7/bcm235xx/clk-core.c

index 2b5da6bb6b21b048c3fef0ae61dc322ae5ff940a..a326dfea6c28acabab86807707ede1e8954ff8a5 100644 (file)
@@ -449,10 +449,9 @@ int clk_enable(struct clk *c)
        if (ret)
                return ret;
 
-       if (!c->use_cnt) {
-               c->use_cnt++;
+       if (!c->use_cnt)
                ret = c->ops->enable(c, 1);
-       }
+       c->use_cnt++;
 
        return ret;
 }
@@ -464,9 +463,10 @@ void clk_disable(struct clk *c)
        if (!c->ops || !c->ops->enable)
                return;
 
-       if (c->use_cnt) {
+       if (c->use_cnt > 0) {
                c->use_cnt--;
-               c->ops->enable(c, 0);
+               if (c->use_cnt == 0)
+                       c->ops->enable(c, 0);
        }
 
        /* disable parent */