RE: [RFC PATCH] iio: adis_buffer: fix buffer ordering for IIO core demultiplexing
From: Sabau, Radu bogdan
Date: Tue Nov 24 2026 - 06:34:31 EST
> -----Original Message-----
> From: Sa, Nuno <nuno.sa@xxxxxxxxxx>
> Sent: Thursday, October 15, 2026 1:17 PM
...
> > >
> > > Would this be the right approach, or is there something I'm missing?
> >
> > It is definitely plausible. For this I'd need some input from someone
> > who can actually test some of these parts.
> >
> > Nuno, you are listed as library maintainer - so can you get someone to
> > look at this please. +CC various other folk from maintainers or who have
> worked
> > in this area in last few years.
> >
> > Otherwise, just a comment to use a Link tag for cross references.
> >
>
> Hmm missed this one! So the issue looks very much real (just by code
> inspection). Just never saw it since the more recent devices I worked with
> just do burst mode which is not affected by that path. Moreover I'm not
> sure any of the affected drivers is really using the IIO demux (though I
> don't think that matters - seems to me the buffer will never respect
> scan_index order so not sure how it was ever right).
>
> +Cc Radu as he has been working with these devices and on the library.
>
> Radu, can you give a quick test here? Worst case scenario and you only
> have devices with burst mode, you can just tweak the driver to disable
> the burst path :)
>
Hi everyone,
I tested this on an ADIS16470 (adis16475 driver) on a RPi4.
The ADIS16470 only uses the burst path in mainline, and its channel is already
in scan_index order, so it does not hit this code by default. To exercise it I used
a local tweak on the driver:
- set .burst_len = 0 so adis_udpate_scan_mode() takes the non-burst
path, and use the generic adis_trigger_handler;
- reorder adis16475_channels[] to temp, accel, gyro so the array order
differs from the scan_index order.
Capturing accel_z + temp with iio_readdev (hex dump of the raw buffer),
compared against read_raw:
Without the patch:
read_raw: accel_z = 0x03174ac0, temp = 0xe7
buffer: 00 eb 03 09 fe 22
The temp word ends up in the upper half of the accel_z slot, accel_z's
high word is shifted, and accel_z's low word lands in the temp slot.
With the patch:
accel_z and temp appear in the right slots and match read_raw
(e.g. accel_z 0x02e97fba vs. a read_raw of ~48.67M, temp 0xf6
vs. 0xe6 as the board warmed up).
So I can confirm the failure on hardware and that this patch fixes it.
Tested-by: Radu Sabau <radu.sabau@xxxxxxxxxx>