diff options
author | 2025-07-29 11:50:57 +0200 | |
---|---|---|
committer | 2025-07-29 14:56:39 +0100 | |
commit | 10dfd36f078423c51602a9a21ed85e8e6c947a00 (patch) | |
tree | 1346b67cada79f52b45e279393826175ccd1390a | |
parent | regulator: mt6370: Fix spelling mistake in mt6370_regualtor_register (diff) | |
download | wireguard-linux-10dfd36f078423c51602a9a21ed85e8e6c947a00.tar.xz wireguard-linux-10dfd36f078423c51602a9a21ed85e8e6c947a00.zip |
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 <jonathanh@nvidia.com>
Fixes: d511206dc7443 ("regulator: core: repeat voltage setting request for stepped regulators")
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
Link: https://patch.msgid.link/20250729-b4-regulator-stepping-fix-v1-1-3f7b8c55d7d7@bootlin.com
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8ed9b96518cf..554d83c4af0c 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3884,7 +3884,7 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, new_delta = ret; /* check that voltage is converging quickly enough */ - if (new_delta - delta > rdev->constraints->max_uV_step) { + if (delta - new_delta < rdev->constraints->max_uV_step) { ret = -EWOULDBLOCK; goto out; } |