Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: DAC: ad5624r_spi: fix bit shift of output data value

The value sent on the SPI bus is shifted by an erroneous number of bits.
The shift value was already computed in the iio_chan_spec structure and
hence subtracting this argument to 16 yields an erroneous data position
in the SPI stream.

Signed-off-by: JM Friedt <jmfriedt@femto-st.fr>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

JM Friedt and committed by
Jonathan Cameron
adfa9698 fd1883f0

+2 -2
+2 -2
drivers/iio/dac/ad5624r_spi.c
··· 22 22 #include "ad5624r.h" 23 23 24 24 static int ad5624r_spi_write(struct spi_device *spi, 25 - u8 cmd, u8 addr, u16 val, u8 len) 25 + u8 cmd, u8 addr, u16 val, u8 shift) 26 26 { 27 27 u32 data; 28 28 u8 msg[3]; ··· 35 35 * 14-, 12-bit input code followed by 0, 2, or 4 don't care bits, 36 36 * for the AD5664R, AD5644R, and AD5624R, respectively. 37 37 */ 38 - data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << (16 - len)); 38 + data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift); 39 39 msg[0] = data >> 16; 40 40 msg[1] = data >> 8; 41 41 msg[2] = data;