Re: [PATCH] iio: adis16480: support burst read function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/7/21 1:31 PM, Sa, Nuno wrote:
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])
I don't think this would work on BE machines. AFAIU, the crc computation
must be done in little endian ("order of bytes low-high"). In BE machines,
crc_buf would be left in BE order which would lead to a wrong crc...
The ' swab16()' was really intentional here (naturally can still be wrong :D)
Yea, that makes sense. crc32() processes byte wise and in the byte buffer we have MSB,LSB,MSB,LSB... and we want to process LSB,MSB,LSB,MSB....



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux