[PATCH 0/2] iio: light: adux1020: fix proximity measurement issues
From: Raffaele Tranfaglia via B4 Relay
Date: Mon Nov 09 2026 - 06:43:48 EST
While testing the guard() conversion of this driver with i2c-stub, I
found two issues in adux1020_measure().
Patch 1 fixes a real bug: the interrupt clear value is computed as
~u16, which integer promotion turns into 0xffffff0f. Plain I2C
adapters silently truncate it to 0xff0f, but SMBus-only adapters reject
it with -EINVAL, so every proximity read fails on them.
Patch 2 extracts the FIFO byte count with FIELD_GET(). The current code
compares the unshifted field against the packet size. Per the
datasheet, the FIFO only stores complete packets, so this does not
misbehave on a working device, hence no Fixes tag.
Tested on arm64 QEMU with i2c-stub (an SMBus-only adapter), lockdep and
UBSAN enabled, planting FIFO byte counts in INT_STATUS by hand:
- before: reads fail with -EINVAL
- patch 1: count 2 returns the planted sample; count 1 also returns it
(issue fixed by patch 2); count 0 times out with -EIO
- patch 1+2: count 2 returns the sample; counts 1 and 0 time out with
-EIO
No lockdep or UBSAN reports.
I prepared these patches with the help of an AI coding assistant, and
reviewed and tested them myself.
---
Raffaele Tranfaglia (2):
iio: light: adux1020: fix interrupt clear value on SMBus-only adapters
iio: light: adux1020: extract the FIFO byte count with FIELD_GET()
drivers/iio/light/adux1020.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
base-commit: b70566610b48ba49dec636019da4d696db64b085
change-id: 20261109-adux1020-measure-fixes-9f3bb844f758
Best regards,
--
Raffaele Tranfaglia <raffaele.tranfaglia@xxxxxxxxx>