linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Holmberg <hans.holmberg@intel.com>
To: dmitry.torokhov@gmail.com
Cc: ting.li@intel.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Hans Holmberg <hans.holmberg@intel.com>
Subject: [PATCH] Input: only send a syn event when needed in input_dev_release_keys
Date: Wed, 26 Aug 2015 09:38:32 +0200	[thread overview]
Message-ID: <1440574712-25629-1-git-send-email-hans.holmberg@intel.com> (raw)

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


             reply	other threads:[~2015-08-26  7:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-26  7:38 Hans Holmberg [this message]
2015-08-26 20:06 ` [PATCH] Input: only send a syn event when needed in input_dev_release_keys Dmitry Torokhov
2015-08-27  8:38   ` Holmberg, Hans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440574712-25629-1-git-send-email-hans.holmberg@intel.com \
    --to=hans.holmberg@intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ting.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).