Skip to contentSkip to conversation

iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing

PATCH In review Shehryar Ahmad 1 participant 2 messages Nov 24 – Nov 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing

Fix adis_update_scan_mode() to iterate in scan_index order. The adis library constructs the SPI transaction in channel array order, while the IIO core demultiplexes the buffer in scan_index order, causing data to land in the wrong slots.

---
RFC discussions at [1]. Tested by Radu Sabau, but not carrying tested by tag, used iio_for_each_active_channel() while RFC patch used for_each_set_bit().

drivers/iio/imu/adis_buffer.c | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/imu/adis_buffer.c +4 -4
index 501da4eae..17af61c7d 100644
@@ -110,10 +110,10 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
 		spi_message_add_tail(&adis->xfer[j], &adis->msg);
 	}
 
-	chan = indio_dev->channels;
-	for (i = 0; i < indio_dev->num_channels; i++, chan++) {
-		if (!test_bit(chan->scan_index, scan_mask))
-			continue;
+	iio_for_each_active_channel(indio_dev, i) {
+		chan = iio_find_channel_from_si(indio_dev, i);
+		if (!chan)
+			return -EINVAL;
 		if (chan->scan_type.storagebits == 32)
 			*tx++ = cpu_to_be16((chan->address + 2) << 8);
 		*tx++ = cpu_to_be16(chan->address << 8);
Signature · 1 line
2.56.1
#1 lore raw

sorry, this missed adding export symbol for find_channel_from_si() and fixes tag, will send in v2 shortly :)