On Thu, 12 Nov 2020 15:43:22 +0100 Nuno Sá <nuno.sa@xxxxxxxxxx> wrote: > When updating the buffer demux, we will skip a scan element from the > device in the case `in_ind != out_ind` and we enter the while loop. > in_ind should only be refreshed with `find_next_bit()` in the end of the > loop. > > Fixes: 5ada4ea9be16 ("staging:iio: add demux optionally to path from device to buffer") > Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx> Yikes that's been there a long time. Could you provide an example of a particular layout and the result of this being wrong? Thanks, Jonathan > --- > drivers/iio/industrialio-buffer.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c > index a4f6bb96d4f4..276b609d7917 100644 > --- a/drivers/iio/industrialio-buffer.c > +++ b/drivers/iio/industrialio-buffer.c > @@ -865,12 +865,12 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, > indio_dev->masklength, > in_ind + 1); > while (in_ind != out_ind) { > - in_ind = find_next_bit(indio_dev->active_scan_mask, > - indio_dev->masklength, > - in_ind + 1); > length = iio_storage_bytes_for_si(indio_dev, in_ind); > /* Make sure we are aligned */ > in_loc = roundup(in_loc, length) + length; > + in_ind = find_next_bit(indio_dev->active_scan_mask, > + indio_dev->masklength, > + in_ind + 1); > } > length = iio_storage_bytes_for_si(indio_dev, in_ind); > out_loc = roundup(out_loc, length);