]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iio: dac: ad5624r_spi: Use put_unaligned_be24()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 21 Apr 2020 00:31:24 +0000 (03:31 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 3 May 2020 08:47:19 +0000 (09:47 +0100)
This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ad5624r_spi.c

index e6c022e1dc1cf64c2cf55a0998ff642a90ec1e6c..2015a5df840c3b6a7c800f6c61cfa4f234cd129a 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 
+#include <asm/unaligned.h>
+
 #include "ad5624r.h"
 
 static int ad5624r_spi_write(struct spi_device *spi,
@@ -35,11 +37,9 @@ static int ad5624r_spi_write(struct spi_device *spi,
         * for the AD5664R, AD5644R, and AD5624R, respectively.
         */
        data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift);
-       msg[0] = data >> 16;
-       msg[1] = data >> 8;
-       msg[2] = data;
+       put_unaligned_be24(data, &msg[0]);
 
-       return spi_write(spi, msg, 3);
+       return spi_write(spi, msg, sizeof(msg));
 }
 
 static int ad5624r_read_raw(struct iio_dev *indio_dev,