Commit 10dfd36
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
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3884 | 3884 | | |
3885 | 3885 | | |
3886 | 3886 | | |
3887 | | - | |
| 3887 | + | |
3888 | 3888 | | |
3889 | 3889 | | |
3890 | 3890 | | |
| |||
0 commit comments