[PATCH 1/4] iio: proximity: aw96103: report negative proximity diff values
From: Arnav Kapoor
Date: Thu Nov 26 2026 - 00:31:06 EST
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.
Fixes: 07b241262dca ("iio: proximity: aw96103: Add support for aw96103/aw96105 proximity sensor")
Signed-off-by: Arnav Kapoor <kapoorarnav43@xxxxxxxxx>
---
drivers/iio/proximity/aw96103.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/proximity/aw96103.c b/drivers/iio/proximity/aw96103.c
index e3ab55170b6c..1fd0ceaf2a05 100644
--- a/drivers/iio/proximity/aw96103.c
+++ b/drivers/iio/proximity/aw96103.c
@@ -268,7 +268,7 @@ static int aw96103_get_diff_raw(struct aw96103 *aw96103, unsigned int chan,
AW96103_REG_DIFF_CH0 + chan * 4, &data);
if (ret)
return ret;
- *buf = (int)(data / AW_DATA_PROCESS_FACTOR);
+ *buf = (s32)data / AW_DATA_PROCESS_FACTOR;
return 0;
}
--
2.53.0