mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing
@ 2026-11-24 21:30 Shehryar Ahmad
  2026-11-25  0:08 ` Shehryar Ahmad
  0 siblings, 1 reply; 3+ messages in thread
From: Shehryar Ahmad @ 2026-11-24 21:30 UTC (permalink / raw)
  To: jic23
  Cc: radu.sabau, Antoniu.Miclaus, Dragos.Bogdan, Michael.Hennerich,
	Nuno.Sa, Robert.Budai, andy, dlechner, linux-iio, linux-kernel,
	linux, shehryar.amd

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.

Signed-off-by: Shehryar Ahmad <shehryar.amd@gmail.com>
---
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().

Link: https://lore.kernel.org/all/20260925110239.59320-1-shehryar.amd@gmail.com/ #[1]
 
drivers/iio/imu/adis_buffer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
index 501da4eae..17af61c7d 100644
--- a/drivers/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -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);
-- 
2.56.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing
  2026-11-24 21:30 [PATCH] iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing Shehryar Ahmad
@ 2026-11-25  0:08 ` Shehryar Ahmad
  2026-11-26  2:15   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Shehryar Ahmad @ 2026-11-25  0:08 UTC (permalink / raw)
  To: shehryar.amd
  Cc: Antoniu.Miclaus, Dragos.Bogdan, Michael.Hennerich, Nuno.Sa,
	Robert.Budai, andy, dlechner, jic23, linux-iio, linux-kernel,
	linux, radu.sabau

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing
  2026-11-25  0:08 ` Shehryar Ahmad
@ 2026-11-26  2:15   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-11-26  2:15 UTC (permalink / raw)
  To: Shehryar Ahmad
  Cc: Antoniu.Miclaus, Dragos.Bogdan, Michael.Hennerich, Nuno.Sa,
	Robert.Budai, andy, dlechner, linux-iio, linux-kernel, linux,
	radu.sabau

On Wed, 25 Nov 2026 05:08:33 +0500
Shehryar Ahmad <shehryar.amd@gmail.com> wrote:

> sorry, this missed adding export symbol for find_channel_from_si()
> and fixes tag, will send in v2 shortly :)
> 
You can add markings to say that your series is on top of a particular
patch on this list.  That function is already exported on my tree
but I'm guessing sashiko tripped up because I haven't pushed that out
so that next picks it up yet.  Hence provide the message ID so
sashiko knows what to look for.  The b4 tool has settings to do this
automatically for you.

Thanks

Jonathan




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-26  2:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 21:30 [PATCH] iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing Shehryar Ahmad
2026-11-25  0:08 ` Shehryar Ahmad
2026-11-26  2:15   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®