lkml.org 
[lkml]   [2021]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5] Input: omap4-keypad - move rest of key scanning to a separate function
Date
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@gmail.com>
Cc: Carl Philipp Klemm <philipp@uvos.xyz>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: ruleh <ruleh@gmx.de>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.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
\
 
 \ /
  Last update: 2021-01-10 20:09    [W:0.191 / U:1.944 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site