Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
519 mauro 1
/*
2
 * $Id: evbug.c,v 1.1 2004-03-22 14:48:14 mauro 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
 
27
#include <linuxcomp.h>
28
 
29
#include <linux/slab.h>
30
#include <linux/module.h>
31
#include <linux/input.h>
32
#include <linux/init.h>
33
#include <linux/device.h>
34
 
35
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
36
MODULE_DESCRIPTION("Input driver event debug module");
37
MODULE_LICENSE("GPL");
38
 
39
static char evbug_name[] = "evbug";
40
 
41
static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
42
{
43
        printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value);
44
}
45
 
46
static struct input_handle *evbug_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
47
{
48
        struct input_handle *handle;
49
 
50
        if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
51
                return NULL;
52
        memset(handle, 0, sizeof(struct input_handle));
53
 
54
        handle->dev = dev;
55
        handle->handler = handler;
56
        handle->name = evbug_name;
57
 
58
        input_open_device(handle);
59
 
60
        printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys);
61
 
62
        return handle;
63
}
64
 
65
static void evbug_disconnect(struct input_handle *handle)
66
{
67
        printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys);
68
 
69
        input_close_device(handle);
70
 
71
        kfree(handle);
72
}
73
 
74
static struct input_device_id evbug_ids[] = {
75
        { .driver_info = 1 },   /* Matches all devices */
76
        { },                    /* Terminating zero entry */
77
};
78
 
79
MODULE_DEVICE_TABLE(input, evbug_ids);
80
 
81
static struct input_handler evbug_handler = {
82
        .event =        evbug_event,
83
        .connect =      evbug_connect,
84
        .disconnect =   evbug_disconnect,
85
        .name =         "evbug",
86
        .id_table =     evbug_ids,
87
};
88
 
89
int __init evbug_init(void)
90
{
91
        input_register_handler(&evbug_handler);
92
        return 0;
93
}
94
 
95
void __exit evbug_exit(void)
96
{
97
        input_unregister_handler(&evbug_handler);
98
}
99
 
100
module_init(evbug_init);
101
module_exit(evbug_exit);