]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: dac: ad5686: fix ref bit initialization for single-channel parts
authorRodrigo Alencar <rodrigo.alencar@analog.com>
Fri, 1 May 2026 09:14:54 +0000 (10:14 +0100)
committerJonathan Cameron <jic23@kernel.org>
Fri, 15 May 2026 11:05:34 +0000 (12:05 +0100)
The reference bit position was ignored when writing the register at the
probe() function (!!val was used). When such bit is 1, internal voltage
reference is disabled so that an external one can be used. For
multi-channel devices, bit 0 of the Internal Reference Setup command
behaves the same way, so AD5686_REF_BIT_MSK is created. The issue exists
since support for single-channel devices were first introduced.

Fixes: be1b24d24541 ("iio:dac:ad5686: Add AD5691R/AD5692R/AD5693/AD5693R support")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/dac/ad5686.c
drivers/iio/dac/ad5686.h

index 4b18498aa0749e3ef44125ff8f73bb5b9fbb898b..b85d5c5a864bbe69da8a33381796673a0a0e5c66 100644 (file)
@@ -509,7 +509,7 @@ int ad5686_probe(struct device *dev,
                break;
        case AD5686_REGMAP:
                cmd = AD5686_CMD_INTERNAL_REFER_SETUP;
-               ref_bit_msk = 0;
+               ref_bit_msk = AD5686_REF_BIT_MSK;
                break;
        case AD5693_REGMAP:
                cmd = AD5686_CMD_CONTROL_REG;
@@ -520,9 +520,9 @@ int ad5686_probe(struct device *dev,
                return -EINVAL;
        }
 
-       val = (has_external_vref | ref_bit_msk);
+       val = has_external_vref ? ref_bit_msk : 0;
 
-       ret = st->write(st, cmd, 0, !!val);
+       ret = st->write(st, cmd, 0, val);
        if (ret)
                return ret;
 
index e7d36bae3e59336816a68bcf81cb1726f79df13a..36e16c5c4581b6753266f30775a8932dc72ebe21 100644 (file)
@@ -46,6 +46,7 @@
 
 #define AD5310_REF_BIT_MSK                     BIT(8)
 #define AD5683_REF_BIT_MSK                     BIT(12)
+#define AD5686_REF_BIT_MSK                     BIT(0)
 #define AD5693_REF_BIT_MSK                     BIT(12)
 
 /**