From: Jonathan Cameron <jic23@kernel.org>
To: linux-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>
Subject: [RESEND PATCH 14/14] iio: adc: at91_adc: poll the enabled trigger from interrupt handler
Date: Mon, 9 Nov 2026 04:28:51 +0000 [thread overview]
Message-ID: <20261109042851.1326940-15-jic23@kernel.org> (raw)
In-Reply-To: <20261109042851.1326940-1-jic23@kernel.org>
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
The driver registers several hardware triggers, any of which may be
selected. The end of conversion interrupt is only enabled for buffered
capture by the set_trigger_state() callback of the trigger being
enabled, and handle_adc_eoc_trigger() then polls indio_dev->trig.
Record the trigger in at91_adc_configure_trigger() before enabling the
interrupt and poll that instead. It is not cleared on disable so that
an interrupt still in flight polls the same trigger as before rather
than dereferencing NULL.
Also use the trigger passed to at91_adc_configure_trigger() to look up
its configuration rather than indio_dev->trig, which is the same
trigger.
This removes the driver's dependencies on the trig field of struct
iio_dev, which is to become private to the IIO core.
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
---
drivers/iio/adc/at91_adc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 0ac74ad92fca..49e7fb2d39f2 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -229,6 +229,7 @@ struct at91_adc_state {
u8 sample_hold_time;
bool sleep_mode;
struct iio_trigger **trig;
+ struct iio_trigger *cur_trig; /* last enabled of trig[] */
bool use_external;
u32 vref_mv;
u32 res; /* resolution used for conversions */
@@ -294,7 +295,7 @@ static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev)
if (iio_buffer_enabled(idev)) {
disable_irq_nosync(irq);
- iio_trigger_poll(idev->trig);
+ iio_trigger_poll(st->cur_trig);
} else {
st->last_value = at91_adc_readl(st, AT91_ADC_CHAN(st, st->chnb));
/* Needed to ACK the DRDY interruption */
@@ -562,7 +563,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
value = at91_adc_get_trigger_value_by_name(idev,
st->caps->triggers,
- idev->trig->name);
+ trig->name);
if (value < 0)
return value;
@@ -581,6 +582,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
AT91_ADC_CH(chan->channel));
}
+ st->cur_trig = trig;
at91_adc_writel(st, AT91_ADC_IER, reg->drdy_mask);
} else {
--
2.56.0
prev parent reply other threads:[~2026-11-09 4:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 4:28 [RESEND PATCH 00/14] IIO: Ensure iio_trigger_poll() is of the device owned trigger Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 01/14] iio: accel: mma8452: unregister own trigger rather than current one Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 02/14] iio: accel: mma8452: poll own trigger from interrupt handler Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 03/14] iio: adc: max1027: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 04/14] iio: adc: ti-ads1119: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 05/14] iio: adc: mxs-lradc-adc: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 06/14] iio: adc: at91-sama5d2: poll own trigger on data ready interrupt Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 07/14] iio: light: vl6180: poll own trigger from interrupt handler Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 08/14] iio: proximity: vl53l0x-i2c: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 09/14] iio: adc: ad4691: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 10/14] iio: chemical: scd30: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 11/14] iio: proximity: vl53l1x-i2c: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 12/14] iio: proximity: irsd200: " Jonathan Cameron
2026-11-09 4:28 ` [RESEND PATCH 13/14] iio: light: vcnl4000: " Jonathan Cameron
2026-11-09 4:28 ` Jonathan Cameron [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=20261109042851.1326940-15-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=jonathan.cameron@oss.qualcomm.com \
--cc=linux-iio@vger.kernel.org \
--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=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 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®