summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorAlban Bedel2014-05-20 12:12:16 +0200
committerMark Brown2014-06-01 20:19:43 +0200
commit064d5cd110f94ce41ca5681dcda8b77fa63d5b95 (patch)
tree2228e893dd2981564e72485e236a5dbae459ca1e /drivers/regulator/core.c
parentregulator: core: Disable unused regulators after deferred probing is done (diff)
downloadkernel-qcow2-linux-064d5cd110f94ce41ca5681dcda8b77fa63d5b95.tar.gz
kernel-qcow2-linux-064d5cd110f94ce41ca5681dcda8b77fa63d5b95.tar.xz
kernel-qcow2-linux-064d5cd110f94ce41ca5681dcda8b77fa63d5b95.zip
regulator: core: Fix the init of DT defined fixed regulators
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> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 236ca3f1df73..d70f00f8fc66 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;
+ }
}
}