evbug.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * $Id: evbug.c,v 1.10 2001/09/25 10:12:07 vojtech Exp $
  3. *
  4. * Copyright (c) 1999-2001 Vojtech Pavlik
  5. */
  6. /*
  7. * Input driver event debug module - dumps all events into syslog
  8. */
  9. /*
  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.
  14. *
  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.
  19. *
  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
  23. *
  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
  27. */
  28. #include <linux/slab.h>
  29. #include <linux/module.h>
  30. #include <linux/input.h>
  31. #include <linux/init.h>
  32. #include <linux/device.h>
  33. MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
  34. MODULE_DESCRIPTION("Input driver event debug module");
  35. MODULE_LICENSE("GPL");
  36. static char evbug_name[] = "evbug";
  37. static void evbug_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
  38. {
  39. printk(KERN_DEBUG "evbug.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value);
  40. }
  41. static struct input_handle *evbug_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
  42. {
  43. struct input_handle *handle;
  44. if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
  45. return NULL;
  46. memset(handle, 0, sizeof(struct input_handle));
  47. handle->dev = dev;
  48. handle->handler = handler;
  49. handle->name = evbug_name;
  50. input_open_device(handle);
  51. printk(KERN_DEBUG "evbug.c: Connected device: \"%s\", %s\n", dev->name, dev->phys);
  52. return handle;
  53. }
  54. static void evbug_disconnect(struct input_handle *handle)
  55. {
  56. printk(KERN_DEBUG "evbug.c: Disconnected device: %s\n", handle->dev->phys);
  57. input_close_device(handle);
  58. kfree(handle);
  59. }
  60. static struct input_device_id evbug_ids[] = {
  61. { .driver_info = 1 }, /* Matches all devices */
  62. { }, /* Terminating zero entry */
  63. };
  64. MODULE_DEVICE_TABLE(input, evbug_ids);
  65. static struct input_handler evbug_handler = {
  66. .event = evbug_event,
  67. .connect = evbug_connect,
  68. .disconnect = evbug_disconnect,
  69. .name = "evbug",
  70. .id_table = evbug_ids,
  71. };
  72. static int __init evbug_init(void)
  73. {
  74. input_register_handler(&evbug_handler);
  75. return 0;
  76. }
  77. static void __exit evbug_exit(void)
  78. {
  79. input_unregister_handler(&evbug_handler);
  80. }
  81. module_init(evbug_init);
  82. module_exit(evbug_exit);