Skip to content

Commit

Permalink
iio: dac: ad5624r_spi: Use put_unaligned_be24()
Browse files Browse the repository at this point in the history
This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <[email protected]>
Cc: Michael Hennerich <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Acked-by: Nuno Sá <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
andy-shev authored and jic23 committed May 3, 2020
1 parent 8b26ab3 commit e065325
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/iio/dac/ad5624r_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit e065325

Please sign in to comment.