From: Marco Chen <marcochen.dev@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>,
pmeerw@pmeerw.net, matt@ranostay.sg, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev
Subject: [PATCH 1/2] iio: health: max30102: rename fifo_count() to fifo_ready()
Date: Fri, 27 Nov 2026 13:26:35 -0500 [thread overview]
Message-ID: <20261127182636.83803-2-marcochen.dev@gmail.com> (raw)
In-Reply-To: <20261127182636.83803-1-marcochen.dev@gmail.com>
The max30102_fifo_count() function does not count anything. It only
reports whether the FIFO_RDY bit is set, or a negative error value.
Rename max30102_fifo_count() to max30102_fifo_ready() and make it return
a bool. A failed status read returns false, which the handler already
treats as no data being available.
With a bool, the use of cnt in max30102_interrupt_handler() is no longer
needed, and a do/while loop can re-check the status after each sample.
The sequence of status and FIFO reads is the same as before.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Marco Chen <marcochen.dev@gmail.com>
---
Follow-up to Jonathan's comment on v2 of the NULL-dereference fix from
a few months ago
https://lore.kernel.org/linux-iio/20260805015826.2b558119@jic23-huawei/#R
Thank you.
drivers/iio/health/max30102.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c
index aee96167f01e..a553c0e011e0 100644
--- a/drivers/iio/health/max30102.c
+++ b/drivers/iio/health/max30102.c
@@ -235,20 +235,17 @@ static const struct iio_buffer_setup_ops max30102_buffer_setup_ops = {
.predisable = max30102_buffer_predisable,
};
-static inline int max30102_fifo_count(struct max30102_data *data)
+static inline bool max30102_fifo_ready(struct max30102_data *data)
{
unsigned int val;
int ret;
ret = regmap_read(data->regmap, MAX30102_REG_INT_STATUS, &val);
if (ret)
- return ret;
+ return false;
/* FIFO has one sample slot left */
- if (val & MAX30102_REG_INT_STATUS_FIFO_RDY)
- return 1;
-
- return 0;
+ return val & MAX30102_REG_INT_STATUS_FIFO_RDY;
}
#define MAX30102_COPY_DATA(i) \
@@ -291,10 +288,9 @@ static irqreturn_t max30102_interrupt_handler(int irq, void *private)
struct iio_dev *indio_dev = private;
struct max30102_data *data = iio_priv(indio_dev);
unsigned int measurements;
- int ret, cnt;
+ int ret;
- cnt = max30102_fifo_count(data);
- if (cnt <= 0)
+ if (!max30102_fifo_ready(data))
return IRQ_HANDLED;
measurements = bitmap_weight(indio_dev->active_scan_mask,
@@ -302,14 +298,13 @@ static irqreturn_t max30102_interrupt_handler(int irq, void *private)
mutex_lock(&data->lock);
- while (cnt || (cnt = max30102_fifo_count(data)) > 0) {
+ do {
ret = max30102_read_measurement(data, measurements);
if (ret)
break;
iio_push_to_buffers(data->indio_dev, data->processed_buffer);
- cnt--;
- }
+ } while (max30102_fifo_ready(data));
mutex_unlock(&data->lock);
--
2.56.1
next prev parent reply other threads:[~2026-11-27 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 18:26 [PATCH 0/2] iio: health: max30102: fifo_ready() rename and I2C error propagation Marco Chen
2026-11-27 18:26 ` Marco Chen [this message]
2026-11-27 18:26 ` [PATCH 2/2] iio: health: max30102: propagate I2C read errors Marco Chen
2026-11-28 0:44 ` [PATCH 0/2] iio: health: max30102: fifo_ready() rename and I2C error propagation Jonathan Cameron
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=20261127182636.83803-2-marcochen.dev@gmail.com \
--to=marcochen.dev@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@ranostay.sg \
--cc=nuno.sa@analog.com \
--cc=pmeerw@pmeerw.net \
--cc=skhan@linuxfoundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.