forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/iio/dac/ad5624r_spi.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AD5624R, AD5644R, AD5664R Digital to analog convertors spi driver
34 *
45 * Copyright 2010-2011 Analog Devices Inc.
5
- *
6
- * Licensed under the GPL-2.
76 */
87
98 #include <linux/interrupt.h>
....@@ -18,6 +17,8 @@
1817
1918 #include <linux/iio/iio.h>
2019 #include <linux/iio/sysfs.h>
20
+
21
+#include <asm/unaligned.h>
2122
2223 #include "ad5624r.h"
2324
....@@ -36,11 +37,9 @@
3637 * for the AD5664R, AD5644R, and AD5624R, respectively.
3738 */
3839 data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << shift);
39
- msg[0] = data >> 16;
40
- msg[1] = data >> 8;
41
- msg[2] = data;
40
+ put_unaligned_be24(data, &msg[0]);
4241
43
- return spi_write(spi, msg, 3);
42
+ return spi_write(spi, msg, sizeof(msg));
4443 }
4544
4645 static int ad5624r_read_raw(struct iio_dev *indio_dev,
....@@ -270,7 +269,6 @@
270269
271270 st->us = spi;
272271
273
- indio_dev->dev.parent = &spi->dev;
274272 indio_dev->name = spi_get_device_id(spi)->name;
275273 indio_dev->info = &ad5624r_info;
276274 indio_dev->modes = INDIO_DIRECT_MODE;