Re: [PATCH] hwmon: (ads7828) Properly handle -EPROBE_DEFER from devm_regulator_get_optional()
From: Guenter Roeck
Date: Tue Aug 04 2026 - 22:49:01 EST
On 8/4/26 19:05, Qingshuang Fu wrote:
From: Qingshuang Fu <fuqingshuang@xxxxxxxxxx>
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 <fuqingshuang@xxxxxxxxxx>
---
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