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