[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aSYTpxnMLFamU4zC@smile.fi.intel.com>
Date: Tue, 25 Nov 2025 22:37:59 +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 v3 7/9] iio: imu: st_lsm6dsx: add event configurability
on a per axis basis
On Tue, Nov 25, 2025 at 09:23:05PM +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.
...
> + /*
> + * If the set of axes for which the event source is enabled does not
> + * change from empty to non-empty or vice versa, there is nothing else
> + * to do.
> + */
> + old_enable = hw->enable_event[event];
> + new_enable = state ? (old_enable | BIT(axis)) :
> + (old_enable & ~BIT(axis));
> + if (!!old_enable == !!new_enable)
> + return 0;
Sorry, I had no time to answer to you on previous round.
I read and found that I was mistaken assuming that the axis
is the bit that appears to be last when doing something here.
Without that assumption my approach (obviously) won't work.
However, the !! here is also not needed, the
if (!old_enable == !new_enable)
will work the same way. This will address my concerns about double negation and
makes code easier to understand as we don't need to implicitly convert integers
to booleans and than back to integers.
(and yes, I run the updated test cases to see it works as expected).
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists