From: Douglas Anderson Subject: [PATCH 2/7] regulator: core: Don't assume always_on when is_enabled returns err Date: Mon, 19 Nov 2018 16:26:49 -0800 Message-ID: <20181120002654.1891-2-dianders@chromium.org> References: <20181120002654.1891-1-dianders@chromium.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20181120002654.1891-1-dianders@chromium.org> Sender: linux-kernel-owner@vger.kernel.org To: Mark Brown Cc: Bjorn Andersson , evgreen@chromium.org, swboyd@chromium.org, Dmitry Osipenko , ryandcase@chromium.org, David Collins , linux-arm-msm@vger.kernel.org, Douglas Anderson , Liam Girdwood , linux-kernel@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org 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 --- 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