]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
staging: iio: sca3000 convert byte order of ring buffer data
authorManuel Stahl <slm@iis.fraunhofer.de>
Thu, 9 Sep 2010 15:40:11 +0000 (17:40 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 14 Sep 2010 23:37:58 +0000 (16:37 -0700)
Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/accel/sca3000_ring.c

index 09836c4f18b8d3e6f32dea8df6dcebfd29c9af05..c93f85cacbc05f5bed7084bb8d37ac05146ed47a 100644 (file)
@@ -53,7 +53,8 @@ static int sca3000_rip_hw_rb(struct iio_ring_buffer *r,
        struct iio_dev *indio_dev = hw_ring->private;
        struct sca3000_state *st = indio_dev->dev_data;
        u8 *rx;
-       int ret, num_available, num_read = 0;
+       s16 *samples;
+       int ret, i, num_available, num_read = 0;
        int bytes_per_sample = 1;
 
        if (st->bpse == 11)
@@ -87,6 +88,17 @@ static int sca3000_rip_hw_rb(struct iio_ring_buffer *r,
        ret = sca3000_read_data(st,
                                SCA3000_REG_ADDR_RING_OUT,
                                data, num_read);
+
+       /* Convert byte order and shift to default resolution */
+       if (st->bpse == 11) {
+               samples = (s16*)(*data+1);
+               for (i = 0; i < (num_read/2); i++) {
+                       samples[i] = be16_to_cpup(
+                                       (__be16 *)&(samples[i]));
+                       samples[i] >>= 3;
+               }
+       }
+
 error_ret:
        mutex_unlock(&st->lock);