Message ID | 1406651339-28901-4-git-send-email-javier.martinez@collabora.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Jul 29, 2014 at 06:28:57PM +0200, Javier Martinez Canillas wrote: > If a selector can't be used on a platform due to voltage constraints, > regulator_list_voltage() returns 0. Doing this unconditionally made > sense since constraints were set in machine_constraints_voltage() at > regulator registration time. > > But for load switches that don't define a voltage output, the parent > supply voltage is used so the constraints should only be applied if > they were defined for the child regulators. No, think about what you're doing here and why we're filtering out unsettable voltages - this causes problems for consumers on regulators that don't have any ability to vary voltages since they will now be able to list voltages that they can't select. I would also expect any regulator where the supplied devices are able to vary the voltage to explicitly provide a constraint even if the implementation is done in a parent regulator. There may be constraints on the child supply which aren't directly present on the parent supply and can be ignored if the child supply is turned off.
Hello Mark, thanks a lot for all your feedback. On 07/29/2014 07:18 PM, Mark Brown wrote: > On Tue, Jul 29, 2014 at 06:28:57PM +0200, Javier Martinez Canillas wrote: >> >> But for load switches that don't define a voltage output, the parent >> supply voltage is used so the constraints should only be applied if >> they were defined for the child regulators. > > No, think about what you're doing here and why we're filtering out > unsettable voltages - this causes problems for consumers on regulators > that don't have any ability to vary voltages since they will now be able > to list voltages that they can't select. > Understood. Thanks for the explanation. > I would also expect any regulator where the supplied devices are able to > vary the voltage to explicitly provide a constraint even if the > implementation is done in a parent regulator. There may be constraints > on the child supply which aren't directly present on the parent supply > and can be ignored if the child supply is turned off. > Agreed, if I explicitly set the voltage constraints on the child supply then this patch is indeed not needed. Best regards, Javier -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jul 30, 2014 at 10:49:25AM +0200, Javier Martinez Canillas wrote: > On 07/29/2014 07:18 PM, Mark Brown wrote: > > I would also expect any regulator where the supplied devices are able to > > vary the voltage to explicitly provide a constraint even if the > > implementation is done in a parent regulator. There may be constraints > > on the child supply which aren't directly present on the parent supply > > and can be ignored if the child supply is turned off. > Agreed, if I explicitly set the voltage constraints on the child supply then > this patch is indeed not needed. We will, however, need some code to pass the child supply constraints on to the parent.
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a3c3785..7472535 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2228,9 +2228,11 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector) } if (ret > 0) { - if (ret < rdev->constraints->min_uV) + if (rdev->constraints->min_uV && + ret < rdev->constraints->min_uV) ret = 0; - else if (ret > rdev->constraints->max_uV) + else if (rdev->constraints->max_uV && + ret > rdev->constraints->max_uV) ret = 0; }
If a selector can't be used on a platform due to voltage constraints, regulator_list_voltage() returns 0. Doing this unconditionally made sense since constraints were set in machine_constraints_voltage() at regulator registration time. But for load switches that don't define a voltage output, the parent supply voltage is used so the constraints should only be applied if they were defined for the child regulators. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> --- drivers/regulator/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)