diff mbox

[v3,03/20] Input: Make sure we follow all EV_KEY events

Message ID 1346528835-363-4-git-send-email-rydberg@euromail.se (mailing list archive)
State New, archived
Headers show

Commit Message

Henrik Rydberg Sept. 1, 2012, 7:46 p.m. UTC
For some EV_KEY types, sending a larger-than-one value causes the
input state to oscillate. This patch makes sure this cannot happen,
clearing up the autorepeat bypass logic in the process.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
 drivers/input/input.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Comments

Dmitry Torokhov Sept. 13, 2012, 5:19 a.m. UTC | #1
On Sat, Sep 01, 2012 at 09:46:58PM +0200, Henrik Rydberg wrote:
> For some EV_KEY types, sending a larger-than-one value causes the
> input state to oscillate. This patch makes sure this cannot happen,
> clearing up the autorepeat bypass logic in the process.
> 
> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/input/input.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 8ebf116..4d64500 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -239,24 +239,30 @@ static void input_handle_event(struct input_dev *dev,
>  		break;
>  
>  	case EV_KEY:
> -		if (is_event_supported(code, dev->keybit, KEY_MAX) &&
> -		    !!test_bit(code, dev->key) != value) {
> +		if (is_event_supported(code, dev->keybit, KEY_MAX)) {
> +
> +			/* auto-repeat bypasses state updates */
> +			if (value == 2) {
> +				disposition = INPUT_PASS_TO_HANDLERS;
> +				break;
> +			}
> +
> +			if (!!test_bit(code, dev->key) != !!value) {
>  
> -			if (value != 2) {
>  				__change_bit(code, dev->key);
> +				disposition = INPUT_PASS_TO_HANDLERS;
> +
>  				if (value)
>  					input_start_autorepeat(dev, code);
>  				else
>  					input_stop_autorepeat(dev);
>  			}
> -
> -			disposition = INPUT_PASS_TO_HANDLERS;
>  		}
>  		break;
>  
>  	case EV_SW:
>  		if (is_event_supported(code, dev->swbit, SW_MAX) &&
> -		    !!test_bit(code, dev->sw) != value) {
> +		    !!test_bit(code, dev->sw) != !!value) {
>  
>  			__change_bit(code, dev->sw);
>  			disposition = INPUT_PASS_TO_HANDLERS;
> @@ -283,7 +289,7 @@ static void input_handle_event(struct input_dev *dev,
>  
>  	case EV_LED:
>  		if (is_event_supported(code, dev->ledbit, LED_MAX) &&
> -		    !!test_bit(code, dev->led) != value) {
> +		    !!test_bit(code, dev->led) != !!value) {
>  
>  			__change_bit(code, dev->led);
>  			disposition = INPUT_PASS_TO_ALL;
> -- 
> 1.7.12
>
diff mbox

Patch

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 8ebf116..4d64500 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -239,24 +239,30 @@  static void input_handle_event(struct input_dev *dev,
 		break;
 
 	case EV_KEY:
-		if (is_event_supported(code, dev->keybit, KEY_MAX) &&
-		    !!test_bit(code, dev->key) != value) {
+		if (is_event_supported(code, dev->keybit, KEY_MAX)) {
+
+			/* auto-repeat bypasses state updates */
+			if (value == 2) {
+				disposition = INPUT_PASS_TO_HANDLERS;
+				break;
+			}
+
+			if (!!test_bit(code, dev->key) != !!value) {
 
-			if (value != 2) {
 				__change_bit(code, dev->key);
+				disposition = INPUT_PASS_TO_HANDLERS;
+
 				if (value)
 					input_start_autorepeat(dev, code);
 				else
 					input_stop_autorepeat(dev);
 			}
-
-			disposition = INPUT_PASS_TO_HANDLERS;
 		}
 		break;
 
 	case EV_SW:
 		if (is_event_supported(code, dev->swbit, SW_MAX) &&
-		    !!test_bit(code, dev->sw) != value) {
+		    !!test_bit(code, dev->sw) != !!value) {
 
 			__change_bit(code, dev->sw);
 			disposition = INPUT_PASS_TO_HANDLERS;
@@ -283,7 +289,7 @@  static void input_handle_event(struct input_dev *dev,
 
 	case EV_LED:
 		if (is_event_supported(code, dev->ledbit, LED_MAX) &&
-		    !!test_bit(code, dev->led) != value) {
+		    !!test_bit(code, dev->led) != !!value) {
 
 			__change_bit(code, dev->led);
 			disposition = INPUT_PASS_TO_ALL;