diff options
author | 2013-02-06 11:09:48 +0800 | |
---|---|---|
committer | 2013-02-08 11:26:03 +0000 | |
commit | c66a566afbe6e2c94b1ae70f70cc1e3d4c73639b (patch) | |
tree | 8f1b8621037193da762fc1a4b52c2561b3733bdb /drivers/regulator | |
parent | regulator: core: if voltage scaling fails, restore original voltage values (diff) | |
download | linux-c66a566afbe6e2c94b1ae70f70cc1e3d4c73639b.tar.gz linux-c66a566afbe6e2c94b1ae70f70cc1e3d4c73639b.tar.bz2 linux-c66a566afbe6e2c94b1ae70f70cc1e3d4c73639b.zip |
regulator: core: Optimize _regulator_do_set_voltage if voltage does not 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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c347fd03b727..7ec2ed6a1d7b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -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; } @@ -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); |