All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] iio: DAC: ad5624r_spi: fix bit shift of output data value
@ 2015-06-19 12:48 jmfriedt
  2015-06-19 12:56 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: jmfriedt @ 2015-06-19 12:48 UTC (permalink / raw)
  To: linux-iio; +Cc: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, JM Friedt

From: JM Friedt <jmfriedt@femto-st.fr>

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>
---
 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;
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iio: DAC: ad5624r_spi: fix bit shift of output data value
  2015-06-19 12:48 [PATCH 1/1] iio: DAC: ad5624r_spi: fix bit shift of output data value jmfriedt
@ 2015-06-19 12:56 ` Lars-Peter Clausen
  2015-06-21 13:04   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2015-06-19 12:56 UTC (permalink / raw)
  To: jmfriedt, linux-iio; +Cc: Michael.Hennerich, jic23, knaack.h, pmeerw

On 06/19/2015 02:48 PM, jmfriedt@femto-st.fr wrote:
> From: JM Friedt <jmfriedt@femto-st.fr>
>
> 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>

Looks good, thanks.

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

> ---
>   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;
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iio: DAC: ad5624r_spi: fix bit shift of output data value
  2015-06-19 12:56 ` Lars-Peter Clausen
@ 2015-06-21 13:04   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2015-06-21 13:04 UTC (permalink / raw)
  To: Lars-Peter Clausen, jmfriedt, linux-iio
  Cc: Michael.Hennerich, knaack.h, pmeerw

On 19/06/15 13:56, Lars-Peter Clausen wrote:
> On 06/19/2015 02:48 PM, jmfriedt@femto-st.fr wrote:
>> From: JM Friedt <jmfriedt@femto-st.fr>
>>
>> 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>
> 
> Looks good, thanks.
> 
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Note this won't go upstream now until after the merge window
(so a couple of weeks at least).

Thanks,

Jonathan
> 
>> ---
>>   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;
>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-21 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-19 12:48 [PATCH 1/1] iio: DAC: ad5624r_spi: fix bit shift of output data value jmfriedt
2015-06-19 12:56 ` Lars-Peter Clausen
2015-06-21 13:04   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.