diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-03-28 13:23:00 +0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-29 21:52:55 +0400 |
commit | 742a73259d2d07ad6870736749aa8d6821ed96d9 (patch) | |
tree | 611eec8737682846eecd01c2049b30513d561aba /drivers/regulator/ab8500.c | |
parent | da0b0c47dcfd92317e2ece4c3434e1f82b55cf8a (diff) | |
download | linux-742a73259d2d07ad6870736749aa8d6821ed96d9.tar.xz |
regulator: ab8500: Update info->update_val only when successfully update register
Don't update info->update_val if write to the register fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r-- | drivers/regulator/ab8500.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index bf34c4cd6631..c7b433a2a3a9 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -184,8 +184,8 @@ static unsigned int ab8500_regulator_get_optimum_mode( static int ab8500_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode) { - int ret = 0; - + int ret; + u8 update_val; struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) { @@ -195,31 +195,42 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_NORMAL: - info->update_val = info->update_val_normal; + update_val = info->update_val_normal; break; case REGULATOR_MODE_IDLE: - info->update_val = info->update_val_idle; + update_val = info->update_val_idle; break; default: return -EINVAL; } + /* ab8500 regulators share mode and enable in the same register bits. + off = 0b00 + low power mode= 0b11 + full powermode = 0b01 + (HW control mode = 0b10) + Thus we don't write to the register when regulator is disabled. + */ if (info->is_enabled) { ret = abx500_mask_and_set_register_interruptible(info->dev, info->update_bank, info->update_reg, - info->update_mask, info->update_val); - if (ret < 0) + info->update_mask, update_val); + if (ret < 0) { dev_err(rdev_get_dev(rdev), "couldn't set regulator mode\n"); + return ret; + } dev_vdbg(rdev_get_dev(rdev), "%s-set_mode (bank, reg, mask, value): " "0x%x, 0x%x, 0x%x, 0x%x\n", info->desc.name, info->update_bank, info->update_reg, - info->update_mask, info->update_val); + info->update_mask, update_val); } - return ret; + info->update_val = update_val; + + return 0; } static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev) |