All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] input: touch: eeti: move ISR code to own function
@ 2019-04-22  8:35 Daniel Mack
  2019-04-22  8:35 ` [PATCH 2/2] input: touch: eeti: read hardware state once after wakeup Daniel Mack
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Mack @ 2019-04-22  8:35 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt; +Cc: linux-input, devicetree, Daniel Mack

Move the ISR handling code to its own function and change the logic to bail
immediately in case of .running is false or if the attn_gpio is available
but unasserted.

This allows us to call the function at any time to check for the state of
attn_gpio.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 drivers/input/touchscreen/eeti_ts.c | 30 +++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 7fe41965c5d1..f5724aaa815b 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -75,14 +75,19 @@ static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf)
 	input_sync(eeti->input);
 }
 
-static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
+static void eeti_ts_read(struct eeti_ts *eeti)
 {
-	struct eeti_ts *eeti = dev_id;
-	int len;
-	int error;
+	int len, error;
 	char buf[6];
 
-	do {
+	for (;;) {
+		if (!eeti->running)
+			break;
+
+		if (eeti->attn_gpio &&
+		    gpiod_get_value_cansleep(eeti->attn_gpio) == 0)
+			break;
+
 		len = i2c_master_recv(eeti->client, buf, sizeof(buf));
 		if (len != sizeof(buf)) {
 			error = len < 0 ? len : -EIO;
@@ -92,12 +97,17 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
 			break;
 		}
 
-		if (buf[0] & 0x80) {
-			/* Motion packet */
+		/* Motion packet */
+		if (buf[0] & 0x80)
 			eeti_ts_report_event(eeti, buf);
-		}
-	} while (eeti->running &&
-		 eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio));
+	}
+}
+
+static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
+{
+	struct eeti_ts *eeti = dev_id;
+
+	eeti_ts_read(eeti);
 
 	return IRQ_HANDLED;
 }
-- 
2.20.1

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

end of thread, other threads:[~2019-04-29  5:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-22  8:35 [PATCH 1/2] input: touch: eeti: move ISR code to own function Daniel Mack
2019-04-22  8:35 ` [PATCH 2/2] input: touch: eeti: read hardware state once after wakeup Daniel Mack
2019-04-23  3:17   ` Dmitry Torokhov
2019-04-23  4:51     ` Daniel Mack
2019-04-23  8:41       ` Dmitry Torokhov
2019-04-28  7:18         ` Daniel Mack
2019-04-28 17:36           ` Dmitry Torokhov
2019-04-28 19:30             ` Daniel Mack
2019-04-28 19:50             ` Daniel Mack
2019-04-29  1:17               ` Dmitry Torokhov
2019-04-29  5:49                 ` Daniel Mack

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.