]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ad4080: fix chip identification
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Tue, 7 Oct 2025 11:15:20 +0000 (11:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Dec 2025 17:40:23 +0000 (18:40 +0100)
commit b66cddc8be7278fd14650ff9182f3794397f8b31 upstream.

Fix AD4080 chip identification by using the correct 16-bit product ID
(0x0050) instead of GENMASK(2, 0). Update the chip reading logic to
use regmap_bulk_read to read both PRODUCT_ID_L and PRODUCT_ID_H
registers and combine them into a 16-bit value.

The original implementation was incorrectly reading only 3 bits,
which would not correctly identify the AD4080 chip.

Fixes: 6b31ba1811b6 ("iio: adc: ad4080: add driver support")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/ad4080.c

index 6e61787ed3213fe4332bd92b938a7a717dada99f..e15310fcd21a36d79de5fd6fd6950b4260889df2 100644 (file)
 
 /* Miscellaneous Definitions */
 #define AD4080_SPI_READ                                                BIT(7)
-#define AD4080_CHIP_ID                                         GENMASK(2, 0)
+#define AD4080_CHIP_ID                                         0x0050
 
 #define AD4080_LVDS_CNV_CLK_CNT_MAX                            7
 
@@ -445,7 +445,8 @@ static int ad4080_setup(struct iio_dev *indio_dev)
 {
        struct ad4080_state *st = iio_priv(indio_dev);
        struct device *dev = regmap_get_device(st->regmap);
-       unsigned int id;
+       __le16 id_le;
+       u16 id;
        int ret;
 
        ret = regmap_write(st->regmap, AD4080_REG_INTERFACE_CONFIG_A,
@@ -458,10 +459,12 @@ static int ad4080_setup(struct iio_dev *indio_dev)
        if (ret)
                return ret;
 
-       ret = regmap_read(st->regmap, AD4080_REG_CHIP_TYPE, &id);
+       ret = regmap_bulk_read(st->regmap, AD4080_REG_PRODUCT_ID_L, &id_le,
+                              sizeof(id_le));
        if (ret)
                return ret;
 
+       id = le16_to_cpu(id_le);
        if (id != AD4080_CHIP_ID)
                dev_info(dev, "Unrecognized CHIP_ID 0x%X\n", id);