Re: [PATCH 2/2] regulator: pwm-regulator: Revert "Add validity checks in continuous .get_voltage"
From: Mike Looijmans
Date: Mon Nov 09 2026 - 01:22:44 EST
On 08-11-2026 16:13, Mark Brown wrote:
On Fri, Nov 06, 2026 at 01:59:56PM +0100, Mike Looijmans wrote:
This reverts commit c92688cac239 ("regulator: pwm-regulator: Add validityAre you sure? We have specific handling for -ENOTRECOVERABLE which just
checks in continuous .get_voltage").
The core, and in particular the machine_constraints_voltage() method,
expects the regulator to report what the current setting is, even if that
is outside the allowed range. The core will then bring the voltage into
that range. It cannot do that if the regulator refuses to return its
setting, and causes probe() to fail for a pwm-regulator when it has
restrictions to the PWM range with messages like:
dsp7-pwm: failed to get the current voltage: -ENOTRECOVERABLE
pwm-regulator dsp7-supply-pwm: error -ENOTRECOVERABLE: Failed to register
regulator pwm-regulator
pwm-regulator dsp7-supply-pwm: probe with driver pwm-regulator failed
with error -131
blindly writes in the range specified in the constraints if the current
voltage is unreadable. If that mechanism isn't working we should fix it
rather than changing drivers.
In core.c:
if (current_uV == -ENOTRECOVERABLE) {
/* This regulator can't be read and must be initialized */
rdev_info(rdev, "Setting %d-%duV\n",
rdev->constraints->min_uV,
rdev->constraints->max_uV);
_regulator_do_set_voltage(rdev,
rdev->constraints->min_uV,
rdev->constraints->max_uV);
current_uV = regulator_get_voltage_rdev(rdev);
}
if (current_uV < 0) {
if (current_uV != -EPROBE_DEFER)
rdev_err(rdev,
"failed to get the current voltage: %pe\n",
ERR_PTR(current_uV));
return current_uV;
}
After _regulator_do_set_voltage() it calls regulator_get_voltage_rdev() again, which keeps returning -ENOTRECOVERABLE, and thus the error path kicks in.
Besides that, regulator_get_voltage() is not supposed to return anyThe rest of the function relies on this to avoid having to deal with
state information, as is mentioned in the API documentation.
voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
- if (voltage < min(max_uV_duty, min_uV_duty) ||
- voltage > max(max_uV_duty, min_uV_duty))
- return -ENOTRECOVERABLE;
wrapping when things are out of range.
It's core.c that will handle that. It expects regulator_get_voltage() to return something out of range, and will correct that situation.
--
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands
T: +31 (0) 499 33 69 69
E: mike.looijmans@xxxxxxxx
W: www.topic.nl