linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: chemical: atlas-sensor: Avoid using irq_work
@ 2021-06-24 10:00 Nicolas Saenz Julienne
  2021-06-24 10:39 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-06-24 10:00 UTC (permalink / raw)
  To: jic23, lars, linux-iio
  Cc: linux-kernel, nsaenzju, matt.ranostay, andy.shevchenko

The atlas sensor driver currently registers a threaded IRQ handler whose
sole responsibility is to trigger an irq_work which will in turn run
iio_trigger_poll() in IRQ context.

This seems overkill given the fact that there already was a opportunity
to run iio_trigger_poll() in IRQ context in the top half of the IRQ
handler. So make use of it, ultimately avoiding a context switch, an
IPI, and reducing latency.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---

NOTE: This was only compile tested. I don't know much about iio_triggers
(or iio for that matter), but while reviewing irq_work usage this showed
up and seemed trivial enough to fix right away. There might be a subtle
reason why this is setup as such, but it would at least warrant a
comment.

 drivers/iio/chemical/atlas-sensor.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 9cb99585b6ff..710daa169d57 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -13,7 +13,6 @@
 #include <linux/mutex.h>
 #include <linux/err.h>
 #include <linux/irq.h>
-#include <linux/irq_work.h>
 #include <linux/i2c.h>
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
@@ -89,7 +88,6 @@ struct atlas_data {
 	struct iio_trigger *trig;
 	struct atlas_device *chip;
 	struct regmap *regmap;
-	struct irq_work work;
 	unsigned int interrupt_enabled;
 	/* 96-bit data + 32-bit pad + 64-bit timestamp */
 	__be32 buffer[6] __aligned(8);
@@ -442,13 +440,6 @@ static const struct iio_buffer_setup_ops atlas_buffer_setup_ops = {
 	.predisable = atlas_buffer_predisable,
 };
 
-static void atlas_work_handler(struct irq_work *work)
-{
-	struct atlas_data *data = container_of(work, struct atlas_data, work);
-
-	iio_trigger_poll(data->trig);
-}
-
 static irqreturn_t atlas_trigger_handler(int irq, void *private)
 {
 	struct iio_poll_func *pf = private;
@@ -474,7 +465,7 @@ static irqreturn_t atlas_interrupt_handler(int irq, void *private)
 	struct iio_dev *indio_dev = private;
 	struct atlas_data *data = iio_priv(indio_dev);
 
-	irq_work_queue(&data->work);
+	iio_trigger_poll(data->trig);
 
 	return IRQ_HANDLED;
 }
@@ -677,12 +668,10 @@ static int atlas_probe(struct i2c_client *client,
 		goto unregister_trigger;
 	}
 
-	init_irq_work(&data->work, atlas_work_handler);
-
 	if (client->irq > 0) {
 		/* interrupt pin toggles on new conversion */
 		ret = devm_request_threaded_irq(&client->dev, client->irq,
-				NULL, atlas_interrupt_handler,
+				atlas_interrupt_handler, NULL,
 				IRQF_TRIGGER_RISING |
 				IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 				"atlas_irq",
-- 
2.31.1


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

end of thread, other threads:[~2021-09-26 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 10:00 [PATCH] iio: chemical: atlas-sensor: Avoid using irq_work Nicolas Saenz Julienne
2021-06-24 10:39 ` Andy Shevchenko
2021-06-24 11:13   ` Nicolas Saenz Julienne
2021-09-26 15:33     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).