[PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic

From: Nuno Sá

Date: Wed Nov 25 2026 - 05:20:47 EST


The REF bit in the control register disables the on-chip 2.5 V
reference when set. Before commit 5483b8d5015b ("iio: adc: ad7887:
invert/rework external ref logic"), the driver set it when an external
reference was used. That commit replaced the use_onchip_ref platform
data flag with the presence of the vref regulator, but kept the
condition as is. As a result, the bit is now set when there is no
external reference, so the on-chip reference gets disabled exactly
when the driver relies on it, and is left enabled when an external
reference is supplied.

Only disable the on-chip reference when a vref regulator is present.

Fixes: 5483b8d5015b ("iio: adc: ad7887: invert/rework external ref logic")
Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
drivers/iio/adc/ad7887.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 827d0c2598ba..980e6a303047 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -271,7 +271,7 @@ static int ad7887_probe(struct spi_device *spi)
/* Setup default message */

mode = AD7887_PM_MODE4;
- if (!st->reg)
+ if (st->reg)
mode |= AD7887_REF_DIS;
if (pdata && pdata->en_dual)
mode |= AD7887_DUAL;

--
2.56.0