aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-08-16 22:46:51 -0400
committerMark Brown <broonie@kernel.org>2015-08-17 15:54:01 -0400
commit30f93ca8323f0c21b789bea0f7db8e8e3a7915c6 (patch)
tree4c89400bb45b766231b2359c36d40417b85e438d
parentbc0195aad0daa2ad5b0d76cce22b167bc3435590 (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>
-rw-r--r--include/linux/regulator/consumer.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index f8a689ed62a5..e325d4606b62 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -552,6 +552,16 @@ static inline int regulator_count_voltages(struct regulator *regulator)
552} 552}
553#endif 553#endif
554 554
555static inline int regulator_set_voltage_triplet(struct regulator *regulator,
556 int min_uV, int target_uV,
557 int max_uV)
558{
559 if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
560 return 0;
561
562 return regulator_set_voltage(regulator, min_uV, max_uV);
563}
564
555static inline int regulator_set_voltage_tol(struct regulator *regulator, 565static inline int regulator_set_voltage_tol(struct regulator *regulator,
556 int new_uV, int tol_uV) 566 int new_uV, int tol_uV)
557{ 567{