]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: adc: ad7606_spi: fix reg write value mask
authorDavid Lechner <dlechner@baylibre.com>
Tue, 29 Apr 2025 01:55:34 +0000 (20:55 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 4 May 2025 16:45:41 +0000 (17:45 +0100)
Fix incorrect value mask for register write. Register values are 8-bit,
not 9. If this function was called with a value > 0xFF and an even addr,
it would cause writing to the next register.

Fixes: f2a22e1e172f ("iio: adc: ad7606: Add support for software mode for ad7616")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250428-iio-adc-ad7606_spi-fix-write-value-mask-v1-1-a2d5e85a809f@baylibre.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7606_spi.c

index 179115e909888b78330ee37b857ba6e355411055..b37458ce3c7087efa7faab16f9f1416a7bea9dee 100644 (file)
@@ -155,7 +155,7 @@ static int ad7606_spi_reg_write(struct ad7606_state *st,
        struct spi_device *spi = to_spi_device(st->dev);
 
        st->d16[0] = cpu_to_be16((st->bops->rd_wr_cmd(addr, 1) << 8) |
-                                 (val & 0x1FF));
+                                 (val & 0xFF));
 
        return spi_write(spi, &st->d16[0], sizeof(st->d16[0]));
 }