Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
494 | giacomo | 1 | /* |
2 | * $Id: evbug.c,v 1.1 2004-03-08 18:47:36 giacomo Exp $ |
||
3 | * |
||
4 | * Copyright (c) 1999-2001 Vojtech Pavlik |
||
5 | */ |
||
6 | |||
7 | /* |
||
8 | * Input driver event debug module - dumps all events into syslog |
||
9 | */ |
||
10 | |||
11 | /* |
||
12 | * This program is free software; you can redistribute it and/or modify |
||
13 | * it under the terms of the GNU General Public License as published by |
||
14 | * the Free Software Foundation; either version 2 of the License, or |
||
15 | * (at your option) any later version. |
||
16 | * |
||
17 | * This program is distributed in the hope that it will be useful, |
||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
20 | * GNU General Public License for more details. |
||
21 | * |
||
22 | * You should have received a copy of the GNU General Public License |
||
23 | * along with this program; if not, write to the Free Software |
||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
25 | * |
||
26 | * Should you need to contact me, the author, you can do so either by |
||
27 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
||
28 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
||
29 | */ |
||
30 | |||
31 | #include <linuxcomp.h> |
||
32 | |||
33 | #include <linux/slab.h> |
||
34 | #include <linux/module.h> |
||
35 | #include <linux/input.h> |
||
36 | #include <linux/init.h> |
||
37 | #include <linux/device.h> |
||
38 | |||
39 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
||
40 | MODULE_DESCRIPTION("Input driver event debug module"); |
||
41 | MODULE_LICENSE("GPL"); |
||
42 | |||
43 | static char evbug_name[] = "evbug"; |
||
44 | |||
45 | static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) |
||
46 | { |
||
47 | printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value); |
||
48 | } |
||
49 | |||
50 | static struct input_handle *evbug_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) |
||
51 | { |
||
52 | struct input_handle *handle; |
||
53 | |||
54 | if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) |
||
55 | return NULL; |
||
56 | memset(handle, 0, sizeof(struct input_handle)); |
||
57 | |||
58 | handle->dev = dev; |
||
59 | handle->handler = handler; |
||
60 | handle->name = evbug_name; |
||
61 | |||
62 | input_open_device(handle); |
||
63 | |||
64 | printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); |
||
65 | |||
66 | return handle; |
||
67 | } |
||
68 | |||
69 | static void evbug_disconnect(struct input_handle *handle) |
||
70 | { |
||
71 | printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys); |
||
72 | |||
73 | input_close_device(handle); |
||
74 | |||
75 | kfree(handle); |
||
76 | } |
||
77 | |||
78 | static struct input_device_id evbug_ids[] = { |
||
79 | { .driver_info = 1 }, /* Matches all devices */ |
||
80 | { }, /* Terminating zero entry */ |
||
81 | }; |
||
82 | |||
83 | MODULE_DEVICE_TABLE(input, evbug_ids); |
||
84 | |||
85 | static struct input_handler evbug_handler = { |
||
86 | .event = evbug_event, |
||
87 | .connect = evbug_connect, |
||
88 | .disconnect = evbug_disconnect, |
||
89 | .name = "evbug", |
||
90 | .id_table = evbug_ids, |
||
91 | }; |
||
92 | |||
93 | int __init evbug_init(void) |
||
94 | { |
||
95 | input_register_handler(&evbug_handler); |
||
96 | return 0; |
||
97 | } |
||
98 | |||
99 | void __exit evbug_exit(void) |
||
100 | { |
||
101 | input_unregister_handler(&evbug_handler); |
||
102 | } |
||
103 | |||
104 | module_init(evbug_init); |
||
105 | module_exit(evbug_exit); |