Re: [PATCH] iio: proximity: sx9324: reject reserved gain values on read

From: Joshua Crofts

Date: Thu Nov 05 2026 - 08:17:06 EST


On Wed, 4 Nov 2026 23:29:18 +0530
Arnav Kapoor <kapoorarnav43@xxxxxxxxx> wrote:

> sx9324_read_gain() is meant to return -EINVAL for the reserved
> PROX_CTRL0 gain codes, 0 and 5 to 7. But the range check sits in the
> else branch of "if (regval)", where regval is always 0, so codes 5 to 7
> are never caught and are reported as gains of 16, 32 and 64, which the
> sensor doesn't support and which write_raw() rejects.
>
> Check both reserved ranges before converting the code to a gain.
>
> Fixes: 108e4d4de2b5 ("iio:proximity:sx9324: Fix hardware gain read/write")
> Signed-off-by: Arnav Kapoor <kapoorarnav43@xxxxxxxxx>
> ---

Makes sense. A stable tag is probably needed.

Reviewed-by: Joshua Crofts <crofts@xxxxxxxxxx>

--
Kind regards,
Joshua Crofts