summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-01-24 05:01:12 +0100
committerMark Brown <broonie@kernel.org>2015-01-26 20:11:35 +0100
commitc6515d2f00dc45d6bf5b6e56c9a7d4dc2e271563 (patch)
treef6f44a8baa061f56d1cfcbf65bd30fb86a3a9df3 /drivers/regulator
parentLinux 3.19-rc1 (diff)
downloadlinux-c6515d2f00dc45d6bf5b6e56c9a7d4dc2e271563.tar.xz
linux-c6515d2f00dc45d6bf5b6e56c9a7d4dc2e271563.zip
regulator: qcom_rpm: Don't update vreg->uV/mV if rpm_reg_write fails
Ensure get_voltage return correct voltage if set_voltage fails. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/qcom_rpm-regulator.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index 8364ff331a81..95099e6bfce3 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -227,9 +227,11 @@ static int rpm_reg_set_mV_sel(struct regulator_dev *rdev,
return uV;
mutex_lock(&vreg->lock);
- vreg->uV = uV;
if (vreg->is_enabled)
- ret = rpm_reg_write(vreg, req, vreg->uV / 1000);
+ ret = rpm_reg_write(vreg, req, uV / 1000);
+
+ if (!ret)
+ vreg->uV = uV;
mutex_unlock(&vreg->lock);
return ret;
@@ -252,9 +254,11 @@ static int rpm_reg_set_uV_sel(struct regulator_dev *rdev,
return uV;
mutex_lock(&vreg->lock);
- vreg->uV = uV;
if (vreg->is_enabled)
- ret = rpm_reg_write(vreg, req, vreg->uV);
+ ret = rpm_reg_write(vreg, req, uV);
+
+ if (!ret)
+ vreg->uV = uV;
mutex_unlock(&vreg->lock);
return ret;