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