Re: [PATCH v2 2/6] iio: proximity: sx9324: fix proximity threshold writes
From: Andy Shevchenko
Date: Mon Nov 23 2026 - 06:16:25 EST
On Mon, Nov 23, 2026 at 01:11:11PM +0200, Andy Shevchenko wrote:
> On Sun, Nov 22, 2026 at 01:16:42PM +0530, Arnav Kapoor wrote:
...
> > {
> > - unsigned int reg, val = _val;
> > + unsigned int reg, val;
> > +
> > + if (_val < 0)
> > + return -EINVAL;
> >
> > reg = SX9324_REG_PROX_CTRL6 + chan->channel / 2;
> > + val = _val;
>
>
> Why not simply
>
> val = _val;
> if (val < 0)
> return -EINVAL;
Ah, see the comment I gave in the other patch.
> ...
> reg = SX9324_REG_PROX_CTRL6 + chan->channel / 2;
>
> Note, reg might still be not used, we have more validations and with your
> approach the reg assignment is in the middle, confusing...
--
With Best Regards,
Andy Shevchenko