linux-kernel.vger.kernel.org archive mirror
 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).