aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Lo <josephl@nvidia.com>2017-07-02 16:38:31 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2017-07-09 17:43:27 -0400
commit0f107573da417c7f5c6d3a0160ebacc3adb019c4 (patch)
tree1ac0904f13444da56c46d2b91df77bbbe183b81d
parent49aac8204da5f344f52ed9b3eb8736ca7a60c4a8 (diff)
Input: gpio_keys - handle the missing key press event in resume phase
The GPIO key press event might be missed in the resume phase, if the key had been released before the system had been resumed to the stage that it could capture the press event. So we simulate the wakeup key press event in case the key had been released by the time we got interrupt handler to run. Signed-off-by: Joseph Lo <josephl@nvidia.com> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/keyboard/gpio_keys.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index da3d362f21b1..a047b9af8369 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -48,6 +48,7 @@ struct gpio_button_data {
48 spinlock_t lock; 48 spinlock_t lock;
49 bool disabled; 49 bool disabled;
50 bool key_pressed; 50 bool key_pressed;
51 bool suspended;
51}; 52};
52 53
53struct gpio_keys_drvdata { 54struct gpio_keys_drvdata {
@@ -396,8 +397,20 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
396 397
397 BUG_ON(irq != bdata->irq); 398 BUG_ON(irq != bdata->irq);
398 399
399 if (bdata->button->wakeup) 400 if (bdata->button->wakeup) {
401 const struct gpio_keys_button *button = bdata->button;
402
400 pm_stay_awake(bdata->input->dev.parent); 403 pm_stay_awake(bdata->input->dev.parent);
404 if (bdata->suspended &&
405 (button->type == 0 || button->type == EV_KEY)) {
406 /*
407 * Simulate wakeup key press in case the key has
408 * already released by the time we got interrupt
409 * handler to run.
410 */
411 input_report_key(bdata->input, button->code, 1);
412 }
413 }
401 414
402 mod_delayed_work(system_wq, 415 mod_delayed_work(system_wq,
403 &bdata->work, 416 &bdata->work,
@@ -855,6 +868,7 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
855 struct gpio_button_data *bdata = &ddata->data[i]; 868 struct gpio_button_data *bdata = &ddata->data[i];
856 if (bdata->button->wakeup) 869 if (bdata->button->wakeup)
857 enable_irq_wake(bdata->irq); 870 enable_irq_wake(bdata->irq);
871 bdata->suspended = true;
858 } 872 }
859 } else { 873 } else {
860 mutex_lock(&input->mutex); 874 mutex_lock(&input->mutex);
@@ -878,6 +892,7 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
878 struct gpio_button_data *bdata = &ddata->data[i]; 892 struct gpio_button_data *bdata = &ddata->data[i];
879 if (bdata->button->wakeup) 893 if (bdata->button->wakeup)
880 disable_irq_wake(bdata->irq); 894 disable_irq_wake(bdata->irq);
895 bdata->suspended = false;
881 } 896 }
882 } else { 897 } else {
883 mutex_lock(&input->mutex); 898 mutex_lock(&input->mutex);