diff options
author | Anshul Garg <aksgarg1989@gmail.com> | 2015-01-08 16:47:37 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-01-08 16:53:34 -0500 |
commit | 2c50ad340c246b7f58f2d916006afe2d85d60698 (patch) | |
tree | b810cc1e06366b50eaba8d5ef71f71758b99c87a | |
parent | 5ab17145708e6ad4582b0372fb3a171be3379293 (diff) |
Input: do not try to filter out events if handler is not a filter
If given input handler is not a filter there is no point is iterating list
of events in a packet to see if some of them need to be filtered out.
Signed-off-by: Anshul Garg <anshul.g@samsung.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/input.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 26199abee36c..cc357f1516a7 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -100,23 +100,24 @@ static unsigned int input_to_handler(struct input_handle *handle, | |||
100 | struct input_value *end = vals; | 100 | struct input_value *end = vals; |
101 | struct input_value *v; | 101 | struct input_value *v; |
102 | 102 | ||
103 | for (v = vals; v != vals + count; v++) { | 103 | if (handler->filter) { |
104 | if (handler->filter && | 104 | for (v = vals; v != vals + count; v++) { |
105 | handler->filter(handle, v->type, v->code, v->value)) | 105 | if (handler->filter(handle, v->type, v->code, v->value)) |
106 | continue; | 106 | continue; |
107 | if (end != v) | 107 | if (end != v) |
108 | *end = *v; | 108 | *end = *v; |
109 | end++; | 109 | end++; |
110 | } | ||
111 | count = end - vals; | ||
110 | } | 112 | } |
111 | 113 | ||
112 | count = end - vals; | ||
113 | if (!count) | 114 | if (!count) |
114 | return 0; | 115 | return 0; |
115 | 116 | ||
116 | if (handler->events) | 117 | if (handler->events) |
117 | handler->events(handle, vals, count); | 118 | handler->events(handle, vals, count); |
118 | else if (handler->event) | 119 | else if (handler->event) |
119 | for (v = vals; v != end; v++) | 120 | for (v = vals; v != vals + count; v++) |
120 | handler->event(handle, v->type, v->code, v->value); | 121 | handler->event(handle, v->type, v->code, v->value); |
121 | 122 | ||
122 | return count; | 123 | return count; |
@@ -143,8 +144,11 @@ static void input_pass_values(struct input_dev *dev, | |||
143 | count = input_to_handler(handle, vals, count); | 144 | count = input_to_handler(handle, vals, count); |
144 | } else { | 145 | } else { |
145 | list_for_each_entry_rcu(handle, &dev->h_list, d_node) | 146 | list_for_each_entry_rcu(handle, &dev->h_list, d_node) |
146 | if (handle->open) | 147 | if (handle->open) { |
147 | count = input_to_handler(handle, vals, count); | 148 | count = input_to_handler(handle, vals, count); |
149 | if (!count) | ||
150 | break; | ||
151 | } | ||
148 | } | 152 | } |
149 | 153 | ||
150 | rcu_read_unlock(); | 154 | rcu_read_unlock(); |