aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/evbug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/evbug.c')
-rw-r--r--drivers/input/evbug.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/drivers/input/evbug.c b/drivers/input/evbug.c
index 5a9653c3128a..c21f2f127234 100644
--- a/drivers/input/evbug.c
+++ b/drivers/input/evbug.c
@@ -38,31 +38,43 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
38MODULE_DESCRIPTION("Input driver event debug module"); 38MODULE_DESCRIPTION("Input driver event debug module");
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41static char evbug_name[] = "evbug";
42
43static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) 41static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
44{ 42{
45 printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", 43 printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n",
46 handle->dev->phys, type, code, value); 44 handle->dev->phys, type, code, value);
47} 45}
48 46
49static struct input_handle *evbug_connect(struct input_handler *handler, struct input_dev *dev, 47static int evbug_connect(struct input_handler *handler, struct input_dev *dev,
50 const struct input_device_id *id) 48 const struct input_device_id *id)
51{ 49{
52 struct input_handle *handle; 50 struct input_handle *handle;
51 int error;
53 52
54 if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL))) 53 handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
55 return NULL; 54 if (!handle)
55 return -ENOMEM;
56 56
57 handle->dev = dev; 57 handle->dev = dev;
58 handle->handler = handler; 58 handle->handler = handler;
59 handle->name = evbug_name; 59 handle->name = "evbug";
60
61 error = input_register_handle(handle);
62 if (error)
63 goto err_free_handle;
60 64
61 input_open_device(handle); 65 error = input_open_device(handle);
66 if (error)
67 goto err_unregister_handle;
62 68
63 printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys); 69 printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys);
64 70
65 return handle; 71 return 0;
72
73 err_unregister_handle:
74 input_unregister_handle(handle);
75 err_free_handle:
76 kfree(handle);
77 return error;
66} 78}
67 79
68static void evbug_disconnect(struct input_handle *handle) 80static void evbug_disconnect(struct input_handle *handle)
@@ -70,7 +82,7 @@ static void evbug_disconnect(struct input_handle *handle)
70 printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys); 82 printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys);
71 83
72 input_close_device(handle); 84 input_close_device(handle);
73 85 input_unregister_handle(handle);
74 kfree(handle); 86 kfree(handle);
75} 87}
76 88