input: matrix-keypad: Move to threaded irq handling
This change moves IRQ handling to threaded IRQ and
removes all instances of spinlock. This is needed for
those gpio IRQ's which are over slow bus (such as I2C)
Change-Id: I943df269c65296fff9f239830d56a625eb2fb71d
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index c7aa2ce..dc1feaa 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -2,6 +2,7 @@
* GPIO driven matrix keyboard driver
*
* Copyright (c) 2008 Marek Vasut <marek.vasut@gmail.com>
+ * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* Based on corgikbd.c
*
@@ -34,7 +35,7 @@
uint32_t last_key_state[MATRIX_MAX_COLS];
struct delayed_work work;
- spinlock_t lock;
+ struct mutex lock;
bool scan_pending;
bool stopped;
bool gpio_all_disabled;
@@ -162,19 +163,17 @@
activate_all_cols(pdata, true);
- /* Enable IRQs again */
- spin_lock_irq(&keypad->lock);
+ mutex_lock(&keypad->lock);
keypad->scan_pending = false;
enable_row_irqs(keypad);
- spin_unlock_irq(&keypad->lock);
+ mutex_unlock(&keypad->lock);
}
static irqreturn_t matrix_keypad_interrupt(int irq, void *id)
{
struct matrix_keypad *keypad = id;
- unsigned long flags;
- spin_lock_irqsave(&keypad->lock, flags);
+ mutex_lock(&keypad->lock);
/*
* See if another IRQ beaten us to it and scheduled the
@@ -190,7 +189,7 @@
msecs_to_jiffies(keypad->pdata->debounce_ms));
out:
- spin_unlock_irqrestore(&keypad->lock, flags);
+ mutex_unlock(&keypad->lock);
return IRQ_HANDLED;
}
@@ -341,10 +340,11 @@
}
} else {
for (i = 0; i < pdata->num_row_gpios; i++) {
- err = request_any_context_irq(
+ err = request_threaded_irq(
gpio_to_irq(pdata->row_gpios[i]),
+ NULL,
matrix_keypad_interrupt,
- IRQF_DISABLED |
+ IRQF_DISABLED | IRQF_ONESHOT |
IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING,
"matrix-keypad", keypad);
@@ -417,7 +417,7 @@
keypad->row_shift = row_shift;
keypad->stopped = true;
INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan);
- spin_lock_init(&keypad->lock);
+ mutex_init(&keypad->lock);
input_dev->name = pdev->name;
input_dev->id.bustype = BUS_HOST;
@@ -479,6 +479,7 @@
for (i = 0; i < pdata->num_col_gpios; i++)
gpio_free(pdata->col_gpios[i]);
+ mutex_destroy(&keypad->lock);
input_unregister_device(keypad->input_dev);
platform_set_drvdata(pdev, NULL);
kfree(keypad->keycodes);