Skip to content

Commit

Permalink
regulator: core: Optimize _regulator_do_set_voltage if voltage does n…
Browse files Browse the repository at this point in the history
…ot change

Optimize _regulator_do_set_voltage() for the case selector is equal to
old_selector. Since the voltage does not change, we don't need to call
set_voltage_sel() and set_voltage_time_sel() in this case.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Feb 8, 2013
1 parent 92d7a55 commit c66a566
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,8 +2185,11 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
best_val = rdev->desc->ops->list_voltage(rdev, ret);
if (min_uV <= best_val && max_uV >= best_val) {
selector = ret;
ret = rdev->desc->ops->set_voltage_sel(rdev,
ret);
if (old_selector == selector)
ret = 0;
else
ret = rdev->desc->ops->set_voltage_sel(
rdev, ret);
} else {
ret = -EINVAL;
}
Expand All @@ -2197,7 +2200,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,

/* Call set_voltage_time_sel if successfully obtained old_selector */
if (ret == 0 && _regulator_is_enabled(rdev) && old_selector >= 0 &&
rdev->desc->ops->set_voltage_time_sel) {
old_selector != selector && rdev->desc->ops->set_voltage_time_sel) {

delay = rdev->desc->ops->set_voltage_time_sel(rdev,
old_selector, selector);
Expand Down

0 comments on commit c66a566

Please sign in to comment.