From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <55841173.30506@metafoo.de> Date: Fri, 19 Jun 2015 14:56:19 +0200 From: Lars-Peter Clausen MIME-Version: 1.0 To: jmfriedt@femto-st.fr, linux-iio@vger.kernel.org CC: Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Subject: Re: [PATCH 1/1] iio: DAC: ad5624r_spi: fix bit shift of output data value References: <1434718086-14722-1-git-send-email-jmfriedt@femto-st.fr> In-Reply-To: <1434718086-14722-1-git-send-email-jmfriedt@femto-st.fr> Content-Type: text/plain; charset=windows-1252; format=flowed List-ID: On 06/19/2015 02:48 PM, jmfriedt@femto-st.fr wrote: > From: JM Friedt > > 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 Looks good, thanks. Acked-by: Lars-Peter Clausen > --- > drivers/iio/dac/ad5624r_spi.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c > index 61bb9d4..e98428d 100644 > --- a/drivers/iio/dac/ad5624r_spi.c > +++ b/drivers/iio/dac/ad5624r_spi.c > @@ -22,7 +22,7 @@ > #include "ad5624r.h" > > static int ad5624r_spi_write(struct spi_device *spi, > - u8 cmd, u8 addr, u16 val, u8 len) > + u8 cmd, u8 addr, u16 val, u8 shift) > { > u32 data; > u8 msg[3]; > @@ -35,7 +35,7 @@ static int ad5624r_spi_write(struct spi_device *spi, > * 14-, 12-bit input code followed by 0, 2, or 4 don't care bits, > * for the AD5664R, AD5644R, and AD5624R, respectively. > */ > - data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << (16 - len)); > + data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift); > msg[0] = data >> 16; > msg[1] = data >> 8; > msg[2] = data; >