From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Gabriel Rondon <grondon@gmail.com>, Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] iio: accel: kionix-kx022a: use scan struct for one-shot and trigger reads
Date: Wed, 19 Aug 2026 07:59:07 +0300 [thread overview]
Message-ID: <e0c893ba-4a72-4ac4-84f7-f3d5e5fdf729@gmail.com> (raw)
In-Reply-To: <20260818215122.52715-2-grondon@gmail.com>
On 19/08/2026 00:51, Gabriel Rondon wrote:
> The driver kept two separate staging areas that hold the same thing:
> buffer[8], a DMA-aligned area used by the one-shot read in
> kx022a_get_axis() and by the triggered handler, and the scan struct,
> used by the FIFO flush path. Both are three __le16 channels plus room
> for the timestamp.
>
> Drop buffer and route the one-shot read and the triggered handler
> through scan.channels, so the driver has a single staging area. Move the
> IIO_DMA_MINALIGN alignment onto scan, since it now backs the regmap bulk
> reads that buffer used to.
>
> No functional change. get_axis() only runs via read_raw() under
> iio_device_claim_direct(), so it cannot run while the triggered buffer is
> active, and the triggered handler only runs while it is; the two never
> touch scan concurrently, exactly as they previously shared buffer.
>
> Signed-off-by: Gabriel Rondon <grondon@gmail.com>
Suggested-by?
Other than that - looks good to me.
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
> ---
> drivers/iio/accel/kionix-kx022a.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
> index 02dd1db7a646..cf2cb751b4e8 100644
> --- a/drivers/iio/accel/kionix-kx022a.c
> +++ b/drivers/iio/accel/kionix-kx022a.c
> @@ -301,11 +301,10 @@ struct kx022a_data {
> __le16 *fifo_buffer;
>
> /* 3 x 16bit accel data + timestamp */
> - __le16 buffer[8] __aligned(IIO_DMA_MINALIGN);
> struct {
> __le16 channels[3];
> aligned_s64 ts;
> - } scan;
> + } scan __aligned(IIO_DMA_MINALIGN);
> };
>
> static const struct iio_mount_matrix *
> @@ -613,12 +612,12 @@ static int kx022a_get_axis(struct kx022a_data *data,
> {
> int ret;
>
> - ret = regmap_bulk_read(data->regmap, chan->address, &data->buffer[0],
> - sizeof(__le16));
> + ret = regmap_bulk_read(data->regmap, chan->address,
> + &data->scan.channels[0], sizeof(__le16));
> if (ret)
> return ret;
>
> - *val = (s16)le16_to_cpu(data->buffer[0]);
> + *val = (s16)le16_to_cpu(data->scan.channels[0]);
>
> return IIO_VAL_INT;
> }
> @@ -1029,12 +1028,12 @@ static irqreturn_t kx022a_trigger_handler(int irq, void *p)
> struct kx022a_data *data = iio_priv(idev);
> int ret;
>
> - ret = regmap_bulk_read(data->regmap, data->chip_info->xout_l, data->buffer,
> - KX022A_FIFO_SAMPLES_SIZE_BYTES);
> + ret = regmap_bulk_read(data->regmap, data->chip_info->xout_l,
> + data->scan.channels, KX022A_FIFO_SAMPLES_SIZE_BYTES);
> if (ret < 0)
> goto err_read;
>
> - iio_push_to_buffers_with_timestamp(idev, data->buffer, data->timestamp);
> + iio_push_to_buffers_with_timestamp(idev, &data->scan, data->timestamp);
> err_read:
> iio_trigger_notify_done(idev->trig);
>
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2026-08-19 4:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 21:51 [PATCH v2 0/2] iio: accel: kionix-kx022a: unify staging buffer and convert to iio_push_to_buffers_with_ts() Gabriel Rondon
2026-08-18 21:51 ` [PATCH v2 1/2] iio: accel: kionix-kx022a: use scan struct for one-shot and trigger reads Gabriel Rondon
2026-08-19 4:59 ` Matti Vaittinen [this message]
2026-08-19 7:17 ` Andy Shevchenko
2026-08-20 2:04 ` Jonathan Cameron
2026-08-18 21:51 ` [PATCH v2 2/2] iio: accel: kionix-kx022a: use iio_push_to_buffers_with_ts() Gabriel Rondon
2026-08-19 5:11 ` Matti Vaittinen
2026-08-20 2:11 ` Jonathan Cameron
2026-08-19 0:09 ` [PATCH v2 0/2] iio: accel: kionix-kx022a: unify staging buffer and convert to iio_push_to_buffers_with_ts() Jonathan Cameron
2026-08-19 5:15 ` Matti Vaittinen
2026-08-19 7:18 ` Andy Shevchenko
2026-08-20 2:15 ` Jonathan Cameron
2026-08-19 7:19 ` 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=e0c893ba-4a72-4ac4-84f7-f3d5e5fdf729@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=grondon@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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
all inboxes | Powered by JetHome®