diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-01-09 14:01:00 +0000 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-01-26 10:28:28 +0000 |
commit | 3c80372dae17cb1a5a493c9ed02f7ca2a8d9ce53 (patch) | |
tree | 58f15af3938c9c9c9c375e7538f145f2368e0ab5 /drivers/staging/iio | |
parent | 9ab82f071125e340a052570df90813b11574f8d4 (diff) |
staging:iio:adis16080: be16 cleanups
The sample buffer contains big endian 16bit words. So use the be16 datatype for
the buffer and use the proper helper functions for endianness conversion instead
of openconding it.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio')
-rw-r--r-- | drivers/staging/iio/gyro/adis16080_core.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index ddeae163982a..d033b6f486a6 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -39,7 +39,7 @@ struct adis16080_state { struct spi_device *us; struct mutex buf_lock; - u8 buf[2] ____cacheline_aligned; + __be16 buf ____cacheline_aligned; }; static int adis16080_read_sample(struct iio_dev *indio_dev, @@ -60,8 +60,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, }; mutex_lock(&st->buf_lock); - st->buf[0] = addr >> 8; - st->buf[1] = addr; + st->buf = cpu_to_be16(addr | ADIS16080_DIN_WRITE); spi_message_init(&m); spi_message_add_tail(&t[0], &m); @@ -69,7 +68,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, ret = spi_sync(st->us, &m); if (ret == 0) - *val = sign_extend32(((st->buf[0] & 0xF) << 8) | st->buf[1], 11); + *val = sign_extend32(be16_to_cpu(st->buf), 11); mutex_unlock(&st->buf_lock); return ret; |