aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);