[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210110190529.46135-4-tony@atomide.com>
Date: Sun, 10 Jan 2021 21:05:27 +0200
From: Tony Lindgren <tony@...mide.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-omap@...r.kernel.org,
Arthur Demchenkov <spinal.by@...il.com>,
Carl Philipp Klemm <philipp@...s.xyz>,
Merlijn Wajer <merlijn@...zup.org>,
Pavel Machek <pavel@....cz>, ruleh <ruleh@....de>,
Sebastian Reichel <sre@...nel.org>
Subject: [PATCH 3/5] Input: omap4-keypad - move rest of key scanning to a separate function
Let's move rest of the key scanning code to omap4_keypad_scan_keys().
We will use omap4_keypad_scan_keys() also for implementing errata
handling to clear the stuck last key in the following patch.
Cc: Arthur Demchenkov <spinal.by@...il.com>
Cc: Carl Philipp Klemm <philipp@...s.xyz>
Cc: Merlijn Wajer <merlijn@...zup.org>
Cc: Pavel Machek <pavel@....cz>
Cc: ruleh <ruleh@....de>
Cc: Sebastian Reichel <sre@...nel.org>
Signed-off-by: Tony Lindgren <tony@...mide.com>
---
drivers/input/keyboard/omap4-keypad.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -71,6 +71,7 @@ struct omap4_keypad {
void __iomem *base;
unsigned int irq;
+ struct mutex lock; /* for key scan */
unsigned int rows;
unsigned int cols;
@@ -154,16 +155,18 @@ static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id)
return IRQ_NONE;
}
-static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
+static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, bool clear)
{
- struct omap4_keypad *keypad_data = dev_id;
struct input_dev *input_dev = keypad_data->input;
u32 low, high;
- u64 keys;
+ u64 keys = 0;
- low = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
- high = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
- keys = low | (u64)high << 32;
+ mutex_lock(&keypad_data->lock);
+ if (!clear) {
+ low = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
+ high = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
+ keys = low | (u64)high << 32;
+ }
/* Scan for key up events for lost key-up interrupts */
omap4_keypad_scan_state(keypad_data, keys, false);
@@ -175,6 +178,15 @@ static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
keypad_data->keys = keys;
+ mutex_unlock(&keypad_data->lock);
+}
+
+static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
+{
+ struct omap4_keypad *keypad_data = dev_id;
+
+ omap4_keypad_scan_keys(keypad_data, false);
+
/* clear pending interrupts */
kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
@@ -307,6 +319,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
}
keypad_data->irq = irq;
+ mutex_init(&keypad_data->lock);
error = omap4_keypad_parse_dt(dev, keypad_data);
if (error)
--
2.30.0
Powered by blists - more mailing lists