From 4121a37166478946910f8f27ae13d4531cd44a74 Mon Sep 17 00:00:00 2001
From: Sedat Dilek <sedat.dilek@gmail.com>
Date: Thu, 13 Sep 2012 06:59:37 +0200
Subject: [PATCH 3/3] Revert "Input: Move autorepeat to the event-passing
 phase"

This reverts commit 8fb3be46299f0d5e9f60aa8cd811a1dbfc81d69e.
---
 drivers/input/input.c |   46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 2e96c3f..54f83d7 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -69,22 +69,6 @@ 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
@@ -121,15 +105,6 @@ 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);
-	}
-
 }
 
 /*
@@ -167,6 +142,22 @@ 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
@@ -260,6 +251,11 @@ 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;
-- 
1.7.9.5

