Skip to content

Commit 0c81bcc

Browse files
dlechgregkh
authored andcommitted
iio: adc: ad7606_spi: fix reg write value mask
commit 89944d8 upstream. 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: f2a22e1 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 399e325 commit 0c81bcc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/adc/ad7606_spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int ad7606_spi_reg_write(struct ad7606_state *st,
151151
struct spi_device *spi = to_spi_device(st->dev);
152152

153153
st->d16[0] = cpu_to_be16((st->bops->rd_wr_cmd(addr, 1) << 8) |
154-
(val & 0x1FF));
154+
(val & 0xFF));
155155

156156
return spi_write(spi, &st->d16[0], sizeof(st->d16[0]));
157157
}

0 commit comments

Comments
 (0)