]> Pileus Git - ~andy/linux/blobdiff - drivers/regulator/core.c
regulator: core: Replace direct ops->enable usage
[~andy/linux] / drivers / regulator / core.c
index d85f31385b24fe9b68ae45dfe0ece4be0ecc2ceb..00feec321e3c68b212d23702edbbe328b3820c3c 100644 (file)
@@ -953,6 +953,8 @@ static int machine_constraints_current(struct regulator_dev *rdev,
        return 0;
 }
 
+static int _regulator_do_enable(struct regulator_dev *rdev);
+
 /**
  * set_machine_constraints - sets regulator constraints
  * @rdev: regulator source
@@ -1013,10 +1015,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
        /* If the constraints say the regulator should be on at this point
         * and we have control then make sure it is enabled.
         */
-       if ((rdev->constraints->always_on || rdev->constraints->boot_on) &&
-           ops->enable) {
-               ret = ops->enable(rdev);
-               if (ret < 0) {
+       if (rdev->constraints->always_on || rdev->constraints->boot_on) {
+               ret = _regulator_do_enable(rdev);
+               if (ret < 0 && ret != -EINVAL) {
                        rdev_err(rdev, "failed to enable\n");
                        goto out;
                }
@@ -1334,9 +1335,8 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
         * If we have return value from dev_lookup fail, we do not expect to
         * succeed, so, quit with appropriate error value
         */
-       if (ret && ret != -ENODEV) {
+       if (ret && ret != -ENODEV)
                goto out;
-       }
 
        if (!devname)
                devname = "deviceless";
@@ -1351,8 +1351,9 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 
                rdev = dummy_regulator_rdev;
                goto found;
-       } else {
-               dev_err(dev, "dummy supplies not allowed\n");
+       /* Don't log an error when called from regulator_get_optional() */
+       } else if (!have_full_constraints() || exclusive) {
+               dev_warn(dev, "dummy supplies not allowed\n");
        }
 
        mutex_unlock(&regulator_list_mutex);
@@ -2244,7 +2245,7 @@ int regulator_is_supported_voltage(struct regulator *regulator,
        if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
                ret = regulator_get_voltage(regulator);
                if (ret >= 0)
-                       return (min_uV <= ret && ret <= max_uV);
+                       return min_uV <= ret && ret <= max_uV;
                else
                        return ret;
        }
@@ -2416,7 +2417,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
        ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
        if (ret < 0)
                goto out;
-       
+
        /* restore original values in case of error */
        old_min_uV = regulator->min_uV;
        old_max_uV = regulator->max_uV;
@@ -2430,7 +2431,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
        ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
        if (ret < 0)
                goto out2;
-       
+
 out:
        mutex_unlock(&rdev->mutex);
        return ret;
@@ -3626,9 +3627,8 @@ int regulator_suspend_finish(void)
                struct regulator_ops *ops = rdev->desc->ops;
 
                mutex_lock(&rdev->mutex);
-               if ((rdev->use_count > 0  || rdev->constraints->always_on) &&
-                               ops->enable) {
-                       error = ops->enable(rdev);
+               if (rdev->use_count > 0  || rdev->constraints->always_on) {
+                       error = _regulator_do_enable(rdev);
                        if (error)
                                ret = error;
                } else {
@@ -3835,9 +3835,8 @@ static int __init regulator_init_complete(void)
                         * goes wrong. */
                        rdev_info(rdev, "disabling\n");
                        ret = ops->disable(rdev);
-                       if (ret != 0) {
+                       if (ret != 0)
                                rdev_err(rdev, "couldn't disable: %d\n", ret);
-                       }
                } else {
                        /* The intention is that in future we will
                         * assume that full constraints are provided