funsoft.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Funsoft Serial USB driver
  3. *
  4. * Copyright (C) 2006 Greg Kroah-Hartman <gregkh@suse.de>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/tty.h>
  13. #include <linux/module.h>
  14. #include <linux/usb.h>
  15. #include <linux/usb/serial.h>
  16. #include <asm/uaccess.h>
  17. static int debug;
  18. static struct usb_device_id id_table [] = {
  19. { USB_DEVICE(0x1404, 0xcddc) },
  20. { },
  21. };
  22. MODULE_DEVICE_TABLE(usb, id_table);
  23. static int funsoft_ioctl(struct usb_serial_port *port, struct file *file,
  24. unsigned int cmd, unsigned long arg)
  25. {
  26. struct ktermios t;
  27. dbg("%s - port %d, cmd 0x%04x", __FUNCTION__, port->number, cmd);
  28. if (cmd == TCSETSF) {
  29. if (user_termios_to_kernel_termios(&t, (struct termios __user *)arg))
  30. return -EFAULT;
  31. dbg("%s - iflag:%x oflag:%x cflag:%x lflag:%x", __FUNCTION__,
  32. t.c_iflag, t.c_oflag, t.c_cflag, t.c_lflag);
  33. if (!(t.c_lflag & ICANON))
  34. return -EINVAL;
  35. }
  36. return -ENOIOCTLCMD;
  37. }
  38. static struct usb_driver funsoft_driver = {
  39. .name = "funsoft",
  40. .probe = usb_serial_probe,
  41. .disconnect = usb_serial_disconnect,
  42. .id_table = id_table,
  43. .no_dynamic_id = 1,
  44. };
  45. static struct usb_serial_driver funsoft_device = {
  46. .driver = {
  47. .owner = THIS_MODULE,
  48. .name = "funsoft",
  49. },
  50. .id_table = id_table,
  51. .usb_driver = &funsoft_driver,
  52. .num_interrupt_in = NUM_DONT_CARE,
  53. .num_bulk_in = NUM_DONT_CARE,
  54. .num_bulk_out = NUM_DONT_CARE,
  55. .num_ports = 1,
  56. .ioctl = funsoft_ioctl,
  57. };
  58. static int __init funsoft_init(void)
  59. {
  60. int retval;
  61. retval = usb_serial_register(&funsoft_device);
  62. if (retval)
  63. return retval;
  64. retval = usb_register(&funsoft_driver);
  65. if (retval)
  66. usb_serial_deregister(&funsoft_device);
  67. return retval;
  68. }
  69. static void __exit funsoft_exit(void)
  70. {
  71. usb_deregister(&funsoft_driver);
  72. usb_serial_deregister(&funsoft_device);
  73. }
  74. module_init(funsoft_init);
  75. module_exit(funsoft_exit);
  76. MODULE_LICENSE("GPL");
  77. module_param(debug, bool, S_IRUGO | S_IWUSR);
  78. MODULE_PARM_DESC(debug, "Debug enabled or not");