f5dae5a
From d561f0543506bc12e7b3355efddb0bfd7ca83c74 Mon Sep 17 00:00:00 2001
f5dae5a
From: Hans de Goede <hdegoede@redhat.com>
f5dae5a
Date: Sat, 22 Jul 2017 13:17:36 +0200
f5dae5a
Subject: [PATCH 2/2] Input: soc_button_array - Suppress power button presses
f5dae5a
 during suspend
f5dae5a
f5dae5a
If the power-button is pressed to wakeup the laptop/tablet from suspend
f5dae5a
and we report a KEY_POWER event to userspace when woken up this will cause
f5dae5a
userspace to immediately suspend the system again which is undesirable.
f5dae5a
f5dae5a
This commit sets the new no_wakeup_events flag in the gpio_keys_button
f5dae5a
struct for the power-button suppressing the undesirable KEY_POWER input
f5dae5a
events on wake-up.
f5dae5a
f5dae5a
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
f5dae5a
---
f5dae5a
Changes in v2:
f5dae5a
-New patch in v2 of this patch-set
f5dae5a
---
f5dae5a
 drivers/input/misc/soc_button_array.c | 5 ++++-
f5dae5a
 1 file changed, 4 insertions(+), 1 deletion(-)
f5dae5a
f5dae5a
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
f5dae5a
index f600f3a7a3c6..27b99831cb97 100644
f5dae5a
--- a/drivers/input/misc/soc_button_array.c
f5dae5a
+++ b/drivers/input/misc/soc_button_array.c
f5dae5a
@@ -27,6 +27,7 @@ struct soc_button_info {
f5dae5a
 	unsigned int event_code;
f5dae5a
 	bool autorepeat;
f5dae5a
 	bool wakeup;
f5dae5a
+	bool no_wakeup_events;
f5dae5a
 };
f5dae5a
 
f5dae5a
 /*
f5dae5a
@@ -100,6 +101,7 @@ soc_button_device_create(struct platform_device *pdev,
f5dae5a
 		gpio_keys[n_buttons].active_low = 1;
f5dae5a
 		gpio_keys[n_buttons].desc = info->name;
f5dae5a
 		gpio_keys[n_buttons].wakeup = info->wakeup;
f5dae5a
+		gpio_keys[n_buttons].no_wakeup_events = info->no_wakeup_events;
f5dae5a
 		/* These devices often use cheap buttons, use 50 ms debounce */
f5dae5a
 		gpio_keys[n_buttons].debounce_interval = 50;
f5dae5a
 		n_buttons++;
f5dae5a
@@ -185,6 +187,7 @@ static int soc_button_parse_btn_desc(struct device *dev,
f5dae5a
 		info->name = "power";
f5dae5a
 		info->event_code = KEY_POWER;
f5dae5a
 		info->wakeup = true;
f5dae5a
+		info->no_wakeup_events = true;
f5dae5a
 	} else if (upage == 0x07 && usage == 0xe3) {
f5dae5a
 		info->name = "home";
f5dae5a
 		info->event_code = KEY_LEFTMETA;
f5dae5a
@@ -369,7 +372,7 @@ static int soc_button_probe(struct platform_device *pdev)
f5dae5a
  * Platforms"
f5dae5a
  */
f5dae5a
 static struct soc_button_info soc_button_PNP0C40[] = {
f5dae5a
-	{ "power", 0, EV_KEY, KEY_POWER, false, true },
f5dae5a
+	{ "power", 0, EV_KEY, KEY_POWER, false, true, true },
f5dae5a
 	{ "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
f5dae5a
 	{ "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
f5dae5a
 	{ "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false },
f5dae5a
-- 
f5dae5a
2.13.4
f5dae5a