]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
OMAP3 PM: convert open-coded iterator to use pwrdm_for_each_clkdm()
authorPaul Walmsley <paul@pwsan.com>
Thu, 22 May 2008 17:33:54 +0000 (11:33 -0600)
committerTony Lindgren <tony@atomide.com>
Wed, 28 May 2008 20:41:51 +0000 (13:41 -0700)
Convert iterators of the list of clockdomains in a powerdomain to use
pwrdm_for_each_clkdm(), rather than an open-coded for-loop.

This also fixes a bug when the D2D clockdomain is added to the 3430ES2
chip.  The open-coded for-loop tested for a NULL pointer in pwrdm_clkdms[]
to determine when to end the loop.  This causes the iterator to fall
off the end of the array when the powerdomain contains the maximum number
of clockdomains per powerdomain (currently 3).

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/pm34xx.c

index a1bfb30f0cf14d33e8727c1bfc28079ce53e7724..7e775cc2b2013a606ea050113b2a6bfab281bf8f 100644 (file)
@@ -179,6 +179,22 @@ static int omap3_can_sleep(void)
        return 1;
 }
 
+/* _clkdm_deny_idle - private callback function used by set_pwrdm_state() */
+static int _clkdm_deny_idle(struct powerdomain *pwrdm,
+                           struct clockdomain *clkdm)
+{
+       omap2_clkdm_deny_idle(clkdm);
+       return 0;
+}
+
+/* _clkdm_allow_idle - private callback function used by set_pwrdm_state() */
+static int _clkdm_allow_idle(struct powerdomain *pwrdm,
+                            struct clockdomain *clkdm)
+{
+       omap2_clkdm_allow_idle(clkdm);
+       return 0;
+}
+
 /* This sets pwrdm state (other than mpu & core. Currently only ON &
  * RET are supported. Function is assuming that clkdm doesn't have
  * hw_sup mode enabled. */
@@ -186,7 +202,6 @@ static int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
 {
        u32 cur_state;
        int ret = 0;
-       int i = 0;
 
        if (pwrdm == NULL || IS_ERR(pwrdm))
                return -EINVAL;
@@ -196,8 +211,7 @@ static int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
        if (cur_state == state)
                return ret;
 
-       for (i = 0; pwrdm->pwrdm_clkdms[i]; i++)
-               omap2_clkdm_deny_idle(pwrdm->pwrdm_clkdms[i]);
+       pwrdm_for_each_clkdm(pwrdm, _clkdm_deny_idle);
 
        ret = pwrdm_set_next_pwrst(pwrdm, state);
        if (ret) {
@@ -206,8 +220,7 @@ static int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
                goto err;
        }
 
-       for (i = 0; pwrdm->pwrdm_clkdms[i]; i++)
-               omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[i]);
+       pwrdm_for_each_clkdm(pwrdm, _clkdm_allow_idle);
 
 err:
        return ret;