Re: [PATCH v1] regulator: defer probe when trying to get voltage from unresolved supply

From: Ondřej Jirman
Date: Mon Nov 02 2020 - 19:59:43 EST


Hello Michal,

On Mon, Nov 02, 2020 at 10:27:27PM +0100, Michał Mirosław wrote:
> regulator_get_voltage_rdev() is called in regulator probe() when
> applying machine constraints. The "fixed" commit exposed the problem
> that non-bypassed regulators can forward the request to its parent
> (like bypassed ones) supply. Return -EPROBE_DEFER when the supply
> is expected but not resolved yet.
>

Tested-by: Ondřej Jirman <megous@xxxxxxxxxx>

thank you very much,
Ondrej

> Fixes: aea6cb99703e ("regulator: resolve supply after creating regulator")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
> Reported-by: Ondřej Jirman <megous@xxxxxxxxxx>
> Reported-by: Corentin Labbe <clabbe.montjoie@xxxxxxxxx>
> ---
> v1: this is a bit different solution than the hack sent earlier. It should
> be equivalent (putting the error code at the source), but please
> test again.
> ---
> drivers/regulator/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index a4ffd71696da..a5ad553da8cd 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -4165,6 +4165,8 @@ int regulator_get_voltage_rdev(struct regulator_dev *rdev)
> ret = rdev->desc->fixed_uV;
> } else if (rdev->supply) {
> ret = regulator_get_voltage_rdev(rdev->supply->rdev);
> + } else if (rdev->supply_name) {
> + return -EPROBE_DEFER;
> } else {
> return -EINVAL;
> }
> --
> 2.20.1
>