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