Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Yash Suthar <yashsuthar983@gmail.com>,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	grondon@gmail.com, linusw@kernel.org, hexlabsecurity@proton.me,
	sakari.ailus@linux.intel.com,
	srinivas.pandruvada@linux.intel.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] iio: accel: bmc150: use DMA-safe buffers for regmap bulk reads
Date: Mon, 31 Aug 2026 01:24:50 +0100	[thread overview]
Message-ID: <20260831012450.3382868c@jic23-huawei> (raw)
In-Reply-To: <ao_hr-0BelQWI27t@ashevche-desk.local>

On Thu, 27 Aug 2026 10:05:19 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Tue, Aug 25, 2026 at 02:21:55PM +0530, Yash Suthar wrote:
> > The FIFO and read_raw buffers are passed to regmap bulk/raw reads,
> > which is not DMA-safe. Moved them into struct bmc150_accel_data
> > after scan, each buffer are protected by mutex, placing them
> > after ensure DMA safety.  
> 
> ...
> 
> >  		j = 0;
> >  		iio_for_each_active_channel(indio_dev, bit)
> > -			memcpy(&data->scan.channels[j++], &buffer[i * 3 + bit],
> > +			memcpy(&data->scan.channels[j++],
> > +			       &data->fifo_buff[i * 3 + bit],
> >  			       sizeof(data->scan.channels[0]));  
> 
> While this works, I find a bit confusing usage of [j++] and [0] together.
> 
> IIUC the below is an equivalent
> 
> 		iio_for_each_active_channel(indio_dev, bit) {
> 			__le16 *val = &data->scan.channels[j++];
> 
> 			memcpy(val, &data->fifo_buff[i * 3 + bit], sizeof(val));
> 		}

This bit I fully agree with. Much more readable.
> 
> and if go further we may use asm/byteorder.h macros instead of plain memcpy().
> 
Here I'm lost.  We are just moving little endian values around.

For that matter if it is a single value, why can't see just assign it?

		iio_for_each_active_channel(indio_dev, bit)
			data->scan.channels[j++] = data->fifo_buf[i * 3 + bit];




> ...
> 
> Maybe this is for a separate change, I dunno. I leave it to others to decide.
> 


  reply	other threads:[~2026-08-31  0:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  8:51 [PATCH v3 0/3] iio: accel: bmc150: DMA-safe buffers and use iio_push_to_buffers_with_ts() Yash Suthar
2026-08-25  8:51 ` [PATCH v3 1/3] iio: accel: bmc150: use aligned scan buffer for both trigger and fifo Yash Suthar
2026-08-27  6:57   ` Andy Shevchenko
2026-08-25  8:51 ` [PATCH v3 2/3] iio: accel: bmc150: use DMA-safe buffers for regmap bulk reads Yash Suthar
2026-08-27  7:05   ` Andy Shevchenko
2026-08-31  0:24     ` Jonathan Cameron [this message]
2026-08-31  6:57       ` Andy Shevchenko
2026-08-25  8:51 ` [PATCH v3 3/3] iio: accel: bmc150: use iio_push_to_buffers_with_ts() Yash Suthar
2026-08-27  7:08   ` Andy Shevchenko
2026-08-31  0:27     ` Jonathan Cameron
2026-08-31  7:00       ` Andy Shevchenko
2026-09-01  1:34         ` Jonathan Cameron
2026-08-27  6:52 ` [PATCH v3 0/3] iio: accel: bmc150: DMA-safe buffers and " Andy Shevchenko

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=20260831012450.3382868c@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=grondon@gmail.com \
    --cc=hexlabsecurity@proton.me \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=yashsuthar983@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