aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/keyboard.c36
-rw-r--r--drivers/input/evdev.c6
-rw-r--r--drivers/input/input.c27
-rw-r--r--include/linux/input.h1
4 files changed, 49 insertions, 21 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 38de44b87506..1e946f585673 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -223,13 +223,13 @@ static void kd_nosound(unsigned long ignored)
223{ 223{
224 struct list_head *node; 224 struct list_head *node;
225 225
226 list_for_each(node,&kbd_handler.h_list) { 226 list_for_each(node, &kbd_handler.h_list) {
227 struct input_handle *handle = to_handle_h(node); 227 struct input_handle *handle = to_handle_h(node);
228 if (test_bit(EV_SND, handle->dev->evbit)) { 228 if (test_bit(EV_SND, handle->dev->evbit)) {
229 if (test_bit(SND_TONE, handle->dev->sndbit)) 229 if (test_bit(SND_TONE, handle->dev->sndbit))
230 input_event(handle->dev, EV_SND, SND_TONE, 0); 230 input_inject_event(handle, EV_SND, SND_TONE, 0);
231 if (test_bit(SND_BELL, handle->dev->sndbit)) 231 if (test_bit(SND_BELL, handle->dev->sndbit))
232 input_event(handle->dev, EV_SND, SND_BELL, 0); 232 input_inject_event(handle, EV_SND, SND_BELL, 0);
233 } 233 }
234 } 234 }
235} 235}
@@ -247,11 +247,11 @@ void kd_mksound(unsigned int hz, unsigned int ticks)
247 struct input_handle *handle = to_handle_h(node); 247 struct input_handle *handle = to_handle_h(node);
248 if (test_bit(EV_SND, handle->dev->evbit)) { 248 if (test_bit(EV_SND, handle->dev->evbit)) {
249 if (test_bit(SND_TONE, handle->dev->sndbit)) { 249 if (test_bit(SND_TONE, handle->dev->sndbit)) {
250 input_event(handle->dev, EV_SND, SND_TONE, hz); 250 input_inject_event(handle, EV_SND, SND_TONE, hz);
251 break; 251 break;
252 } 252 }
253 if (test_bit(SND_BELL, handle->dev->sndbit)) { 253 if (test_bit(SND_BELL, handle->dev->sndbit)) {
254 input_event(handle->dev, EV_SND, SND_BELL, 1); 254 input_inject_event(handle, EV_SND, SND_BELL, 1);
255 break; 255 break;
256 } 256 }
257 } 257 }
@@ -272,15 +272,15 @@ int kbd_rate(struct kbd_repeat *rep)
272 unsigned int d = 0; 272 unsigned int d = 0;
273 unsigned int p = 0; 273 unsigned int p = 0;
274 274
275 list_for_each(node,&kbd_handler.h_list) { 275 list_for_each(node, &kbd_handler.h_list) {
276 struct input_handle *handle = to_handle_h(node); 276 struct input_handle *handle = to_handle_h(node);
277 struct input_dev *dev = handle->dev; 277 struct input_dev *dev = handle->dev;
278 278
279 if (test_bit(EV_REP, dev->evbit)) { 279 if (test_bit(EV_REP, dev->evbit)) {
280 if (rep->delay > 0) 280 if (rep->delay > 0)
281 input_event(dev, EV_REP, REP_DELAY, rep->delay); 281 input_inject_event(handle, EV_REP, REP_DELAY, rep->delay);
282 if (rep->period > 0) 282 if (rep->period > 0)
283 input_event(dev, EV_REP, REP_PERIOD, rep->period); 283 input_inject_event(handle, EV_REP, REP_PERIOD, rep->period);
284 d = dev->rep[REP_DELAY]; 284 d = dev->rep[REP_DELAY];
285 p = dev->rep[REP_PERIOD]; 285 p = dev->rep[REP_PERIOD];
286 } 286 }
@@ -988,7 +988,7 @@ static inline unsigned char getleds(void)
988 * interrupt routines for this thing allows us to easily mask 988 * interrupt routines for this thing allows us to easily mask
989 * this when we don't want any of the above to happen. 989 * this when we don't want any of the above to happen.
990 * This allows for easy and efficient race-condition prevention 990 * This allows for easy and efficient race-condition prevention
991 * for kbd_start => input_event(dev, EV_LED, ...) => ... 991 * for kbd_start => input_inject_event(dev, EV_LED, ...) => ...
992 */ 992 */
993 993
994static void kbd_bh(unsigned long dummy) 994static void kbd_bh(unsigned long dummy)
@@ -998,11 +998,11 @@ static void kbd_bh(unsigned long dummy)
998 998
999 if (leds != ledstate) { 999 if (leds != ledstate) {
1000 list_for_each(node, &kbd_handler.h_list) { 1000 list_for_each(node, &kbd_handler.h_list) {
1001 struct input_handle * handle = to_handle_h(node); 1001 struct input_handle *handle = to_handle_h(node);
1002 input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); 1002 input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
1003 input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); 1003 input_inject_event(handle, EV_LED, LED_NUML, !!(leds & 0x02));
1004 input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04)); 1004 input_inject_event(handle, EV_LED, LED_CAPSL, !!(leds & 0x04));
1005 input_sync(handle->dev); 1005 input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
1006 } 1006 }
1007 } 1007 }
1008 1008
@@ -1310,10 +1310,10 @@ static void kbd_start(struct input_handle *handle)
1310 1310
1311 tasklet_disable(&keyboard_tasklet); 1311 tasklet_disable(&keyboard_tasklet);
1312 if (leds != 0xff) { 1312 if (leds != 0xff) {
1313 input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); 1313 input_inject_event(handle, EV_LED, LED_SCROLLL, !!(leds & 0x01));
1314 input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); 1314 input_inject_event(handle, EV_LED, LED_NUML, !!(leds & 0x02));
1315 input_event(handle->dev, EV_LED, LED_CAPSL, !!(leds & 0x04)); 1315 input_inject_event(handle, EV_LED, LED_CAPSL, !!(leds & 0x04));
1316 input_sync(handle->dev); 1316 input_inject_event(handle, EV_SYN, SYN_REPORT, 0);
1317 } 1317 }
1318 tasklet_enable(&keyboard_tasklet); 1318 tasklet_enable(&keyboard_tasklet);
1319} 1319}
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 2426a5d8537d..4bf48188cc91 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -256,7 +256,7 @@ static ssize_t evdev_write(struct file * file, const char __user * buffer, size_
256 256
257 if (evdev_event_from_user(buffer + retval, &event)) 257 if (evdev_event_from_user(buffer + retval, &event))
258 return -EFAULT; 258 return -EFAULT;
259 input_event(list->evdev->handle.dev, event.type, event.code, event.value); 259 input_inject_event(&list->evdev->handle, event.type, event.code, event.value);
260 retval += evdev_event_size(); 260 retval += evdev_event_size();
261 } 261 }
262 262
@@ -424,8 +424,8 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
424 if (get_user(v, ip + 1)) 424 if (get_user(v, ip + 1))
425 return -EFAULT; 425 return -EFAULT;
426 426
427 input_event(dev, EV_REP, REP_DELAY, u); 427 input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u);
428 input_event(dev, EV_REP, REP_PERIOD, v); 428 input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v);
429 429
430 return 0; 430 return 0;
431 431
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7aeebb9071c2..e20913942927 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -35,6 +35,16 @@ static LIST_HEAD(input_handler_list);
35 35
36static struct input_handler *input_table[8]; 36static struct input_handler *input_table[8];
37 37
38/**
39 * input_event() - report new input event
40 * @handle: device that generated the event
41 * @type: type of the event
42 * @code: event code
43 * @value: value of the event
44 *
45 * This function should be used by drivers implementing various input devices
46 * See also input_inject_event()
47 */
38void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 48void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
39{ 49{
40 struct input_handle *handle; 50 struct input_handle *handle;
@@ -183,6 +193,23 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
183} 193}
184EXPORT_SYMBOL(input_event); 194EXPORT_SYMBOL(input_event);
185 195
196/**
197 * input_inject_event() - send input event from input handler
198 * @handle: input handle to send event through
199 * @type: type of the event
200 * @code: event code
201 * @value: value of the event
202 *
203 * Similar to input_event() but will ignore event if device is "grabbed" and handle
204 * injecting event is not the one that owns the device.
205 */
206void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
207{
208 if (!handle->dev->grab || handle->dev->grab == handle)
209 input_event(handle->dev, type, code, value);
210}
211EXPORT_SYMBOL(input_inject_event);
212
186static void input_repeat_key(unsigned long data) 213static void input_repeat_key(unsigned long data)
187{ 214{
188 struct input_dev *dev = (void *) data; 215 struct input_dev *dev = (void *) data;
diff --git a/include/linux/input.h b/include/linux/input.h
index 55e628e8805b..b3253ab72ff7 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1053,6 +1053,7 @@ void input_close_device(struct input_handle *);
1053int input_flush_device(struct input_handle* handle, struct file* file); 1053int input_flush_device(struct input_handle* handle, struct file* file);
1054 1054
1055void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 1055void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
1056void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
1056 1057
1057static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) 1058static inline void input_report_key(struct input_dev *dev, unsigned int code, int value)
1058{ 1059{