Re: [PATCH] hwmon: (ads7828) Properly handle -EPROBE_DEFER from devm_regulator_get_optional()

Guenter Roeck <[email protected]> Tue, 4 Aug 2026 19:48:43 -0700
Newsgroups org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 8/4/26 19:05, Qingshuang Fu wrote:
> From: Qingshuang Fu <[email protected]>
> 
> When devm_regulator_get_optional() returns -EPROBE_DEFER, the driver
> currently ignores the error and incorrectly falls back to internal VREF,
> even if an external vref is defined in device tree.
> 
> This could lead to conflicting voltage sources on the VREF pin and
> inaccurate ADC readings.
> 
> Check for -EPROBE_DEFER explicitly and return it to trigger probe deferral.
> Treat other errors (such as -ENODEV) as "no external vref" and use internal
> reference.
> 

Only -ENODEV means "no external vref". All other errors should trigger an error return.

Guenter


> Fixes: a8ddfea09566 ("hwmon: (ads7828) Accept optional parameters from device tree")
> Signed-off-by: Qingshuang Fu <[email protected]>
> ---
>   drivers/hwmon/ads7828.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
> index 149cfcec78dc..1c4a04cb023c 100644
> --- a/drivers/hwmon/ads7828.c
> +++ b/drivers/hwmon/ads7828.c
> @@ -133,6 +133,8 @@ static int ads7828_probe(struct i2c_client *client)
>   			    vref_mv > ADS7828_EXT_VREF_MV_MAX)
>   				return -EINVAL;
>   			ext_vref = true;
> +		} else if (PTR_ERR(reg) == -EPROBE_DEFER) {
> +			return PTR_ERR(reg);
>   		}
>   	}
>   
> 
> base-commit: c21bb4193868a8de71fc4693fa741e195fdf5d86