[ar71xx] create firmware image for the Ubiquiti LS-SR71 board
[openwrt/svn-archive/archive.git] / target / linux / s3c24xx / patches-2.6.24 / 1058-fix-EVIOCGRAB-semantics.patch.patch
1 From a6b37451a52ae7d30c2493b9cc14b8604e81587d Mon Sep 17 00:00:00 2001
2 From: mokopatches <mokopatches@openmoko.org>
3 Date: Sun, 13 Apr 2008 07:23:53 +0100
4 Subject: [PATCH] fix-EVIOCGRAB-semantics.patch
5
6 ---
7 drivers/input/evdev.c | 32 +++++++++++++++-----------------
8 1 files changed, 15 insertions(+), 17 deletions(-)
9
10 diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
11 index e5b4e9b..2f3d825 100644
12 --- a/drivers/input/evdev.c
13 +++ b/drivers/input/evdev.c
14 @@ -28,7 +28,7 @@ struct evdev {
15 char name[16];
16 struct input_handle handle;
17 wait_queue_head_t wait;
18 - struct evdev_client *grab;
19 + int *grab;
20 struct list_head client_list;
21 spinlock_t client_lock; /* protects client_list */
22 struct mutex mutex;
23 @@ -39,6 +39,7 @@ struct evdev_client {
24 struct input_event buffer[EVDEV_BUFFER_SIZE];
25 int head;
26 int tail;
27 + int grab;
28 spinlock_t buffer_lock; /* protects access to buffer, head and tail */
29 struct fasync_struct *fasync;
30 struct evdev *evdev;
31 @@ -79,12 +80,8 @@ static void evdev_event(struct input_handle *handle,
32
33 rcu_read_lock();
34
35 - client = rcu_dereference(evdev->grab);
36 - if (client)
37 + list_for_each_entry_rcu(client, &evdev->client_list, node)
38 evdev_pass_event(client, &event);
39 - else
40 - list_for_each_entry_rcu(client, &evdev->client_list, node)
41 - evdev_pass_event(client, &event);
42
43 rcu_read_unlock();
44
45 @@ -135,14 +132,15 @@ static int evdev_grab(struct evdev *evdev, struct evdev_client *client)
46 {
47 int error;
48
49 - if (evdev->grab)
50 + if (client->grab)
51 return -EBUSY;
52
53 - error = input_grab_device(&evdev->handle);
54 - if (error)
55 - return error;
56 -
57 - rcu_assign_pointer(evdev->grab, client);
58 + if (!evdev->grab++) {
59 + error = input_grab_device(&evdev->handle);
60 + if (error)
61 + return error;
62 + }
63 + client->grab = 1;
64 synchronize_rcu();
65
66 return 0;
67 @@ -150,12 +148,12 @@ static int evdev_grab(struct evdev *evdev, struct evdev_client *client)
68
69 static int evdev_ungrab(struct evdev *evdev, struct evdev_client *client)
70 {
71 - if (evdev->grab != client)
72 + if (!client->grab)
73 return -EINVAL;
74
75 - rcu_assign_pointer(evdev->grab, NULL);
76 - synchronize_rcu();
77 - input_release_device(&evdev->handle);
78 + if (!--evdev->grab && evdev->exist)
79 + input_release_device(&evdev->handle);
80 + client->grab = 0;
81
82 return 0;
83 }
84 @@ -230,7 +228,7 @@ static int evdev_release(struct inode *inode, struct file *file)
85 struct evdev *evdev = client->evdev;
86
87 mutex_lock(&evdev->mutex);
88 - if (evdev->grab == client)
89 + if (client->grab)
90 evdev_ungrab(evdev, client);
91 mutex_unlock(&evdev->mutex);
92
93 --
94 1.5.6.5
95