linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: only send a syn event when needed in input_dev_release_keys
@ 2015-08-26  7:38 Hans Holmberg
  2015-08-26 20:06 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Holmberg @ 2015-08-26  7:38 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: ting.li, linux-input, linux-kernel, Hans Holmberg

A SYN event is reported in input_release_keys even if no keys are
released. Stop doing this as the superfluous event can prevent autosleep
if a user has opened a device with EPOLLWAKEUP enabled.

Based on a patch developed by Ting Li <ting.li@intel.com>.

Signed-off-by: Hans Holmberg <hans.holmberg@intel.com>
---
 drivers/input/input.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 78d2499..c748805 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -675,12 +675,18 @@ EXPORT_SYMBOL(input_close_device);
 static void input_dev_release_keys(struct input_dev *dev)
 {
 	int code;
+	bool key_released = false;
 
 	if (is_event_supported(EV_KEY, dev->evbit, EV_MAX)) {
-		for_each_set_bit(code, dev->key, KEY_CNT)
+		for_each_set_bit(code, dev->key, KEY_CNT) {
 			input_pass_event(dev, EV_KEY, code, 0);
-		memset(dev->key, 0, sizeof(dev->key));
-		input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
+			key_released = true;
+		}
+
+		if (key_released) {
+			memset(dev->key, 0, sizeof(dev->key));
+			input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
+		}
 	}
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-27  8:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-26  7:38 [PATCH] Input: only send a syn event when needed in input_dev_release_keys Hans Holmberg
2015-08-26 20:06 ` Dmitry Torokhov
2015-08-27  8:38   ` Holmberg, Hans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).