1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/kernel.h>
16#include <linux/errno.h>
17#include <linux/slab.h>
18#include <linux/tty.h>
19#include <linux/tty_driver.h>
20#include <linux/tty_flip.h>
21#include <linux/module.h>
22#include <linux/spinlock.h>
23#include <linux/uaccess.h>
24#include <linux/usb.h>
25#include <linux/usb/serial.h>
26
27#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
28#define DRIVER_DESC "USB Empeg Mark I/II Driver"
29
30#define EMPEG_VENDOR_ID 0x084f
31#define EMPEG_PRODUCT_ID 0x0001
32
33
34static int empeg_startup(struct usb_serial *serial);
35static void empeg_init_termios(struct tty_struct *tty);
36
37static const struct usb_device_id id_table[] = {
38 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
39 { }
40};
41
42MODULE_DEVICE_TABLE(usb, id_table);
43
44static struct usb_serial_driver empeg_device = {
45 .driver = {
46 .owner = THIS_MODULE,
47 .name = "empeg",
48 },
49 .id_table = id_table,
50 .num_ports = 1,
51 .bulk_out_size = 256,
52 .throttle = usb_serial_generic_throttle,
53 .unthrottle = usb_serial_generic_unthrottle,
54 .attach = empeg_startup,
55 .init_termios = empeg_init_termios,
56};
57
58static struct usb_serial_driver * const serial_drivers[] = {
59 &empeg_device, NULL
60};
61
62static int empeg_startup(struct usb_serial *serial)
63{
64 int r;
65
66 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
67 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
68 serial->dev->actconfig->desc.bConfigurationValue);
69 return -ENODEV;
70 }
71
72 r = usb_reset_configuration(serial->dev);
73
74
75 return r;
76}
77
78static void empeg_init_termios(struct tty_struct *tty)
79{
80 struct ktermios *termios = &tty->termios;
81
82
83
84
85
86
87
88
89
90
91 termios->c_iflag
92 &= ~(IGNBRK
93 | BRKINT
94 | PARMRK
95 | ISTRIP
96 | INLCR
97 | IGNCR
98 | ICRNL
99 | IXON);
100
101 termios->c_oflag
102 &= ~OPOST;
103
104 termios->c_lflag
105 &= ~(ECHO
106 | ECHONL
107 | ICANON
108 | ISIG
109 | IEXTEN);
110
111 termios->c_cflag
112 &= ~(CSIZE
113 | PARENB
114 | CBAUD);
115
116 termios->c_cflag
117 |= CS8;
118
119 tty_encode_baud_rate(tty, 115200, 115200);
120}
121
122module_usb_serial_driver(serial_drivers, id_table);
123
124MODULE_AUTHOR(DRIVER_AUTHOR);
125MODULE_DESCRIPTION(DRIVER_DESC);
126MODULE_LICENSE("GPL v2");
127