[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQMgxUNA8XNhPZdG@smile.fi.intel.com>
Date: Thu, 30 Oct 2025 10:24:37 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Francesco Lavra <flavra@...libre.com>
Cc: Lorenzo Bianconi <lorenzo@...nel.org>,
Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 8/9] iio: imu: st_lsm6dsx: add event configurability on a
per axis basis
On Thu, Oct 30, 2025 at 08:27:51AM +0100, Francesco Lavra wrote:
> In order to be able to configure event detection on a per axis
> basis (for either setting an event threshold/sensitivity value, or
> enabling/disabling event detection), add new axis-specific fields
> to struct st_lsm6dsx_event_src, and modify the logic that handles
> event configuration to properly handle axis-specific settings when
> supported by a given event source.
> A future commit will add actual event sources with per-axis
> configurability.
...
> + old_enable = hw->enable_event[event];
> + new_enable = state ? (old_enable | BIT(axis)) : (old_enable & ~BIT(axis));
> + if (!!old_enable == !!new_enable)
This is an interesting check. So, old_enable and new_enable are _not_ booleans, right?
So, this means the check test if _any_ of the bit was set and kept set or none were set
and non is going to be set. Correct? I think a short comment would be good to have.
> + return 0;
...
> +static const struct st_lsm6dsx_reg *st_lsm6dsx_get_event_reg(struct st_lsm6dsx_hw *hw,
> + enum st_lsm6dsx_event_id event,
> + const struct iio_chan_spec *chan)
> +{
> + const struct st_lsm6dsx_event_src *src = &hw->settings->event_settings.sources[event];
> + const struct st_lsm6dsx_reg *reg;
> +
> + switch (chan->channel2) {
> + case IIO_MOD_X:
> + reg = &src->x_value;
> + break;
> + case IIO_MOD_Y:
> + reg = &src->y_value;
> + break;
> + case IIO_MOD_Z:
> + reg = &src->z_value;
> + break;
> + default:
> + return NULL;
> + }
> + if (!reg->addr)
> + reg = &src->value;
> + return reg;
if (reg->addr)
return reg;
/* Perhaps a comment here to explain the choice */
return &src->value;
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists