From: Lars-Peter Clausen <lars@xxxxxxxxxx>
Sent: Wednesday, April 7, 2021 10:25 AM
To: Sa, Nuno <Nuno.Sa@xxxxxxxxxx>; linux-iio@xxxxxxxxxxxxxxx
Cc: Jonathan Cameron <jic23@xxxxxxxxxx>; Hennerich, Michael
<Michael.Hennerich@xxxxxxxxxx>
Subject: Re: [PATCH] iio: adis16480: support burst read function
[External]
On 4/6/21 5:14 PM, Nuno Sa wrote:
Some supported devices support burst read function. This provides a
method
for reading a batch of data (status, temperature, gyroscopes,
accelerometers, time stamp/data counter, and CRC code), which
does not
require a stall time between each 16-bit segment and only requires
one
command on the DIN line to initiate. Devices supporting this mode
are:
* adis16495-1
* adis16495-2
* adis16495-3
* adis16497-1
* adis16497-2
* adis16497-3
Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx>
Looks good to me, just some thoughts on CRC and endiness
conversion.
---
drivers/iio/imu/adis16480.c | 157
+++++++++++++++++++++++++++++++++---
1 file changed, 144 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index f81b86690b76..341945f8339e 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -5,6 +5,7 @@
* Copyright 2012 Analog Devices Inc.
*/
[...]
+static bool adis16480_validate_crc(const u16 *buf, const u8 n_elem,
const u32 crc)
const __be16 *buf
+{
+ u32 crc_calc;
+ u16 crc_buf[15];
+ int j;
+
+ for (j = 0; j < n_elem; j++)
+ crc_buf[j] = swab16(buf[j]);
be16_to_cpu(buf[j])