Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <nuno.sa@analog.com>
To: Shehryar Ahmad <shehryar.amd@gmail.com>
Cc: jic23@kernel.org, radu.sabau@analog.com,
	Antoniu.Miclaus@analog.com, Dragos.Bogdan@analog.com,
	Michael.Hennerich@analog.com, Robert.Budai@analog.com,
	andy@kernel.org, dlechner@baylibre.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux@analog.com
Subject: Re: [PATCH] iio: imu: adis_buffer: fix buffer ordering for IIO core demultiplexing
Date: Fri, 27 Nov 2026 09:33:14 +0000	[thread overview]
Message-ID: <awlONu_ohrpr6cPx@nsa> (raw)
In-Reply-To: <20261124213118.63979-1-shehryar.amd@gmail.com>

On Wed, Nov 25, 2026 at 02:30:54AM +0500, Shehryar Ahmad wrote:
> 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>
> ---

You got some tags in the RFC that you ignored...

- Nuno Sá

> 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
> 

      parent reply	other threads:[~2026-11-27  9:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2026-11-27  9:33 ` Nuno Sá [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awlONu_ohrpr6cPx@nsa \
    --to=nuno.sa@analog.com \
    --cc=Antoniu.Miclaus@analog.com \
    --cc=Dragos.Bogdan@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=Robert.Budai@analog.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=radu.sabau@analog.com \
    --cc=shehryar.amd@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox