At boot sometimes regulators (like qcom-rpmh-regulator) will return
-EINVAL if we don't know the enable state of the regulator.  We
shouldn't take this to mean that the regulator is an always-on
regulator, but that was what was happening since "-EINVAL" is non-zero
and a few places in the code were not properly checking for errors.

Let's resolve this.

Signed-off-by: Douglas Anderson <diand...@chromium.org>
---

 drivers/regulator/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ff5ca185bb8f..0052bbc8c531 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1622,7 +1622,7 @@ static struct regulator *create_regulator(struct 
regulator_dev *rdev,
         * enable/disable calls.
         */
        if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_STATUS) &&
-           _regulator_is_enabled(rdev))
+           _regulator_is_enabled(rdev) > 0)
                regulator->always_on = true;
 
        regulator_unlock(rdev);
@@ -1811,7 +1811,7 @@ static int regulator_resolve_supply(struct regulator_dev 
*rdev)
        }
 
        /* Cascade always-on state to supply */
-       if (_regulator_is_enabled(rdev)) {
+       if (_regulator_is_enabled(rdev) > 0) {
                ret = regulator_enable(rdev->supply);
                if (ret < 0) {
                        _regulator_put(rdev->supply);
-- 
2.19.1.1215.g8438c0b245-goog

Reply via email to