Message ID | f98416ac-230c-0362-ed50-a7f92ff283d7@codeaurora.org (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
On Wed, Apr 25, 2018 at 02:04:56PM -0700, David Collins wrote: > > Using -EAGAIN for "I can't ever read the configuration from this > > regulator" doesn't seem right - it's not like any number of retries > > will ever manage to read the value back. > In this case, the _regulator_get_voltage() call can succeed, but only > after a voltage is explicitly requested from the framework side. The ... > Do you still have reservations about using -EAGAIN for this purpose? If > so, which error code would you suggest using? Yes, that's clearly a problem - -EAGAIN is more for situations where you can just immediately retry like signal interruptions. If the caller repetedly sits and tries to read the voltage it'll never succeed unless something else comes along and sets something.
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 65f9b7c..e61983d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -910,6 +910,19 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, rdev->constraints->min_uV && rdev->constraints->max_uV) { int target_min, target_max; int current_uV = _regulator_get_voltage(rdev); + if (current_uV == -EAGAIN) { + /* + * Regulator voltage cannot be read until after + * configuration; try setting constraint range. + */ + 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); + } if (current_uV < 0) { rdev_err(rdev,