0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/kernel.h>
0016 #include <linux/errno.h>
0017 #include <linux/slab.h>
0018 #include <linux/tty.h>
0019 #include <linux/tty_driver.h>
0020 #include <linux/tty_flip.h>
0021 #include <linux/module.h>
0022 #include <linux/spinlock.h>
0023 #include <linux/uaccess.h>
0024 #include <linux/usb.h>
0025 #include <linux/usb/serial.h>
0026
0027 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
0028 #define DRIVER_DESC "USB Empeg Mark I/II Driver"
0029
0030 #define EMPEG_VENDOR_ID 0x084f
0031 #define EMPEG_PRODUCT_ID 0x0001
0032
0033
0034 static int empeg_startup(struct usb_serial *serial);
0035 static void empeg_init_termios(struct tty_struct *tty);
0036
0037 static const struct usb_device_id id_table[] = {
0038 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
0039 { }
0040 };
0041
0042 MODULE_DEVICE_TABLE(usb, id_table);
0043
0044 static struct usb_serial_driver empeg_device = {
0045 .driver = {
0046 .owner = THIS_MODULE,
0047 .name = "empeg",
0048 },
0049 .id_table = id_table,
0050 .num_ports = 1,
0051 .bulk_out_size = 256,
0052 .throttle = usb_serial_generic_throttle,
0053 .unthrottle = usb_serial_generic_unthrottle,
0054 .attach = empeg_startup,
0055 .init_termios = empeg_init_termios,
0056 };
0057
0058 static struct usb_serial_driver * const serial_drivers[] = {
0059 &empeg_device, NULL
0060 };
0061
0062 static int empeg_startup(struct usb_serial *serial)
0063 {
0064 int r;
0065
0066 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
0067 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
0068 serial->dev->actconfig->desc.bConfigurationValue);
0069 return -ENODEV;
0070 }
0071
0072 r = usb_reset_configuration(serial->dev);
0073
0074
0075 return r;
0076 }
0077
0078 static void empeg_init_termios(struct tty_struct *tty)
0079 {
0080 struct ktermios *termios = &tty->termios;
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 termios->c_iflag
0092 &= ~(IGNBRK
0093 | BRKINT
0094 | PARMRK
0095 | ISTRIP
0096 | INLCR
0097 | IGNCR
0098 | ICRNL
0099 | IXON);
0100
0101 termios->c_oflag
0102 &= ~OPOST;
0103
0104 termios->c_lflag
0105 &= ~(ECHO
0106 | ECHONL
0107 | ICANON
0108 | ISIG
0109 | IEXTEN);
0110
0111 termios->c_cflag
0112 &= ~(CSIZE
0113 | PARENB
0114 | CBAUD);
0115
0116 termios->c_cflag
0117 |= CS8;
0118
0119 tty_encode_baud_rate(tty, 115200, 115200);
0120 }
0121
0122 module_usb_serial_driver(serial_drivers, id_table);
0123
0124 MODULE_AUTHOR(DRIVER_AUTHOR);
0125 MODULE_DESCRIPTION(DRIVER_DESC);
0126 MODULE_LICENSE("GPL v2");