Thread (20 messages) flat view 20 messages, 6 authors, 2016-08-23
STALE3641d

Revision v1 of 4 in this series.

Revisions (4)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v2 [diff vs current]
  4. v1 current

[PATCH 3/9] regulator: core: Try full range when adjusting regulators to constraints

From: Chen-Yu Tsai <hidden>
Date: 2016-08-21 03:07:22
Also in: linux-arm-kernel, lkml
Subsystem: the rest, voltage and current regulator framework · Maintainers: Linus Torvalds, Liam Girdwood, Mark Brown

Currently when we try to bring regulator in bounds of its constraints,
we pick either the minimum or maximum voltage as the target. This fails
if the regulator range is not continuous, and the target voltage is not
an exact value the regulator can achieve, i.e. the target is not aligned
to the step of the regulator.

Instead pass the full range of the constraints, and have the regulator
core work out a suitable voltage within.

Fixes: ("regulator: core: Ensure we are at least in bounds for our
	 constraints")
Signed-off-by: Chen-Yu Tsai <redacted>
---
 drivers/regulator/core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index db320e8fa865..86f69c92ce7a 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -897,13 +897,9 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
 		target_min = current_uV;
 		target_max = current_uV;
 
-		if (current_uV < rdev->constraints->min_uV) {
+		if (current_uV < rdev->constraints->min_uV ||
+		    current_uV > rdev->constraints->max_uV) {
 			target_min = rdev->constraints->min_uV;
-			target_max = rdev->constraints->min_uV;
-		}
-
-		if (current_uV > rdev->constraints->max_uV) {
-			target_min = rdev->constraints->max_uV;
 			target_max = rdev->constraints->max_uV;
 		}
 
-- 
2.9.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help