]> Pileus Git - ~andy/linux/blobdiff - drivers/regulator/core.c
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[~andy/linux] / drivers / regulator / core.c
index 58452ac0f165fa0b54025252d34eb8c206e68719..d3e38790906ed889de2b78454516ec1410eb6466 100644 (file)
@@ -158,6 +158,13 @@ static int regulator_check_consumers(struct regulator_dev *rdev,
        struct regulator *regulator;
 
        list_for_each_entry(regulator, &rdev->consumer_list, list) {
+               /*
+                * Assume consumers that didn't say anything are OK
+                * with anything in the constraint range.
+                */
+               if (!regulator->min_uV && !regulator->max_uV)
+                       continue;
+
                if (*max_uV > regulator->max_uV)
                        *max_uV = regulator->max_uV;
                if (*min_uV < regulator->min_uV)
@@ -1879,12 +1886,14 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
                if (sel < 0)
                        return sel;
                ret = rdev->desc->ops->list_voltage(rdev, sel);
-       }
-       if (rdev->desc->ops->get_voltage)
+       } else if (rdev->desc->ops->get_voltage) {
                ret = rdev->desc->ops->get_voltage(rdev);
-       else
+       } else {
                return -EINVAL;
+       }
 
+       if (ret < 0)
+               return ret;
        return ret - rdev->constraints->uV_offset;
 }
 
@@ -2097,16 +2106,26 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
 
        mutex_lock(&rdev->mutex);
 
+       /*
+        * first check to see if we can set modes at all, otherwise just
+        * tell the consumer everything is OK.
+        */
        regulator->uA_load = uA_load;
        ret = regulator_check_drms(rdev);
-       if (ret < 0)
+       if (ret < 0) {
+               ret = 0;
                goto out;
-       ret = -EINVAL;
+       }
 
-       /* sanity check */
        if (!rdev->desc->ops->get_optimum_mode)
                goto out;
 
+       /*
+        * we can actually do this so any errors are indicators of
+        * potential real failure.
+        */
+       ret = -EINVAL;
+
        /* get output voltage */
        output_uV = _regulator_get_voltage(rdev);
        if (output_uV <= 0) {