All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: iio@vger.kernel.org, Miquel Raynal <miquel.raynal@bootlin.com>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	Song Qiang <songqiang1304521@gmail.com>,
	Radu Sabau <radu.sabau@analog.com>,
	Maxwell Doose <maxwell@maxwelld.cc>,
	Tomasz Duszynski <tduszyns@gmail.com>,
	Erikas Bitovtas <xerikasxx@gmail.com>,
	Waqar Hameed <waqar.hameed@axis.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-kernel@vger.kernel.org,
	"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>,
	stable@vger.kernel.org
Subject: [PATCH 01/14] iio: accel: mma8452: unregister own trigger rather than current one
Date: Mon,  9 Nov 2026 03:52:39 +0000	[thread overview]
Message-ID: <20261109035252.1295926-2-jic23@kernel.org> (raw)
In-Reply-To: <20261109035252.1295926-1-jic23@kernel.org>

From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>

mma8452_trigger_cleanup() uses indio_dev->trig to unregister the trigger.
That may or may not be the one it registered as this driver allows
triggers other than its own to be used.

Keep a pointer to the driver's own trigger in struct mma8452_data and
unregister that instead.

Fixes: ae6d9ce05691 ("iio: mma8452: Add support for interrupt driven triggers.")
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
 drivers/iio/accel/mma8452.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index dc8031e14c29..f9abff3842fc 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -115,6 +115,7 @@
  * @orientation:		mounting matrix, flipped axis etc.
  * @chip_info:			chip specific data
  * @regs:			reference to voltage regulators
+ * @trig:			data ready trigger, if an interrupt is available
  * @buffer:			triggered buffer
  * @sleep_val:			time in ms to sleep while waiting for drdy
  * @ctrl_reg1:			CTRL_REG1 register shadow value
@@ -127,6 +128,7 @@ struct mma8452_data {
 	struct iio_mount_matrix orientation;
 	const struct mma_chip_info *chip_info;
 	struct regulator_bulk_data regs[2];
+	struct iio_trigger *trig;
 
 	/* Ensure correct alignment of time stamp when present */
 	struct {
@@ -1526,6 +1528,7 @@ static int mma8452_trigger_setup(struct iio_dev *indio_dev)
 	if (ret)
 		return ret;
 
+	data->trig = trig;
 	indio_dev->trig = iio_trigger_get(trig);
 
 	return 0;
@@ -1533,8 +1536,10 @@ static int mma8452_trigger_setup(struct iio_dev *indio_dev)
 
 static void mma8452_trigger_cleanup(struct iio_dev *indio_dev)
 {
-	if (indio_dev->trig)
-		iio_trigger_unregister(indio_dev->trig);
+	struct mma8452_data *data = iio_priv(indio_dev);
+
+	if (data->trig)
+		iio_trigger_unregister(data->trig);
 }
 
 static int mma8452_reset(struct i2c_client *client)
-- 
2.56.0


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

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  3:52 [PATCH 00/14] IIO: Ensure iio_trigger_poll() is of the device owned trigger Jonathan Cameron
2026-11-09  3:52 ` Jonathan Cameron [this message]
2026-11-09  3:52 ` [PATCH 02/14] iio: accel: mma8452: poll own trigger from interrupt handler Jonathan Cameron
2026-11-09  3:52 ` [PATCH 03/14] iio: adc: max1027: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 04/14] iio: adc: ti-ads1119: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 05/14] iio: adc: mxs-lradc-adc: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 06/14] iio: adc: at91-sama5d2: poll own trigger on data ready interrupt Jonathan Cameron
2026-11-09  3:52 ` [PATCH 07/14] iio: light: vl6180: poll own trigger from interrupt handler Jonathan Cameron
2026-11-09  3:52 ` [PATCH 08/14] iio: proximity: vl53l0x-i2c: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 09/14] iio: adc: ad4691: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 10/14] iio: chemical: scd30: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 11/14] iio: proximity: vl53l1x-i2c: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 12/14] iio: proximity: irsd200: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 13/14] iio: light: vcnl4000: " Jonathan Cameron
2026-11-09  3:52 ` [PATCH 14/14] iio: adc: at91_adc: poll the enabled " Jonathan Cameron
2026-11-09  4:22 ` [PATCH 00/14] IIO: Ensure iio_trigger_poll() is of the device owned trigger 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=20261109035252.1295926-2-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andy@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=dlechner@baylibre.com \
    --cc=iio@vger.kernel.org \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxwell@maxwelld.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=radu.sabau@analog.com \
    --cc=songqiang1304521@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tduszyns@gmail.com \
    --cc=waqar.hameed@axis.com \
    --cc=xerikasxx@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 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.