diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-05-09 05:49:40 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-05-27 05:34:37 -0400 |
commit | 98ea5c218ed150bf7cabb879db4fc2c106b6fa5b (patch) | |
tree | 778c910cd569ec3813b6fdd05eb81532a860a3d1 /drivers/regulator/mc13892-regulator.c | |
parent | bf5892a8167e4aa5a9a6d72f803fde850e0c5753 (diff) |
regulator: Use mc13xxx_reg_write instead of mc13xxx_reg_rmw in mc13892_sw_regulator_set_voltage
Currently, we call mc13xxx_reg_read and mc13xxx_reg_rmw for the same register.
This can be converted to simply a mc13xxx_reg_read and a mc13xxx_reg_write,
thus save a redundant register read.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/mc13892-regulator.c')
-rw-r--r-- | drivers/regulator/mc13892-regulator.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index ba909cb0d2b8..c1ed67ec5148 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
@@ -431,7 +431,8 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev, | |||
431 | int min_uV, int max_uV, unsigned *selector) | 431 | int min_uV, int max_uV, unsigned *selector) |
432 | { | 432 | { |
433 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 433 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
434 | int hi, value, val, mask, id = rdev_get_id(rdev); | 434 | int hi, value, mask, id = rdev_get_id(rdev); |
435 | u32 valread; | ||
435 | int ret; | 436 | int ret; |
436 | 437 | ||
437 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", | 438 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", |
@@ -447,15 +448,16 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev, | |||
447 | 448 | ||
448 | mc13xxx_lock(priv->mc13xxx); | 449 | mc13xxx_lock(priv->mc13xxx); |
449 | ret = mc13xxx_reg_read(priv->mc13xxx, | 450 | ret = mc13xxx_reg_read(priv->mc13xxx, |
450 | mc13892_regulators[id].vsel_reg, &val); | 451 | mc13892_regulators[id].vsel_reg, &valread); |
451 | if (ret) | 452 | if (ret) |
452 | goto err; | 453 | goto err; |
453 | 454 | ||
454 | hi = val & MC13892_SWITCHERS0_SWxHI; | ||
455 | if (value > 1375) | 455 | if (value > 1375) |
456 | hi = 1; | 456 | hi = 1; |
457 | if (value < 1100) | 457 | else if (value < 1100) |
458 | hi = 0; | 458 | hi = 0; |
459 | else | ||
460 | hi = valread & MC13892_SWITCHERS0_SWxHI; | ||
459 | 461 | ||
460 | if (hi) { | 462 | if (hi) { |
461 | value = (value - 1100000) / 25000; | 463 | value = (value - 1100000) / 25000; |
@@ -464,8 +466,10 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev, | |||
464 | value = (value - 600000) / 25000; | 466 | value = (value - 600000) / 25000; |
465 | 467 | ||
466 | mask = mc13892_regulators[id].vsel_mask | MC13892_SWITCHERS0_SWxHI; | 468 | mask = mc13892_regulators[id].vsel_mask | MC13892_SWITCHERS0_SWxHI; |
467 | ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13892_regulators[id].vsel_reg, | 469 | valread = (valread & ~mask) | |
468 | mask, value << mc13892_regulators[id].vsel_shift); | 470 | (value << mc13892_regulators[id].vsel_shift); |
471 | ret = mc13xxx_reg_write(priv->mc13xxx, mc13892_regulators[id].vsel_reg, | ||
472 | valread); | ||
469 | err: | 473 | err: |
470 | mc13xxx_unlock(priv->mc13xxx); | 474 | mc13xxx_unlock(priv->mc13xxx); |
471 | 475 | ||