OSDN Git Service

Input: evdev - Don't hold wakelock when no data is available to user-space
authorArve Hjønnevåg <arve@android.com>
Tue, 24 Jan 2012 01:15:45 +0000 (17:15 -0800)
committerArve Hjønnevåg <arve@android.com>
Wed, 1 Feb 2012 00:00:26 +0000 (16:00 -0800)
If there is no SYN_REPORT event in the buffer the buffer data is invisible
to user-space. The wakelock should not be held in this case.

Change-Id: Idae890ff0da8eb46a2cfce61a95b3a97252551ad
Signed-off-by: Arve Hjønnevåg <arve@android.com>
drivers/input/evdev.c

index 5c5f9db..23f5545 100644 (file)
@@ -62,7 +62,6 @@ static void evdev_pass_event(struct evdev_client *client,
        /* Interrupts are disabled, just acquire the lock. */
        spin_lock(&client->buffer_lock);
 
-       wake_lock_timeout(&client->wake_lock, 5 * HZ);
        client->buffer[client->head++] = *event;
        client->head &= client->bufsize - 1;
 
@@ -79,10 +78,12 @@ static void evdev_pass_event(struct evdev_client *client,
                client->buffer[client->tail].value = 0;
 
                client->packet_head = client->tail;
+               wake_unlock(&client->wake_lock);
        }
 
        if (event->type == EV_SYN && event->code == SYN_REPORT) {
                client->packet_head = client->head;
+               wake_lock_timeout(&client->wake_lock, 5 * HZ);
                kill_fasync(&client->fasync, SIGIO, POLL_IN);
        }
 
@@ -385,7 +386,7 @@ static int evdev_fetch_next_event(struct evdev_client *client,
        if (have_event) {
                *event = client->buffer[client->tail++];
                client->tail &= client->bufsize - 1;
-               if (client->head == client->tail)
+               if (client->packet_head == client->tail)
                        wake_unlock(&client->wake_lock);
        }