mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad7768-1: disable IRQ autoenable
@ 2025-07-18  1:33 Jonathan Santos
  2025-07-18  9:18 ` Nuno Sá
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Santos @ 2025-07-18  1:33 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: Jonathan Santos, lars, Michael.Hennerich, jic23, dlechner,
	nuno.sa, andy, jonath4nns

The device continuously converts data while powered up, generating
interrupts in the background. Configure the IRQ to be enabled and
disabled manually as needed to avoid unnecessary CPU load.

Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
---
 drivers/iio/adc/ad7768-1.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
index a2e061f0cb08..3eea03c004c3 100644
--- a/drivers/iio/adc/ad7768-1.c
+++ b/drivers/iio/adc/ad7768-1.c
@@ -395,8 +395,10 @@ static int ad7768_scan_direct(struct iio_dev *indio_dev)
 	if (ret < 0)
 		return ret;
 
+	enable_irq(st->spi->irq);
 	ret = wait_for_completion_timeout(&st->completion,
 					  msecs_to_jiffies(1000));
+	disable_irq(st->spi->irq);
 	if (!ret)
 		return -ETIMEDOUT;
 
@@ -1130,7 +1132,21 @@ static const struct iio_buffer_setup_ops ad7768_buffer_ops = {
 	.predisable = &ad7768_buffer_predisable,
 };
 
+static int ad7768_set_trigger_state(struct iio_trigger *trig, bool enable)
+{
+	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+	struct ad7768_state *st = iio_priv(indio_dev);
+
+	if (enable)
+		enable_irq(st->spi->irq);
+	else
+		disable_irq(st->spi->irq);
+
+	return 0;
+}
+
 static const struct iio_trigger_ops ad7768_trigger_ops = {
+	.set_trigger_state = ad7768_set_trigger_state,
 	.validate_device = iio_trigger_validate_own_device,
 };
 
@@ -1417,7 +1433,7 @@ static int ad7768_probe(struct spi_device *spi)
 
 	ret = devm_request_irq(&spi->dev, spi->irq,
 			       &ad7768_interrupt,
-			       IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+			       IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
 			       indio_dev->name, indio_dev);
 	if (ret)
 		return ret;

base-commit: 0a686b9c4f847dc21346df8e56d5b119918fefef
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-27 15:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-18  1:33 [PATCH] iio: adc: ad7768-1: disable IRQ autoenable Jonathan Santos
2025-07-18  9:18 ` Nuno Sá
2025-07-19 12:08   ` Jonathan Cameron
2025-07-25 20:01     ` Jonathan Santos
2025-07-27 15:38       ` Jonathan Cameron

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®