Re: [PATCH 1/4] iio: proximity: aw96103: report negative proximity diff values

From: Andy Shevchenko

Date: Thu Nov 26 2026 - 09:29:26 EST


On Thu, Nov 26, 2026 at 11:00:25AM +0530, Arnav Kapoor wrote:
> The DIFF registers hold a signed S21.10 fixed-point value (Awinic's own
> aw_sar driver documents the diff data format as S21.10), which goes
> negative when the measured capacitance drops below the baseline.
> aw96103_get_diff_raw() divides it as a u32, so a diff of -1 (0xfffffc00)
> is reported as 4194303 instead of -1.
>
> Do the division on the value as an s32.

...

> if (ret)
> return ret;
> - *buf = (int)(data / AW_DATA_PROCESS_FACTOR);
> + *buf = (s32)data / AW_DATA_PROCESS_FACTOR;

The type of data is u32, however regmap expects unsigned int.
I would change the type and leave (int) casting (yes, the change
is required still, I noticed it).

--
With Best Regards,
Andy Shevchenko