Skip to content

Commit 10dfd36

Browse files
rgantoisbroonie
authored andcommitted
regulator: core: correct convergence check in regulator_set_voltage()
The logic in regulator_set_voltage() which checks for a non-convergence condition on a stepped regulator is flawed. regulator_set_voltage() checks if the error in target voltage has increased or decreased, and returns -EWOULDBLOCK if the error has not decreased enough. The correct non-convergence condition is: new_delta - delta > -rdev->constraints->max_uV_step or equivalently: delta - new_delta < rdev->constraints->max_uV_step But the currently used condition is: new_delta - delta > rdev->constraints->max_uV_step Which may cause an infinite loop if the voltage error doesn't converge. Fix this by correcting the convergence condition. Suggested-by: Jon Hunter <[email protected]> Fixes: d511206 ("regulator: core: repeat voltage setting request for stepped regulators") Signed-off-by: Romain Gantois <[email protected]> Link: https://patch.msgid.link/[email protected] Tested-by: Jon Hunter <[email protected]> Reviewed-by: Jon Hunter <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 0bd042a commit 10dfd36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3884,7 +3884,7 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator,
38843884
new_delta = ret;
38853885

38863886
/* check that voltage is converging quickly enough */
3887-
if (new_delta - delta > rdev->constraints->max_uV_step) {
3887+
if (delta - new_delta < rdev->constraints->max_uV_step) {
38883888
ret = -EWOULDBLOCK;
38893889
goto out;
38903890
}

0 commit comments

Comments
 (0)