]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/regulator/core.c
regulator: Allow boot_on regulators to be disabled by clients
[linux-2.6-omap-h63xx.git] / drivers / regulator / core.c
index 2ff76349f392d364ced271af303004a602b8e0a3..08441e24946e44a77730cc0eb5630129e4871acc 100644 (file)
@@ -776,10 +776,6 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                        }
        }
 
-       /* are we enabled at boot time by firmware / bootloader */
-       if (rdev->constraints->boot_on)
-               rdev->use_count = 1;
-
        /* do we need to setup our suspend state */
        if (constraints->initial_state) {
                ret = suspend_prepare(rdev, constraints->initial_state);
@@ -808,11 +804,10 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                }
        }
 
-       /* if always_on is set then turn the regulator on if it's not
-        * already on. */
-       if (constraints->always_on && ops->enable &&
-           ((ops->is_enabled && !ops->is_enabled(rdev)) ||
-            (!ops->is_enabled && !constraints->boot_on))) {
+       /* If the constraints say the regulator should be on at this point
+        * and we have control then make sure it is enabled.
+        */
+       if ((constraints->always_on || constraints->boot_on) && ops->enable) {
                ret = ops->enable(rdev);
                if (ret < 0) {
                        printk(KERN_ERR "%s: failed to enable %s\n",