Re: [PATCH 1/9] iio: imu: st_lsm6dsx: dynamically initialize iio_chan_spec data

From: Francesco Lavra

Date: Fri Oct 31 2025 - 07:43:47 EST


On Fri, 2025-10-31 at 10:32 +0200, Andy Shevchenko wrote:
> On Fri, Oct 31, 2025 at 09:26:19AM +0100, Francesco Lavra wrote:
> > On Thu, 2025-10-30 at 17:42 +0100, Lorenzo Bianconi wrote:
>
> > > > +       chan->ext_info = st_lsm6dsx_ext_info;
> > > > +       if (id == ST_LSM6DSX_ID_ACC) {
> > > > +               if (hw->settings->event_settings.wakeup_reg.addr) {
> > >
> > >         if (id == ST_LSM6DSX_ID_ACC &&
> > >             hw->settings->event_settings.wakeup_reg.addr) {
> > >             ...
> > >         }
> >
> > In patch 4/9, the inner conditional will be replaced by more generic
> > code,
> > so we would revert to if (id == ST_LSM6DSX_ID_ACC) [...]
>
> Hmm... The obvious follow up question is why can't we stick with the
> original
> conditional to begin with?

There is no original conditional, this is new code.
So the code here is `if (cond1) {if (cond2) {}}`; in patch 4/9 it will
become `if (cond1) {something else}`.
Or, better yet, as you suggested earlier, in the next revision the code
here will be `if (cond1) helper()`, and in the patch 4/9 this will stay the
same and only the code inside the helper will change.

Attachment: signature.asc
Description: This is a digitally signed message part