2 * Copyright (c) 1999-2001 Vojtech Pavlik
6 * Input driver event debug module - dumps all events into syslog
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #include <linux/slab.h>
32 #include <linux/module.h>
33 #include <linux/input.h>
34 #include <linux/init.h>
35 #include <linux/device.h>
37 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
38 MODULE_DESCRIPTION("Input driver event debug module");
39 MODULE_LICENSE("GPL");
41 static void evbug_event(struct input_handle
*handle
, unsigned int type
, unsigned int code
, int value
)
43 printk(KERN_DEBUG
pr_fmt("Event. Dev: %s, Type: %d, Code: %d, Value: %d\n"),
44 dev_name(&handle
->dev
->dev
), type
, code
, value
);
47 static int evbug_connect(struct input_handler
*handler
, struct input_dev
*dev
,
48 const struct input_device_id
*id
)
50 struct input_handle
*handle
;
53 handle
= kzalloc(sizeof(struct input_handle
), GFP_KERNEL
);
58 handle
->handler
= handler
;
59 handle
->name
= "evbug";
61 error
= input_register_handle(handle
);
65 error
= input_open_device(handle
);
67 goto err_unregister_handle
;
69 printk(KERN_DEBUG
pr_fmt("Connected device: %s (%s at %s)\n"),
71 dev
->name
?: "unknown",
72 dev
->phys
?: "unknown");
76 err_unregister_handle
:
77 input_unregister_handle(handle
);
83 static void evbug_disconnect(struct input_handle
*handle
)
85 printk(KERN_DEBUG
pr_fmt("Disconnected device: %s\n"),
86 dev_name(&handle
->dev
->dev
));
88 input_close_device(handle
);
89 input_unregister_handle(handle
);
93 static const struct input_device_id evbug_ids
[] = {
94 { .driver_info
= 1 }, /* Matches all devices */
95 { }, /* Terminating zero entry */
98 MODULE_DEVICE_TABLE(input
, evbug_ids
);
100 static struct input_handler evbug_handler
= {
101 .event
= evbug_event
,
102 .connect
= evbug_connect
,
103 .disconnect
= evbug_disconnect
,
105 .id_table
= evbug_ids
,
108 static int __init
evbug_init(void)
110 return input_register_handler(&evbug_handler
);
113 static void __exit
evbug_exit(void)
115 input_unregister_handler(&evbug_handler
);
118 module_init(evbug_init
);
119 module_exit(evbug_exit
);