aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab8500.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-04-09 08:15:06 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-17 10:08:22 -0400
commitf04adc5ab3b70ad9b7d17d6a6fc2113669134a4d (patch)
treee2d2abca0f6de8060440b49799de66c448d0325b /drivers/regulator/ab8500.c
parent241896ce8d112f10dae5538be41fad9eeb9e5e46 (diff)
regulator: ab8500: Don't update info->update_val if write to register fails
This patch ensures info->update_val is consistent with current register value. 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.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 29a727ca399b..5fd3b34274cc 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -392,9 +392,8 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
392 val = info->mode_val_idle; 392 val = info->mode_val_idle;
393 break; 393 break;
394 default: 394 default:
395 if (info->shared_mode) 395 ret = -EINVAL;
396 mutex_unlock(&shared_mode_mutex); 396 goto out_unlock;
397 return -EINVAL;
398 } 397 }
399 398
400 bank = info->mode_bank; 399 bank = info->mode_bank;
@@ -405,17 +404,14 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
405 404
406 switch (mode) { 405 switch (mode) {
407 case REGULATOR_MODE_NORMAL: 406 case REGULATOR_MODE_NORMAL:
408 info->update_val = info->update_val_normal;
409 val = info->update_val_normal; 407 val = info->update_val_normal;
410 break; 408 break;
411 case REGULATOR_MODE_IDLE: 409 case REGULATOR_MODE_IDLE:
412 info->update_val = info->update_val_idle;
413 val = info->update_val_idle; 410 val = info->update_val_idle;
414 break; 411 break;
415 default: 412 default:
416 if (info->shared_mode) 413 ret = -EINVAL;
417 mutex_unlock(&shared_mode_mutex); 414 goto out_unlock;
418 return -EINVAL;
419 } 415 }
420 416
421 bank = info->update_bank; 417 bank = info->update_bank;
@@ -426,9 +422,11 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
426 if (dmr || ab8500_regulator_is_enabled(rdev)) { 422 if (dmr || ab8500_regulator_is_enabled(rdev)) {
427 ret = abx500_mask_and_set_register_interruptible(info->dev, 423 ret = abx500_mask_and_set_register_interruptible(info->dev,
428 bank, reg, mask, val); 424 bank, reg, mask, val);
429 if (ret < 0) 425 if (ret < 0) {
430 dev_err(rdev_get_dev(rdev), 426 dev_err(rdev_get_dev(rdev),
431 "couldn't set regulator mode\n"); 427 "couldn't set regulator mode\n");
428 goto out_unlock;
429 }
432 430
433 dev_vdbg(rdev_get_dev(rdev), 431 dev_vdbg(rdev_get_dev(rdev),
434 "%s-set_mode (bank, reg, mask, value): " 432 "%s-set_mode (bank, reg, mask, value): "
@@ -437,6 +435,10 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
437 mask, val); 435 mask, val);
438 } 436 }
439 437
438 if (!dmr)
439 info->update_val = val;
440
441out_unlock:
440 if (info->shared_mode) 442 if (info->shared_mode)
441 mutex_unlock(&shared_mode_mutex); 443 mutex_unlock(&shared_mode_mutex);
442 444