staging: iio: replace combine_8_to_16 with be16_to_cpup where possible.
authorJonathan Cameron <jic23@cam.ac.uk>
Sun, 11 Jul 2010 15:39:12 +0000 (16:39 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 22 Jul 2010 18:38:28 +0000 (11:38 -0700)
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Barry Song <21cnbao@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/accel/adis16209_ring.c
drivers/staging/iio/accel/adis16240_ring.c
drivers/staging/iio/gyro/adis16260_ring.c
drivers/staging/iio/imu/adis16300_ring.c
drivers/staging/iio/imu/adis16350_ring.c
drivers/staging/iio/imu/adis16400_ring.c

index ad715388156a11798f0546052d97a1a356fe897b..5945d6712cbf9df3c2bb816d3232f13415c056af 100644 (file)
 #include "../trigger.h"
 #include "adis16209.h"
 
-/**
- * combine_8_to_16() utility function to munge to u8s into u16
- **/
-static inline u16 combine_8_to_16(u8 lower, u8 upper)
-{
-       u16 _lower = lower;
-       u16 _upper = upper;
-       return _lower | (_upper << 8);
-}
-
 static IIO_SCAN_EL_C(supply, ADIS16209_SCAN_SUPPLY, IIO_UNSIGNED(14),
                     ADIS16209_SUPPLY_OUT, NULL);
 static IIO_SCAN_EL_C(accel_x, ADIS16209_SCAN_ACC_X, IIO_SIGNED(14),
@@ -139,10 +129,9 @@ static void adis16209_trigger_bh_to_ring(struct work_struct *work_s)
 
        if (st->indio_dev->scan_count)
                if (adis16209_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < st->indio_dev->scan_count; i++) {
-                               data[i] = combine_8_to_16(st->rx[i*2+1],
-                                                         st->rx[i*2]);
-                       }
+                       for (; i < st->indio_dev->scan_count; i++)
+                               data[i] = be16_to_cpup(
+                                       (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (st->indio_dev->scan_timestamp)
index 5cced2ecead649ad5813b0a4df701daa9ca5fc3a..ecf1110b52d63c97c79f328988aaee4d24c23de5 100644 (file)
 #include "../trigger.h"
 #include "adis16240.h"
 
-/**
- * combine_8_to_16() utility function to munge to u8s into u16
- **/
-static inline u16 combine_8_to_16(u8 lower, u8 upper)
-{
-       u16 _lower = lower;
-       u16 _upper = upper;
-       return _lower | (_upper << 8);
-}
-
 static IIO_SCAN_EL_C(supply, ADIS16240_SCAN_SUPPLY, IIO_UNSIGNED(10),
                ADIS16240_SUPPLY_OUT, NULL);
 static IIO_SCAN_EL_C(accel_x, ADIS16240_SCAN_ACC_X, IIO_SIGNED(10),
@@ -131,10 +121,9 @@ static void adis16240_trigger_bh_to_ring(struct work_struct *work_s)
 
        if (st->indio_dev->scan_count)
                if (adis16240_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < st->indio_dev->scan_count; i++) {
-                               data[i] = combine_8_to_16(st->rx[i*2+1],
-                                               st->rx[i*2]);
-                       }
+                       for (; i < st->indio_dev->scan_count; i++)
+                               data[i] = be16_to_cpup(
+                                       (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (st->indio_dev->scan_timestamp)
index 97d7660906e0ed97d4466af8f142b6ab74ba455d..57ebc8c0bb7793a76dbb76d63e03dcbf9d747871 100644 (file)
 #include "../trigger.h"
 #include "adis16260.h"
 
-/**
- * combine_8_to_16() utility function to munge to u8s into u16
- **/
-static inline u16 combine_8_to_16(u8 lower, u8 upper)
-{
-       u16 _lower = lower;
-       u16 _upper = upper;
-       return _lower | (_upper << 8);
-}
-
 static IIO_SCAN_EL_C(supply, ADIS16260_SCAN_SUPPLY, IIO_UNSIGNED(12),
                ADIS16260_SUPPLY_OUT, NULL);
 static IIO_SCAN_EL_C(gyro, ADIS16260_SCAN_GYRO, IIO_SIGNED(14),
@@ -134,10 +124,9 @@ static void adis16260_trigger_bh_to_ring(struct work_struct *work_s)
 
        if (st->indio_dev->scan_count)
                if (adis16260_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < st->indio_dev->scan_count; i++) {
-                               data[i] = combine_8_to_16(st->rx[i*2+1],
-                                               st->rx[i*2]);
-                       }
+                       for (; i < st->indio_dev->scan_count; i++)
+                               data[i] = be16_to_cpup(
+                                       (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (st->indio_dev->scan_timestamp)
index 6b25f12df1619d1ce12af9048255533c433011fe..a76d43cd209aa717f70e621151032ed9a029d108 100644 (file)
 #include "../trigger.h"
 #include "adis16300.h"
 
-/**
- * combine_8_to_16() utility function to munge to u8s into u16
- **/
-static inline u16 combine_8_to_16(u8 lower, u8 upper)
-{
-       u16 _lower = lower;
-       u16 _upper = upper;
-       return _lower | (_upper << 8);
-}
-
 static IIO_SCAN_EL_C(supply, ADIS16300_SCAN_SUPPLY, IIO_UNSIGNED(14),
                     ADIS16300_SUPPLY_OUT, NULL);
 
@@ -158,10 +148,9 @@ static void adis16300_trigger_bh_to_ring(struct work_struct *work_s)
 
        if (st->indio_dev->scan_count)
                if (adis16300_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < st->indio_dev->scan_count; i++) {
-                               data[i] = combine_8_to_16(st->rx[i*2+1],
-                                                         st->rx[i*2]);
-                       }
+                       for (; i < st->indio_dev->scan_count; i++)
+                               data[i] = be16_to_cpup(
+                                       (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (st->indio_dev->scan_timestamp)
index 28c13ef9dd48937b1f1cb00031eaeda189be4b5d..ca4f685d2f5ef0bc81dc9f2f9ef7b6bc8c2533d9 100644 (file)
 #include "../trigger.h"
 #include "adis16350.h"
 
-/**
- * combine_8_to_16() utility function to munge to u8s into u16
- **/
-static inline u16 combine_8_to_16(u8 lower, u8 upper)
-{
-       u16 _lower = lower;
-       u16 _upper = upper;
-       return _lower | (_upper << 8);
-}
-
 static IIO_SCAN_EL_C(supply, ADIS16350_SCAN_SUPPLY, IIO_UNSIGNED(12),
                ADIS16350_SUPPLY_OUT, NULL);
 
@@ -158,10 +148,9 @@ static void adis16350_trigger_bh_to_ring(struct work_struct *work_s)
 
        if (st->indio_dev->scan_count)
                if (adis16350_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < st->indio_dev->scan_count; i++) {
-                               data[i] = combine_8_to_16(st->rx[i*2+1],
-                                                         st->rx[i*2]);
-                       }
+                       for (; i < st->indio_dev->scan_count; i++)
+                               data[i] = be16_to_cpup(
+                                       (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (st->indio_dev->scan_timestamp)
index 95f53b26b4f06349e5819d3f975d12dbb245e0bd..59d62a780963f3d1e7fe3b93a0c5e12ee1e82609 100644 (file)
 #include "../trigger.h"
 #include "adis16400.h"
 
-/**
- * combine_8_to_16() utility function to munge to u8s into u16
- **/
-static inline u16 combine_8_to_16(u8 lower, u8 upper)
-{
-       u16 _lower = lower;
-       u16 _upper = upper;
-       return _lower | (_upper << 8);
-}
-
 static IIO_SCAN_EL_C(supply, ADIS16400_SCAN_SUPPLY, IIO_SIGNED(14),
                     ADIS16400_SUPPLY_OUT, NULL);
 
@@ -167,10 +157,9 @@ static void adis16400_trigger_bh_to_ring(struct work_struct *work_s)
 
        if (st->indio_dev->scan_count)
                if (adis16400_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < st->indio_dev->scan_count; i++) {
-                               data[i] = combine_8_to_16(st->rx[i*2+1],
-                                                         st->rx[i*2]);
-                       }
+                       for (; i < st->indio_dev->scan_count; i++)
+                               data[i] = be16_to_cpup(
+                                       (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (st->indio_dev->scan_timestamp)