* [PATCH V3] regulator: core: Define regulator_set_voltage_triplet()
@ 2015-08-17 2:46 Viresh Kumar
2015-08-25 22:53 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Viresh Kumar @ 2015-08-17 2:46 UTC (permalink / raw)
To: broonie
Cc: linaro-kernel, sboyd, nm, Viresh Kumar, Liam Girdwood,
open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK
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>
---
V2->V3:
- Improve commit log, with how its useful at regulator API level.
- Compare regulator_set_voltage() == 0, instead of
!regulator_set_voltage().
V1->V2:
- Change the order of arguments to regulator_set_voltage_triplet() to
min/target/max instead of target/min/max.
include/linux/regulator/consumer.h | 10 ++++++++++
1 file changed, 10 insertions(+)
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)
}
#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)
{
--
2.4.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V3] regulator: core: Define regulator_set_voltage_triplet()
2015-08-17 2:46 [PATCH V3] regulator: core: Define regulator_set_voltage_triplet() Viresh Kumar
@ 2015-08-25 22:53 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2015-08-25 22:53 UTC (permalink / raw)
To: Viresh Kumar
Cc: broonie, linaro-kernel, nm, Liam Girdwood,
open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK
On 08/17, Viresh Kumar wrote:
> 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>
> ---
Looks good to me.
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-25 22:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 2:46 [PATCH V3] regulator: core: Define regulator_set_voltage_triplet() Viresh Kumar
2015-08-25 22:53 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox