Re: [PATCH v2 2/6] iio: proximity: sx9324: fix proximity threshold writes
From: Arnav Kapoor
Date: Mon Nov 23 2026 - 08:18:05 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:
...
> Why not simply
>
> val = _val;
> if (val < 0)
> return -EINVAL;
val is unsigned int, so I think that check would never be true; it has
to test _val, or be the val > INT_MAX form from your comment on 3/6.
Whichever form Jonathan prefers there, I'll use the same one in all four.
> ...
> 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...
Agreed, reg belongs after the val > 0xff check, right before the
guard(). I'll fix it in v3 as soon as I get the val verdict.
Thanks,
Arnav