All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: don't fail to apply_uV for fixed regulators without set_voltage
@ 2012-07-03 22:03 Stephen Warren
  2012-07-03 22:32 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2012-07-03 22:03 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

When instantiating a regulator from device tree,
of_get_regulation_constraints() sets apply_uV=true when min_uV==max_uV.
If the regulator only supports that one voltage, it may not implement
set_voltage or set_voltage_sel. If so, the call from
machine_constraints_voltage() to _regulator_do_set_voltage() will fail,
since the latter requires one of those ops to be implemented. Avoid this
problem by avoiding the call to _regulator_do_set_voltage() if the
regulator is already set of the specified voltage.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Are regulators required to implement get_voltage()? If not, this change
would cause a regression.

An alternative might be to just implement set_voltage*() in the relevant
regulator driver, although it seem like it'd intended to be optional.
Would that be preferable? The driver in question is for the MAX8907 which
isn't upstream yet, but I'll be sending patches for it as soon as I have
legal approval; the code is written and working.

 drivers/regulator/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ef07b62..8196764 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -790,7 +790,8 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
 
 	/* do we need to apply the constraint voltage */
 	if (rdev->constraints->apply_uV &&
-	    rdev->constraints->min_uV == rdev->constraints->max_uV) {
+	    rdev->constraints->min_uV == rdev->constraints->max_uV &&
+	    _regulator_get_voltage(rdev) != rdev->constraints->min_uV) {
 		ret = _regulator_do_set_voltage(rdev,
 						rdev->constraints->min_uV,
 						rdev->constraints->max_uV);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: don't fail to apply_uV for fixed regulators without set_voltage
  2012-07-03 22:03 [PATCH] regulator: don't fail to apply_uV for fixed regulators without set_voltage Stephen Warren
@ 2012-07-03 22:32 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-07-03 22:32 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-kernel, Stephen Warren

On Tue, Jul 03, 2012 at 04:03:34PM -0600, Stephen Warren wrote:

> When instantiating a regulator from device tree,
> of_get_regulation_constraints() sets apply_uV=true when min_uV==max_uV.
> If the regulator only supports that one voltage, it may not implement
> set_voltage or set_voltage_sel. If so, the call from
> machine_constraints_voltage() to _regulator_do_set_voltage() will fail,
> since the latter requires one of those ops to be implemented. Avoid this
> problem by avoiding the call to _regulator_do_set_voltage() if the
> regulator is already set of the specified voltage.

This just seems like someone's written a silly device tree - they're
asking the OS to set a voltage on something with a fixed voltage.  From
discussion on IRC it seems like this was a misunderstanding on your part
about what one is intended to put in the device tree, the idea is that
the DT should only specify things that are changed on the board - users
shouldn't need to cut'n'paste information that's fixed in the PMIC
silicon into each board DT.

Besides, there's clearly not anything specific to setting constraints
about this...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-03 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-03 22:03 [PATCH] regulator: don't fail to apply_uV for fixed regulators without set_voltage Stephen Warren
2012-07-03 22:32 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.