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 2/2] iio: light: adux1020: extract the FIFO byte count with FIELD_GET()
Date: Mon, 09 Nov 2026 11:39:03 +0000	[thread overview]
Message-ID: <20261109-adux1020-measure-fixes-v1-2-fe1ba63f28bc@gmail.com> (raw)
In-Reply-To: <20261109-adux1020-measure-fixes-v1-0-fe1ba63f28bc@gmail.com>

From: Raffaele Tranfaglia <raffaele.tranfaglia@gmail.com>

adux1020_measure() masks INT_STATUS with ADUX1020_FIFO_STATUS_MASK but
does not shift the result down, so it compares 256 times the FIFO byte
count against the packet size. A count of 1 would thus be treated as a
complete 2-byte proximity packet.

This does not happen on a correctly working device, because the FIFO
only stores complete packets and the driver always reads complete
packets, so the count is always a multiple of the packet size. Still,
use FIELD_GET() so the comparison matches the datasheet's polling
procedure and does not depend on that.

Signed-off-by: Raffaele Tranfaglia <raffaele.tranfaglia@gmail.com>
---
 drivers/iio/light/adux1020.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/adux1020.c b/drivers/iio/light/adux1020.c
index cccd509dd18a..dd5230c6dceb 100644
--- a/drivers/iio/light/adux1020.c
+++ b/drivers/iio/light/adux1020.c
@@ -331,7 +331,7 @@ static int adux1020_measure(struct adux1020_data *data,
 		if (ret < 0)
 			return ret;
 
-		status &= ADUX1020_FIFO_STATUS_MASK;
+		status = FIELD_GET(ADUX1020_FIFO_STATUS_MASK, status);
 		if (status >= adux1020_modes[mode].bytes)
 			break;
 		msleep(20);

-- 
2.56.0



      parent 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 [PATCH 0/2] iio: light: adux1020: fix proximity measurement issues Raffaele Tranfaglia via B4 Relay
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 ` Raffaele Tranfaglia via B4 Relay [this message]

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-2-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®