From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Arnav Kapoor" <kapoorarnav43@gmail.com>
Subject: [PATCH v2 1/4] iio: proximity: aw96103: report negative proximity diff values
Date: Sat, 28 Nov 2026 17:21:38 +0530 [thread overview]
Message-ID: <20261128115144.557411-2-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261128115144.557411-1-kapoorarnav43@gmail.com>
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.
Convert the value to int before the division instead of after it, and
declare it as unsigned int, the type regmap_read() takes.
Fixes: 07b241262dca ("iio: proximity: aw96103: Add support for aw96103/aw96105 proximity sensor")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
drivers/iio/proximity/aw96103.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/proximity/aw96103.c b/drivers/iio/proximity/aw96103.c
index e3ab55170b6c..483b3bf18d19 100644
--- a/drivers/iio/proximity/aw96103.c
+++ b/drivers/iio/proximity/aw96103.c
@@ -261,14 +261,14 @@ static const struct regmap_config aw96103_regmap_confg = {
static int aw96103_get_diff_raw(struct aw96103 *aw96103, unsigned int chan,
int *buf)
{
- u32 data;
+ unsigned int data;
int ret;
ret = regmap_read(aw96103->regmap,
AW96103_REG_DIFF_CH0 + chan * 4, &data);
if (ret)
return ret;
- *buf = (int)(data / AW_DATA_PROCESS_FACTOR);
+ *buf = (int)data / AW_DATA_PROCESS_FACTOR;
return 0;
}
--
2.53.0
next prev parent reply other threads:[~2026-11-28 11:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 11:51 [PATCH v2 0/4] iio: proximity: aw96103: fix diff sign, missing config, async config lifetime and event values Arnav Kapoor
2026-11-28 11:51 ` Arnav Kapoor [this message]
2026-11-28 11:51 ` [PATCH v2 2/4] iio: proximity: aw96103: use the default configuration without firmware Arnav Kapoor
2026-11-28 11:51 ` [PATCH v2 3/4] iio: proximity: aw96103: wait for the configuration load before freeing Arnav Kapoor
2026-11-28 11:51 ` [PATCH v2 4/4] iio: proximity: aw96103: reject out-of-range debounce and hysteresis values Arnav Kapoor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261128115144.557411-2-kapoorarnav43@gmail.com \
--to=kapoorarnav43@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®