From: Arve Hjønnevåg Date: Tue, 24 Jan 2012 01:15:45 +0000 (-0800) Subject: Input: evdev - Don't hold wakelock when no data is available to user-space X-Git-Tag: firefly_0821_release~7613^2~182 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7cc846069a8a9116d8c81526c459070eed0e3477;p=firefly-linux-kernel-4.4.55.git Input: evdev - Don't hold wakelock when no data is available to user-space 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 --- diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 5c5f9db28075..23f5545367b2 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -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); }