* [PATCH v2] regulator: core: Fix the init of DT defined fixed regulators
@ 2014-05-20 10:12 Alban Bedel
2014-06-01 18:19 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Alban Bedel @ 2014-05-20 10:12 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Liam Girdwood, Alban Bedel
When a regulator is defined using DT and it has a single voltage the
regulator init always tries to apply this voltage. However it fails if
the regulator isn't settable because it is using an internal low level
function. To overcome this we now first query the regulator and only
set it if needed.
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
---
drivers/regulator/core.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9a09f3c..7375997 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -844,13 +844,22 @@ 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) {
- ret = _regulator_do_set_voltage(rdev,
- rdev->constraints->min_uV,
- rdev->constraints->max_uV);
- if (ret < 0) {
- rdev_err(rdev, "failed to apply %duV constraint\n",
- rdev->constraints->min_uV);
- return ret;
+ int current_uV = _regulator_get_voltage(rdev);
+ if (current_uV < 0) {
+ rdev_err(rdev, "failed to get the current voltage\n");
+ return current_uV;
+ }
+ if (current_uV < rdev->constraints->min_uV ||
+ current_uV > rdev->constraints->max_uV) {
+ ret = _regulator_do_set_voltage(
+ rdev, rdev->constraints->min_uV,
+ rdev->constraints->max_uV);
+ if (ret < 0) {
+ rdev_err(rdev,
+ "failed to apply %duV constraint\n",
+ rdev->constraints->min_uV);
+ return ret;
+ }
}
}
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] regulator: core: Fix the init of DT defined fixed regulators
2014-05-20 10:12 [PATCH v2] regulator: core: Fix the init of DT defined fixed regulators Alban Bedel
@ 2014-06-01 18:19 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-06-01 18:19 UTC (permalink / raw)
To: Alban Bedel; +Cc: linux-kernel, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 387 bytes --]
On Tue, May 20, 2014 at 12:12:16PM +0200, Alban Bedel wrote:
> When a regulator is defined using DT and it has a single voltage the
> regulator init always tries to apply this voltage. However it fails if
> the regulator isn't settable because it is using an internal low level
> function. To overcome this we now first query the regulator and only
> set it if needed.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-01 18:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-20 10:12 [PATCH v2] regulator: core: Fix the init of DT defined fixed regulators Alban Bedel
2014-06-01 18:19 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®