0087-Input-Hold-wake-lock-while-event-queue-is-not-empty.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 0d1077627288e51b5604f270eae6cf9f5ccd3871 Mon Sep 17 00:00:00 2001
  2. From: =?utf-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <[email protected]>
  3. Date: Fri, 17 Oct 2008 15:20:55 -0700
  4. Subject: [PATCH 087/134] Input: Hold wake lock while event queue is not empty.
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=utf-8
  7. Content-Transfer-Encoding: 8bit
  8. Allows userspace code to process input events while
  9. the device appears to be asleep.
  10. Signed-off-by: Arve Hjønnevåg <[email protected]>
  11. ---
  12. drivers/input/evdev.c | 7 +++++++
  13. 1 files changed, 7 insertions(+), 0 deletions(-)
  14. --- a/drivers/input/evdev.c
  15. +++ b/drivers/input/evdev.c
  16. @@ -19,6 +19,7 @@
  17. #include <linux/input.h>
  18. #include <linux/major.h>
  19. #include <linux/device.h>
  20. +#include <linux/wakelock.h>
  21. #include "input-compat.h"
  22. struct evdev {
  23. @@ -43,6 +44,7 @@ struct evdev_client {
  24. struct fasync_struct *fasync;
  25. struct evdev *evdev;
  26. struct list_head node;
  27. + struct wake_lock wake_lock;
  28. };
  29. static struct evdev *evdev_table[EVDEV_MINORS];
  30. @@ -55,6 +57,7 @@ static void evdev_pass_event(struct evde
  31. * Interrupts are disabled, just acquire the lock
  32. */
  33. spin_lock(&client->buffer_lock);
  34. + wake_lock_timeout(&client->wake_lock, 5 * HZ);
  35. client->buffer[client->head++] = *event;
  36. client->head &= EVDEV_BUFFER_SIZE - 1;
  37. spin_unlock(&client->buffer_lock);
  38. @@ -233,6 +236,7 @@ static int evdev_release(struct inode *i
  39. mutex_unlock(&evdev->mutex);
  40. evdev_detach_client(evdev, client);
  41. + wake_lock_destroy(&client->wake_lock);
  42. kfree(client);
  43. evdev_close_device(evdev);
  44. @@ -269,6 +273,7 @@ static int evdev_open(struct inode *inod
  45. }
  46. spin_lock_init(&client->buffer_lock);
  47. + wake_lock_init(&client->wake_lock, WAKE_LOCK_SUSPEND, "evdev");
  48. client->evdev = evdev;
  49. evdev_attach_client(evdev, client);
  50. @@ -332,6 +337,8 @@ static int evdev_fetch_next_event(struct
  51. if (have_event) {
  52. *event = client->buffer[client->tail++];
  53. client->tail &= EVDEV_BUFFER_SIZE - 1;
  54. + if (client->head == client->tail)
  55. + wake_unlock(&client->wake_lock);
  56. }
  57. spin_unlock_irq(&client->buffer_lock);