staging: iio: resolver: ad2s1210: do not use fault register for dummy read
authorDavid Lechner <dlechner@baylibre.com>
Fri, 6 Oct 2023 00:50:18 +0000 (19:50 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 11 Oct 2023 14:54:40 +0000 (15:54 +0100)
When reading registers on the AD2S1210 chip, we have to supply a "dummy"
address for the second SPI tx byte so that we don't accidentally write
to a register. This register will be read and the value discarded on the
next regmap read or write call.

Reading the fault register has a side-effect of clearing the faults
so we should not use this register for the dummy read.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20231005-ad2s1210-mainline-v4-1-ec00746840fc@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/resolver/ad2s1210.c

index 67d8af0dd7ae2734924ff21ad090d66a560c3a1b..8fbde9517fe94f725422c0302f6fa85264b3540a 100644 (file)
@@ -166,9 +166,10 @@ static int ad2s1210_regmap_reg_read(void *context, unsigned int reg,
        st->tx[0] = reg;
        /*
         * Must be valid register address here otherwise this could write data.
-        * It doesn't matter which one.
+        * It doesn't matter which one as long as reading doesn't have side-
+        * effects.
         */
-       st->tx[1] = AD2S1210_REG_FAULT;
+       st->tx[1] = AD2S1210_REG_CONTROL;
 
        ret = spi_sync_transfer(st->sdev, xfers, ARRAY_SIZE(xfers));
        if (ret < 0)