Skip to content

Commit

Permalink
regulator: qcom_rpm: Don't update vreg->uV/mV if rpm_reg_write fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Mark Brown committed Jan 26, 2015
1 parent 97bf6af commit c6515d2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/regulator/qcom_rpm-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c6515d2

Please sign in to comment.