mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Raffaele Tranfaglia via B4 Relay <devnull+raffaele.tranfaglia.gmail.com@kernel.org>
To: "Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>
Cc: linux@analog.com, linux-iio@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	 Raffaele Tranfaglia <raffaele.tranfaglia@gmail.com>
Subject: [PATCH 0/2] iio: light: adux1020: fix proximity measurement issues
Date: Mon, 09 Nov 2026 11:39:01 +0000	[thread overview]
Message-ID: <20261109-adux1020-measure-fixes-v1-0-fe1ba63f28bc@gmail.com> (raw)

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@gmail.com>



             reply	other threads:[~2026-11-09 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 11:39 Raffaele Tranfaglia via B4 Relay [this message]
2026-11-09 11:39 ` [PATCH 1/2] iio: light: adux1020: fix interrupt clear value on SMBus-only adapters Raffaele Tranfaglia via B4 Relay
2026-11-09 23:49   ` Andy Shevchenko
2026-11-09 11:39 ` [PATCH 2/2] iio: light: adux1020: extract the FIFO byte count with FIELD_GET() Raffaele Tranfaglia via B4 Relay

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=20261109-adux1020-measure-fixes-v1-0-fe1ba63f28bc@gmail.com \
    --to=devnull+raffaele.tranfaglia.gmail.com@kernel.org \
    --cc=Michael.Hennerich@analog.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=linux@analog.com \
    --cc=mani@kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=raffaele.tranfaglia@gmail.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®