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