]> git.karo-electronics.de Git - linux-beck.git/commitdiff
IIO: GYRO: ADXRS450: Add missing parity bit generation
authorMichael Hennerich <michael.hennerich@analog.com>
Fri, 29 Apr 2011 12:17:01 +0000 (14:17 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 3 May 2011 18:40:02 +0000 (11:40 -0700)
Add missing parity bit generation. Failure to add the parity bit
caused half of the register accesses to fail.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/gyro/adxrs450_core.c

index c02e3ef40a0fc6f02ac1010a691a2f206409243d..5671276580f0829c70e3080b9e708f3edf9ed611 100644 (file)
@@ -59,6 +59,9 @@ static int adxrs450_spi_read_reg_16(struct device *dev,
        st->tx[2] = 0;
        st->tx[3] = 0;
 
+       if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1))
+               st->tx[3]  |= ADXRS450_P;
+
        spi_message_init(&msg);
        spi_message_add_tail(&xfers[0], &msg);
        spi_message_add_tail(&xfers[1], &msg);
@@ -103,6 +106,10 @@ static int adxrs450_spi_write_reg_16(struct device *dev,
        st->tx[1] = reg_address << 1 | val >> 15;
        st->tx[2] = val >> 7;
        st->tx[3] = val << 1;
+
+       if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1))
+               st->tx[3]  |= ADXRS450_P;
+
        spi_message_init(&msg);
        spi_message_add_tail(&xfers, &msg);
        ret = spi_sync(st->us, &msg);