Linux IIO development
 help / color / mirror / Atom feed
From: Stepan Ionichev <sozdayvek@gmail.com>
To: jic23@kernel.org
Cc: mazziesaccount@gmail.com, dlechner@baylibre.com,
	nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, sozdayvek@gmail.com
Subject: [PATCH v3] iio: pressure: rohm-bm1390: harden trigger handler against transient errors
Date: Mon, 18 May 2026 23:11:10 +0500	[thread overview]
Message-ID: <20260518181110.1467-1-sozdayvek@gmail.com> (raw)

bm1390_trigger_handler() returns from three error paths without calling
iio_trigger_notify_done(). The success path at the end does, so on a
transient regmap or read failure the trigger's use_count is never
decremented and iio_trigger_poll_chained() drops subsequent dispatches
until the trigger is reattached.

This is not a fix for a reported bug, only hardening against hardware
or bus glitches; if a glitch is persistent the device is wedged and
needs an unbind anyway, which is left to the user.

Split the function so the inner helper returns bool with the data-read
outcome, and the outer IRQ handler calls iio_trigger_notify_done()
once and reports the result via IRQ_RETVAL().

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
v3:
- Split into bm1390_handle_trigger() helper returning bool, with the IRQ
  wrapper calling iio_trigger_notify_done() once (Andy)
- Drop Fixes: and Cc: stable@; this is hardware-failure hardening, not
  a user-visible bug fix (Jonathan)
- Reframe the commit message accordingly

v1: https://lore.kernel.org/all/20260517160801.269-1-sozdayvek@gmail.com/
v2: https://lore.kernel.org/all/20260518094238.1986-1-sozdayvek@gmail.com/

 drivers/iio/pressure/rohm-bm1390.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/pressure/rohm-bm1390.c b/drivers/iio/pressure/rohm-bm1390.c
index 08146ca0f..007c1559f 100644
--- a/drivers/iio/pressure/rohm-bm1390.c
+++ b/drivers/iio/pressure/rohm-bm1390.c
@@ -621,17 +621,15 @@ static const struct iio_buffer_setup_ops bm1390_buffer_ops = {
 	.predisable = bm1390_buffer_predisable,
 };
 
-static irqreturn_t bm1390_trigger_handler(int irq, void *p)
+static bool bm1390_handle_trigger(struct iio_dev *idev)
 {
-	struct iio_poll_func *pf = p;
-	struct iio_dev *idev = pf->indio_dev;
 	struct bm1390_data *data = iio_priv(idev);
 	int ret, status;
 
 	/* DRDY is acked by reading status reg */
 	ret = regmap_read(data->regmap, BM1390_REG_STATUS, &status);
 	if (ret || !status)
-		return IRQ_NONE;
+		return false;
 
 	dev_dbg(data->dev, "DRDY trig status 0x%x\n", status);
 
@@ -639,7 +637,7 @@ static irqreturn_t bm1390_trigger_handler(int irq, void *p)
 		ret = bm1390_pressure_read(data, &data->buf.pressure);
 		if (ret) {
 			dev_warn(data->dev, "sample read failed %d\n", ret);
-			return IRQ_NONE;
+			return false;
 		}
 	}
 
@@ -648,15 +646,26 @@ static irqreturn_t bm1390_trigger_handler(int irq, void *p)
 				       &data->buf.temp, sizeof(data->buf.temp));
 		if (ret) {
 			dev_warn(data->dev, "temp read failed %d\n", ret);
-			return IRQ_HANDLED;
+			return true;
 		}
 	}
 
 	iio_push_to_buffers_with_ts(idev, &data->buf, sizeof(data->buf),
 				    data->timestamp);
+
+	return true;
+}
+
+static irqreturn_t bm1390_trigger_handler(int irq, void *p)
+{
+	struct iio_poll_func *pf = p;
+	struct iio_dev *idev = pf->indio_dev;
+	bool result;
+
+	result = bm1390_handle_trigger(idev);
 	iio_trigger_notify_done(idev->trig);
 
-	return IRQ_HANDLED;
+	return IRQ_RETVAL(result);
 }
 
 /* Get timestamps and wake the thread if we need to read data */
-- 
2.43.0


             reply	other threads:[~2026-05-18 18:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 18:11 Stepan Ionichev [this message]
2026-05-19  6:19 ` [PATCH v3] iio: pressure: rohm-bm1390: harden trigger handler against transient errors Matti Vaittinen
2026-07-03 23:00   ` 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=20260518181110.1467-1-sozdayvek@gmail.com \
    --to=sozdayvek@gmail.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=mazziesaccount@gmail.com \
    --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