diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-08-17 08:16:51 +0530 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2016-04-01 13:27:19 +0800 |
commit | 955666559885a49f4250e8930c1268398f2bb06a (patch) | |
tree | 737db9191c25402f110de173f33c55199af50b31 | |
parent | 374312cf8d24adff2f3161e53349d8758614324e (diff) |
regulator: core: Define regulator_set_voltage_triplet()
Voltage tolerance isn't necessarily same on both sides of the target
voltage and regulator_set_voltage_tol() wouldn't be suitable in such
cases.
Add another routine regulator_set_voltage_triplet(), which accepts
target, min and max voltages as arguments.
This first tries to set the voltage between the target voltage and the
upper limit, then fall back on the full range. The idea behind this is
to set regulator's voltage as close to the target voltage, as possible.
Based on regulator_set_voltage_tol().
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit 30f93ca8323f0c21b789bea0f7db8e8e3a7915c6)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
-rw-r--r-- | include/linux/regulator/consumer.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index f540b1496e2f..7f96b1b8f7bb 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -533,6 +533,16 @@ static inline int regulator_count_voltages(struct regulator *regulator) } #endif +static inline int regulator_set_voltage_triplet(struct regulator *regulator, + int min_uV, int target_uV, + int max_uV) +{ + if (regulator_set_voltage(regulator, target_uV, max_uV) == 0) + return 0; + + return regulator_set_voltage(regulator, min_uV, max_uV); +} + static inline int regulator_set_voltage_tol(struct regulator *regulator, int new_uV, int tol_uV) { |