From patchwork Sun Aug 26 12:57:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 1375191 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E772FDFB6E for ; Sun, 26 Aug 2012 12:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753286Ab2HZMx2 (ORCPT ); Sun, 26 Aug 2012 08:53:28 -0400 Received: from smtprelay-b22.telenor.se ([195.54.99.213]:44548 "EHLO smtprelay-b22.telenor.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753530Ab2HZMxL (ORCPT ); Sun, 26 Aug 2012 08:53:11 -0400 Received: from ipb1.telenor.se (ipb1.telenor.se [195.54.127.164]) by smtprelay-b22.telenor.se (Postfix) with ESMTP id BA7A8C951; Sun, 26 Aug 2012 14:53:09 +0200 (CEST) X-SENDER-IP: [85.230.170.20] X-LISTENER: [smtp.bredband.net] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApRZALMbOlBV5qoUPGdsb2JhbABFhRqFI7AtGQEBAQEeGQ0ngiEBBScvEwEPEAhJOQoUBgESiBG7SRSSBQObQI0P X-IronPort-AV: E=Sophos;i="4.77,830,1336341600"; d="scan'208";a="400013437" Received: from c-14aae655.710-13-64736c12.cust.bredbandsbolaget.se (HELO polaris) ([85.230.170.20]) by ipb1.telenor.se with SMTP; 26 Aug 2012 14:53:08 +0200 Received: by polaris (sSMTP sendmail emulation); Sun, 26 Aug 2012 14:58:25 +0200 From: "Henrik Rydberg" To: Dmitry Torokhov , Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Henrik Rydberg Subject: [PATCH 06/20] Input: Move autorepeat to the event-passing phase Date: Sun, 26 Aug 2012 14:57:24 +0200 Message-Id: <1345985858-445-7-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1345985858-445-1-git-send-email-rydberg@euromail.se> References: <1345985858-445-1-git-send-email-rydberg@euromail.se> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Preparing to split event filtering and event passing, move the autorepeat function to the point where the event is actually passed. Signed-off-by: Henrik Rydberg --- drivers/input/input.c | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 4d64500..a57c4a5 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -69,6 +69,22 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz) return value; } +static void input_start_autorepeat(struct input_dev *dev, int code) +{ + if (test_bit(EV_REP, dev->evbit) && + dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && + dev->timer.data) { + dev->repeat_key = code; + mod_timer(&dev->timer, + jiffies + msecs_to_jiffies(dev->rep[REP_DELAY])); + } +} + +static void input_stop_autorepeat(struct input_dev *dev) +{ + del_timer(&dev->timer); +} + /* * Pass event first through all filters and then, if event has not been * filtered out, through all open handles. This function is called with @@ -105,6 +121,15 @@ static void input_pass_event(struct input_dev *dev, } rcu_read_unlock(); + + /* trigger auto repeat for key events */ + if (type == EV_KEY && value != 2) { + if (value) + input_start_autorepeat(dev, code); + else + input_stop_autorepeat(dev); + } + } /* @@ -142,22 +167,6 @@ static void input_repeat_key(unsigned long data) spin_unlock_irqrestore(&dev->event_lock, flags); } -static void input_start_autorepeat(struct input_dev *dev, int code) -{ - if (test_bit(EV_REP, dev->evbit) && - dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && - dev->timer.data) { - dev->repeat_key = code; - mod_timer(&dev->timer, - jiffies + msecs_to_jiffies(dev->rep[REP_DELAY])); - } -} - -static void input_stop_autorepeat(struct input_dev *dev) -{ - del_timer(&dev->timer); -} - #define INPUT_IGNORE_EVENT 0 #define INPUT_PASS_TO_HANDLERS 1 #define INPUT_PASS_TO_DEVICE 2 @@ -251,11 +260,6 @@ static void input_handle_event(struct input_dev *dev, __change_bit(code, dev->key); disposition = INPUT_PASS_TO_HANDLERS; - - if (value) - input_start_autorepeat(dev, code); - else - input_stop_autorepeat(dev); } } break;