diff options
Diffstat (limited to 'drivers/usb/serial')
31 files changed, 1169 insertions, 990 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 43d6db696f9..99fefed7791 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -92,6 +92,16 @@ config USB_SERIAL_BELKIN | |||
92 | To compile this driver as a module, choose M here: the | 92 | To compile this driver as a module, choose M here: the |
93 | module will be called belkin_sa. | 93 | module will be called belkin_sa. |
94 | 94 | ||
95 | config USB_SERIAL_CH341 | ||
96 | tristate "USB Winchiphead CH341 Single Port Serial Driver" | ||
97 | depends on USB_SERIAL | ||
98 | help | ||
99 | Say Y here if you want to use a Winchiphead CH341 single port | ||
100 | USB to serial adapter. | ||
101 | |||
102 | To compile this driver as a module, choose M here: the | ||
103 | module will be called ch341. | ||
104 | |||
95 | config USB_SERIAL_WHITEHEAT | 105 | config USB_SERIAL_WHITEHEAT |
96 | tristate "USB ConnectTech WhiteHEAT Serial Driver" | 106 | tristate "USB ConnectTech WhiteHEAT Serial Driver" |
97 | depends on USB_SERIAL | 107 | depends on USB_SERIAL |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 07a976eca6b..d6fb384e52b 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -15,6 +15,7 @@ obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o | |||
15 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o | 15 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o |
16 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o | 16 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o |
17 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o | 17 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o |
18 | obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o | ||
18 | obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o | 19 | obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o |
19 | obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o | 20 | obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o |
20 | obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o | 21 | obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index cff6fd190a2..77bb893bf2e 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | static struct usb_device_id id_table [] = { | 19 | static struct usb_device_id id_table [] = { |
20 | { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ | 20 | { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ |
21 | { USB_DEVICE(0x413c, 0x8115) }, /* Dell Wireless HSDPA 5500 */ | ||
22 | { }, | 21 | { }, |
23 | }; | 22 | }; |
24 | MODULE_DEVICE_TABLE(usb, id_table); | 23 | MODULE_DEVICE_TABLE(usb, id_table); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index c9fd486c1c7..2a8e537cb04 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -172,11 +172,6 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
172 | 172 | ||
173 | dbg("%s - port %d", __FUNCTION__, port->number); | 173 | dbg("%s - port %d", __FUNCTION__, port->number); |
174 | 174 | ||
175 | if (!port->tty || !port->tty->termios) { | ||
176 | dbg("%s - no tty structures", __FUNCTION__); | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | spin_lock_irqsave(&priv->lock, flags); | 175 | spin_lock_irqsave(&priv->lock, flags); |
181 | if (!priv->termios_initialized) { | 176 | if (!priv->termios_initialized) { |
182 | *(port->tty->termios) = tty_std_termios; | 177 | *(port->tty->termios) = tty_std_termios; |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index e67ce25f751..86724e88570 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -383,6 +383,10 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
383 | } | 383 | } |
384 | 384 | ||
385 | baud = tty_get_baud_rate(port->tty); | 385 | baud = tty_get_baud_rate(port->tty); |
386 | if (baud == 0) { | ||
387 | dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__); | ||
388 | return; | ||
389 | } | ||
386 | urb_value = BELKIN_SA_BAUD(baud); | 390 | urb_value = BELKIN_SA_BAUD(baud); |
387 | /* Clip to maximum speed */ | 391 | /* Clip to maximum speed */ |
388 | if (urb_value == 0) | 392 | if (urb_value == 0) |
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index c08a38402b9..0b14aea8ebd 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -36,6 +36,16 @@ static int usb_serial_device_match (struct device *dev, struct device_driver *dr | |||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | static ssize_t show_port_number(struct device *dev, | ||
40 | struct device_attribute *attr, char *buf) | ||
41 | { | ||
42 | struct usb_serial_port *port = to_usb_serial_port(dev); | ||
43 | |||
44 | return sprintf(buf, "%d\n", port->number - port->serial->minor); | ||
45 | } | ||
46 | |||
47 | static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL); | ||
48 | |||
39 | static int usb_serial_device_probe (struct device *dev) | 49 | static int usb_serial_device_probe (struct device *dev) |
40 | { | 50 | { |
41 | struct usb_serial_driver *driver; | 51 | struct usb_serial_driver *driver; |
@@ -62,6 +72,10 @@ static int usb_serial_device_probe (struct device *dev) | |||
62 | goto exit; | 72 | goto exit; |
63 | } | 73 | } |
64 | 74 | ||
75 | retval = device_create_file(dev, &dev_attr_port_number); | ||
76 | if (retval) | ||
77 | goto exit; | ||
78 | |||
65 | minor = port->number; | 79 | minor = port->number; |
66 | tty_register_device (usb_serial_tty_driver, minor, dev); | 80 | tty_register_device (usb_serial_tty_driver, minor, dev); |
67 | dev_info(&port->serial->dev->dev, | 81 | dev_info(&port->serial->dev->dev, |
@@ -84,6 +98,8 @@ static int usb_serial_device_remove (struct device *dev) | |||
84 | return -ENODEV; | 98 | return -ENODEV; |
85 | } | 99 | } |
86 | 100 | ||
101 | device_remove_file(&port->dev, &dev_attr_port_number); | ||
102 | |||
87 | driver = port->serial->type; | 103 | driver = port->serial->type; |
88 | if (driver->port_remove) { | 104 | if (driver->port_remove) { |
89 | if (!try_module_get(driver->driver.owner)) { | 105 | if (!try_module_get(driver->driver.owner)) { |
@@ -138,7 +154,7 @@ static void free_dynids(struct usb_serial_driver *drv) | |||
138 | static struct driver_attribute drv_attrs[] = { | 154 | static struct driver_attribute drv_attrs[] = { |
139 | __ATTR_NULL, | 155 | __ATTR_NULL, |
140 | }; | 156 | }; |
141 | static inline void free_dynids(struct usb_driver *drv) | 157 | static inline void free_dynids(struct usb_serial_driver *drv) |
142 | { | 158 | { |
143 | } | 159 | } |
144 | #endif | 160 | #endif |
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c new file mode 100644 index 00000000000..6b252ceb39a --- /dev/null +++ b/drivers/usb/serial/ch341.c | |||
@@ -0,0 +1,354 @@ | |||
1 | /* | ||
2 | * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk> | ||
3 | * | ||
4 | * ch341.c implements a serial port driver for the Winchiphead CH341. | ||
5 | * | ||
6 | * The CH341 device can be used to implement an RS232 asynchronous | ||
7 | * serial port, an IEEE-1284 parallel printer port or a memory-like | ||
8 | * interface. In all cases the CH341 supports an I2C interface as well. | ||
9 | * This driver only supports the asynchronous serial interface. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License version | ||
13 | * 2 as published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/tty.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/usb.h> | ||
21 | #include <linux/usb/serial.h> | ||
22 | #include <linux/serial.h> | ||
23 | |||
24 | #define DEFAULT_BAUD_RATE 2400 | ||
25 | #define DEFAULT_TIMEOUT 1000 | ||
26 | |||
27 | static int debug; | ||
28 | |||
29 | static struct usb_device_id id_table [] = { | ||
30 | { USB_DEVICE(0x4348, 0x5523) }, | ||
31 | { }, | ||
32 | }; | ||
33 | MODULE_DEVICE_TABLE(usb, id_table); | ||
34 | |||
35 | struct ch341_private { | ||
36 | unsigned baud_rate; | ||
37 | u8 dtr; | ||
38 | u8 rts; | ||
39 | }; | ||
40 | |||
41 | static int ch341_control_out(struct usb_device *dev, u8 request, | ||
42 | u16 value, u16 index) | ||
43 | { | ||
44 | int r; | ||
45 | dbg("ch341_control_out(%02x,%02x,%04x,%04x)", USB_DIR_OUT|0x40, | ||
46 | (int)request, (int)value, (int)index); | ||
47 | |||
48 | r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, | ||
49 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, | ||
50 | value, index, NULL, 0, DEFAULT_TIMEOUT); | ||
51 | |||
52 | return r; | ||
53 | } | ||
54 | |||
55 | static int ch341_control_in(struct usb_device *dev, | ||
56 | u8 request, u16 value, u16 index, | ||
57 | char *buf, unsigned bufsize) | ||
58 | { | ||
59 | int r; | ||
60 | dbg("ch341_control_in(%02x,%02x,%04x,%04x,%p,%u)", USB_DIR_IN|0x40, | ||
61 | (int)request, (int)value, (int)index, buf, (int)bufsize); | ||
62 | |||
63 | r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, | ||
64 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, | ||
65 | value, index, buf, bufsize, DEFAULT_TIMEOUT); | ||
66 | return r; | ||
67 | } | ||
68 | |||
69 | static int ch341_set_baudrate(struct usb_device *dev, | ||
70 | struct ch341_private *priv) | ||
71 | { | ||
72 | short a, b; | ||
73 | int r; | ||
74 | |||
75 | dbg("ch341_set_baudrate(%d)", priv->baud_rate); | ||
76 | switch (priv->baud_rate) { | ||
77 | case 2400: | ||
78 | a = 0xd901; | ||
79 | b = 0x0038; | ||
80 | break; | ||
81 | case 4800: | ||
82 | a = 0x6402; | ||
83 | b = 0x001f; | ||
84 | break; | ||
85 | case 9600: | ||
86 | a = 0xb202; | ||
87 | b = 0x0013; | ||
88 | break; | ||
89 | case 19200: | ||
90 | a = 0xd902; | ||
91 | b = 0x000d; | ||
92 | break; | ||
93 | case 38400: | ||
94 | a = 0x6403; | ||
95 | b = 0x000a; | ||
96 | break; | ||
97 | case 115200: | ||
98 | a = 0xcc03; | ||
99 | b = 0x0008; | ||
100 | break; | ||
101 | default: | ||
102 | return -EINVAL; | ||
103 | } | ||
104 | |||
105 | r = ch341_control_out(dev, 0x9a, 0x1312, a); | ||
106 | if (!r) | ||
107 | r = ch341_control_out(dev, 0x9a, 0x0f2c, b); | ||
108 | |||
109 | return r; | ||
110 | } | ||
111 | |||
112 | static int ch341_set_handshake(struct usb_device *dev, | ||
113 | struct ch341_private *priv) | ||
114 | { | ||
115 | dbg("ch341_set_handshake(%d,%d)", priv->dtr, priv->rts); | ||
116 | return ch341_control_out(dev, 0xa4, | ||
117 | ~((priv->dtr?1<<5:0)|(priv->rts?1<<6:0)), 0); | ||
118 | } | ||
119 | |||
120 | static int ch341_get_status(struct usb_device *dev) | ||
121 | { | ||
122 | char *buffer; | ||
123 | int r; | ||
124 | const unsigned size = 8; | ||
125 | |||
126 | dbg("ch341_get_status()"); | ||
127 | |||
128 | buffer = kmalloc(size, GFP_KERNEL); | ||
129 | if (!buffer) | ||
130 | return -ENOMEM; | ||
131 | |||
132 | r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); | ||
133 | if ( r < 0) | ||
134 | goto out; | ||
135 | |||
136 | /* Not having the datasheet for the CH341, we ignore the bytes returned | ||
137 | * from the device. Return error if the device did not respond in time. | ||
138 | */ | ||
139 | r = 0; | ||
140 | |||
141 | out: kfree(buffer); | ||
142 | return r; | ||
143 | } | ||
144 | |||
145 | /* -------------------------------------------------------------------------- */ | ||
146 | |||
147 | static int ch341_configure(struct usb_device *dev, struct ch341_private *priv) | ||
148 | { | ||
149 | char *buffer; | ||
150 | int r; | ||
151 | const unsigned size = 8; | ||
152 | |||
153 | dbg("ch341_configure()"); | ||
154 | |||
155 | buffer = kmalloc(size, GFP_KERNEL); | ||
156 | if (!buffer) | ||
157 | return -ENOMEM; | ||
158 | |||
159 | /* expect two bytes 0x27 0x00 */ | ||
160 | r = ch341_control_in(dev, 0x5f, 0, 0, buffer, size); | ||
161 | if (r < 0) | ||
162 | goto out; | ||
163 | |||
164 | r = ch341_control_out(dev, 0xa1, 0, 0); | ||
165 | if (r < 0) | ||
166 | goto out; | ||
167 | |||
168 | r = ch341_set_baudrate(dev, priv); | ||
169 | if (r < 0) | ||
170 | goto out; | ||
171 | |||
172 | /* expect two bytes 0x56 0x00 */ | ||
173 | r = ch341_control_in(dev, 0x95, 0x2518, 0, buffer, size); | ||
174 | if (r < 0) | ||
175 | goto out; | ||
176 | |||
177 | r = ch341_control_out(dev, 0x9a, 0x2518, 0x0050); | ||
178 | if (r < 0) | ||
179 | goto out; | ||
180 | |||
181 | /* expect 0xff 0xee */ | ||
182 | r = ch341_get_status(dev); | ||
183 | if (r < 0) | ||
184 | goto out; | ||
185 | |||
186 | r = ch341_control_out(dev, 0xa1, 0x501f, 0xd90a); | ||
187 | if (r < 0) | ||
188 | goto out; | ||
189 | |||
190 | r = ch341_set_baudrate(dev, priv); | ||
191 | if (r < 0) | ||
192 | goto out; | ||
193 | |||
194 | r = ch341_set_handshake(dev, priv); | ||
195 | if (r < 0) | ||
196 | goto out; | ||
197 | |||
198 | /* expect 0x9f 0xee */ | ||
199 | r = ch341_get_status(dev); | ||
200 | |||
201 | out: kfree(buffer); | ||
202 | return r; | ||
203 | } | ||
204 | |||
205 | /* allocate private data */ | ||
206 | static int ch341_attach(struct usb_serial *serial) | ||
207 | { | ||
208 | struct ch341_private *priv; | ||
209 | int r; | ||
210 | |||
211 | dbg("ch341_attach()"); | ||
212 | |||
213 | /* private data */ | ||
214 | priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL); | ||
215 | if (!priv) | ||
216 | return -ENOMEM; | ||
217 | |||
218 | priv->baud_rate = DEFAULT_BAUD_RATE; | ||
219 | priv->dtr = 1; | ||
220 | priv->rts = 1; | ||
221 | |||
222 | r = ch341_configure(serial->dev, priv); | ||
223 | if (r < 0) | ||
224 | goto error; | ||
225 | |||
226 | usb_set_serial_port_data(serial->port[0], priv); | ||
227 | return 0; | ||
228 | |||
229 | error: kfree(priv); | ||
230 | return r; | ||
231 | } | ||
232 | |||
233 | /* open this device, set default parameters */ | ||
234 | static int ch341_open(struct usb_serial_port *port, struct file *filp) | ||
235 | { | ||
236 | struct usb_serial *serial = port->serial; | ||
237 | struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); | ||
238 | int r; | ||
239 | |||
240 | dbg("ch341_open()"); | ||
241 | |||
242 | priv->baud_rate = DEFAULT_BAUD_RATE; | ||
243 | priv->dtr = 1; | ||
244 | priv->rts = 1; | ||
245 | |||
246 | r = ch341_configure(serial->dev, priv); | ||
247 | if (r) | ||
248 | goto out; | ||
249 | |||
250 | r = ch341_set_handshake(serial->dev, priv); | ||
251 | if (r) | ||
252 | goto out; | ||
253 | |||
254 | r = ch341_set_baudrate(serial->dev, priv); | ||
255 | if (r) | ||
256 | goto out; | ||
257 | |||
258 | r = usb_serial_generic_open(port, filp); | ||
259 | |||
260 | out: return r; | ||
261 | } | ||
262 | |||
263 | /* Old_termios contains the original termios settings and | ||
264 | * tty->termios contains the new setting to be used. | ||
265 | */ | ||
266 | static void ch341_set_termios(struct usb_serial_port *port, | ||
267 | struct ktermios *old_termios) | ||
268 | { | ||
269 | struct ch341_private *priv = usb_get_serial_port_data(port); | ||
270 | struct tty_struct *tty = port->tty; | ||
271 | unsigned baud_rate; | ||
272 | |||
273 | dbg("ch341_set_termios()"); | ||
274 | |||
275 | if (!tty || !tty->termios) | ||
276 | return; | ||
277 | |||
278 | baud_rate = tty_get_baud_rate(tty); | ||
279 | |||
280 | switch (baud_rate) { | ||
281 | case 2400: | ||
282 | case 4800: | ||
283 | case 9600: | ||
284 | case 19200: | ||
285 | case 38400: | ||
286 | case 115200: | ||
287 | priv->baud_rate = baud_rate; | ||
288 | break; | ||
289 | default: | ||
290 | dbg("Rate %d not supported, using %d", | ||
291 | baud_rate, DEFAULT_BAUD_RATE); | ||
292 | priv->baud_rate = DEFAULT_BAUD_RATE; | ||
293 | } | ||
294 | |||
295 | ch341_set_baudrate(port->serial->dev, priv); | ||
296 | |||
297 | /* Unimplemented: | ||
298 | * (cflag & CSIZE) : data bits [5, 8] | ||
299 | * (cflag & PARENB) : parity {NONE, EVEN, ODD} | ||
300 | * (cflag & CSTOPB) : stop bits [1, 2] | ||
301 | */ | ||
302 | } | ||
303 | |||
304 | static struct usb_driver ch341_driver = { | ||
305 | .name = "ch341", | ||
306 | .probe = usb_serial_probe, | ||
307 | .disconnect = usb_serial_disconnect, | ||
308 | .id_table = id_table, | ||
309 | .no_dynamic_id = 1, | ||
310 | }; | ||
311 | |||
312 | static struct usb_serial_driver ch341_device = { | ||
313 | .driver = { | ||
314 | .owner = THIS_MODULE, | ||
315 | .name = "ch341-uart", | ||
316 | }, | ||
317 | .id_table = id_table, | ||
318 | .usb_driver = &ch341_driver, | ||
319 | .num_interrupt_in = NUM_DONT_CARE, | ||
320 | .num_bulk_in = 1, | ||
321 | .num_bulk_out = 1, | ||
322 | .num_ports = 1, | ||
323 | .open = ch341_open, | ||
324 | .set_termios = ch341_set_termios, | ||
325 | .attach = ch341_attach, | ||
326 | }; | ||
327 | |||
328 | static int __init ch341_init(void) | ||
329 | { | ||
330 | int retval; | ||
331 | |||
332 | retval = usb_serial_register(&ch341_device); | ||
333 | if (retval) | ||
334 | return retval; | ||
335 | retval = usb_register(&ch341_driver); | ||
336 | if (retval) | ||
337 | usb_serial_deregister(&ch341_device); | ||
338 | return retval; | ||
339 | } | ||
340 | |||
341 | static void __exit ch341_exit(void) | ||
342 | { | ||
343 | usb_deregister(&ch341_driver); | ||
344 | usb_serial_deregister(&ch341_device); | ||
345 | } | ||
346 | |||
347 | module_init(ch341_init); | ||
348 | module_exit(ch341_exit); | ||
349 | MODULE_LICENSE("GPL"); | ||
350 | |||
351 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
352 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
353 | |||
354 | /* EOF ch341.c */ | ||
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index e831cb7f64f..eb7df1835c1 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -53,6 +53,7 @@ static void cp2101_shutdown(struct usb_serial*); | |||
53 | static int debug; | 53 | static int debug; |
54 | 54 | ||
55 | static struct usb_device_id id_table [] = { | 55 | static struct usb_device_id id_table [] = { |
56 | { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ | ||
56 | { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ | 57 | { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ |
57 | { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ | 58 | { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ |
58 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ | 59 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ |
@@ -356,7 +357,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
356 | 357 | ||
357 | dbg("%s - port %d", __FUNCTION__, port->number); | 358 | dbg("%s - port %d", __FUNCTION__, port->number); |
358 | 359 | ||
359 | if ((!port->tty) || (!port->tty->termios)) { | 360 | if (!port->tty || !port->tty->termios) { |
360 | dbg("%s - no tty structures", __FUNCTION__); | 361 | dbg("%s - no tty structures", __FUNCTION__); |
361 | return; | 362 | return; |
362 | } | 363 | } |
@@ -521,55 +522,40 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
521 | 522 | ||
522 | dbg("%s - port %d", __FUNCTION__, port->number); | 523 | dbg("%s - port %d", __FUNCTION__, port->number); |
523 | 524 | ||
524 | if ((!port->tty) || (!port->tty->termios)) { | 525 | if (!port->tty || !port->tty->termios) { |
525 | dbg("%s - no tty structures", __FUNCTION__); | 526 | dbg("%s - no tty structures", __FUNCTION__); |
526 | return; | 527 | return; |
527 | } | 528 | } |
528 | cflag = port->tty->termios->c_cflag; | 529 | cflag = port->tty->termios->c_cflag; |
529 | 530 | old_cflag = old_termios->c_cflag; | |
530 | /* Check that they really want us to change something */ | 531 | baud = tty_get_baud_rate(port->tty); |
531 | if (old_termios) { | ||
532 | if ((cflag == old_termios->c_cflag) && | ||
533 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) | ||
534 | == RELEVANT_IFLAG(old_termios->c_iflag))) { | ||
535 | dbg("%s - nothing to change...", __FUNCTION__); | ||
536 | return; | ||
537 | } | ||
538 | |||
539 | old_cflag = old_termios->c_cflag; | ||
540 | } | ||
541 | 532 | ||
542 | /* If the baud rate is to be updated*/ | 533 | /* If the baud rate is to be updated*/ |
543 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { | 534 | if (baud != tty_termios_baud_rate(old_termios)) { |
544 | switch (cflag & CBAUD) { | 535 | switch (baud) { |
545 | /* | 536 | case 0: |
546 | * The baud rates which are commented out below | 537 | case 600: |
547 | * appear to be supported by the device | 538 | case 1200: |
548 | * but are non-standard | 539 | case 1800: |
549 | */ | 540 | case 2400: |
550 | case B0: baud = 0; break; | 541 | case 4800: |
551 | case B600: baud = 600; break; | 542 | case 7200: |
552 | case B1200: baud = 1200; break; | 543 | case 9600: |
553 | case B1800: baud = 1800; break; | 544 | case 14400: |
554 | case B2400: baud = 2400; break; | 545 | case 19200: |
555 | case B4800: baud = 4800; break; | 546 | case 28800: |
556 | /*case B7200: baud = 7200; break;*/ | 547 | case 38400: |
557 | case B9600: baud = 9600; break; | 548 | case 55854: |
558 | /*ase B14400: baud = 14400; break;*/ | 549 | case 57600: |
559 | case B19200: baud = 19200; break; | 550 | case 115200: |
560 | /*case B28800: baud = 28800; break;*/ | 551 | case 127117: |
561 | case B38400: baud = 38400; break; | 552 | case 230400: |
562 | /*case B55854: baud = 55054; break;*/ | 553 | case 460800: |
563 | case B57600: baud = 57600; break; | 554 | case 921600: |
564 | case B115200: baud = 115200; break; | 555 | case 3686400: |
565 | /*case B127117: baud = 127117; break;*/ | 556 | break; |
566 | case B230400: baud = 230400; break; | ||
567 | case B460800: baud = 460800; break; | ||
568 | case B921600: baud = 921600; break; | ||
569 | /*case B3686400: baud = 3686400; break;*/ | ||
570 | default: | 557 | default: |
571 | dev_err(&port->dev, "cp2101 driver does not " | 558 | baud = 9600; |
572 | "support the baudrate requested\n"); | ||
573 | break; | 559 | break; |
574 | } | 560 | } |
575 | 561 | ||
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 976f54ec26e..dab2e66d111 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -433,38 +433,38 @@ struct digi_port { | |||
433 | 433 | ||
434 | /* Local Function Declarations */ | 434 | /* Local Function Declarations */ |
435 | 435 | ||
436 | static void digi_wakeup_write( struct usb_serial_port *port ); | 436 | static void digi_wakeup_write(struct usb_serial_port *port); |
437 | static void digi_wakeup_write_lock(struct work_struct *work); | 437 | static void digi_wakeup_write_lock(struct work_struct *work); |
438 | static int digi_write_oob_command( struct usb_serial_port *port, | 438 | static int digi_write_oob_command(struct usb_serial_port *port, |
439 | unsigned char *buf, int count, int interruptible ); | 439 | unsigned char *buf, int count, int interruptible); |
440 | static int digi_write_inb_command( struct usb_serial_port *port, | 440 | static int digi_write_inb_command(struct usb_serial_port *port, |
441 | unsigned char *buf, int count, unsigned long timeout ); | 441 | unsigned char *buf, int count, unsigned long timeout); |
442 | static int digi_set_modem_signals( struct usb_serial_port *port, | 442 | static int digi_set_modem_signals(struct usb_serial_port *port, |
443 | unsigned int modem_signals, int interruptible ); | 443 | unsigned int modem_signals, int interruptible); |
444 | static int digi_transmit_idle( struct usb_serial_port *port, | 444 | static int digi_transmit_idle(struct usb_serial_port *port, |
445 | unsigned long timeout ); | 445 | unsigned long timeout); |
446 | static void digi_rx_throttle (struct usb_serial_port *port); | 446 | static void digi_rx_throttle (struct usb_serial_port *port); |
447 | static void digi_rx_unthrottle (struct usb_serial_port *port); | 447 | static void digi_rx_unthrottle (struct usb_serial_port *port); |
448 | static void digi_set_termios( struct usb_serial_port *port, | 448 | static void digi_set_termios(struct usb_serial_port *port, |
449 | struct ktermios *old_termios ); | 449 | struct ktermios *old_termios); |
450 | static void digi_break_ctl( struct usb_serial_port *port, int break_state ); | 450 | static void digi_break_ctl(struct usb_serial_port *port, int break_state); |
451 | static int digi_ioctl( struct usb_serial_port *port, struct file *file, | 451 | static int digi_ioctl(struct usb_serial_port *port, struct file *file, |
452 | unsigned int cmd, unsigned long arg ); | 452 | unsigned int cmd, unsigned long arg); |
453 | static int digi_tiocmget( struct usb_serial_port *port, struct file *file ); | 453 | static int digi_tiocmget(struct usb_serial_port *port, struct file *file); |
454 | static int digi_tiocmset( struct usb_serial_port *port, struct file *file, | 454 | static int digi_tiocmset(struct usb_serial_port *port, struct file *file, |
455 | unsigned int set, unsigned int clear ); | 455 | unsigned int set, unsigned int clear); |
456 | static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count ); | 456 | static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count); |
457 | static void digi_write_bulk_callback( struct urb *urb ); | 457 | static void digi_write_bulk_callback(struct urb *urb); |
458 | static int digi_write_room( struct usb_serial_port *port ); | 458 | static int digi_write_room(struct usb_serial_port *port); |
459 | static int digi_chars_in_buffer( struct usb_serial_port *port ); | 459 | static int digi_chars_in_buffer(struct usb_serial_port *port); |
460 | static int digi_open( struct usb_serial_port *port, struct file *filp ); | 460 | static int digi_open(struct usb_serial_port *port, struct file *filp); |
461 | static void digi_close( struct usb_serial_port *port, struct file *filp ); | 461 | static void digi_close(struct usb_serial_port *port, struct file *filp); |
462 | static int digi_startup_device( struct usb_serial *serial ); | 462 | static int digi_startup_device(struct usb_serial *serial); |
463 | static int digi_startup( struct usb_serial *serial ); | 463 | static int digi_startup(struct usb_serial *serial); |
464 | static void digi_shutdown( struct usb_serial *serial ); | 464 | static void digi_shutdown(struct usb_serial *serial); |
465 | static void digi_read_bulk_callback( struct urb *urb ); | 465 | static void digi_read_bulk_callback(struct urb *urb); |
466 | static int digi_read_inb_callback( struct urb *urb ); | 466 | static int digi_read_inb_callback(struct urb *urb); |
467 | static int digi_read_oob_callback( struct urb *urb ); | 467 | static int digi_read_oob_callback(struct urb *urb); |
468 | 468 | ||
469 | 469 | ||
470 | /* Statics */ | 470 | /* Statics */ |
@@ -576,9 +576,9 @@ static struct usb_serial_driver digi_acceleport_4_device = { | |||
576 | * with the equivalent code. | 576 | * with the equivalent code. |
577 | */ | 577 | */ |
578 | 578 | ||
579 | static inline long cond_wait_interruptible_timeout_irqrestore( | 579 | static long cond_wait_interruptible_timeout_irqrestore( |
580 | wait_queue_head_t *q, long timeout, | 580 | wait_queue_head_t *q, long timeout, |
581 | spinlock_t *lock, unsigned long flags ) | 581 | spinlock_t *lock, unsigned long flags) |
582 | { | 582 | { |
583 | DEFINE_WAIT(wait); | 583 | DEFINE_WAIT(wait); |
584 | 584 | ||
@@ -600,18 +600,16 @@ static inline long cond_wait_interruptible_timeout_irqrestore( | |||
600 | 600 | ||
601 | static void digi_wakeup_write_lock(struct work_struct *work) | 601 | static void digi_wakeup_write_lock(struct work_struct *work) |
602 | { | 602 | { |
603 | struct digi_port *priv = | 603 | struct digi_port *priv = container_of(work, struct digi_port, dp_wakeup_work); |
604 | container_of(work, struct digi_port, dp_wakeup_work); | ||
605 | struct usb_serial_port *port = priv->dp_port; | 604 | struct usb_serial_port *port = priv->dp_port; |
606 | unsigned long flags; | 605 | unsigned long flags; |
607 | 606 | ||
608 | 607 | spin_lock_irqsave(&priv->dp_port_lock, flags); | |
609 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 608 | digi_wakeup_write(port); |
610 | digi_wakeup_write( port ); | 609 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
611 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | ||
612 | } | 610 | } |
613 | 611 | ||
614 | static void digi_wakeup_write( struct usb_serial_port *port ) | 612 | static void digi_wakeup_write(struct usb_serial_port *port) |
615 | { | 613 | { |
616 | tty_wakeup(port->tty); | 614 | tty_wakeup(port->tty); |
617 | } | 615 | } |
@@ -628,8 +626,8 @@ static void digi_wakeup_write( struct usb_serial_port *port ) | |||
628 | * returned by usb_submit_urb. | 626 | * returned by usb_submit_urb. |
629 | */ | 627 | */ |
630 | 628 | ||
631 | static int digi_write_oob_command( struct usb_serial_port *port, | 629 | static int digi_write_oob_command(struct usb_serial_port *port, |
632 | unsigned char *buf, int count, int interruptible ) | 630 | unsigned char *buf, int count, int interruptible) |
633 | { | 631 | { |
634 | 632 | ||
635 | int ret = 0; | 633 | int ret = 0; |
@@ -638,49 +636,37 @@ static int digi_write_oob_command( struct usb_serial_port *port, | |||
638 | struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); | 636 | struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); |
639 | unsigned long flags = 0; | 637 | unsigned long flags = 0; |
640 | 638 | ||
639 | dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count); | ||
641 | 640 | ||
642 | dbg( "digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count ); | 641 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); |
643 | 642 | while(count > 0) { | |
644 | spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); | 643 | while(oob_port->write_urb->status == -EINPROGRESS |
645 | 644 | || oob_priv->dp_write_urb_in_use) { | |
646 | while( count > 0 ) { | ||
647 | |||
648 | while( oob_port->write_urb->status == -EINPROGRESS | ||
649 | || oob_priv->dp_write_urb_in_use ) { | ||
650 | cond_wait_interruptible_timeout_irqrestore( | 645 | cond_wait_interruptible_timeout_irqrestore( |
651 | &oob_port->write_wait, DIGI_RETRY_TIMEOUT, | 646 | &oob_port->write_wait, DIGI_RETRY_TIMEOUT, |
652 | &oob_priv->dp_port_lock, flags ); | 647 | &oob_priv->dp_port_lock, flags); |
653 | if( interruptible && signal_pending(current) ) { | 648 | if (interruptible && signal_pending(current)) |
654 | return( -EINTR ); | 649 | return -EINTR; |
655 | } | 650 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); |
656 | spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); | ||
657 | } | 651 | } |
658 | 652 | ||
659 | /* len must be a multiple of 4, so commands are not split */ | 653 | /* len must be a multiple of 4, so commands are not split */ |
660 | len = min(count, oob_port->bulk_out_size ); | 654 | len = min(count, oob_port->bulk_out_size); |
661 | if( len > 4 ) | 655 | if (len > 4) |
662 | len &= ~3; | 656 | len &= ~3; |
663 | 657 | memcpy(oob_port->write_urb->transfer_buffer, buf, len); | |
664 | memcpy( oob_port->write_urb->transfer_buffer, buf, len ); | ||
665 | oob_port->write_urb->transfer_buffer_length = len; | 658 | oob_port->write_urb->transfer_buffer_length = len; |
666 | oob_port->write_urb->dev = port->serial->dev; | 659 | oob_port->write_urb->dev = port->serial->dev; |
667 | 660 | if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) { | |
668 | if( (ret=usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0 ) { | ||
669 | oob_priv->dp_write_urb_in_use = 1; | 661 | oob_priv->dp_write_urb_in_use = 1; |
670 | count -= len; | 662 | count -= len; |
671 | buf += len; | 663 | buf += len; |
672 | } | 664 | } |
673 | |||
674 | } | ||
675 | |||
676 | spin_unlock_irqrestore( &oob_priv->dp_port_lock, flags ); | ||
677 | |||
678 | if( ret ) { | ||
679 | err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, | ||
680 | ret ); | ||
681 | } | 665 | } |
682 | 666 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); | |
683 | return( ret ); | 667 | if (ret) |
668 | err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret); | ||
669 | return ret; | ||
684 | 670 | ||
685 | } | 671 | } |
686 | 672 | ||
@@ -697,63 +683,58 @@ dbg( "digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, co | |||
697 | * error returned by digi_write. | 683 | * error returned by digi_write. |
698 | */ | 684 | */ |
699 | 685 | ||
700 | static int digi_write_inb_command( struct usb_serial_port *port, | 686 | static int digi_write_inb_command(struct usb_serial_port *port, |
701 | unsigned char *buf, int count, unsigned long timeout ) | 687 | unsigned char *buf, int count, unsigned long timeout) |
702 | { | 688 | { |
703 | |||
704 | int ret = 0; | 689 | int ret = 0; |
705 | int len; | 690 | int len; |
706 | struct digi_port *priv = usb_get_serial_port_data(port); | 691 | struct digi_port *priv = usb_get_serial_port_data(port); |
707 | unsigned char *data = port->write_urb->transfer_buffer; | 692 | unsigned char *data = port->write_urb->transfer_buffer; |
708 | unsigned long flags = 0; | 693 | unsigned long flags = 0; |
709 | 694 | ||
695 | dbg("digi_write_inb_command: TOP: port=%d, count=%d", | ||
696 | priv->dp_port_num, count); | ||
710 | 697 | ||
711 | dbg( "digi_write_inb_command: TOP: port=%d, count=%d", priv->dp_port_num, | 698 | if (timeout) |
712 | count ); | ||
713 | |||
714 | if( timeout ) | ||
715 | timeout += jiffies; | 699 | timeout += jiffies; |
716 | else | 700 | else |
717 | timeout = ULONG_MAX; | 701 | timeout = ULONG_MAX; |
718 | 702 | ||
719 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 703 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
720 | 704 | while(count > 0 && ret == 0) { | |
721 | while( count > 0 && ret == 0 ) { | 705 | while((port->write_urb->status == -EINPROGRESS |
722 | 706 | || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) { | |
723 | while( (port->write_urb->status == -EINPROGRESS | ||
724 | || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) { | ||
725 | cond_wait_interruptible_timeout_irqrestore( | 707 | cond_wait_interruptible_timeout_irqrestore( |
726 | &port->write_wait, DIGI_RETRY_TIMEOUT, | 708 | &port->write_wait, DIGI_RETRY_TIMEOUT, |
727 | &priv->dp_port_lock, flags ); | 709 | &priv->dp_port_lock, flags); |
728 | if( signal_pending(current) ) { | 710 | if (signal_pending(current)) |
729 | return( -EINTR ); | 711 | return -EINTR; |
730 | } | 712 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
731 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | ||
732 | } | 713 | } |
733 | 714 | ||
734 | /* len must be a multiple of 4 and small enough to */ | 715 | /* len must be a multiple of 4 and small enough to */ |
735 | /* guarantee the write will send buffered data first, */ | 716 | /* guarantee the write will send buffered data first, */ |
736 | /* so commands are in order with data and not split */ | 717 | /* so commands are in order with data and not split */ |
737 | len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len ); | 718 | len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len); |
738 | if( len > 4 ) | 719 | if (len > 4) |
739 | len &= ~3; | 720 | len &= ~3; |
740 | 721 | ||
741 | /* write any buffered data first */ | 722 | /* write any buffered data first */ |
742 | if( priv->dp_out_buf_len > 0 ) { | 723 | if (priv->dp_out_buf_len > 0) { |
743 | data[0] = DIGI_CMD_SEND_DATA; | 724 | data[0] = DIGI_CMD_SEND_DATA; |
744 | data[1] = priv->dp_out_buf_len; | 725 | data[1] = priv->dp_out_buf_len; |
745 | memcpy( data+2, priv->dp_out_buf, | 726 | memcpy(data + 2, priv->dp_out_buf, |
746 | priv->dp_out_buf_len ); | 727 | priv->dp_out_buf_len); |
747 | memcpy( data+2+priv->dp_out_buf_len, buf, len ); | 728 | memcpy(data + 2 + priv->dp_out_buf_len, buf, len); |
748 | port->write_urb->transfer_buffer_length | 729 | port->write_urb->transfer_buffer_length |
749 | = priv->dp_out_buf_len+2+len; | 730 | = priv->dp_out_buf_len + 2 + len; |
750 | } else { | 731 | } else { |
751 | memcpy( data, buf, len ); | 732 | memcpy(data, buf, len); |
752 | port->write_urb->transfer_buffer_length = len; | 733 | port->write_urb->transfer_buffer_length = len; |
753 | } | 734 | } |
754 | port->write_urb->dev = port->serial->dev; | 735 | port->write_urb->dev = port->serial->dev; |
755 | 736 | ||
756 | if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) { | 737 | if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) { |
757 | priv->dp_write_urb_in_use = 1; | 738 | priv->dp_write_urb_in_use = 1; |
758 | priv->dp_out_buf_len = 0; | 739 | priv->dp_out_buf_len = 0; |
759 | count -= len; | 740 | count -= len; |
@@ -761,16 +742,12 @@ count ); | |||
761 | } | 742 | } |
762 | 743 | ||
763 | } | 744 | } |
745 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | ||
764 | 746 | ||
765 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 747 | if (ret) |
766 | 748 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | |
767 | if( ret ) { | 749 | __FUNCTION__, ret, priv->dp_port_num); |
768 | err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, | 750 | return ret; |
769 | ret, priv->dp_port_num ); | ||
770 | } | ||
771 | |||
772 | return( ret ); | ||
773 | |||
774 | } | 751 | } |
775 | 752 | ||
776 | 753 | ||
@@ -784,8 +761,8 @@ count ); | |||
784 | * returned by usb_submit_urb. | 761 | * returned by usb_submit_urb. |
785 | */ | 762 | */ |
786 | 763 | ||
787 | static int digi_set_modem_signals( struct usb_serial_port *port, | 764 | static int digi_set_modem_signals(struct usb_serial_port *port, |
788 | unsigned int modem_signals, int interruptible ) | 765 | unsigned int modem_signals, int interruptible) |
789 | { | 766 | { |
790 | 767 | ||
791 | int ret; | 768 | int ret; |
@@ -796,60 +773,47 @@ static int digi_set_modem_signals( struct usb_serial_port *port, | |||
796 | unsigned long flags = 0; | 773 | unsigned long flags = 0; |
797 | 774 | ||
798 | 775 | ||
799 | dbg( "digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x", | 776 | dbg("digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x", |
800 | port_priv->dp_port_num, modem_signals ); | 777 | port_priv->dp_port_num, modem_signals); |
801 | 778 | ||
802 | spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); | 779 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); |
803 | spin_lock( &port_priv->dp_port_lock ); | 780 | spin_lock(&port_priv->dp_port_lock); |
804 | 781 | ||
805 | while( oob_port->write_urb->status == -EINPROGRESS | 782 | while(oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) { |
806 | || oob_priv->dp_write_urb_in_use ) { | 783 | spin_unlock(&port_priv->dp_port_lock); |
807 | spin_unlock( &port_priv->dp_port_lock ); | ||
808 | cond_wait_interruptible_timeout_irqrestore( | 784 | cond_wait_interruptible_timeout_irqrestore( |
809 | &oob_port->write_wait, DIGI_RETRY_TIMEOUT, | 785 | &oob_port->write_wait, DIGI_RETRY_TIMEOUT, |
810 | &oob_priv->dp_port_lock, flags ); | 786 | &oob_priv->dp_port_lock, flags); |
811 | if( interruptible && signal_pending(current) ) { | 787 | if (interruptible && signal_pending(current)) |
812 | return( -EINTR ); | 788 | return -EINTR; |
813 | } | 789 | spin_lock_irqsave(&oob_priv->dp_port_lock, flags); |
814 | spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); | 790 | spin_lock(&port_priv->dp_port_lock); |
815 | spin_lock( &port_priv->dp_port_lock ); | ||
816 | } | 791 | } |
817 | |||
818 | data[0] = DIGI_CMD_SET_DTR_SIGNAL; | 792 | data[0] = DIGI_CMD_SET_DTR_SIGNAL; |
819 | data[1] = port_priv->dp_port_num; | 793 | data[1] = port_priv->dp_port_num; |
820 | data[2] = (modem_signals&TIOCM_DTR) ? | 794 | data[2] = (modem_signals&TIOCM_DTR) ? DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE; |
821 | DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE; | ||
822 | data[3] = 0; | 795 | data[3] = 0; |
823 | |||
824 | data[4] = DIGI_CMD_SET_RTS_SIGNAL; | 796 | data[4] = DIGI_CMD_SET_RTS_SIGNAL; |
825 | data[5] = port_priv->dp_port_num; | 797 | data[5] = port_priv->dp_port_num; |
826 | data[6] = (modem_signals&TIOCM_RTS) ? | 798 | data[6] = (modem_signals&TIOCM_RTS) ? DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE; |
827 | DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE; | ||
828 | data[7] = 0; | 799 | data[7] = 0; |
829 | 800 | ||
830 | oob_port->write_urb->transfer_buffer_length = 8; | 801 | oob_port->write_urb->transfer_buffer_length = 8; |
831 | oob_port->write_urb->dev = port->serial->dev; | 802 | oob_port->write_urb->dev = port->serial->dev; |
832 | 803 | ||
833 | if( (ret=usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0 ) { | 804 | if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) { |
834 | oob_priv->dp_write_urb_in_use = 1; | 805 | oob_priv->dp_write_urb_in_use = 1; |
835 | port_priv->dp_modem_signals = | 806 | port_priv->dp_modem_signals = |
836 | (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS)) | 807 | (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS)) |
837 | | (modem_signals&(TIOCM_DTR|TIOCM_RTS)); | 808 | | (modem_signals&(TIOCM_DTR|TIOCM_RTS)); |
838 | } | 809 | } |
839 | 810 | spin_unlock(&port_priv->dp_port_lock); | |
840 | spin_unlock( &port_priv->dp_port_lock ); | 811 | spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); |
841 | spin_unlock_irqrestore( &oob_priv->dp_port_lock, flags ); | 812 | if (ret) |
842 | 813 | err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret); | |
843 | if( ret ) { | 814 | return ret; |
844 | err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, | ||
845 | ret ); | ||
846 | } | ||
847 | |||
848 | return( ret ); | ||
849 | |||
850 | } | 815 | } |
851 | 816 | ||
852 | |||
853 | /* | 817 | /* |
854 | * Digi Transmit Idle | 818 | * Digi Transmit Idle |
855 | * | 819 | * |
@@ -862,203 +826,182 @@ port_priv->dp_port_num, modem_signals ); | |||
862 | * port at a time, so its ok. | 826 | * port at a time, so its ok. |
863 | */ | 827 | */ |
864 | 828 | ||
865 | static int digi_transmit_idle( struct usb_serial_port *port, | 829 | static int digi_transmit_idle(struct usb_serial_port *port, |
866 | unsigned long timeout ) | 830 | unsigned long timeout) |
867 | { | 831 | { |
868 | |||
869 | int ret; | 832 | int ret; |
870 | unsigned char buf[2]; | 833 | unsigned char buf[2]; |
871 | struct digi_port *priv = usb_get_serial_port_data(port); | 834 | struct digi_port *priv = usb_get_serial_port_data(port); |
872 | unsigned long flags = 0; | 835 | unsigned long flags = 0; |
873 | 836 | ||
874 | 837 | spin_lock_irqsave(&priv->dp_port_lock, flags); | |
875 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | ||
876 | priv->dp_transmit_idle = 0; | 838 | priv->dp_transmit_idle = 0; |
877 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 839 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
878 | 840 | ||
879 | buf[0] = DIGI_CMD_TRANSMIT_IDLE; | 841 | buf[0] = DIGI_CMD_TRANSMIT_IDLE; |
880 | buf[1] = 0; | 842 | buf[1] = 0; |
881 | 843 | ||
882 | timeout += jiffies; | 844 | timeout += jiffies; |
883 | 845 | ||
884 | if( (ret=digi_write_inb_command( port, buf, 2, timeout-jiffies )) != 0 ) | 846 | if ((ret = digi_write_inb_command(port, buf, 2, timeout - jiffies)) != 0) |
885 | return( ret ); | 847 | return ret; |
886 | 848 | ||
887 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 849 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
888 | 850 | ||
889 | while( time_before(jiffies, timeout) && !priv->dp_transmit_idle ) { | 851 | while(time_before(jiffies, timeout) && !priv->dp_transmit_idle) { |
890 | cond_wait_interruptible_timeout_irqrestore( | 852 | cond_wait_interruptible_timeout_irqrestore( |
891 | &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT, | 853 | &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT, |
892 | &priv->dp_port_lock, flags ); | 854 | &priv->dp_port_lock, flags); |
893 | if( signal_pending(current) ) { | 855 | if (signal_pending(current)) |
894 | return( -EINTR ); | 856 | return -EINTR; |
895 | } | 857 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
896 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | ||
897 | } | 858 | } |
898 | |||
899 | priv->dp_transmit_idle = 0; | 859 | priv->dp_transmit_idle = 0; |
900 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 860 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
901 | 861 | return 0; | |
902 | return( 0 ); | ||
903 | 862 | ||
904 | } | 863 | } |
905 | 864 | ||
906 | 865 | ||
907 | static void digi_rx_throttle( struct usb_serial_port *port ) | 866 | static void digi_rx_throttle(struct usb_serial_port *port) |
908 | { | 867 | { |
909 | |||
910 | unsigned long flags; | 868 | unsigned long flags; |
911 | struct digi_port *priv = usb_get_serial_port_data(port); | 869 | struct digi_port *priv = usb_get_serial_port_data(port); |
912 | 870 | ||
913 | 871 | ||
914 | dbg( "digi_rx_throttle: TOP: port=%d", priv->dp_port_num ); | 872 | dbg("digi_rx_throttle: TOP: port=%d", priv->dp_port_num); |
915 | 873 | ||
916 | /* stop receiving characters by not resubmitting the read urb */ | 874 | /* stop receiving characters by not resubmitting the read urb */ |
917 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 875 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
918 | priv->dp_throttled = 1; | 876 | priv->dp_throttled = 1; |
919 | priv->dp_throttle_restart = 0; | 877 | priv->dp_throttle_restart = 0; |
920 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 878 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
921 | |||
922 | } | 879 | } |
923 | 880 | ||
924 | 881 | ||
925 | static void digi_rx_unthrottle( struct usb_serial_port *port ) | 882 | static void digi_rx_unthrottle(struct usb_serial_port *port) |
926 | { | 883 | { |
927 | |||
928 | int ret = 0; | 884 | int ret = 0; |
929 | unsigned long flags; | 885 | unsigned long flags; |
930 | struct digi_port *priv = usb_get_serial_port_data(port); | 886 | struct digi_port *priv = usb_get_serial_port_data(port); |
931 | 887 | ||
932 | dbg( "digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num ); | 888 | dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num); |
933 | 889 | ||
934 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 890 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
935 | 891 | ||
936 | /* turn throttle off */ | 892 | /* turn throttle off */ |
937 | priv->dp_throttled = 0; | 893 | priv->dp_throttled = 0; |
938 | priv->dp_throttle_restart = 0; | 894 | priv->dp_throttle_restart = 0; |
939 | 895 | ||
940 | /* restart read chain */ | 896 | /* restart read chain */ |
941 | if( priv->dp_throttle_restart ) { | 897 | if (priv->dp_throttle_restart) { |
942 | port->read_urb->dev = port->serial->dev; | 898 | port->read_urb->dev = port->serial->dev; |
943 | ret = usb_submit_urb( port->read_urb, GFP_ATOMIC ); | 899 | ret = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
944 | } | 900 | } |
945 | 901 | ||
946 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 902 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
947 | |||
948 | if( ret ) { | ||
949 | err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, | ||
950 | ret, priv->dp_port_num ); | ||
951 | } | ||
952 | 903 | ||
904 | if (ret) | ||
905 | err("%s: usb_submit_urb failed, ret=%d, port=%d", | ||
906 | __FUNCTION__, ret, priv->dp_port_num); | ||
953 | } | 907 | } |
954 | 908 | ||
955 | 909 | ||
956 | static void digi_set_termios( struct usb_serial_port *port, | 910 | static void digi_set_termios(struct usb_serial_port *port, |
957 | struct ktermios *old_termios ) | 911 | struct ktermios *old_termios) |
958 | { | 912 | { |
959 | 913 | ||
960 | struct digi_port *priv = usb_get_serial_port_data(port); | 914 | struct digi_port *priv = usb_get_serial_port_data(port); |
961 | unsigned int iflag = port->tty->termios->c_iflag; | 915 | struct tty_struct *tty = port->tty; |
962 | unsigned int cflag = port->tty->termios->c_cflag; | 916 | unsigned int iflag = tty->termios->c_iflag; |
917 | unsigned int cflag = tty->termios->c_cflag; | ||
963 | unsigned int old_iflag = old_termios->c_iflag; | 918 | unsigned int old_iflag = old_termios->c_iflag; |
964 | unsigned int old_cflag = old_termios->c_cflag; | 919 | unsigned int old_cflag = old_termios->c_cflag; |
965 | unsigned char buf[32]; | 920 | unsigned char buf[32]; |
966 | unsigned int modem_signals; | 921 | unsigned int modem_signals; |
967 | int arg,ret; | 922 | int arg,ret; |
968 | int i = 0; | 923 | int i = 0; |
924 | speed_t baud; | ||
969 | 925 | ||
970 | 926 | dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag); | |
971 | dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag ); | ||
972 | 927 | ||
973 | /* set baud rate */ | 928 | /* set baud rate */ |
974 | if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { | 929 | if ((baud = tty_get_baud_rate(tty)) != tty_termios_baud_rate(old_termios)) { |
975 | |||
976 | arg = -1; | 930 | arg = -1; |
977 | 931 | ||
978 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 932 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
979 | if( (old_cflag&CBAUD) == B0 ) { | 933 | if ((old_cflag&CBAUD) == B0) { |
980 | /* don't set RTS if using hardware flow control */ | 934 | /* don't set RTS if using hardware flow control */ |
981 | /* and throttling input */ | 935 | /* and throttling input */ |
982 | modem_signals = TIOCM_DTR; | 936 | modem_signals = TIOCM_DTR; |
983 | if( !(port->tty->termios->c_cflag & CRTSCTS) || | 937 | if (!(tty->termios->c_cflag & CRTSCTS) || |
984 | !test_bit(TTY_THROTTLED, &port->tty->flags) ) { | 938 | !test_bit(TTY_THROTTLED, &tty->flags)) |
985 | modem_signals |= TIOCM_RTS; | 939 | modem_signals |= TIOCM_RTS; |
986 | } | 940 | digi_set_modem_signals(port, modem_signals, 1); |
987 | digi_set_modem_signals( port, modem_signals, 1 ); | ||
988 | } | 941 | } |
989 | 942 | switch (baud) { | |
990 | switch( (cflag&CBAUD) ) { | ||
991 | /* drop DTR and RTS on transition to B0 */ | 943 | /* drop DTR and RTS on transition to B0 */ |
992 | case B0: digi_set_modem_signals( port, 0, 1 ); break; | 944 | case 0: digi_set_modem_signals(port, 0, 1); break; |
993 | case B50: arg = DIGI_BAUD_50; break; | 945 | case 50: arg = DIGI_BAUD_50; break; |
994 | case B75: arg = DIGI_BAUD_75; break; | 946 | case 75: arg = DIGI_BAUD_75; break; |
995 | case B110: arg = DIGI_BAUD_110; break; | 947 | case 110: arg = DIGI_BAUD_110; break; |
996 | case B150: arg = DIGI_BAUD_150; break; | 948 | case 150: arg = DIGI_BAUD_150; break; |
997 | case B200: arg = DIGI_BAUD_200; break; | 949 | case 200: arg = DIGI_BAUD_200; break; |
998 | case B300: arg = DIGI_BAUD_300; break; | 950 | case 300: arg = DIGI_BAUD_300; break; |
999 | case B600: arg = DIGI_BAUD_600; break; | 951 | case 600: arg = DIGI_BAUD_600; break; |
1000 | case B1200: arg = DIGI_BAUD_1200; break; | 952 | case 1200: arg = DIGI_BAUD_1200; break; |
1001 | case B1800: arg = DIGI_BAUD_1800; break; | 953 | case 1800: arg = DIGI_BAUD_1800; break; |
1002 | case B2400: arg = DIGI_BAUD_2400; break; | 954 | case 2400: arg = DIGI_BAUD_2400; break; |
1003 | case B4800: arg = DIGI_BAUD_4800; break; | 955 | case 4800: arg = DIGI_BAUD_4800; break; |
1004 | case B9600: arg = DIGI_BAUD_9600; break; | 956 | case 9600: arg = DIGI_BAUD_9600; break; |
1005 | case B19200: arg = DIGI_BAUD_19200; break; | 957 | case 19200: arg = DIGI_BAUD_19200; break; |
1006 | case B38400: arg = DIGI_BAUD_38400; break; | 958 | case 38400: arg = DIGI_BAUD_38400; break; |
1007 | case B57600: arg = DIGI_BAUD_57600; break; | 959 | case 57600: arg = DIGI_BAUD_57600; break; |
1008 | case B115200: arg = DIGI_BAUD_115200; break; | 960 | case 115200: arg = DIGI_BAUD_115200; break; |
1009 | case B230400: arg = DIGI_BAUD_230400; break; | 961 | case 230400: arg = DIGI_BAUD_230400; break; |
1010 | case B460800: arg = DIGI_BAUD_460800; break; | 962 | case 460800: arg = DIGI_BAUD_460800; break; |
1011 | default: | 963 | default: |
1012 | dbg( "digi_set_termios: can't handle baud rate 0x%x", | 964 | arg = DIGI_BAUD_9600; |
1013 | (cflag&CBAUD) ); | 965 | baud = 9600; |
1014 | break; | 966 | break; |
1015 | } | 967 | } |
1016 | 968 | if (arg != -1) { | |
1017 | if( arg != -1 ) { | ||
1018 | buf[i++] = DIGI_CMD_SET_BAUD_RATE; | 969 | buf[i++] = DIGI_CMD_SET_BAUD_RATE; |
1019 | buf[i++] = priv->dp_port_num; | 970 | buf[i++] = priv->dp_port_num; |
1020 | buf[i++] = arg; | 971 | buf[i++] = arg; |
1021 | buf[i++] = 0; | 972 | buf[i++] = 0; |
1022 | } | 973 | } |
1023 | |||
1024 | } | 974 | } |
1025 | |||
1026 | /* set parity */ | 975 | /* set parity */ |
1027 | if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) { | 976 | if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) { |
1028 | 977 | if (cflag&PARENB) { | |
1029 | if( (cflag&PARENB) ) { | 978 | if (cflag&PARODD) |
1030 | if( (cflag&PARODD) ) | ||
1031 | arg = DIGI_PARITY_ODD; | 979 | arg = DIGI_PARITY_ODD; |
1032 | else | 980 | else |
1033 | arg = DIGI_PARITY_EVEN; | 981 | arg = DIGI_PARITY_EVEN; |
1034 | } else { | 982 | } else { |
1035 | arg = DIGI_PARITY_NONE; | 983 | arg = DIGI_PARITY_NONE; |
1036 | } | 984 | } |
1037 | |||
1038 | buf[i++] = DIGI_CMD_SET_PARITY; | 985 | buf[i++] = DIGI_CMD_SET_PARITY; |
1039 | buf[i++] = priv->dp_port_num; | 986 | buf[i++] = priv->dp_port_num; |
1040 | buf[i++] = arg; | 987 | buf[i++] = arg; |
1041 | buf[i++] = 0; | 988 | buf[i++] = 0; |
1042 | |||
1043 | } | 989 | } |
1044 | |||
1045 | /* set word size */ | 990 | /* set word size */ |
1046 | if( (cflag&CSIZE) != (old_cflag&CSIZE) ) { | 991 | if ((cflag&CSIZE) != (old_cflag&CSIZE)) { |
1047 | |||
1048 | arg = -1; | 992 | arg = -1; |
1049 | 993 | switch (cflag&CSIZE) { | |
1050 | switch( (cflag&CSIZE) ) { | ||
1051 | case CS5: arg = DIGI_WORD_SIZE_5; break; | 994 | case CS5: arg = DIGI_WORD_SIZE_5; break; |
1052 | case CS6: arg = DIGI_WORD_SIZE_6; break; | 995 | case CS6: arg = DIGI_WORD_SIZE_6; break; |
1053 | case CS7: arg = DIGI_WORD_SIZE_7; break; | 996 | case CS7: arg = DIGI_WORD_SIZE_7; break; |
1054 | case CS8: arg = DIGI_WORD_SIZE_8; break; | 997 | case CS8: arg = DIGI_WORD_SIZE_8; break; |
1055 | default: | 998 | default: |
1056 | dbg( "digi_set_termios: can't handle word size %d", | 999 | dbg("digi_set_termios: can't handle word size %d", |
1057 | (cflag&CSIZE) ); | 1000 | (cflag&CSIZE)); |
1058 | break; | 1001 | break; |
1059 | } | 1002 | } |
1060 | 1003 | ||
1061 | if( arg != -1 ) { | 1004 | if (arg != -1) { |
1062 | buf[i++] = DIGI_CMD_SET_WORD_SIZE; | 1005 | buf[i++] = DIGI_CMD_SET_WORD_SIZE; |
1063 | buf[i++] = priv->dp_port_num; | 1006 | buf[i++] = priv->dp_port_num; |
1064 | buf[i++] = arg; | 1007 | buf[i++] = arg; |
@@ -1068,9 +1011,9 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol | |||
1068 | } | 1011 | } |
1069 | 1012 | ||
1070 | /* set stop bits */ | 1013 | /* set stop bits */ |
1071 | if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) { | 1014 | if ((cflag&CSTOPB) != (old_cflag&CSTOPB)) { |
1072 | 1015 | ||
1073 | if( (cflag&CSTOPB) ) | 1016 | if ((cflag&CSTOPB)) |
1074 | arg = DIGI_STOP_BITS_2; | 1017 | arg = DIGI_STOP_BITS_2; |
1075 | else | 1018 | else |
1076 | arg = DIGI_STOP_BITS_1; | 1019 | arg = DIGI_STOP_BITS_1; |
@@ -1083,18 +1026,15 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol | |||
1083 | } | 1026 | } |
1084 | 1027 | ||
1085 | /* set input flow control */ | 1028 | /* set input flow control */ |
1086 | if( (iflag&IXOFF) != (old_iflag&IXOFF) | 1029 | if ((iflag&IXOFF) != (old_iflag&IXOFF) |
1087 | || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) { | 1030 | || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) { |
1088 | |||
1089 | arg = 0; | 1031 | arg = 0; |
1090 | 1032 | if (iflag&IXOFF) | |
1091 | if( (iflag&IXOFF) ) | ||
1092 | arg |= DIGI_INPUT_FLOW_CONTROL_XON_XOFF; | 1033 | arg |= DIGI_INPUT_FLOW_CONTROL_XON_XOFF; |
1093 | else | 1034 | else |
1094 | arg &= ~DIGI_INPUT_FLOW_CONTROL_XON_XOFF; | 1035 | arg &= ~DIGI_INPUT_FLOW_CONTROL_XON_XOFF; |
1095 | 1036 | ||
1096 | if( (cflag&CRTSCTS) ) { | 1037 | if (cflag&CRTSCTS) { |
1097 | |||
1098 | arg |= DIGI_INPUT_FLOW_CONTROL_RTS; | 1038 | arg |= DIGI_INPUT_FLOW_CONTROL_RTS; |
1099 | 1039 | ||
1100 | /* On USB-4 it is necessary to assert RTS prior */ | 1040 | /* On USB-4 it is necessary to assert RTS prior */ |
@@ -1107,43 +1047,37 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol | |||
1107 | } else { | 1047 | } else { |
1108 | arg &= ~DIGI_INPUT_FLOW_CONTROL_RTS; | 1048 | arg &= ~DIGI_INPUT_FLOW_CONTROL_RTS; |
1109 | } | 1049 | } |
1110 | |||
1111 | buf[i++] = DIGI_CMD_SET_INPUT_FLOW_CONTROL; | 1050 | buf[i++] = DIGI_CMD_SET_INPUT_FLOW_CONTROL; |
1112 | buf[i++] = priv->dp_port_num; | 1051 | buf[i++] = priv->dp_port_num; |
1113 | buf[i++] = arg; | 1052 | buf[i++] = arg; |
1114 | buf[i++] = 0; | 1053 | buf[i++] = 0; |
1115 | |||
1116 | } | 1054 | } |
1117 | 1055 | ||
1118 | /* set output flow control */ | 1056 | /* set output flow control */ |
1119 | if( (iflag&IXON) != (old_iflag&IXON) | 1057 | if ((iflag&IXON) != (old_iflag&IXON) |
1120 | || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) { | 1058 | || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) { |
1121 | |||
1122 | arg = 0; | 1059 | arg = 0; |
1123 | 1060 | if (iflag&IXON) | |
1124 | if( (iflag&IXON) ) | ||
1125 | arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; | 1061 | arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; |
1126 | else | 1062 | else |
1127 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; | 1063 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; |
1128 | 1064 | ||
1129 | if( (cflag&CRTSCTS) ) { | 1065 | if (cflag&CRTSCTS) { |
1130 | arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; | 1066 | arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; |
1131 | } else { | 1067 | } else { |
1132 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; | 1068 | arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; |
1133 | port->tty->hw_stopped = 0; | 1069 | tty->hw_stopped = 0; |
1134 | } | 1070 | } |
1135 | 1071 | ||
1136 | buf[i++] = DIGI_CMD_SET_OUTPUT_FLOW_CONTROL; | 1072 | buf[i++] = DIGI_CMD_SET_OUTPUT_FLOW_CONTROL; |
1137 | buf[i++] = priv->dp_port_num; | 1073 | buf[i++] = priv->dp_port_num; |
1138 | buf[i++] = arg; | 1074 | buf[i++] = arg; |
1139 | buf[i++] = 0; | 1075 | buf[i++] = 0; |
1140 | |||
1141 | } | 1076 | } |
1142 | 1077 | ||
1143 | /* set receive enable/disable */ | 1078 | /* set receive enable/disable */ |
1144 | if( (cflag&CREAD) != (old_cflag&CREAD) ) { | 1079 | if ((cflag&CREAD) != (old_cflag&CREAD)) { |
1145 | 1080 | if (cflag&CREAD) | |
1146 | if( (cflag&CREAD) ) | ||
1147 | arg = DIGI_ENABLE; | 1081 | arg = DIGI_ENABLE; |
1148 | else | 1082 | else |
1149 | arg = DIGI_DISABLE; | 1083 | arg = DIGI_DISABLE; |
@@ -1152,32 +1086,26 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol | |||
1152 | buf[i++] = priv->dp_port_num; | 1086 | buf[i++] = priv->dp_port_num; |
1153 | buf[i++] = arg; | 1087 | buf[i++] = arg; |
1154 | buf[i++] = 0; | 1088 | buf[i++] = 0; |
1155 | |||
1156 | } | 1089 | } |
1157 | 1090 | if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0) | |
1158 | if( (ret=digi_write_oob_command( port, buf, i, 1 )) != 0 ) | 1091 | dbg("digi_set_termios: write oob failed, ret=%d", ret); |
1159 | dbg( "digi_set_termios: write oob failed, ret=%d", ret ); | ||
1160 | 1092 | ||
1161 | } | 1093 | } |
1162 | 1094 | ||
1163 | 1095 | ||
1164 | static void digi_break_ctl( struct usb_serial_port *port, int break_state ) | 1096 | static void digi_break_ctl(struct usb_serial_port *port, int break_state) |
1165 | { | 1097 | { |
1166 | |||
1167 | unsigned char buf[4]; | 1098 | unsigned char buf[4]; |
1168 | 1099 | ||
1169 | |||
1170 | buf[0] = DIGI_CMD_BREAK_CONTROL; | 1100 | buf[0] = DIGI_CMD_BREAK_CONTROL; |
1171 | buf[1] = 2; /* length */ | 1101 | buf[1] = 2; /* length */ |
1172 | buf[2] = break_state ? 1 : 0; | 1102 | buf[2] = break_state ? 1 : 0; |
1173 | buf[3] = 0; /* pad */ | 1103 | buf[3] = 0; /* pad */ |
1174 | 1104 | digi_write_inb_command(port, buf, 4, 0); | |
1175 | digi_write_inb_command( port, buf, 4, 0 ); | ||
1176 | |||
1177 | } | 1105 | } |
1178 | 1106 | ||
1179 | 1107 | ||
1180 | static int digi_tiocmget( struct usb_serial_port *port, struct file *file ) | 1108 | static int digi_tiocmget(struct usb_serial_port *port, struct file *file) |
1181 | { | 1109 | { |
1182 | struct digi_port *priv = usb_get_serial_port_data(port); | 1110 | struct digi_port *priv = usb_get_serial_port_data(port); |
1183 | unsigned int val; | 1111 | unsigned int val; |
@@ -1185,15 +1113,15 @@ static int digi_tiocmget( struct usb_serial_port *port, struct file *file ) | |||
1185 | 1113 | ||
1186 | dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); | 1114 | dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); |
1187 | 1115 | ||
1188 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1116 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1189 | val = priv->dp_modem_signals; | 1117 | val = priv->dp_modem_signals; |
1190 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1118 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1191 | return val; | 1119 | return val; |
1192 | } | 1120 | } |
1193 | 1121 | ||
1194 | 1122 | ||
1195 | static int digi_tiocmset( struct usb_serial_port *port, struct file *file, | 1123 | static int digi_tiocmset(struct usb_serial_port *port, struct file *file, |
1196 | unsigned int set, unsigned int clear ) | 1124 | unsigned int set, unsigned int clear) |
1197 | { | 1125 | { |
1198 | struct digi_port *priv = usb_get_serial_port_data(port); | 1126 | struct digi_port *priv = usb_get_serial_port_data(port); |
1199 | unsigned int val; | 1127 | unsigned int val; |
@@ -1201,41 +1129,34 @@ static int digi_tiocmset( struct usb_serial_port *port, struct file *file, | |||
1201 | 1129 | ||
1202 | dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); | 1130 | dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); |
1203 | 1131 | ||
1204 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1132 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1205 | val = (priv->dp_modem_signals & ~clear) | set; | 1133 | val = (priv->dp_modem_signals & ~clear) | set; |
1206 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1134 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1207 | return digi_set_modem_signals( port, val, 1 ); | 1135 | return digi_set_modem_signals(port, val, 1); |
1208 | } | 1136 | } |
1209 | 1137 | ||
1210 | 1138 | ||
1211 | static int digi_ioctl( struct usb_serial_port *port, struct file *file, | 1139 | static int digi_ioctl(struct usb_serial_port *port, struct file *file, |
1212 | unsigned int cmd, unsigned long arg ) | 1140 | unsigned int cmd, unsigned long arg) |
1213 | { | 1141 | { |
1214 | |||
1215 | struct digi_port *priv = usb_get_serial_port_data(port); | 1142 | struct digi_port *priv = usb_get_serial_port_data(port); |
1216 | 1143 | dbg("digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd); | |
1217 | dbg( "digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd ); | ||
1218 | 1144 | ||
1219 | switch (cmd) { | 1145 | switch (cmd) { |
1220 | |||
1221 | case TIOCMIWAIT: | 1146 | case TIOCMIWAIT: |
1222 | /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ | 1147 | /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ |
1223 | /* TODO */ | 1148 | /* TODO */ |
1224 | return( 0 ); | 1149 | return 0; |
1225 | |||
1226 | case TIOCGICOUNT: | 1150 | case TIOCGICOUNT: |
1227 | /* return count of modemline transitions */ | 1151 | /* return count of modemline transitions */ |
1228 | /* TODO */ | 1152 | /* TODO */ |
1229 | return 0; | 1153 | return 0; |
1230 | |||
1231 | } | 1154 | } |
1232 | 1155 | return -ENOIOCTLCMD; | |
1233 | return( -ENOIOCTLCMD ); | ||
1234 | 1156 | ||
1235 | } | 1157 | } |
1236 | 1158 | ||
1237 | 1159 | static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count) | |
1238 | static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count ) | ||
1239 | { | 1160 | { |
1240 | 1161 | ||
1241 | int ret,data_len,new_len; | 1162 | int ret,data_len,new_len; |
@@ -1243,35 +1164,29 @@ static int digi_write( struct usb_serial_port *port, const unsigned char *buf, i | |||
1243 | unsigned char *data = port->write_urb->transfer_buffer; | 1164 | unsigned char *data = port->write_urb->transfer_buffer; |
1244 | unsigned long flags = 0; | 1165 | unsigned long flags = 0; |
1245 | 1166 | ||
1246 | 1167 | dbg("digi_write: TOP: port=%d, count=%d, in_interrupt=%ld", | |
1247 | dbg( "digi_write: TOP: port=%d, count=%d, in_interrupt=%ld", | 1168 | priv->dp_port_num, count, in_interrupt()); |
1248 | priv->dp_port_num, count, in_interrupt() ); | ||
1249 | 1169 | ||
1250 | /* copy user data (which can sleep) before getting spin lock */ | 1170 | /* copy user data (which can sleep) before getting spin lock */ |
1251 | count = min( count, port->bulk_out_size-2 ); | 1171 | count = min(count, port->bulk_out_size-2); |
1252 | count = min( 64, count); | 1172 | count = min(64, count); |
1253 | 1173 | ||
1254 | /* be sure only one write proceeds at a time */ | 1174 | /* be sure only one write proceeds at a time */ |
1255 | /* there are races on the port private buffer */ | 1175 | /* there are races on the port private buffer */ |
1256 | /* and races to check write_urb->status */ | 1176 | /* and races to check write_urb->status */ |
1257 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1177 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1258 | 1178 | ||
1259 | /* wait for urb status clear to submit another urb */ | 1179 | /* wait for urb status clear to submit another urb */ |
1260 | if( port->write_urb->status == -EINPROGRESS | 1180 | if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) { |
1261 | || priv->dp_write_urb_in_use ) { | ||
1262 | |||
1263 | /* buffer data if count is 1 (probably put_char) if possible */ | 1181 | /* buffer data if count is 1 (probably put_char) if possible */ |
1264 | if( count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE ) { | 1182 | if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) { |
1265 | priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; | 1183 | priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; |
1266 | new_len = 1; | 1184 | new_len = 1; |
1267 | } else { | 1185 | } else { |
1268 | new_len = 0; | 1186 | new_len = 0; |
1269 | } | 1187 | } |
1270 | 1188 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | |
1271 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1189 | return new_len; |
1272 | |||
1273 | return( new_len ); | ||
1274 | |||
1275 | } | 1190 | } |
1276 | 1191 | ||
1277 | /* allow space for any buffered data and for new data, up to */ | 1192 | /* allow space for any buffered data and for new data, up to */ |
@@ -1279,9 +1194,9 @@ priv->dp_port_num, count, in_interrupt() ); | |||
1279 | new_len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len); | 1194 | new_len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len); |
1280 | data_len = new_len + priv->dp_out_buf_len; | 1195 | data_len = new_len + priv->dp_out_buf_len; |
1281 | 1196 | ||
1282 | if( data_len == 0 ) { | 1197 | if (data_len == 0) { |
1283 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1198 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1284 | return( 0 ); | 1199 | return 0; |
1285 | } | 1200 | } |
1286 | 1201 | ||
1287 | port->write_urb->transfer_buffer_length = data_len+2; | 1202 | port->write_urb->transfer_buffer_length = data_len+2; |
@@ -1291,32 +1206,29 @@ priv->dp_port_num, count, in_interrupt() ); | |||
1291 | *data++ = data_len; | 1206 | *data++ = data_len; |
1292 | 1207 | ||
1293 | /* copy in buffered data first */ | 1208 | /* copy in buffered data first */ |
1294 | memcpy( data, priv->dp_out_buf, priv->dp_out_buf_len ); | 1209 | memcpy(data, priv->dp_out_buf, priv->dp_out_buf_len); |
1295 | data += priv->dp_out_buf_len; | 1210 | data += priv->dp_out_buf_len; |
1296 | 1211 | ||
1297 | /* copy in new data */ | 1212 | /* copy in new data */ |
1298 | memcpy( data, buf, new_len ); | 1213 | memcpy(data, buf, new_len); |
1299 | 1214 | ||
1300 | if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) { | 1215 | if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) { |
1301 | priv->dp_write_urb_in_use = 1; | 1216 | priv->dp_write_urb_in_use = 1; |
1302 | ret = new_len; | 1217 | ret = new_len; |
1303 | priv->dp_out_buf_len = 0; | 1218 | priv->dp_out_buf_len = 0; |
1304 | } | 1219 | } |
1305 | 1220 | ||
1306 | /* return length of new data written, or error */ | 1221 | /* return length of new data written, or error */ |
1307 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1222 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1308 | if( ret < 0 ) { | 1223 | if (ret < 0) |
1309 | err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, | 1224 | err("%s: usb_submit_urb failed, ret=%d, port=%d", |
1310 | ret, priv->dp_port_num ); | 1225 | __FUNCTION__, ret, priv->dp_port_num); |
1311 | } | 1226 | dbg("digi_write: returning %d", ret); |
1312 | 1227 | return ret; | |
1313 | dbg( "digi_write: returning %d", ret ); | ||
1314 | return( ret ); | ||
1315 | 1228 | ||
1316 | } | 1229 | } |
1317 | 1230 | ||
1318 | 1231 | static void digi_write_bulk_callback(struct urb *urb) | |
1319 | static void digi_write_bulk_callback( struct urb *urb ) | ||
1320 | { | 1232 | { |
1321 | 1233 | ||
1322 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 1234 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
@@ -1326,153 +1238,136 @@ static void digi_write_bulk_callback( struct urb *urb ) | |||
1326 | int ret = 0; | 1238 | int ret = 0; |
1327 | int status = urb->status; | 1239 | int status = urb->status; |
1328 | 1240 | ||
1329 | 1241 | dbg("digi_write_bulk_callback: TOP, urb->status=%d", status); | |
1330 | dbg("digi_write_bulk_callback: TOP, urb status=%d", status); | ||
1331 | 1242 | ||
1332 | /* port and serial sanity check */ | 1243 | /* port and serial sanity check */ |
1333 | if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) { | 1244 | if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) { |
1334 | err("%s: port or port->private is NULL, status=%d", | 1245 | err("%s: port or port->private is NULL, status=%d", |
1335 | __FUNCTION__, status); | 1246 | __FUNCTION__, status); |
1336 | return; | 1247 | return; |
1337 | } | 1248 | } |
1338 | serial = port->serial; | 1249 | serial = port->serial; |
1339 | if( serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL ) { | 1250 | if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) { |
1340 | err("%s: serial or serial->private is NULL, status=%d", | 1251 | err("%s: serial or serial->private is NULL, status=%d", |
1341 | __FUNCTION__, status); | 1252 | __FUNCTION__, status); |
1342 | return; | 1253 | return; |
1343 | } | 1254 | } |
1344 | 1255 | ||
1345 | /* handle oob callback */ | 1256 | /* handle oob callback */ |
1346 | if( priv->dp_port_num == serial_priv->ds_oob_port_num ) { | 1257 | if (priv->dp_port_num == serial_priv->ds_oob_port_num) { |
1347 | dbg( "digi_write_bulk_callback: oob callback" ); | 1258 | dbg("digi_write_bulk_callback: oob callback"); |
1348 | spin_lock( &priv->dp_port_lock ); | 1259 | spin_lock(&priv->dp_port_lock); |
1349 | priv->dp_write_urb_in_use = 0; | 1260 | priv->dp_write_urb_in_use = 0; |
1350 | wake_up_interruptible( &port->write_wait ); | 1261 | wake_up_interruptible(&port->write_wait); |
1351 | spin_unlock( &priv->dp_port_lock ); | 1262 | spin_unlock(&priv->dp_port_lock); |
1352 | return; | 1263 | return; |
1353 | } | 1264 | } |
1354 | 1265 | ||
1355 | /* try to send any buffered data on this port, if it is open */ | 1266 | /* try to send any buffered data on this port, if it is open */ |
1356 | spin_lock( &priv->dp_port_lock ); | 1267 | spin_lock(&priv->dp_port_lock); |
1357 | priv->dp_write_urb_in_use = 0; | 1268 | priv->dp_write_urb_in_use = 0; |
1358 | if( port->open_count && port->write_urb->status != -EINPROGRESS | 1269 | if (port->open_count && port->write_urb->status != -EINPROGRESS |
1359 | && priv->dp_out_buf_len > 0 ) { | 1270 | && priv->dp_out_buf_len > 0) { |
1360 | |||
1361 | *((unsigned char *)(port->write_urb->transfer_buffer)) | 1271 | *((unsigned char *)(port->write_urb->transfer_buffer)) |
1362 | = (unsigned char)DIGI_CMD_SEND_DATA; | 1272 | = (unsigned char)DIGI_CMD_SEND_DATA; |
1363 | *((unsigned char *)(port->write_urb->transfer_buffer)+1) | 1273 | *((unsigned char *)(port->write_urb->transfer_buffer)+1) |
1364 | = (unsigned char)priv->dp_out_buf_len; | 1274 | = (unsigned char)priv->dp_out_buf_len; |
1365 | 1275 | port->write_urb->transfer_buffer_length = priv->dp_out_buf_len+2; | |
1366 | port->write_urb->transfer_buffer_length | ||
1367 | = priv->dp_out_buf_len+2; | ||
1368 | port->write_urb->dev = serial->dev; | 1276 | port->write_urb->dev = serial->dev; |
1369 | 1277 | memcpy(port->write_urb->transfer_buffer+2, priv->dp_out_buf, | |
1370 | memcpy( port->write_urb->transfer_buffer+2, priv->dp_out_buf, | 1278 | priv->dp_out_buf_len); |
1371 | priv->dp_out_buf_len ); | 1279 | if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) { |
1372 | |||
1373 | if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) { | ||
1374 | priv->dp_write_urb_in_use = 1; | 1280 | priv->dp_write_urb_in_use = 1; |
1375 | priv->dp_out_buf_len = 0; | 1281 | priv->dp_out_buf_len = 0; |
1376 | } | 1282 | } |
1377 | |||
1378 | } | 1283 | } |
1379 | |||
1380 | /* wake up processes sleeping on writes immediately */ | 1284 | /* wake up processes sleeping on writes immediately */ |
1381 | digi_wakeup_write( port ); | 1285 | digi_wakeup_write(port); |
1382 | |||
1383 | /* also queue up a wakeup at scheduler time, in case we */ | 1286 | /* also queue up a wakeup at scheduler time, in case we */ |
1384 | /* lost the race in write_chan(). */ | 1287 | /* lost the race in write_chan(). */ |
1385 | schedule_work(&priv->dp_wakeup_work); | 1288 | schedule_work(&priv->dp_wakeup_work); |
1386 | 1289 | ||
1387 | spin_unlock( &priv->dp_port_lock ); | 1290 | spin_unlock(&priv->dp_port_lock); |
1388 | 1291 | if (ret) | |
1389 | if( ret ) { | 1292 | err("%s: usb_submit_urb failed, ret=%d, port=%d", |
1390 | err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, | 1293 | __FUNCTION__, ret, priv->dp_port_num); |
1391 | ret, priv->dp_port_num ); | ||
1392 | } | ||
1393 | |||
1394 | } | 1294 | } |
1395 | 1295 | ||
1396 | 1296 | static int digi_write_room(struct usb_serial_port *port) | |
1397 | static int digi_write_room( struct usb_serial_port *port ) | ||
1398 | { | 1297 | { |
1399 | 1298 | ||
1400 | int room; | 1299 | int room; |
1401 | struct digi_port *priv = usb_get_serial_port_data(port); | 1300 | struct digi_port *priv = usb_get_serial_port_data(port); |
1402 | unsigned long flags = 0; | 1301 | unsigned long flags = 0; |
1403 | 1302 | ||
1303 | spin_lock_irqsave(&priv->dp_port_lock, flags); | ||
1404 | 1304 | ||
1405 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1305 | if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) |
1406 | |||
1407 | if( port->write_urb->status == -EINPROGRESS | ||
1408 | || priv->dp_write_urb_in_use ) | ||
1409 | room = 0; | 1306 | room = 0; |
1410 | else | 1307 | else |
1411 | room = port->bulk_out_size - 2 - priv->dp_out_buf_len; | 1308 | room = port->bulk_out_size - 2 - priv->dp_out_buf_len; |
1412 | 1309 | ||
1413 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1310 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1414 | 1311 | dbg("digi_write_room: port=%d, room=%d", priv->dp_port_num, room); | |
1415 | dbg( "digi_write_room: port=%d, room=%d", priv->dp_port_num, room ); | 1312 | return room; |
1416 | return( room ); | ||
1417 | 1313 | ||
1418 | } | 1314 | } |
1419 | 1315 | ||
1420 | 1316 | static int digi_chars_in_buffer(struct usb_serial_port *port) | |
1421 | static int digi_chars_in_buffer( struct usb_serial_port *port ) | ||
1422 | { | 1317 | { |
1423 | 1318 | ||
1424 | struct digi_port *priv = usb_get_serial_port_data(port); | 1319 | struct digi_port *priv = usb_get_serial_port_data(port); |
1425 | 1320 | ||
1426 | 1321 | ||
1427 | if( port->write_urb->status == -EINPROGRESS | 1322 | if (port->write_urb->status == -EINPROGRESS |
1428 | || priv->dp_write_urb_in_use ) { | 1323 | || priv->dp_write_urb_in_use) { |
1429 | dbg( "digi_chars_in_buffer: port=%d, chars=%d", priv->dp_port_num, port->bulk_out_size - 2 ); | 1324 | dbg("digi_chars_in_buffer: port=%d, chars=%d", |
1430 | /* return( port->bulk_out_size - 2 ); */ | 1325 | priv->dp_port_num, port->bulk_out_size - 2); |
1431 | return( 256 ); | 1326 | /* return(port->bulk_out_size - 2); */ |
1327 | return 256; | ||
1432 | } else { | 1328 | } else { |
1433 | dbg( "digi_chars_in_buffer: port=%d, chars=%d", priv->dp_port_num, priv->dp_out_buf_len ); | 1329 | dbg("digi_chars_in_buffer: port=%d, chars=%d", |
1434 | return( priv->dp_out_buf_len ); | 1330 | priv->dp_port_num, priv->dp_out_buf_len); |
1331 | return priv->dp_out_buf_len; | ||
1435 | } | 1332 | } |
1436 | 1333 | ||
1437 | } | 1334 | } |
1438 | 1335 | ||
1439 | 1336 | ||
1440 | static int digi_open( struct usb_serial_port *port, struct file *filp ) | 1337 | static int digi_open(struct usb_serial_port *port, struct file *filp) |
1441 | { | 1338 | { |
1442 | |||
1443 | int ret; | 1339 | int ret; |
1444 | unsigned char buf[32]; | 1340 | unsigned char buf[32]; |
1445 | struct digi_port *priv = usb_get_serial_port_data(port); | 1341 | struct digi_port *priv = usb_get_serial_port_data(port); |
1446 | struct ktermios not_termios; | 1342 | struct ktermios not_termios; |
1447 | unsigned long flags = 0; | 1343 | unsigned long flags = 0; |
1448 | 1344 | ||
1449 | 1345 | dbg("digi_open: TOP: port=%d, open_count=%d", | |
1450 | dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count ); | 1346 | priv->dp_port_num, port->open_count); |
1451 | 1347 | ||
1452 | /* be sure the device is started up */ | 1348 | /* be sure the device is started up */ |
1453 | if( digi_startup_device( port->serial ) != 0 ) | 1349 | if (digi_startup_device(port->serial) != 0) |
1454 | return( -ENXIO ); | 1350 | return -ENXIO; |
1455 | 1351 | ||
1456 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1352 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1457 | 1353 | ||
1458 | /* don't wait on a close in progress for non-blocking opens */ | 1354 | /* don't wait on a close in progress for non-blocking opens */ |
1459 | if( priv->dp_in_close && (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0 ) { | 1355 | if (priv->dp_in_close && (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) { |
1460 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1356 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1461 | return( -EAGAIN ); | 1357 | return -EAGAIN; |
1462 | } | 1358 | } |
1463 | 1359 | ||
1464 | /* wait for a close in progress to finish */ | 1360 | /* wait for a close in progress to finish */ |
1465 | while( priv->dp_in_close ) { | 1361 | while(priv->dp_in_close) { |
1466 | cond_wait_interruptible_timeout_irqrestore( | 1362 | cond_wait_interruptible_timeout_irqrestore( |
1467 | &priv->dp_close_wait, DIGI_RETRY_TIMEOUT, | 1363 | &priv->dp_close_wait, DIGI_RETRY_TIMEOUT, |
1468 | &priv->dp_port_lock, flags ); | 1364 | &priv->dp_port_lock, flags); |
1469 | if( signal_pending(current) ) { | 1365 | if (signal_pending(current)) |
1470 | return( -EINTR ); | 1366 | return -EINTR; |
1471 | } | 1367 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1472 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | ||
1473 | } | 1368 | } |
1474 | 1369 | ||
1475 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1370 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1476 | 1371 | ||
1477 | /* read modem signals automatically whenever they change */ | 1372 | /* read modem signals automatically whenever they change */ |
1478 | buf[0] = DIGI_CMD_READ_INPUT_SIGNALS; | 1373 | buf[0] = DIGI_CMD_READ_INPUT_SIGNALS; |
@@ -1486,23 +1381,22 @@ dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_cou | |||
1486 | buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; | 1381 | buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; |
1487 | buf[7] = 0; | 1382 | buf[7] = 0; |
1488 | 1383 | ||
1489 | if( (ret=digi_write_oob_command( port, buf, 8, 1 )) != 0 ) | 1384 | if ((ret = digi_write_oob_command(port, buf, 8, 1)) != 0) |
1490 | dbg( "digi_open: write oob failed, ret=%d", ret ); | 1385 | dbg("digi_open: write oob failed, ret=%d", ret); |
1491 | 1386 | ||
1492 | /* set termios settings */ | 1387 | /* set termios settings */ |
1493 | not_termios.c_cflag = ~port->tty->termios->c_cflag; | 1388 | not_termios.c_cflag = ~port->tty->termios->c_cflag; |
1494 | not_termios.c_iflag = ~port->tty->termios->c_iflag; | 1389 | not_termios.c_iflag = ~port->tty->termios->c_iflag; |
1495 | digi_set_termios( port, ¬_termios ); | 1390 | digi_set_termios(port, ¬_termios); |
1496 | 1391 | ||
1497 | /* set DTR and RTS */ | 1392 | /* set DTR and RTS */ |
1498 | digi_set_modem_signals( port, TIOCM_DTR|TIOCM_RTS, 1 ); | 1393 | digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1); |
1499 | |||
1500 | return( 0 ); | ||
1501 | 1394 | ||
1395 | return 0; | ||
1502 | } | 1396 | } |
1503 | 1397 | ||
1504 | 1398 | ||
1505 | static void digi_close( struct usb_serial_port *port, struct file *filp ) | 1399 | static void digi_close(struct usb_serial_port *port, struct file *filp) |
1506 | { | 1400 | { |
1507 | DEFINE_WAIT(wait); | 1401 | DEFINE_WAIT(wait); |
1508 | int ret; | 1402 | int ret; |
@@ -1511,40 +1405,37 @@ static void digi_close( struct usb_serial_port *port, struct file *filp ) | |||
1511 | struct digi_port *priv = usb_get_serial_port_data(port); | 1405 | struct digi_port *priv = usb_get_serial_port_data(port); |
1512 | unsigned long flags = 0; | 1406 | unsigned long flags = 0; |
1513 | 1407 | ||
1514 | 1408 | dbg("digi_close: TOP: port=%d, open_count=%d", | |
1515 | dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count ); | 1409 | priv->dp_port_num, port->open_count); |
1516 | |||
1517 | 1410 | ||
1518 | /* if disconnected, just clear flags */ | 1411 | /* if disconnected, just clear flags */ |
1519 | if (!usb_get_intfdata(port->serial->interface)) | 1412 | if (!usb_get_intfdata(port->serial->interface)) |
1520 | goto exit; | 1413 | goto exit; |
1521 | 1414 | ||
1522 | /* do cleanup only after final close on this port */ | 1415 | /* do cleanup only after final close on this port */ |
1523 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1416 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1524 | priv->dp_in_close = 1; | 1417 | priv->dp_in_close = 1; |
1525 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1418 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1526 | 1419 | ||
1527 | /* tell line discipline to process only XON/XOFF */ | 1420 | /* tell line discipline to process only XON/XOFF */ |
1528 | tty->closing = 1; | 1421 | tty->closing = 1; |
1529 | 1422 | ||
1530 | /* wait for output to drain */ | 1423 | /* wait for output to drain */ |
1531 | if( (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0 ) { | 1424 | if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) |
1532 | tty_wait_until_sent( tty, DIGI_CLOSE_TIMEOUT ); | 1425 | tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT); |
1533 | } | ||
1534 | 1426 | ||
1535 | /* flush driver and line discipline buffers */ | 1427 | /* flush driver and line discipline buffers */ |
1536 | if( tty->driver->flush_buffer ) | 1428 | if (tty->driver->flush_buffer) |
1537 | tty->driver->flush_buffer( tty ); | 1429 | tty->driver->flush_buffer(tty); |
1538 | tty_ldisc_flush(tty); | 1430 | tty_ldisc_flush(tty); |
1539 | 1431 | ||
1540 | if (port->serial->dev) { | 1432 | if (port->serial->dev) { |
1541 | /* wait for transmit idle */ | 1433 | /* wait for transmit idle */ |
1542 | if( (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0 ) { | 1434 | if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) { |
1543 | digi_transmit_idle( port, DIGI_CLOSE_TIMEOUT ); | 1435 | digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT); |
1544 | } | 1436 | } |
1545 | |||
1546 | /* drop DTR and RTS */ | 1437 | /* drop DTR and RTS */ |
1547 | digi_set_modem_signals( port, 0, 0 ); | 1438 | digi_set_modem_signals(port, 0, 0); |
1548 | 1439 | ||
1549 | /* disable input flow control */ | 1440 | /* disable input flow control */ |
1550 | buf[0] = DIGI_CMD_SET_INPUT_FLOW_CONTROL; | 1441 | buf[0] = DIGI_CMD_SET_INPUT_FLOW_CONTROL; |
@@ -1576,8 +1467,8 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co | |||
1576 | buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; | 1467 | buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; |
1577 | buf[19] = 0; | 1468 | buf[19] = 0; |
1578 | 1469 | ||
1579 | if( (ret=digi_write_oob_command( port, buf, 20, 0 )) != 0 ) | 1470 | if ((ret = digi_write_oob_command(port, buf, 20, 0)) != 0) |
1580 | dbg( "digi_close: write oob failed, ret=%d", ret ); | 1471 | dbg("digi_close: write oob failed, ret=%d", ret); |
1581 | 1472 | ||
1582 | /* wait for final commands on oob port to complete */ | 1473 | /* wait for final commands on oob port to complete */ |
1583 | prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE); | 1474 | prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE); |
@@ -1587,17 +1478,14 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co | |||
1587 | /* shutdown any outstanding bulk writes */ | 1478 | /* shutdown any outstanding bulk writes */ |
1588 | usb_kill_urb(port->write_urb); | 1479 | usb_kill_urb(port->write_urb); |
1589 | } | 1480 | } |
1590 | |||
1591 | tty->closing = 0; | 1481 | tty->closing = 0; |
1592 | |||
1593 | exit: | 1482 | exit: |
1594 | spin_lock_irqsave( &priv->dp_port_lock, flags ); | 1483 | spin_lock_irqsave(&priv->dp_port_lock, flags); |
1595 | priv->dp_write_urb_in_use = 0; | 1484 | priv->dp_write_urb_in_use = 0; |
1596 | priv->dp_in_close = 0; | 1485 | priv->dp_in_close = 0; |
1597 | wake_up_interruptible( &priv->dp_close_wait ); | 1486 | wake_up_interruptible(&priv->dp_close_wait); |
1598 | spin_unlock_irqrestore( &priv->dp_port_lock, flags ); | 1487 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
1599 | 1488 | dbg("digi_close: done"); | |
1600 | dbg( "digi_close: done" ); | ||
1601 | } | 1489 | } |
1602 | 1490 | ||
1603 | 1491 | ||
@@ -1608,155 +1496,136 @@ dbg( "digi_close: done" ); | |||
1608 | * urbs initialized. Returns 0 if successful, non-zero error otherwise. | 1496 | * urbs initialized. Returns 0 if successful, non-zero error otherwise. |
1609 | */ | 1497 | */ |
1610 | 1498 | ||
1611 | static int digi_startup_device( struct usb_serial *serial ) | 1499 | static int digi_startup_device(struct usb_serial *serial) |
1612 | { | 1500 | { |
1613 | |||
1614 | int i,ret = 0; | 1501 | int i,ret = 0; |
1615 | struct digi_serial *serial_priv = usb_get_serial_data(serial); | 1502 | struct digi_serial *serial_priv = usb_get_serial_data(serial); |
1616 | struct usb_serial_port *port; | 1503 | struct usb_serial_port *port; |
1617 | 1504 | ||
1618 | |||
1619 | /* be sure this happens exactly once */ | 1505 | /* be sure this happens exactly once */ |
1620 | spin_lock( &serial_priv->ds_serial_lock ); | 1506 | spin_lock(&serial_priv->ds_serial_lock); |
1621 | if( serial_priv->ds_device_started ) { | 1507 | if (serial_priv->ds_device_started) { |
1622 | spin_unlock( &serial_priv->ds_serial_lock ); | 1508 | spin_unlock(&serial_priv->ds_serial_lock); |
1623 | return( 0 ); | 1509 | return 0; |
1624 | } | 1510 | } |
1625 | serial_priv->ds_device_started = 1; | 1511 | serial_priv->ds_device_started = 1; |
1626 | spin_unlock( &serial_priv->ds_serial_lock ); | 1512 | spin_unlock(&serial_priv->ds_serial_lock); |
1627 | 1513 | ||
1628 | /* start reading from each bulk in endpoint for the device */ | 1514 | /* start reading from each bulk in endpoint for the device */ |
1629 | /* set USB_DISABLE_SPD flag for write bulk urbs */ | 1515 | /* set USB_DISABLE_SPD flag for write bulk urbs */ |
1630 | for( i=0; i<serial->type->num_ports+1; i++ ) { | 1516 | for (i = 0; i < serial->type->num_ports + 1; i++) { |
1631 | |||
1632 | port = serial->port[i]; | 1517 | port = serial->port[i]; |
1633 | |||
1634 | port->write_urb->dev = port->serial->dev; | 1518 | port->write_urb->dev = port->serial->dev; |
1635 | 1519 | if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) { | |
1636 | if( (ret=usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0 ) { | 1520 | err("%s: usb_submit_urb failed, ret=%d, port=%d", |
1637 | err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, | 1521 | __FUNCTION__, ret, i); |
1638 | ret, i ); | ||
1639 | break; | 1522 | break; |
1640 | } | 1523 | } |
1641 | |||
1642 | } | 1524 | } |
1643 | 1525 | return ret; | |
1644 | return( ret ); | ||
1645 | |||
1646 | } | 1526 | } |
1647 | 1527 | ||
1648 | 1528 | ||
1649 | static int digi_startup( struct usb_serial *serial ) | 1529 | static int digi_startup(struct usb_serial *serial) |
1650 | { | 1530 | { |
1651 | 1531 | ||
1652 | int i; | 1532 | int i; |
1653 | struct digi_port *priv; | 1533 | struct digi_port *priv; |
1654 | struct digi_serial *serial_priv; | 1534 | struct digi_serial *serial_priv; |
1655 | 1535 | ||
1656 | 1536 | dbg("digi_startup: TOP"); | |
1657 | dbg( "digi_startup: TOP" ); | ||
1658 | 1537 | ||
1659 | /* allocate the private data structures for all ports */ | 1538 | /* allocate the private data structures for all ports */ |
1660 | /* number of regular ports + 1 for the out-of-band port */ | 1539 | /* number of regular ports + 1 for the out-of-band port */ |
1661 | for( i=0; i<serial->type->num_ports+1; i++ ) { | 1540 | for(i = 0; i < serial->type->num_ports + 1; i++) { |
1662 | |||
1663 | /* allocate port private structure */ | 1541 | /* allocate port private structure */ |
1664 | priv = kmalloc( sizeof(struct digi_port), | 1542 | priv = kmalloc(sizeof(struct digi_port), GFP_KERNEL); |
1665 | GFP_KERNEL ); | 1543 | if (priv == NULL) { |
1666 | if( priv == (struct digi_port *)0 ) { | 1544 | while (--i >= 0) |
1667 | while( --i >= 0 ) | 1545 | kfree(usb_get_serial_port_data(serial->port[i])); |
1668 | kfree( usb_get_serial_port_data(serial->port[i]) ); | 1546 | return 1; /* error */ |
1669 | return( 1 ); /* error */ | ||
1670 | } | 1547 | } |
1671 | 1548 | ||
1672 | /* initialize port private structure */ | 1549 | /* initialize port private structure */ |
1673 | spin_lock_init( &priv->dp_port_lock ); | 1550 | spin_lock_init(&priv->dp_port_lock); |
1674 | priv->dp_port_num = i; | 1551 | priv->dp_port_num = i; |
1675 | priv->dp_out_buf_len = 0; | 1552 | priv->dp_out_buf_len = 0; |
1676 | priv->dp_write_urb_in_use = 0; | 1553 | priv->dp_write_urb_in_use = 0; |
1677 | priv->dp_modem_signals = 0; | 1554 | priv->dp_modem_signals = 0; |
1678 | init_waitqueue_head( &priv->dp_modem_change_wait ); | 1555 | init_waitqueue_head(&priv->dp_modem_change_wait); |
1679 | priv->dp_transmit_idle = 0; | 1556 | priv->dp_transmit_idle = 0; |
1680 | init_waitqueue_head( &priv->dp_transmit_idle_wait ); | 1557 | init_waitqueue_head(&priv->dp_transmit_idle_wait); |
1681 | priv->dp_throttled = 0; | 1558 | priv->dp_throttled = 0; |
1682 | priv->dp_throttle_restart = 0; | 1559 | priv->dp_throttle_restart = 0; |
1683 | init_waitqueue_head( &priv->dp_flush_wait ); | 1560 | init_waitqueue_head(&priv->dp_flush_wait); |
1684 | priv->dp_in_close = 0; | 1561 | priv->dp_in_close = 0; |
1685 | init_waitqueue_head( &priv->dp_close_wait ); | 1562 | init_waitqueue_head(&priv->dp_close_wait); |
1686 | INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock); | 1563 | INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock); |
1687 | priv->dp_port = serial->port[i]; | 1564 | priv->dp_port = serial->port[i]; |
1688 | |||
1689 | /* initialize write wait queue for this port */ | 1565 | /* initialize write wait queue for this port */ |
1690 | init_waitqueue_head( &serial->port[i]->write_wait ); | 1566 | init_waitqueue_head(&serial->port[i]->write_wait); |
1691 | 1567 | ||
1692 | usb_set_serial_port_data(serial->port[i], priv); | 1568 | usb_set_serial_port_data(serial->port[i], priv); |
1693 | } | 1569 | } |
1694 | 1570 | ||
1695 | /* allocate serial private structure */ | 1571 | /* allocate serial private structure */ |
1696 | serial_priv = kmalloc( sizeof(struct digi_serial), | 1572 | serial_priv = kmalloc(sizeof(struct digi_serial), GFP_KERNEL); |
1697 | GFP_KERNEL ); | 1573 | if (serial_priv == NULL) { |
1698 | if( serial_priv == (struct digi_serial *)0 ) { | 1574 | for (i = 0; i < serial->type->num_ports + 1; i++) |
1699 | for( i=0; i<serial->type->num_ports+1; i++ ) | 1575 | kfree(usb_get_serial_port_data(serial->port[i])); |
1700 | kfree( usb_get_serial_port_data(serial->port[i]) ); | 1576 | return 1; /* error */ |
1701 | return( 1 ); /* error */ | ||
1702 | } | 1577 | } |
1703 | 1578 | ||
1704 | /* initialize serial private structure */ | 1579 | /* initialize serial private structure */ |
1705 | spin_lock_init( &serial_priv->ds_serial_lock ); | 1580 | spin_lock_init(&serial_priv->ds_serial_lock); |
1706 | serial_priv->ds_oob_port_num = serial->type->num_ports; | 1581 | serial_priv->ds_oob_port_num = serial->type->num_ports; |
1707 | serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num]; | 1582 | serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num]; |
1708 | serial_priv->ds_device_started = 0; | 1583 | serial_priv->ds_device_started = 0; |
1709 | usb_set_serial_data(serial, serial_priv); | 1584 | usb_set_serial_data(serial, serial_priv); |
1710 | 1585 | ||
1711 | return( 0 ); | 1586 | return 0; |
1712 | |||
1713 | } | 1587 | } |
1714 | 1588 | ||
1715 | 1589 | ||
1716 | static void digi_shutdown( struct usb_serial *serial ) | 1590 | static void digi_shutdown(struct usb_serial *serial) |
1717 | { | 1591 | { |
1718 | |||
1719 | int i; | 1592 | int i; |
1720 | 1593 | dbg("digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt()); | |
1721 | |||
1722 | dbg( "digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt() ); | ||
1723 | 1594 | ||
1724 | /* stop reads and writes on all ports */ | 1595 | /* stop reads and writes on all ports */ |
1725 | for( i=0; i<serial->type->num_ports+1; i++ ) { | 1596 | for (i = 0; i < serial->type->num_ports + 1; i++) { |
1726 | usb_kill_urb(serial->port[i]->read_urb); | 1597 | usb_kill_urb(serial->port[i]->read_urb); |
1727 | usb_kill_urb(serial->port[i]->write_urb); | 1598 | usb_kill_urb(serial->port[i]->write_urb); |
1728 | } | 1599 | } |
1729 | 1600 | ||
1730 | /* free the private data structures for all ports */ | 1601 | /* free the private data structures for all ports */ |
1731 | /* number of regular ports + 1 for the out-of-band port */ | 1602 | /* number of regular ports + 1 for the out-of-band port */ |
1732 | for( i=0; i<serial->type->num_ports+1; i++ ) | 1603 | for(i = 0; i < serial->type->num_ports + 1; i++) |
1733 | kfree( usb_get_serial_port_data(serial->port[i]) ); | 1604 | kfree(usb_get_serial_port_data(serial->port[i])); |
1734 | kfree( usb_get_serial_data(serial) ); | 1605 | kfree(usb_get_serial_data(serial)); |
1735 | } | 1606 | } |
1736 | 1607 | ||
1737 | 1608 | ||
1738 | static void digi_read_bulk_callback( struct urb *urb ) | 1609 | static void digi_read_bulk_callback(struct urb *urb) |
1739 | { | 1610 | { |
1740 | |||
1741 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 1611 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
1742 | struct digi_port *priv; | 1612 | struct digi_port *priv; |
1743 | struct digi_serial *serial_priv; | 1613 | struct digi_serial *serial_priv; |
1744 | int ret; | 1614 | int ret; |
1745 | int status = urb->status; | 1615 | int status = urb->status; |
1746 | 1616 | ||
1747 | 1617 | dbg("digi_read_bulk_callback: TOP"); | |
1748 | dbg( "digi_read_bulk_callback: TOP" ); | ||
1749 | 1618 | ||
1750 | /* port sanity check, do not resubmit if port is not valid */ | 1619 | /* port sanity check, do not resubmit if port is not valid */ |
1751 | if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) { | 1620 | if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { |
1752 | err("%s: port or port->private is NULL, status=%d", | 1621 | err("%s: port or port->private is NULL, status=%d", |
1753 | __FUNCTION__, status); | 1622 | __FUNCTION__, status); |
1754 | return; | 1623 | return; |
1755 | } | 1624 | } |
1756 | if( port->serial == NULL | 1625 | if (port->serial == NULL || |
1757 | || (serial_priv=usb_get_serial_data(port->serial)) == NULL ) { | 1626 | (serial_priv=usb_get_serial_data(port->serial)) == NULL) { |
1758 | err("%s: serial is bad or serial->private is NULL, status=%d", | 1627 | err("%s: serial is bad or serial->private is NULL, status=%d", |
1759 | __FUNCTION__, status); | 1628 | __FUNCTION__, status); |
1760 | return; | 1629 | return; |
1761 | } | 1630 | } |
1762 | 1631 | ||
@@ -1768,24 +1637,23 @@ dbg( "digi_read_bulk_callback: TOP" ); | |||
1768 | } | 1637 | } |
1769 | 1638 | ||
1770 | /* handle oob or inb callback, do not resubmit if error */ | 1639 | /* handle oob or inb callback, do not resubmit if error */ |
1771 | if( priv->dp_port_num == serial_priv->ds_oob_port_num ) { | 1640 | if (priv->dp_port_num == serial_priv->ds_oob_port_num) { |
1772 | if( digi_read_oob_callback( urb ) != 0 ) | 1641 | if (digi_read_oob_callback(urb) != 0) |
1773 | return; | 1642 | return; |
1774 | } else { | 1643 | } else { |
1775 | if( digi_read_inb_callback( urb ) != 0 ) | 1644 | if (digi_read_inb_callback(urb) != 0) |
1776 | return; | 1645 | return; |
1777 | } | 1646 | } |
1778 | 1647 | ||
1779 | /* continue read */ | 1648 | /* continue read */ |
1780 | urb->dev = port->serial->dev; | 1649 | urb->dev = port->serial->dev; |
1781 | if( (ret=usb_submit_urb(urb, GFP_ATOMIC)) != 0 ) { | 1650 | if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { |
1782 | err("%s: failed resubmitting urb, ret=%d, port=%d", __FUNCTION__, | 1651 | err("%s: failed resubmitting urb, ret=%d, port=%d", |
1783 | ret, priv->dp_port_num ); | 1652 | __FUNCTION__, ret, priv->dp_port_num); |
1784 | } | 1653 | } |
1785 | 1654 | ||
1786 | } | 1655 | } |
1787 | 1656 | ||
1788 | |||
1789 | /* | 1657 | /* |
1790 | * Digi Read INB Callback | 1658 | * Digi Read INB Callback |
1791 | * | 1659 | * |
@@ -1796,7 +1664,7 @@ dbg( "digi_read_bulk_callback: TOP" ); | |||
1796 | * throttled, and -1 if the sanity checks failed. | 1664 | * throttled, and -1 if the sanity checks failed. |
1797 | */ | 1665 | */ |
1798 | 1666 | ||
1799 | static int digi_read_inb_callback( struct urb *urb ) | 1667 | static int digi_read_inb_callback(struct urb *urb) |
1800 | { | 1668 | { |
1801 | 1669 | ||
1802 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 1670 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
@@ -1812,72 +1680,67 @@ static int digi_read_inb_callback( struct urb *urb ) | |||
1812 | 1680 | ||
1813 | /* do not process callbacks on closed ports */ | 1681 | /* do not process callbacks on closed ports */ |
1814 | /* but do continue the read chain */ | 1682 | /* but do continue the read chain */ |
1815 | if( port->open_count == 0 ) | 1683 | if (port->open_count == 0) |
1816 | return( 0 ); | 1684 | return 0; |
1817 | 1685 | ||
1818 | /* short/multiple packet check */ | 1686 | /* short/multiple packet check */ |
1819 | if( urb->actual_length != len + 2 ) { | 1687 | if (urb->actual_length != len + 2) { |
1820 | err("%s: INCOMPLETE OR MULTIPLE PACKET, urb status=%d, " | 1688 | err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " |
1821 | "port=%d, opcode=%d, len=%d, actual_length=%d, " | 1689 | "port=%d, opcode=%d, len=%d, actual_length=%d, " |
1822 | "port_status=%d", __FUNCTION__, status, priv->dp_port_num, | 1690 | "status=%d", __FUNCTION__, status, priv->dp_port_num, |
1823 | opcode, len, urb->actual_length, port_status); | 1691 | opcode, len, urb->actual_length, port_status); |
1824 | return( -1 ); | 1692 | return -1; |
1825 | } | 1693 | } |
1826 | 1694 | ||
1827 | spin_lock( &priv->dp_port_lock ); | 1695 | spin_lock(&priv->dp_port_lock); |
1828 | 1696 | ||
1829 | /* check for throttle; if set, do not resubmit read urb */ | 1697 | /* check for throttle; if set, do not resubmit read urb */ |
1830 | /* indicate the read chain needs to be restarted on unthrottle */ | 1698 | /* indicate the read chain needs to be restarted on unthrottle */ |
1831 | throttled = priv->dp_throttled; | 1699 | throttled = priv->dp_throttled; |
1832 | if( throttled ) | 1700 | if (throttled) |
1833 | priv->dp_throttle_restart = 1; | 1701 | priv->dp_throttle_restart = 1; |
1834 | 1702 | ||
1835 | /* receive data */ | 1703 | /* receive data */ |
1836 | if( opcode == DIGI_CMD_RECEIVE_DATA ) { | 1704 | if (opcode == DIGI_CMD_RECEIVE_DATA) { |
1837 | |||
1838 | /* get flag from port_status */ | 1705 | /* get flag from port_status */ |
1839 | flag = 0; | 1706 | flag = 0; |
1840 | 1707 | ||
1841 | /* overrun is special, not associated with a char */ | 1708 | /* overrun is special, not associated with a char */ |
1842 | if (port_status & DIGI_OVERRUN_ERROR) { | 1709 | if (port_status & DIGI_OVERRUN_ERROR) |
1843 | tty_insert_flip_char( tty, 0, TTY_OVERRUN ); | 1710 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
1844 | } | ||
1845 | 1711 | ||
1846 | /* break takes precedence over parity, */ | 1712 | /* break takes precedence over parity, */ |
1847 | /* which takes precedence over framing errors */ | 1713 | /* which takes precedence over framing errors */ |
1848 | if (port_status & DIGI_BREAK_ERROR) { | 1714 | if (port_status & DIGI_BREAK_ERROR) |
1849 | flag = TTY_BREAK; | 1715 | flag = TTY_BREAK; |
1850 | } else if (port_status & DIGI_PARITY_ERROR) { | 1716 | else if (port_status & DIGI_PARITY_ERROR) |
1851 | flag = TTY_PARITY; | 1717 | flag = TTY_PARITY; |
1852 | } else if (port_status & DIGI_FRAMING_ERROR) { | 1718 | else if (port_status & DIGI_FRAMING_ERROR) |
1853 | flag = TTY_FRAME; | 1719 | flag = TTY_FRAME; |
1854 | } | ||
1855 | 1720 | ||
1856 | /* data length is len-1 (one byte of len is port_status) */ | 1721 | /* data length is len-1 (one byte of len is port_status) */ |
1857 | --len; | 1722 | --len; |
1858 | 1723 | ||
1859 | len = tty_buffer_request_room(tty, len); | 1724 | len = tty_buffer_request_room(tty, len); |
1860 | if( len > 0 ) { | 1725 | if (len > 0) { |
1861 | /* Hot path */ | 1726 | /* Hot path */ |
1862 | if(flag == TTY_NORMAL) | 1727 | if (flag == TTY_NORMAL) |
1863 | tty_insert_flip_string(tty, data, len); | 1728 | tty_insert_flip_string(tty, data, len); |
1864 | else { | 1729 | else { |
1865 | for(i = 0; i < len; i++) | 1730 | for(i = 0; i < len; i++) |
1866 | tty_insert_flip_char(tty, data[i], flag); | 1731 | tty_insert_flip_char(tty, data[i], flag); |
1867 | } | 1732 | } |
1868 | tty_flip_buffer_push( tty ); | 1733 | tty_flip_buffer_push(tty); |
1869 | } | 1734 | } |
1870 | } | 1735 | } |
1736 | spin_unlock(&priv->dp_port_lock); | ||
1871 | 1737 | ||
1872 | spin_unlock( &priv->dp_port_lock ); | 1738 | if (opcode == DIGI_CMD_RECEIVE_DISABLE) |
1873 | 1739 | dbg("%s: got RECEIVE_DISABLE", __FUNCTION__); | |
1874 | if( opcode == DIGI_CMD_RECEIVE_DISABLE ) { | 1740 | else if (opcode != DIGI_CMD_RECEIVE_DATA) |
1875 | dbg("%s: got RECEIVE_DISABLE", __FUNCTION__ ); | 1741 | dbg("%s: unknown opcode: %d", __FUNCTION__, opcode); |
1876 | } else if( opcode != DIGI_CMD_RECEIVE_DATA ) { | ||
1877 | dbg("%s: unknown opcode: %d", __FUNCTION__, opcode ); | ||
1878 | } | ||
1879 | 1742 | ||
1880 | return( throttled ? 1 : 0 ); | 1743 | return(throttled ? 1 : 0); |
1881 | 1744 | ||
1882 | } | 1745 | } |
1883 | 1746 | ||
@@ -1891,7 +1754,7 @@ static int digi_read_inb_callback( struct urb *urb ) | |||
1891 | * -1 if the sanity checks failed. | 1754 | * -1 if the sanity checks failed. |
1892 | */ | 1755 | */ |
1893 | 1756 | ||
1894 | static int digi_read_oob_callback( struct urb *urb ) | 1757 | static int digi_read_oob_callback(struct urb *urb) |
1895 | { | 1758 | { |
1896 | 1759 | ||
1897 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 1760 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
@@ -1900,87 +1763,75 @@ static int digi_read_oob_callback( struct urb *urb ) | |||
1900 | int opcode, line, status, val; | 1763 | int opcode, line, status, val; |
1901 | int i; | 1764 | int i; |
1902 | 1765 | ||
1903 | 1766 | dbg("digi_read_oob_callback: port=%d, len=%d", | |
1904 | dbg( "digi_read_oob_callback: port=%d, len=%d", priv->dp_port_num, | 1767 | priv->dp_port_num, urb->actual_length); |
1905 | urb->actual_length ); | ||
1906 | 1768 | ||
1907 | /* handle each oob command */ | 1769 | /* handle each oob command */ |
1908 | for( i=0; i<urb->actual_length-3; ) { | 1770 | for(i = 0; i < urb->actual_length - 3;) { |
1909 | |||
1910 | opcode = ((unsigned char *)urb->transfer_buffer)[i++]; | 1771 | opcode = ((unsigned char *)urb->transfer_buffer)[i++]; |
1911 | line = ((unsigned char *)urb->transfer_buffer)[i++]; | 1772 | line = ((unsigned char *)urb->transfer_buffer)[i++]; |
1912 | status = ((unsigned char *)urb->transfer_buffer)[i++]; | 1773 | status = ((unsigned char *)urb->transfer_buffer)[i++]; |
1913 | val = ((unsigned char *)urb->transfer_buffer)[i++]; | 1774 | val = ((unsigned char *)urb->transfer_buffer)[i++]; |
1914 | 1775 | ||
1915 | dbg( "digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d", | 1776 | dbg("digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d", |
1916 | opcode, line, status, val ); | 1777 | opcode, line, status, val); |
1917 | 1778 | ||
1918 | if( status != 0 || line >= serial->type->num_ports ) | 1779 | if (status != 0 || line >= serial->type->num_ports) |
1919 | continue; | 1780 | continue; |
1920 | 1781 | ||
1921 | port = serial->port[line]; | 1782 | port = serial->port[line]; |
1922 | 1783 | ||
1923 | if ((priv=usb_get_serial_port_data(port)) == NULL ) | 1784 | if ((priv=usb_get_serial_port_data(port)) == NULL) |
1924 | return -1; | 1785 | return -1; |
1925 | 1786 | ||
1926 | if( opcode == DIGI_CMD_READ_INPUT_SIGNALS ) { | 1787 | if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) { |
1927 | 1788 | spin_lock(&priv->dp_port_lock); | |
1928 | spin_lock( &priv->dp_port_lock ); | ||
1929 | |||
1930 | /* convert from digi flags to termiox flags */ | 1789 | /* convert from digi flags to termiox flags */ |
1931 | if( val & DIGI_READ_INPUT_SIGNALS_CTS ) { | 1790 | if (val & DIGI_READ_INPUT_SIGNALS_CTS) { |
1932 | priv->dp_modem_signals |= TIOCM_CTS; | 1791 | priv->dp_modem_signals |= TIOCM_CTS; |
1933 | /* port must be open to use tty struct */ | 1792 | /* port must be open to use tty struct */ |
1934 | if( port->open_count | 1793 | if (port->open_count |
1935 | && port->tty->termios->c_cflag & CRTSCTS ) { | 1794 | && port->tty->termios->c_cflag & CRTSCTS) { |
1936 | port->tty->hw_stopped = 0; | 1795 | port->tty->hw_stopped = 0; |
1937 | digi_wakeup_write( port ); | 1796 | digi_wakeup_write(port); |
1938 | } | 1797 | } |
1939 | } else { | 1798 | } else { |
1940 | priv->dp_modem_signals &= ~TIOCM_CTS; | 1799 | priv->dp_modem_signals &= ~TIOCM_CTS; |
1941 | /* port must be open to use tty struct */ | 1800 | /* port must be open to use tty struct */ |
1942 | if( port->open_count | 1801 | if (port->open_count |
1943 | && port->tty->termios->c_cflag & CRTSCTS ) { | 1802 | && port->tty->termios->c_cflag & CRTSCTS) { |
1944 | port->tty->hw_stopped = 1; | 1803 | port->tty->hw_stopped = 1; |
1945 | } | 1804 | } |
1946 | } | 1805 | } |
1947 | if( val & DIGI_READ_INPUT_SIGNALS_DSR ) | 1806 | if (val & DIGI_READ_INPUT_SIGNALS_DSR) |
1948 | priv->dp_modem_signals |= TIOCM_DSR; | 1807 | priv->dp_modem_signals |= TIOCM_DSR; |
1949 | else | 1808 | else |
1950 | priv->dp_modem_signals &= ~TIOCM_DSR; | 1809 | priv->dp_modem_signals &= ~TIOCM_DSR; |
1951 | if( val & DIGI_READ_INPUT_SIGNALS_RI ) | 1810 | if (val & DIGI_READ_INPUT_SIGNALS_RI) |
1952 | priv->dp_modem_signals |= TIOCM_RI; | 1811 | priv->dp_modem_signals |= TIOCM_RI; |
1953 | else | 1812 | else |
1954 | priv->dp_modem_signals &= ~TIOCM_RI; | 1813 | priv->dp_modem_signals &= ~TIOCM_RI; |
1955 | if( val & DIGI_READ_INPUT_SIGNALS_DCD ) | 1814 | if (val & DIGI_READ_INPUT_SIGNALS_DCD) |
1956 | priv->dp_modem_signals |= TIOCM_CD; | 1815 | priv->dp_modem_signals |= TIOCM_CD; |
1957 | else | 1816 | else |
1958 | priv->dp_modem_signals &= ~TIOCM_CD; | 1817 | priv->dp_modem_signals &= ~TIOCM_CD; |
1959 | 1818 | ||
1960 | wake_up_interruptible( &priv->dp_modem_change_wait ); | 1819 | wake_up_interruptible(&priv->dp_modem_change_wait); |
1961 | spin_unlock( &priv->dp_port_lock ); | 1820 | spin_unlock(&priv->dp_port_lock); |
1962 | 1821 | } else if (opcode == DIGI_CMD_TRANSMIT_IDLE) { | |
1963 | } else if( opcode == DIGI_CMD_TRANSMIT_IDLE ) { | 1822 | spin_lock(&priv->dp_port_lock); |
1964 | |||
1965 | spin_lock( &priv->dp_port_lock ); | ||
1966 | priv->dp_transmit_idle = 1; | 1823 | priv->dp_transmit_idle = 1; |
1967 | wake_up_interruptible( &priv->dp_transmit_idle_wait ); | 1824 | wake_up_interruptible(&priv->dp_transmit_idle_wait); |
1968 | spin_unlock( &priv->dp_port_lock ); | 1825 | spin_unlock(&priv->dp_port_lock); |
1969 | 1826 | } else if (opcode == DIGI_CMD_IFLUSH_FIFO) { | |
1970 | } else if( opcode == DIGI_CMD_IFLUSH_FIFO ) { | 1827 | wake_up_interruptible(&priv->dp_flush_wait); |
1971 | |||
1972 | wake_up_interruptible( &priv->dp_flush_wait ); | ||
1973 | |||
1974 | } | 1828 | } |
1975 | |||
1976 | } | 1829 | } |
1977 | 1830 | return 0; | |
1978 | return( 0 ); | ||
1979 | 1831 | ||
1980 | } | 1832 | } |
1981 | 1833 | ||
1982 | 1834 | static int __init digi_init(void) | |
1983 | static int __init digi_init (void) | ||
1984 | { | 1835 | { |
1985 | int retval; | 1836 | int retval; |
1986 | retval = usb_serial_register(&digi_acceleport_2_device); | 1837 | retval = usb_serial_register(&digi_acceleport_2_device); |
@@ -2002,12 +1853,11 @@ failed_acceleport_2_device: | |||
2002 | return retval; | 1853 | return retval; |
2003 | } | 1854 | } |
2004 | 1855 | ||
2005 | |||
2006 | static void __exit digi_exit (void) | 1856 | static void __exit digi_exit (void) |
2007 | { | 1857 | { |
2008 | usb_deregister (&digi_driver); | 1858 | usb_deregister(&digi_driver); |
2009 | usb_serial_deregister (&digi_acceleport_2_device); | 1859 | usb_serial_deregister(&digi_acceleport_2_device); |
2010 | usb_serial_deregister (&digi_acceleport_4_device); | 1860 | usb_serial_deregister(&digi_acceleport_4_device); |
2011 | } | 1861 | } |
2012 | 1862 | ||
2013 | 1863 | ||
@@ -2015,8 +1865,8 @@ module_init(digi_init); | |||
2015 | module_exit(digi_exit); | 1865 | module_exit(digi_exit); |
2016 | 1866 | ||
2017 | 1867 | ||
2018 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 1868 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2019 | MODULE_DESCRIPTION( DRIVER_DESC ); | 1869 | MODULE_DESCRIPTION(DRIVER_DESC); |
2020 | MODULE_LICENSE("GPL"); | 1870 | MODULE_LICENSE("GPL"); |
2021 | 1871 | ||
2022 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 1872 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 7b1673a4407..e4c248c98e8 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -538,6 +538,8 @@ static struct usb_device_id id_table_combined [] = { | |||
538 | { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) }, | 538 | { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) }, |
539 | { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) }, | 539 | { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) }, |
540 | { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, | 540 | { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, |
541 | { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, | ||
542 | { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, | ||
541 | { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, | 543 | { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, |
542 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, | 544 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, |
543 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, | 545 | { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, |
@@ -566,6 +568,7 @@ static struct usb_device_id id_table_combined [] = { | |||
566 | { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) }, | 568 | { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) }, |
567 | { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, | 569 | { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) }, |
568 | { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, | 570 | { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) }, |
571 | { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) }, | ||
569 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), | 572 | { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), |
570 | .driver_info = (kernel_ulong_t)&ftdi_olimex_quirk }, | 573 | .driver_info = (kernel_ulong_t)&ftdi_olimex_quirk }, |
571 | { }, /* Optional parameter entry */ | 574 | { }, /* Optional parameter entry */ |
@@ -1166,7 +1169,9 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) | |||
1166 | /* XXX see create_sysfs_attrs */ | 1169 | /* XXX see create_sysfs_attrs */ |
1167 | if (priv->chip_type != SIO) { | 1170 | if (priv->chip_type != SIO) { |
1168 | device_remove_file(&port->dev, &dev_attr_event_char); | 1171 | device_remove_file(&port->dev, &dev_attr_event_char); |
1169 | if (priv->chip_type == FT232BM || priv->chip_type == FT2232C) { | 1172 | if (priv->chip_type == FT232BM || |
1173 | priv->chip_type == FT2232C || | ||
1174 | priv->chip_type == FT232RL) { | ||
1170 | device_remove_file(&port->dev, &dev_attr_latency_timer); | 1175 | device_remove_file(&port->dev, &dev_attr_latency_timer); |
1171 | } | 1176 | } |
1172 | } | 1177 | } |
@@ -2099,6 +2104,7 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) | |||
2099 | case FT8U232AM: | 2104 | case FT8U232AM: |
2100 | case FT232BM: | 2105 | case FT232BM: |
2101 | case FT2232C: | 2106 | case FT2232C: |
2107 | case FT232RL: | ||
2102 | /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same | 2108 | /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same |
2103 | format as the data returned from the in point */ | 2109 | format as the data returned from the in point */ |
2104 | if ((ret = usb_control_msg(port->serial->dev, | 2110 | if ((ret = usb_control_msg(port->serial->dev, |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index d9e49716db1..b57b90ae9f9 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -430,6 +430,9 @@ | |||
430 | */ | 430 | */ |
431 | #define EVOLUTION_VID 0xDEEE /* Vendor ID */ | 431 | #define EVOLUTION_VID 0xDEEE /* Vendor ID */ |
432 | #define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ | 432 | #define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ |
433 | #define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/ | ||
434 | #define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/ | ||
435 | #define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */ | ||
433 | 436 | ||
434 | /* Pyramid Computer GmbH */ | 437 | /* Pyramid Computer GmbH */ |
435 | #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ | 438 | #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ |
@@ -531,6 +534,14 @@ | |||
531 | #define OLIMEX_VID 0x15BA | 534 | #define OLIMEX_VID 0x15BA |
532 | #define OLIMEX_ARM_USB_OCD_PID 0x0003 | 535 | #define OLIMEX_ARM_USB_OCD_PID 0x0003 |
533 | 536 | ||
537 | |||
538 | /* | ||
539 | * The Mobility Lab (TML) | ||
540 | * Submitted by Pierre Castella | ||
541 | */ | ||
542 | #define TML_VID 0x1B91 /* Vendor ID */ | ||
543 | #define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */ | ||
544 | |||
534 | /* Commands */ | 545 | /* Commands */ |
535 | #define FTDI_SIO_RESET 0 /* Reset the port */ | 546 | #define FTDI_SIO_RESET 0 /* Reset the port */ |
536 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ | 547 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ |
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c index 4092f6dc9ef..b5194dc7d3b 100644 --- a/drivers/usb/serial/funsoft.c +++ b/drivers/usb/serial/funsoft.c | |||
@@ -24,26 +24,6 @@ static struct usb_device_id id_table [] = { | |||
24 | }; | 24 | }; |
25 | MODULE_DEVICE_TABLE(usb, id_table); | 25 | MODULE_DEVICE_TABLE(usb, id_table); |
26 | 26 | ||
27 | static int funsoft_ioctl(struct usb_serial_port *port, struct file *file, | ||
28 | unsigned int cmd, unsigned long arg) | ||
29 | { | ||
30 | struct ktermios t; | ||
31 | |||
32 | dbg("%s - port %d, cmd 0x%04x", __FUNCTION__, port->number, cmd); | ||
33 | |||
34 | if (cmd == TCSETSF) { | ||
35 | if (user_termios_to_kernel_termios(&t, (struct termios __user *)arg)) | ||
36 | return -EFAULT; | ||
37 | |||
38 | dbg("%s - iflag:%x oflag:%x cflag:%x lflag:%x", __FUNCTION__, | ||
39 | t.c_iflag, t.c_oflag, t.c_cflag, t.c_lflag); | ||
40 | |||
41 | if (!(t.c_lflag & ICANON)) | ||
42 | return -EINVAL; | ||
43 | } | ||
44 | return -ENOIOCTLCMD; | ||
45 | } | ||
46 | |||
47 | static struct usb_driver funsoft_driver = { | 27 | static struct usb_driver funsoft_driver = { |
48 | .name = "funsoft", | 28 | .name = "funsoft", |
49 | .probe = usb_serial_probe, | 29 | .probe = usb_serial_probe, |
@@ -63,7 +43,6 @@ static struct usb_serial_driver funsoft_device = { | |||
63 | .num_bulk_in = NUM_DONT_CARE, | 43 | .num_bulk_in = NUM_DONT_CARE, |
64 | .num_bulk_out = NUM_DONT_CARE, | 44 | .num_bulk_out = NUM_DONT_CARE, |
65 | .num_ports = 1, | 45 | .num_ports = 1, |
66 | .ioctl = funsoft_ioctl, | ||
67 | }; | 46 | }; |
68 | 47 | ||
69 | static int __init funsoft_init(void) | 48 | static int __init funsoft_init(void) |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 04bd3b7a298..f1c90cfe725 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Garmin GPS driver | 2 | * Garmin GPS driver |
3 | * | 3 | * |
4 | * Copyright (C) 2006 Hermann Kneissel herkne@users.sourceforge.net | 4 | * Copyright (C) 2006,2007 Hermann Kneissel herkne@users.sourceforge.net |
5 | * | 5 | * |
6 | * The latest version of the driver can be found at | 6 | * The latest version of the driver can be found at |
7 | * http://sourceforge.net/projects/garmin-gps/ | 7 | * http://sourceforge.net/projects/garmin-gps/ |
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
36 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
37 | #include <asm/atomic.h> | ||
37 | #include <linux/usb.h> | 38 | #include <linux/usb.h> |
38 | #include <linux/usb/serial.h> | 39 | #include <linux/usb/serial.h> |
39 | 40 | ||
@@ -52,7 +53,7 @@ static int debug = 0; | |||
52 | */ | 53 | */ |
53 | 54 | ||
54 | #define VERSION_MAJOR 0 | 55 | #define VERSION_MAJOR 0 |
55 | #define VERSION_MINOR 28 | 56 | #define VERSION_MINOR 31 |
56 | 57 | ||
57 | #define _STR(s) #s | 58 | #define _STR(s) #s |
58 | #define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b) | 59 | #define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b) |
@@ -141,6 +142,8 @@ struct garmin_data { | |||
141 | __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */ | 142 | __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */ |
142 | __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */ | 143 | __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */ |
143 | __u8 privpkt[4*6]; | 144 | __u8 privpkt[4*6]; |
145 | atomic_t req_count; | ||
146 | atomic_t resp_count; | ||
144 | spinlock_t lock; | 147 | spinlock_t lock; |
145 | struct list_head pktlist; | 148 | struct list_head pktlist; |
146 | }; | 149 | }; |
@@ -171,8 +174,6 @@ struct garmin_data { | |||
171 | #define CLEAR_HALT_REQUIRED 0x0001 | 174 | #define CLEAR_HALT_REQUIRED 0x0001 |
172 | 175 | ||
173 | #define FLAGS_QUEUING 0x0100 | 176 | #define FLAGS_QUEUING 0x0100 |
174 | #define FLAGS_APP_RESP_SEEN 0x0200 | ||
175 | #define FLAGS_APP_REQ_SEEN 0x0400 | ||
176 | #define FLAGS_DROP_DATA 0x0800 | 177 | #define FLAGS_DROP_DATA 0x0800 |
177 | 178 | ||
178 | #define FLAGS_GSP_SKIP 0x1000 | 179 | #define FLAGS_GSP_SKIP 0x1000 |
@@ -186,7 +187,8 @@ struct garmin_data { | |||
186 | /* function prototypes */ | 187 | /* function prototypes */ |
187 | static void gsp_next_packet(struct garmin_data * garmin_data_p); | 188 | static void gsp_next_packet(struct garmin_data * garmin_data_p); |
188 | static int garmin_write_bulk(struct usb_serial_port *port, | 189 | static int garmin_write_bulk(struct usb_serial_port *port, |
189 | const unsigned char *buf, int count); | 190 | const unsigned char *buf, int count, |
191 | int dismiss_ack); | ||
190 | 192 | ||
191 | /* some special packets to be send or received */ | 193 | /* some special packets to be send or received */ |
192 | static unsigned char const GARMIN_START_SESSION_REQ[] | 194 | static unsigned char const GARMIN_START_SESSION_REQ[] |
@@ -233,9 +235,7 @@ static struct usb_driver garmin_driver = { | |||
233 | 235 | ||
234 | static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p) | 236 | static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p) |
235 | { | 237 | { |
236 | return ((garmin_data_p->flags | 238 | return atomic_read(&garmin_data_p->req_count) == atomic_read(&garmin_data_p->resp_count); |
237 | & (FLAGS_APP_REQ_SEEN|FLAGS_APP_RESP_SEEN)) | ||
238 | == FLAGS_APP_REQ_SEEN); | ||
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
@@ -463,7 +463,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) | |||
463 | usbdata[2] = __cpu_to_le32(size); | 463 | usbdata[2] = __cpu_to_le32(size); |
464 | 464 | ||
465 | garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer, | 465 | garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer, |
466 | GARMIN_PKTHDR_LENGTH+size); | 466 | GARMIN_PKTHDR_LENGTH+size, 0); |
467 | 467 | ||
468 | /* if this was an abort-transfer command, flush all | 468 | /* if this was an abort-transfer command, flush all |
469 | queued data. */ | 469 | queued data. */ |
@@ -818,7 +818,7 @@ static int nat_receive(struct garmin_data * garmin_data_p, | |||
818 | if (garmin_data_p->insize >= len) { | 818 | if (garmin_data_p->insize >= len) { |
819 | garmin_write_bulk (garmin_data_p->port, | 819 | garmin_write_bulk (garmin_data_p->port, |
820 | garmin_data_p->inbuffer, | 820 | garmin_data_p->inbuffer, |
821 | len); | 821 | len, 0); |
822 | garmin_data_p->insize = 0; | 822 | garmin_data_p->insize = 0; |
823 | 823 | ||
824 | /* if this was an abort-transfer command, | 824 | /* if this was an abort-transfer command, |
@@ -893,10 +893,11 @@ static int garmin_clear(struct garmin_data * garmin_data_p) | |||
893 | 893 | ||
894 | struct usb_serial_port *port = garmin_data_p->port; | 894 | struct usb_serial_port *port = garmin_data_p->port; |
895 | 895 | ||
896 | if (port != NULL && garmin_data_p->flags & FLAGS_APP_RESP_SEEN) { | 896 | if (port != NULL && atomic_read(&garmin_data_p->resp_count)) { |
897 | /* send a terminate command */ | 897 | /* send a terminate command */ |
898 | status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ, | 898 | status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ, |
899 | sizeof(GARMIN_STOP_TRANSFER_REQ)); | 899 | sizeof(GARMIN_STOP_TRANSFER_REQ), |
900 | 1); | ||
900 | } | 901 | } |
901 | 902 | ||
902 | /* flush all queued data */ | 903 | /* flush all queued data */ |
@@ -939,7 +940,8 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
939 | dbg("%s - starting session ...", __FUNCTION__); | 940 | dbg("%s - starting session ...", __FUNCTION__); |
940 | garmin_data_p->state = STATE_ACTIVE; | 941 | garmin_data_p->state = STATE_ACTIVE; |
941 | status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, | 942 | status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, |
942 | sizeof(GARMIN_START_SESSION_REQ)); | 943 | sizeof(GARMIN_START_SESSION_REQ), |
944 | 0); | ||
943 | 945 | ||
944 | if (status >= 0) { | 946 | if (status >= 0) { |
945 | 947 | ||
@@ -950,7 +952,8 @@ static int garmin_init_session(struct usb_serial_port *port) | |||
950 | /* not needed, but the win32 driver does it too ... */ | 952 | /* not needed, but the win32 driver does it too ... */ |
951 | status = garmin_write_bulk(port, | 953 | status = garmin_write_bulk(port, |
952 | GARMIN_START_SESSION_REQ2, | 954 | GARMIN_START_SESSION_REQ2, |
953 | sizeof(GARMIN_START_SESSION_REQ2)); | 955 | sizeof(GARMIN_START_SESSION_REQ2), |
956 | 0); | ||
954 | if (status >= 0) { | 957 | if (status >= 0) { |
955 | status = 0; | 958 | status = 0; |
956 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 959 | spin_lock_irqsave(&garmin_data_p->lock, flags); |
@@ -987,6 +990,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp) | |||
987 | garmin_data_p->mode = initial_mode; | 990 | garmin_data_p->mode = initial_mode; |
988 | garmin_data_p->count = 0; | 991 | garmin_data_p->count = 0; |
989 | garmin_data_p->flags = 0; | 992 | garmin_data_p->flags = 0; |
993 | atomic_set(&garmin_data_p->req_count, 0); | ||
994 | atomic_set(&garmin_data_p->resp_count, 0); | ||
990 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 995 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); |
991 | 996 | ||
992 | /* shutdown any bulk reads that might be going on */ | 997 | /* shutdown any bulk reads that might be going on */ |
@@ -1035,28 +1040,39 @@ static void garmin_write_bulk_callback (struct urb *urb) | |||
1035 | { | 1040 | { |
1036 | unsigned long flags; | 1041 | unsigned long flags; |
1037 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 1042 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
1038 | struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); | ||
1039 | int status = urb->status; | 1043 | int status = urb->status; |
1040 | 1044 | ||
1041 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | 1045 | if (port) { |
1042 | kfree (urb->transfer_buffer); | 1046 | struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); |
1043 | 1047 | ||
1044 | dbg("%s - port %d", __FUNCTION__, port->number); | 1048 | dbg("%s - port %d", __FUNCTION__, port->number); |
1045 | 1049 | ||
1046 | if (status) { | 1050 | if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer) |
1047 | dbg("%s - nonzero write bulk status received: %d", | 1051 | && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) { |
1048 | __FUNCTION__, status); | 1052 | gsp_send_ack(garmin_data_p, ((__u8 *)urb->transfer_buffer)[4]); |
1049 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1053 | } |
1050 | garmin_data_p->flags |= CLEAR_HALT_REQUIRED; | 1054 | |
1051 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | 1055 | if (status) { |
1056 | dbg("%s - nonzero write bulk status received: %d", | ||
1057 | __FUNCTION__, urb->status); | ||
1058 | spin_lock_irqsave(&garmin_data_p->lock, flags); | ||
1059 | garmin_data_p->flags |= CLEAR_HALT_REQUIRED; | ||
1060 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1061 | } | ||
1062 | |||
1063 | usb_serial_port_softint(port); | ||
1052 | } | 1064 | } |
1053 | 1065 | ||
1054 | usb_serial_port_softint(port); | 1066 | /* Ignore errors that resulted from garmin_write_bulk with dismiss_ack=1 */ |
1067 | |||
1068 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | ||
1069 | kfree (urb->transfer_buffer); | ||
1055 | } | 1070 | } |
1056 | 1071 | ||
1057 | 1072 | ||
1058 | static int garmin_write_bulk (struct usb_serial_port *port, | 1073 | static int garmin_write_bulk (struct usb_serial_port *port, |
1059 | const unsigned char *buf, int count) | 1074 | const unsigned char *buf, int count, |
1075 | int dismiss_ack) | ||
1060 | { | 1076 | { |
1061 | unsigned long flags; | 1077 | unsigned long flags; |
1062 | struct usb_serial *serial = port->serial; | 1078 | struct usb_serial *serial = port->serial; |
@@ -1093,13 +1109,12 @@ static int garmin_write_bulk (struct usb_serial_port *port, | |||
1093 | usb_sndbulkpipe (serial->dev, | 1109 | usb_sndbulkpipe (serial->dev, |
1094 | port->bulk_out_endpointAddress), | 1110 | port->bulk_out_endpointAddress), |
1095 | buffer, count, | 1111 | buffer, count, |
1096 | garmin_write_bulk_callback, port); | 1112 | garmin_write_bulk_callback, |
1113 | dismiss_ack ? NULL : port); | ||
1097 | urb->transfer_flags |= URB_ZERO_PACKET; | 1114 | urb->transfer_flags |= URB_ZERO_PACKET; |
1098 | 1115 | ||
1099 | if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { | 1116 | if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { |
1100 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1117 | atomic_inc(&garmin_data_p->req_count); |
1101 | garmin_data_p->flags |= FLAGS_APP_REQ_SEEN; | ||
1102 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1103 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { | 1118 | if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { |
1104 | pkt_clear(garmin_data_p); | 1119 | pkt_clear(garmin_data_p); |
1105 | garmin_data_p->state = STATE_GSP_WAIT_DATA; | 1120 | garmin_data_p->state = STATE_GSP_WAIT_DATA; |
@@ -1114,13 +1129,6 @@ static int garmin_write_bulk (struct usb_serial_port *port, | |||
1114 | "failed with status = %d\n", | 1129 | "failed with status = %d\n", |
1115 | __FUNCTION__, status); | 1130 | __FUNCTION__, status); |
1116 | count = status; | 1131 | count = status; |
1117 | } else { | ||
1118 | |||
1119 | if (GARMIN_LAYERID_APPL == getLayerId(buffer) | ||
1120 | && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) { | ||
1121 | |||
1122 | gsp_send_ack(garmin_data_p, buffer[4]); | ||
1123 | } | ||
1124 | } | 1132 | } |
1125 | 1133 | ||
1126 | /* we are done with this urb, so let the host driver | 1134 | /* we are done with this urb, so let the host driver |
@@ -1135,7 +1143,6 @@ static int garmin_write_bulk (struct usb_serial_port *port, | |||
1135 | static int garmin_write (struct usb_serial_port *port, | 1143 | static int garmin_write (struct usb_serial_port *port, |
1136 | const unsigned char *buf, int count) | 1144 | const unsigned char *buf, int count) |
1137 | { | 1145 | { |
1138 | unsigned long flags; | ||
1139 | int pktid, pktsiz, len; | 1146 | int pktid, pktsiz, len; |
1140 | struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); | 1147 | struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); |
1141 | __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; | 1148 | __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; |
@@ -1186,9 +1193,7 @@ static int garmin_write (struct usb_serial_port *port, | |||
1186 | break; | 1193 | break; |
1187 | 1194 | ||
1188 | case PRIV_PKTID_RESET_REQ: | 1195 | case PRIV_PKTID_RESET_REQ: |
1189 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1196 | atomic_inc(&garmin_data_p->req_count); |
1190 | garmin_data_p->flags |= FLAGS_APP_REQ_SEEN; | ||
1191 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1192 | break; | 1197 | break; |
1193 | 1198 | ||
1194 | case PRIV_PKTID_SET_DEF_MODE: | 1199 | case PRIV_PKTID_SET_DEF_MODE: |
@@ -1241,8 +1246,6 @@ static int garmin_chars_in_buffer (struct usb_serial_port *port) | |||
1241 | static void garmin_read_process(struct garmin_data * garmin_data_p, | 1246 | static void garmin_read_process(struct garmin_data * garmin_data_p, |
1242 | unsigned char *data, unsigned data_length) | 1247 | unsigned char *data, unsigned data_length) |
1243 | { | 1248 | { |
1244 | unsigned long flags; | ||
1245 | |||
1246 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { | 1249 | if (garmin_data_p->flags & FLAGS_DROP_DATA) { |
1247 | /* abort-transfer cmd is actice */ | 1250 | /* abort-transfer cmd is actice */ |
1248 | dbg("%s - pkt dropped", __FUNCTION__); | 1251 | dbg("%s - pkt dropped", __FUNCTION__); |
@@ -1254,9 +1257,7 @@ static void garmin_read_process(struct garmin_data * garmin_data_p, | |||
1254 | the device */ | 1257 | the device */ |
1255 | if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY, | 1258 | if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY, |
1256 | sizeof(GARMIN_APP_LAYER_REPLY))) { | 1259 | sizeof(GARMIN_APP_LAYER_REPLY))) { |
1257 | spin_lock_irqsave(&garmin_data_p->lock, flags); | 1260 | atomic_inc(&garmin_data_p->resp_count); |
1258 | garmin_data_p->flags |= FLAGS_APP_RESP_SEEN; | ||
1259 | spin_unlock_irqrestore(&garmin_data_p->lock, flags); | ||
1260 | } | 1261 | } |
1261 | 1262 | ||
1262 | /* if throttling is active or postprecessing is required | 1263 | /* if throttling is active or postprecessing is required |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index dd42f57089f..2ecb1d2a034 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -2366,9 +2366,8 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa | |||
2366 | int status; | 2366 | int status; |
2367 | unsigned char number = edge_port->port->number - edge_port->port->serial->minor; | 2367 | unsigned char number = edge_port->port->number - edge_port->port->serial->minor; |
2368 | 2368 | ||
2369 | if ((!edge_serial->is_epic) || | 2369 | if (edge_serial->is_epic && |
2370 | ((edge_serial->is_epic) && | 2370 | !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) { |
2371 | (!edge_serial->epic_descriptor.Supports.IOSPSetBaudRate))) { | ||
2372 | dbg("SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d", | 2371 | dbg("SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d", |
2373 | edge_port->port->number, baudRate); | 2372 | edge_port->port->number, baudRate); |
2374 | return 0; | 2373 | return 0; |
@@ -2461,18 +2460,16 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r | |||
2461 | 2460 | ||
2462 | dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __FUNCTION__, regValue); | 2461 | dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __FUNCTION__, regValue); |
2463 | 2462 | ||
2464 | if ((!edge_serial->is_epic) || | 2463 | if (edge_serial->is_epic && |
2465 | ((edge_serial->is_epic) && | 2464 | !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && |
2466 | (!edge_serial->epic_descriptor.Supports.IOSPWriteMCR) && | 2465 | regNum == MCR) { |
2467 | (regNum == MCR))) { | ||
2468 | dbg("SendCmdWriteUartReg - Not writing to MCR Register"); | 2466 | dbg("SendCmdWriteUartReg - Not writing to MCR Register"); |
2469 | return 0; | 2467 | return 0; |
2470 | } | 2468 | } |
2471 | 2469 | ||
2472 | if ((!edge_serial->is_epic) || | 2470 | if (edge_serial->is_epic && |
2473 | ((edge_serial->is_epic) && | 2471 | !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && |
2474 | (!edge_serial->epic_descriptor.Supports.IOSPWriteLCR) && | 2472 | regNum == LCR) { |
2475 | (regNum == LCR))) { | ||
2476 | dbg ("SendCmdWriteUartReg - Not writing to LCR Register"); | 2473 | dbg ("SendCmdWriteUartReg - Not writing to LCR Register"); |
2477 | return 0; | 2474 | return 0; |
2478 | } | 2475 | } |
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 0d3903691e8..b8670905bc3 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -2794,16 +2794,14 @@ static void edge_shutdown (struct usb_serial *serial) | |||
2794 | 2794 | ||
2795 | dbg ("%s", __FUNCTION__); | 2795 | dbg ("%s", __FUNCTION__); |
2796 | 2796 | ||
2797 | for (i=0; i < serial->num_ports; ++i) { | 2797 | for (i = 0; i < serial->num_ports; ++i) { |
2798 | edge_port = usb_get_serial_port_data(serial->port[i]); | 2798 | edge_port = usb_get_serial_port_data(serial->port[i]); |
2799 | edge_remove_sysfs_attrs(edge_port->port); | 2799 | edge_remove_sysfs_attrs(edge_port->port); |
2800 | if (edge_port) { | 2800 | edge_buf_free(edge_port->ep_out_buf); |
2801 | edge_buf_free(edge_port->ep_out_buf); | 2801 | kfree(edge_port); |
2802 | kfree(edge_port); | ||
2803 | } | ||
2804 | usb_set_serial_port_data(serial->port[i], NULL); | 2802 | usb_set_serial_port_data(serial->port[i], NULL); |
2805 | } | 2803 | } |
2806 | kfree (usb_get_serial_data(serial)); | 2804 | kfree(usb_get_serial_data(serial)); |
2807 | usb_set_serial_data(serial, NULL); | 2805 | usb_set_serial_data(serial, NULL); |
2808 | } | 2806 | } |
2809 | 2807 | ||
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 0455c1552ae..e836ad07fdb 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -256,6 +256,7 @@ static struct usb_device_id ipaq_id_table [] = { | |||
256 | { USB_DEVICE(0x04DD, 0x9121) }, /* SHARP WS004SH USB Modem */ | 256 | { USB_DEVICE(0x04DD, 0x9121) }, /* SHARP WS004SH USB Modem */ |
257 | { USB_DEVICE(0x04DD, 0x9123) }, /* SHARP WS007SH USB Modem */ | 257 | { USB_DEVICE(0x04DD, 0x9123) }, /* SHARP WS007SH USB Modem */ |
258 | { USB_DEVICE(0x04DD, 0x9151) }, /* SHARP S01SH USB Modem */ | 258 | { USB_DEVICE(0x04DD, 0x9151) }, /* SHARP S01SH USB Modem */ |
259 | { USB_DEVICE(0x04DD, 0x91AC) }, /* SHARP WS011SH USB Modem */ | ||
259 | { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ | 260 | { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ |
260 | { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */ | 261 | { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */ |
261 | { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */ | 262 | { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */ |
@@ -545,6 +546,7 @@ static struct usb_device_id ipaq_id_table [] = { | |||
545 | { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ | 546 | { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ |
546 | { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ | 547 | { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ |
547 | { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ | 548 | { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ |
549 | { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC smartphone modems */ | ||
548 | { } /* Terminating entry */ | 550 | { } /* Terminating entry */ |
549 | }; | 551 | }; |
550 | 552 | ||
@@ -645,11 +647,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) | |||
645 | kfree(port->bulk_out_buffer); | 647 | kfree(port->bulk_out_buffer); |
646 | port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); | 648 | port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); |
647 | if (port->bulk_in_buffer == NULL) { | 649 | if (port->bulk_in_buffer == NULL) { |
650 | port->bulk_out_buffer = NULL; /* prevent double free */ | ||
648 | goto enomem; | 651 | goto enomem; |
649 | } | 652 | } |
650 | port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); | 653 | port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); |
651 | if (port->bulk_out_buffer == NULL) { | 654 | if (port->bulk_out_buffer == NULL) { |
652 | kfree(port->bulk_in_buffer); | 655 | kfree(port->bulk_in_buffer); |
656 | port->bulk_in_buffer = NULL; | ||
653 | goto enomem; | 657 | goto enomem; |
654 | } | 658 | } |
655 | port->read_urb->transfer_buffer = port->bulk_in_buffer; | 659 | port->read_urb->transfer_buffer = port->bulk_in_buffer; |
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 5a4127e62c4..90e3216abd1 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -728,24 +728,32 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
728 | #endif | 728 | #endif |
729 | } | 729 | } |
730 | 730 | ||
731 | switch(cflag & CBAUD) { | 731 | switch(tty_get_baud_rate(port->tty)) { |
732 | case B0: /* handled below */ | 732 | case 0: /* handled below */ |
733 | break; | 733 | break; |
734 | case B1200: priv->cfg.baudrate = kl5kusb105a_sio_b1200; | 734 | case 1200: |
735 | priv->cfg.baudrate = kl5kusb105a_sio_b1200; | ||
735 | break; | 736 | break; |
736 | case B2400: priv->cfg.baudrate = kl5kusb105a_sio_b2400; | 737 | case 2400: |
738 | priv->cfg.baudrate = kl5kusb105a_sio_b2400; | ||
737 | break; | 739 | break; |
738 | case B4800: priv->cfg.baudrate = kl5kusb105a_sio_b4800; | 740 | case 4800: |
741 | priv->cfg.baudrate = kl5kusb105a_sio_b4800; | ||
739 | break; | 742 | break; |
740 | case B9600: priv->cfg.baudrate = kl5kusb105a_sio_b9600; | 743 | case 9600: |
744 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | ||
741 | break; | 745 | break; |
742 | case B19200: priv->cfg.baudrate = kl5kusb105a_sio_b19200; | 746 | case 19200: |
747 | priv->cfg.baudrate = kl5kusb105a_sio_b19200; | ||
743 | break; | 748 | break; |
744 | case B38400: priv->cfg.baudrate = kl5kusb105a_sio_b38400; | 749 | case 38400: |
750 | priv->cfg.baudrate = kl5kusb105a_sio_b38400; | ||
745 | break; | 751 | break; |
746 | case B57600: priv->cfg.baudrate = kl5kusb105a_sio_b57600; | 752 | case 57600: |
753 | priv->cfg.baudrate = kl5kusb105a_sio_b57600; | ||
747 | break; | 754 | break; |
748 | case B115200: priv->cfg.baudrate = kl5kusb105a_sio_b115200; | 755 | case 115200: |
756 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; | ||
749 | break; | 757 | break; |
750 | default: | 758 | default: |
751 | err("KLSI USB->Serial converter:" | 759 | err("KLSI USB->Serial converter:" |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 02a86dbc0e9..6f224195bd2 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -82,6 +82,7 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | |||
82 | unsigned int set, unsigned int clear); | 82 | unsigned int set, unsigned int clear); |
83 | static void kobil_read_int_callback( struct urb *urb ); | 83 | static void kobil_read_int_callback( struct urb *urb ); |
84 | static void kobil_write_callback( struct urb *purb ); | 84 | static void kobil_write_callback( struct urb *purb ); |
85 | static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old); | ||
85 | 86 | ||
86 | 87 | ||
87 | static struct usb_device_id id_table [] = { | 88 | static struct usb_device_id id_table [] = { |
@@ -119,6 +120,7 @@ static struct usb_serial_driver kobil_device = { | |||
119 | .attach = kobil_startup, | 120 | .attach = kobil_startup, |
120 | .shutdown = kobil_shutdown, | 121 | .shutdown = kobil_shutdown, |
121 | .ioctl = kobil_ioctl, | 122 | .ioctl = kobil_ioctl, |
123 | .set_termios = kobil_set_termios, | ||
122 | .tiocmget = kobil_tiocmget, | 124 | .tiocmget = kobil_tiocmget, |
123 | .tiocmset = kobil_tiocmset, | 125 | .tiocmset = kobil_tiocmset, |
124 | .open = kobil_open, | 126 | .open = kobil_open, |
@@ -137,7 +139,6 @@ struct kobil_private { | |||
137 | int cur_pos; // index of the next char to send in buf | 139 | int cur_pos; // index of the next char to send in buf |
138 | __u16 device_type; | 140 | __u16 device_type; |
139 | int line_state; | 141 | int line_state; |
140 | struct ktermios internal_termios; | ||
141 | }; | 142 | }; |
142 | 143 | ||
143 | 144 | ||
@@ -216,7 +217,7 @@ static void kobil_shutdown (struct usb_serial *serial) | |||
216 | 217 | ||
217 | static int kobil_open (struct usb_serial_port *port, struct file *filp) | 218 | static int kobil_open (struct usb_serial_port *port, struct file *filp) |
218 | { | 219 | { |
219 | int i, result = 0; | 220 | int result = 0; |
220 | struct kobil_private *priv; | 221 | struct kobil_private *priv; |
221 | unsigned char *transfer_buffer; | 222 | unsigned char *transfer_buffer; |
222 | int transfer_buffer_length = 8; | 223 | int transfer_buffer_length = 8; |
@@ -242,16 +243,6 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) | |||
242 | port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; | 243 | port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; |
243 | port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) | 244 | port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) |
244 | 245 | ||
245 | // set up internal termios structure | ||
246 | priv->internal_termios.c_iflag = port->tty->termios->c_iflag; | ||
247 | priv->internal_termios.c_oflag = port->tty->termios->c_oflag; | ||
248 | priv->internal_termios.c_cflag = port->tty->termios->c_cflag; | ||
249 | priv->internal_termios.c_lflag = port->tty->termios->c_lflag; | ||
250 | |||
251 | for (i=0; i<NCCS; i++) { | ||
252 | priv->internal_termios.c_cc[i] = port->tty->termios->c_cc[i]; | ||
253 | } | ||
254 | |||
255 | // allocate memory for transfer buffer | 246 | // allocate memory for transfer buffer |
256 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); | 247 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); |
257 | if (! transfer_buffer) { | 248 | if (! transfer_buffer) { |
@@ -607,102 +598,79 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, | |||
607 | return (result < 0) ? result : 0; | 598 | return (result < 0) ? result : 0; |
608 | } | 599 | } |
609 | 600 | ||
610 | 601 | static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old) | |
611 | static int kobil_ioctl(struct usb_serial_port *port, struct file *file, | ||
612 | unsigned int cmd, unsigned long arg) | ||
613 | { | 602 | { |
614 | struct kobil_private * priv; | 603 | struct kobil_private * priv; |
615 | int result; | 604 | int result; |
616 | unsigned short urb_val = 0; | 605 | unsigned short urb_val = 0; |
617 | unsigned char *transfer_buffer; | 606 | int c_cflag = port->tty->termios->c_cflag; |
618 | int transfer_buffer_length = 8; | 607 | speed_t speed; |
619 | char *settings; | 608 | void * settings; |
620 | void __user *user_arg = (void __user *)arg; | ||
621 | 609 | ||
622 | priv = usb_get_serial_port_data(port); | 610 | priv = usb_get_serial_port_data(port); |
623 | if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { | 611 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) |
624 | // This device doesn't support ioctl calls | 612 | // This device doesn't support ioctl calls |
625 | return 0; | 613 | return; |
626 | } | ||
627 | |||
628 | switch (cmd) { | ||
629 | case TCGETS: // 0x5401 | ||
630 | if (!access_ok(VERIFY_WRITE, user_arg, sizeof(struct ktermios))) { | ||
631 | dbg("%s - port %d Error in access_ok", __FUNCTION__, port->number); | ||
632 | return -EFAULT; | ||
633 | } | ||
634 | if (kernel_termios_to_user_termios((struct ktermios __user *)arg, | ||
635 | &priv->internal_termios)) | ||
636 | return -EFAULT; | ||
637 | return 0; | ||
638 | |||
639 | case TCSETS: // 0x5402 | ||
640 | if (!(port->tty->termios)) { | ||
641 | dbg("%s - port %d Error: port->tty->termios is NULL", __FUNCTION__, port->number); | ||
642 | return -ENOTTY; | ||
643 | } | ||
644 | if (!access_ok(VERIFY_READ, user_arg, sizeof(struct ktermios))) { | ||
645 | dbg("%s - port %d Error in access_ok", __FUNCTION__, port->number); | ||
646 | return -EFAULT; | ||
647 | } | ||
648 | if (user_termios_to_kernel_termios(&priv->internal_termios, | ||
649 | (struct ktermios __user *)arg)) | ||
650 | return -EFAULT; | ||
651 | |||
652 | settings = kzalloc(50, GFP_KERNEL); | ||
653 | if (! settings) { | ||
654 | return -ENOBUFS; | ||
655 | } | ||
656 | 614 | ||
657 | switch (priv->internal_termios.c_cflag & CBAUD) { | 615 | switch (speed = tty_get_baud_rate(port->tty)) { |
658 | case B1200: | 616 | case 1200: |
659 | urb_val = SUSBCR_SBR_1200; | 617 | urb_val = SUSBCR_SBR_1200; |
660 | strcat(settings, "1200 "); | ||
661 | break; | 618 | break; |
662 | case B9600: | 619 | case 9600: |
663 | default: | 620 | default: |
664 | urb_val = SUSBCR_SBR_9600; | 621 | urb_val = SUSBCR_SBR_9600; |
665 | strcat(settings, "9600 "); | ||
666 | break; | 622 | break; |
667 | } | 623 | } |
624 | urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : SUSBCR_SPASB_1StopBit; | ||
625 | |||
626 | settings = kzalloc(50, GFP_KERNEL); | ||
627 | if (! settings) | ||
628 | return; | ||
668 | 629 | ||
669 | urb_val |= (priv->internal_termios.c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : SUSBCR_SPASB_1StopBit; | 630 | sprintf(settings, "%d ", speed); |
670 | strcat(settings, (priv->internal_termios.c_cflag & CSTOPB) ? "2 StopBits " : "1 StopBit "); | ||
671 | 631 | ||
672 | if (priv->internal_termios.c_cflag & PARENB) { | 632 | if (c_cflag & PARENB) { |
673 | if (priv->internal_termios.c_cflag & PARODD) { | 633 | if (c_cflag & PARODD) { |
674 | urb_val |= SUSBCR_SPASB_OddParity; | 634 | urb_val |= SUSBCR_SPASB_OddParity; |
675 | strcat(settings, "Odd Parity"); | 635 | strcat(settings, "Odd Parity"); |
676 | } else { | ||
677 | urb_val |= SUSBCR_SPASB_EvenParity; | ||
678 | strcat(settings, "Even Parity"); | ||
679 | } | ||
680 | } else { | 636 | } else { |
681 | urb_val |= SUSBCR_SPASB_NoParity; | 637 | urb_val |= SUSBCR_SPASB_EvenParity; |
682 | strcat(settings, "No Parity"); | 638 | strcat(settings, "Even Parity"); |
683 | } | 639 | } |
684 | dbg("%s - port %d setting port to: %s", __FUNCTION__, port->number, settings ); | 640 | } else { |
641 | urb_val |= SUSBCR_SPASB_NoParity; | ||
642 | strcat(settings, "No Parity"); | ||
643 | } | ||
685 | 644 | ||
686 | result = usb_control_msg( port->serial->dev, | 645 | result = usb_control_msg( port->serial->dev, |
687 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 646 | usb_rcvctrlpipe(port->serial->dev, 0 ), |
688 | SUSBCRequest_SetBaudRateParityAndStopBits, | 647 | SUSBCRequest_SetBaudRateParityAndStopBits, |
689 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | 648 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
690 | urb_val, | 649 | urb_val, |
691 | 0, | 650 | 0, |
692 | settings, | 651 | settings, |
693 | 0, | 652 | 0, |
694 | KOBIL_TIMEOUT | 653 | KOBIL_TIMEOUT |
695 | ); | 654 | ); |
655 | kfree(settings); | ||
656 | } | ||
696 | 657 | ||
697 | dbg("%s - port %d Send set_baudrate URB returns: %i", __FUNCTION__, port->number, result); | 658 | static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) |
698 | kfree(settings); | 659 | { |
660 | struct kobil_private * priv = usb_get_serial_port_data(port); | ||
661 | unsigned char *transfer_buffer; | ||
662 | int transfer_buffer_length = 8; | ||
663 | int result; | ||
664 | |||
665 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) | ||
666 | // This device doesn't support ioctl calls | ||
699 | return 0; | 667 | return 0; |
700 | 668 | ||
669 | switch (cmd) { | ||
701 | case TCFLSH: // 0x540B | 670 | case TCFLSH: // 0x540B |
702 | transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); | 671 | transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); |
703 | if (! transfer_buffer) { | 672 | if (! transfer_buffer) |
704 | return -ENOBUFS; | 673 | return -ENOBUFS; |
705 | } | ||
706 | 674 | ||
707 | result = usb_control_msg( port->serial->dev, | 675 | result = usb_control_msg( port->serial->dev, |
708 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 676 | usb_rcvctrlpipe(port->serial->dev, 0 ), |
@@ -716,15 +684,13 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, | |||
716 | ); | 684 | ); |
717 | 685 | ||
718 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __FUNCTION__, port->number, result); | 686 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __FUNCTION__, port->number, result); |
719 | |||
720 | kfree(transfer_buffer); | 687 | kfree(transfer_buffer); |
721 | return ((result < 0) ? -EFAULT : 0); | 688 | return (result < 0) ? -EFAULT : 0; |
722 | 689 | default: | |
690 | return -ENOIOCTLCMD; | ||
723 | } | 691 | } |
724 | return -ENOIOCTLCMD; | ||
725 | } | 692 | } |
726 | 693 | ||
727 | |||
728 | static int __init kobil_init (void) | 694 | static int __init kobil_init (void) |
729 | { | 695 | { |
730 | int retval; | 696 | int retval; |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 2a3fabcf518..0dc99f75bb0 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -184,21 +184,21 @@ struct mct_u232_private { | |||
184 | * we do not know how to support. We ignore them for the moment. | 184 | * we do not know how to support. We ignore them for the moment. |
185 | * XXX Rate-limit the error message, it's user triggerable. | 185 | * XXX Rate-limit the error message, it's user triggerable. |
186 | */ | 186 | */ |
187 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) | 187 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value) |
188 | { | 188 | { |
189 | if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID | 189 | if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID |
190 | || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { | 190 | || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { |
191 | switch (value) { | 191 | switch (value) { |
192 | case B300: return 0x01; | 192 | case 300: return 0x01; |
193 | case B600: return 0x02; /* this one not tested */ | 193 | case 600: return 0x02; /* this one not tested */ |
194 | case B1200: return 0x03; | 194 | case 1200: return 0x03; |
195 | case B2400: return 0x04; | 195 | case 2400: return 0x04; |
196 | case B4800: return 0x06; | 196 | case 4800: return 0x06; |
197 | case B9600: return 0x08; | 197 | case 9600: return 0x08; |
198 | case B19200: return 0x09; | 198 | case 19200: return 0x09; |
199 | case B38400: return 0x0a; | 199 | case 38400: return 0x0a; |
200 | case B57600: return 0x0b; | 200 | case 57600: return 0x0b; |
201 | case B115200: return 0x0c; | 201 | case 115200: return 0x0c; |
202 | default: | 202 | default: |
203 | err("MCT USB-RS232: unsupported baudrate request 0x%x," | 203 | err("MCT USB-RS232: unsupported baudrate request 0x%x," |
204 | " using default of B9600", value); | 204 | " using default of B9600", value); |
@@ -206,16 +206,16 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) | |||
206 | } | 206 | } |
207 | } else { | 207 | } else { |
208 | switch (value) { | 208 | switch (value) { |
209 | case B300: value = 300; break; | 209 | case 300: break; |
210 | case B600: value = 600; break; | 210 | case 600: break; |
211 | case B1200: value = 1200; break; | 211 | case 1200: break; |
212 | case B2400: value = 2400; break; | 212 | case 2400: break; |
213 | case B4800: value = 4800; break; | 213 | case 4800: break; |
214 | case B9600: value = 9600; break; | 214 | case 9600: break; |
215 | case B19200: value = 19200; break; | 215 | case 19200: break; |
216 | case B38400: value = 38400; break; | 216 | case 38400: break; |
217 | case B57600: value = 57600; break; | 217 | case 57600: break; |
218 | case B115200: value = 115200; break; | 218 | case 115200: break; |
219 | default: | 219 | default: |
220 | err("MCT USB-RS232: unsupported baudrate request 0x%x," | 220 | err("MCT USB-RS232: unsupported baudrate request 0x%x," |
221 | " using default of B9600", value); | 221 | " using default of B9600", value); |
@@ -226,7 +226,7 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) | |||
226 | } | 226 | } |
227 | 227 | ||
228 | static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port, | 228 | static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port, |
229 | int value) | 229 | speed_t value) |
230 | { | 230 | { |
231 | __le32 divisor; | 231 | __le32 divisor; |
232 | int rc; | 232 | int rc; |
@@ -634,7 +634,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port, | |||
634 | mct_u232_set_modem_ctrl(serial, control_state); | 634 | mct_u232_set_modem_ctrl(serial, control_state); |
635 | } | 635 | } |
636 | 636 | ||
637 | mct_u232_set_baud_rate(serial, port, cflag & CBAUD); | 637 | mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty)); |
638 | 638 | ||
639 | if ((cflag & CBAUD) == B0 ) { | 639 | if ((cflag & CBAUD) == B0 ) { |
640 | dbg("%s: baud is B0", __FUNCTION__); | 640 | dbg("%s: baud is B0", __FUNCTION__); |
diff --git a/drivers/usb/serial/mct_u232.h b/drivers/usb/serial/mct_u232.h index a61bac8f224..aae10c8174d 100644 --- a/drivers/usb/serial/mct_u232.h +++ b/drivers/usb/serial/mct_u232.h | |||
@@ -79,7 +79,7 @@ | |||
79 | * and "Intel solution". They are the regular MCT and "Sitecom" for us. | 79 | * and "Intel solution". They are the regular MCT and "Sitecom" for us. |
80 | * This is pointless to document in the header, see the code for the bits. | 80 | * This is pointless to document in the header, see the code for the bits. |
81 | */ | 81 | */ |
82 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value); | 82 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value); |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Line Control Register (LCR) | 85 | * Line Control Register (LCR) |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 231b584f6d0..01e811becec 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -110,11 +110,6 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
110 | 110 | ||
111 | dbg("%s"," : Entering\n"); | 111 | dbg("%s"," : Entering\n"); |
112 | 112 | ||
113 | if (!urb) { | ||
114 | dbg("%s","Invalid Pointer !!!!:\n"); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | switch (status) { | 113 | switch (status) { |
119 | case 0: | 114 | case 0: |
120 | /* success */ | 115 | /* success */ |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 37f41f576d3..f76480f1455 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -436,11 +436,6 @@ static void mos7840_control_callback(struct urb *urb) | |||
436 | int result = 0; | 436 | int result = 0; |
437 | int status = urb->status; | 437 | int status = urb->status; |
438 | 438 | ||
439 | if (!urb) { | ||
440 | dbg("%s", "Invalid Pointer !!!!:\n"); | ||
441 | return; | ||
442 | } | ||
443 | |||
444 | mos7840_port = (struct moschip_port *)urb->context; | 439 | mos7840_port = (struct moschip_port *)urb->context; |
445 | 440 | ||
446 | switch (status) { | 441 | switch (status) { |
@@ -525,10 +520,6 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
525 | int status = urb->status; | 520 | int status = urb->status; |
526 | 521 | ||
527 | dbg("%s", " : Entering\n"); | 522 | dbg("%s", " : Entering\n"); |
528 | if (!urb) { | ||
529 | dbg("%s", "Invalid Pointer !!!!:\n"); | ||
530 | return; | ||
531 | } | ||
532 | 523 | ||
533 | switch (status) { | 524 | switch (status) { |
534 | case 0: | 525 | case 0: |
@@ -676,11 +667,6 @@ static void mos7840_bulk_in_callback(struct urb *urb) | |||
676 | struct tty_struct *tty; | 667 | struct tty_struct *tty; |
677 | int status = urb->status; | 668 | int status = urb->status; |
678 | 669 | ||
679 | if (!urb) { | ||
680 | dbg("%s", "Invalid Pointer !!!!:\n"); | ||
681 | return; | ||
682 | } | ||
683 | |||
684 | if (status) { | 670 | if (status) { |
685 | dbg("nonzero read bulk status received: %d", status); | 671 | dbg("nonzero read bulk status received: %d", status); |
686 | return; | 672 | return; |
@@ -753,11 +739,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb) | |||
753 | int status = urb->status; | 739 | int status = urb->status; |
754 | int i; | 740 | int i; |
755 | 741 | ||
756 | if (!urb) { | ||
757 | dbg("%s", "Invalid Pointer !!!!:\n"); | ||
758 | return; | ||
759 | } | ||
760 | |||
761 | mos7840_port = (struct moschip_port *)urb->context; | 742 | mos7840_port = (struct moschip_port *)urb->context; |
762 | spin_lock(&mos7840_port->pool_lock); | 743 | spin_lock(&mos7840_port->pool_lock); |
763 | for (i = 0; i < NUM_URBS; i++) { | 744 | for (i = 0; i < NUM_URBS; i++) { |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 84c12b5f127..a18659e0700 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -108,8 +108,10 @@ static int option_send_setup(struct usb_serial_port *port); | |||
108 | #define HUAWEI_VENDOR_ID 0x12D1 | 108 | #define HUAWEI_VENDOR_ID 0x12D1 |
109 | #define HUAWEI_PRODUCT_E600 0x1001 | 109 | #define HUAWEI_PRODUCT_E600 0x1001 |
110 | #define HUAWEI_PRODUCT_E220 0x1003 | 110 | #define HUAWEI_PRODUCT_E220 0x1003 |
111 | #define HUAWEI_PRODUCT_E220BIS 0x1004 | ||
111 | 112 | ||
112 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 | 113 | #define NOVATELWIRELESS_VENDOR_ID 0x1410 |
114 | #define DELL_VENDOR_ID 0x413C | ||
113 | 115 | ||
114 | #define ANYDATA_VENDOR_ID 0x16d5 | 116 | #define ANYDATA_VENDOR_ID 0x16d5 |
115 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 | 117 | #define ANYDATA_PRODUCT_ADU_E100A 0x6501 |
@@ -119,8 +121,6 @@ static int option_send_setup(struct usb_serial_port *port); | |||
119 | #define BANDRICH_PRODUCT_C100_1 0x1002 | 121 | #define BANDRICH_PRODUCT_C100_1 0x1002 |
120 | #define BANDRICH_PRODUCT_C100_2 0x1003 | 122 | #define BANDRICH_PRODUCT_C100_2 0x1003 |
121 | 123 | ||
122 | #define DELL_VENDOR_ID 0x413C | ||
123 | |||
124 | static struct usb_device_id option_ids[] = { | 124 | static struct usb_device_id option_ids[] = { |
125 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 125 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
126 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 126 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
@@ -159,6 +159,7 @@ static struct usb_device_id option_ids[] = { | |||
159 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, | 159 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_ETNA_KOI_NETWORK) }, |
160 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, | 160 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, |
161 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220) }, | 161 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220) }, |
162 | { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220BIS) }, | ||
162 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1100) }, /* Novatel Merlin XS620/S640 */ | 163 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1100) }, /* Novatel Merlin XS620/S640 */ |
163 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1110) }, /* Novatel Merlin S620 */ | 164 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1110) }, /* Novatel Merlin S620 */ |
164 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1120) }, /* Novatel Merlin EX720 */ | 165 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x1120) }, /* Novatel Merlin EX720 */ |
@@ -171,11 +172,17 @@ static struct usb_device_id option_ids[] = { | |||
171 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ | 172 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ |
172 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ | 173 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ |
173 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ | 174 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ |
175 | { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ | ||
176 | { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | ||
177 | { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ | ||
178 | { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ | ||
179 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ | ||
180 | { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ | ||
181 | { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ | ||
174 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, | 182 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, |
175 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, | 183 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, |
176 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 184 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
177 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 185 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
178 | { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard */ | ||
179 | { } /* Terminating entry */ | 186 | { } /* Terminating entry */ |
180 | }; | 187 | }; |
181 | MODULE_DEVICE_TABLE(usb, option_ids); | 188 | MODULE_DEVICE_TABLE(usb, option_ids); |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index d7db71eca52..d19861166b5 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -817,23 +817,6 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, | |||
817 | __FUNCTION__, port->number, cmd, arg); | 817 | __FUNCTION__, port->number, cmd, arg); |
818 | 818 | ||
819 | switch (cmd) { | 819 | switch (cmd) { |
820 | case TCGETS: | ||
821 | if (copy_to_user(user_arg, port->tty->termios, | ||
822 | sizeof(struct ktermios))) { | ||
823 | return -EFAULT; | ||
824 | } | ||
825 | return 0; | ||
826 | |||
827 | case TCSETS: | ||
828 | case TCSETSW: /* FIXME: this is not the same! */ | ||
829 | case TCSETSF: /* FIXME: this is not the same! */ | ||
830 | if (copy_from_user(port->tty->termios, user_arg, | ||
831 | sizeof(struct ktermios))) { | ||
832 | return -EFAULT; | ||
833 | } | ||
834 | oti6858_set_termios(port, NULL); | ||
835 | return 0; | ||
836 | |||
837 | case TCFLSH: | 820 | case TCFLSH: |
838 | /* FIXME */ | 821 | /* FIXME */ |
839 | return 0; | 822 | return 0; |
@@ -1161,7 +1144,7 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) | |||
1161 | if (size == 0) | 1144 | if (size == 0) |
1162 | return NULL; | 1145 | return NULL; |
1163 | 1146 | ||
1164 | pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); | 1147 | pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); |
1165 | if (pb == NULL) | 1148 | if (pb == NULL) |
1166 | return NULL; | 1149 | return NULL; |
1167 | 1150 | ||
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index f9f85f56f0d..1da57fd9ea2 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -73,6 +73,7 @@ static struct usb_device_id id_table [] = { | |||
73 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) }, | 73 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) }, |
74 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, | 74 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, |
75 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) }, | 75 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) }, |
76 | { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_EF81) }, | ||
76 | { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, | 77 | { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, |
77 | { USB_DEVICE(NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID) }, | 78 | { USB_DEVICE(NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID) }, |
78 | { USB_DEVICE(CA_42_CA42_VENDOR_ID, CA_42_CA42_PRODUCT_ID) }, | 79 | { USB_DEVICE(CA_42_CA42_VENDOR_ID, CA_42_CA42_PRODUCT_ID) }, |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index f9a71d0c102..c39bace5cbc 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -59,6 +59,7 @@ | |||
59 | #define SIEMENS_PRODUCT_ID_SX1 0x0001 | 59 | #define SIEMENS_PRODUCT_ID_SX1 0x0001 |
60 | #define SIEMENS_PRODUCT_ID_X65 0x0003 | 60 | #define SIEMENS_PRODUCT_ID_X65 0x0003 |
61 | #define SIEMENS_PRODUCT_ID_X75 0x0004 | 61 | #define SIEMENS_PRODUCT_ID_X75 0x0004 |
62 | #define SIEMENS_PRODUCT_ID_EF81 0x0005 | ||
62 | 63 | ||
63 | #define SYNTECH_VENDOR_ID 0x0745 | 64 | #define SYNTECH_VENDOR_ID 0x0745 |
64 | #define SYNTECH_PRODUCT_ID 0x0001 | 65 | #define SYNTECH_PRODUCT_ID 0x0001 |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 86899d55d8d..4e6dcc199be 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -74,13 +74,13 @@ | |||
74 | #include <linux/usb/serial.h> | 74 | #include <linux/usb/serial.h> |
75 | 75 | ||
76 | 76 | ||
77 | #ifndef CONFIG_USB_SAFE_PADDED | 77 | #ifndef CONFIG_USB_SERIAL_SAFE_PADDED |
78 | #define CONFIG_USB_SAFE_PADDED 0 | 78 | #define CONFIG_USB_SERIAL_SAFE_PADDED 0 |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | static int debug; | 81 | static int debug; |
82 | static int safe = 1; | 82 | static int safe = 1; |
83 | static int padded = CONFIG_USB_SAFE_PADDED; | 83 | static int padded = CONFIG_USB_SERIAL_SAFE_PADDED; |
84 | 84 | ||
85 | #define DRIVER_VERSION "v0.0b" | 85 | #define DRIVER_VERSION "v0.0b" |
86 | #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com" | 86 | #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com" |
@@ -90,18 +90,12 @@ MODULE_AUTHOR (DRIVER_AUTHOR); | |||
90 | MODULE_DESCRIPTION (DRIVER_DESC); | 90 | MODULE_DESCRIPTION (DRIVER_DESC); |
91 | MODULE_LICENSE("GPL"); | 91 | MODULE_LICENSE("GPL"); |
92 | 92 | ||
93 | #if defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) && !defined(CONFIG_USBD_SAFE_SERIAL_PRODUCT) | ||
94 | #error "SAFE_SERIAL_VENDOR defined without SAFE_SERIAL_PRODUCT" | ||
95 | #endif | ||
96 | |||
97 | #if ! defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) | ||
98 | static __u16 vendor; // no default | 93 | static __u16 vendor; // no default |
99 | static __u16 product; // no default | 94 | static __u16 product; // no default |
100 | module_param(vendor, ushort, 0); | 95 | module_param(vendor, ushort, 0); |
101 | MODULE_PARM_DESC(vendor, "User specified USB idVendor (required)"); | 96 | MODULE_PARM_DESC(vendor, "User specified USB idVendor (required)"); |
102 | module_param(product, ushort, 0); | 97 | module_param(product, ushort, 0); |
103 | MODULE_PARM_DESC(product, "User specified USB idProduct (required)"); | 98 | MODULE_PARM_DESC(product, "User specified USB idProduct (required)"); |
104 | #endif | ||
105 | 99 | ||
106 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 100 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
107 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 101 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
@@ -145,11 +139,6 @@ static struct usb_device_id id_table[] = { | |||
145 | {MY_USB_DEVICE (0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie | 139 | {MY_USB_DEVICE (0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie |
146 | {MY_USB_DEVICE (0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie | 140 | {MY_USB_DEVICE (0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Collie |
147 | {MY_USB_DEVICE (0x5f9, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Sharp tmp | 141 | {MY_USB_DEVICE (0x5f9, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, // Sharp tmp |
148 | #if defined(CONFIG_USB_SAFE_SERIAL_VENDOR) | ||
149 | {MY_USB_DEVICE | ||
150 | (CONFIG_USB_SAFE_SERIAL_VENDOR, CONFIG_USB_SAFE_SERIAL_PRODUCT, CDC_DEVICE_CLASS, | ||
151 | LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, | ||
152 | #endif | ||
153 | // extra null entry for module | 142 | // extra null entry for module |
154 | // vendor/produc parameters | 143 | // vendor/produc parameters |
155 | {MY_USB_DEVICE (0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, | 144 | {MY_USB_DEVICE (0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)}, |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index e7db20343d1..0bb8de4cc52 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | USB Driver for Sierra Wireless | 2 | USB Driver for Sierra Wireless |
3 | 3 | ||
4 | Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com> | 4 | Copyright (C) 2006, 2007 Kevin Lloyd <linux@sierrawireless.com> |
5 | 5 | ||
6 | IMPORTANT DISCLAIMER: This driver is not commercially supported by | 6 | IMPORTANT DISCLAIMER: This driver is not commercially supported by |
7 | Sierra Wireless. Use at your own risk. | 7 | Sierra Wireless. Use at your own risk. |
@@ -12,10 +12,9 @@ | |||
12 | 12 | ||
13 | Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de> | 13 | Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de> |
14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> | 14 | Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> |
15 | |||
16 | */ | 15 | */ |
17 | 16 | ||
18 | #define DRIVER_VERSION "v.1.0.6" | 17 | #define DRIVER_VERSION "v.1.2.5b" |
19 | #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" | 18 | #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" |
20 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" | 19 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" |
21 | 20 | ||
@@ -28,23 +27,99 @@ | |||
28 | #include <linux/usb.h> | 27 | #include <linux/usb.h> |
29 | #include <linux/usb/serial.h> | 28 | #include <linux/usb/serial.h> |
30 | 29 | ||
30 | #define SWIMS_USB_REQUEST_SetMode 0x0B | ||
31 | #define SWIMS_USB_REQUEST_TYPE_SetMode 0x40 | ||
32 | #define SWIMS_USB_INDEX_SetMode 0x0000 | ||
33 | #define SWIMS_SET_MODE_Modem 0x0001 | ||
34 | |||
35 | /* per port private data */ | ||
36 | #define N_IN_URB 4 | ||
37 | #define N_OUT_URB 4 | ||
38 | #define IN_BUFLEN 4096 | ||
39 | |||
40 | static int debug; | ||
41 | |||
42 | enum devicetype { | ||
43 | DEVICE_3_PORT = 0, | ||
44 | DEVICE_1_PORT = 1, | ||
45 | DEVICE_INSTALLER = 2, | ||
46 | }; | ||
47 | |||
48 | static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) | ||
49 | { | ||
50 | int result; | ||
51 | dev_dbg(&udev->dev, "%s", "SET POWER STATE"); | ||
52 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
53 | 0x00, /* __u8 request */ | ||
54 | 0x40, /* __u8 request type */ | ||
55 | swiState, /* __u16 value */ | ||
56 | 0, /* __u16 index */ | ||
57 | NULL, /* void *data */ | ||
58 | 0, /* __u16 size */ | ||
59 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | ||
60 | return result; | ||
61 | } | ||
62 | |||
63 | static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode) | ||
64 | { | ||
65 | int result; | ||
66 | dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH"); | ||
67 | result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
68 | SWIMS_USB_REQUEST_SetMode, /* __u8 request */ | ||
69 | SWIMS_USB_REQUEST_TYPE_SetMode, /* __u8 request type */ | ||
70 | eSocMode, /* __u16 value */ | ||
71 | SWIMS_USB_INDEX_SetMode, /* __u16 index */ | ||
72 | NULL, /* void *data */ | ||
73 | 0, /* __u16 size */ | ||
74 | USB_CTRL_SET_TIMEOUT); /* int timeout */ | ||
75 | return result; | ||
76 | } | ||
77 | |||
78 | static int sierra_probe(struct usb_interface *iface, | ||
79 | const struct usb_device_id *id) | ||
80 | { | ||
81 | int result; | ||
82 | struct usb_device *udev; | ||
83 | |||
84 | udev = usb_get_dev(interface_to_usbdev(iface)); | ||
85 | |||
86 | /* Check if in installer mode */ | ||
87 | if (id->driver_info == DEVICE_INSTALLER) { | ||
88 | dev_dbg(&udev->dev, "%s", "FOUND DEVICE(SW)\n"); | ||
89 | result = sierra_set_ms_mode(udev, SWIMS_SET_MODE_Modem); | ||
90 | /*We do not want to bind to the device when in installer mode*/ | ||
91 | return -EIO; | ||
92 | } | ||
93 | |||
94 | return usb_serial_probe(iface, id); | ||
95 | } | ||
31 | 96 | ||
32 | static struct usb_device_id id_table [] = { | 97 | static struct usb_device_id id_table [] = { |
33 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ | 98 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ |
34 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ | 99 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ |
35 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ | 100 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ |
101 | { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ | ||
36 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ | 102 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ |
37 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ | 103 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ |
38 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */ | ||
39 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ | 104 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ |
105 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */ | ||
106 | |||
40 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ | 107 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
41 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ | 108 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
42 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ | 109 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ |
43 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ | 110 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ |
44 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ | 111 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ |
112 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ | ||
113 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ | ||
114 | { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ | ||
115 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ | ||
116 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ | ||
117 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */ | ||
45 | 118 | ||
46 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ | 119 | { USB_DEVICE(0x1199, 0x0112), .driver_info = DEVICE_1_PORT }, /* Sierra Wireless AirCard 580 */ |
47 | { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */ | 120 | { USB_DEVICE(0x0F3D, 0x0112), .driver_info = DEVICE_1_PORT }, /* Airprime/Sierra PC 5220 */ |
121 | |||
122 | { USB_DEVICE(0x1199, 0x0FFF), .driver_info = DEVICE_INSTALLER}, | ||
48 | { } | 123 | { } |
49 | }; | 124 | }; |
50 | MODULE_DEVICE_TABLE(usb, id_table); | 125 | MODULE_DEVICE_TABLE(usb, id_table); |
@@ -58,35 +133,36 @@ static struct usb_device_id id_table_1port [] = { | |||
58 | static struct usb_device_id id_table_3port [] = { | 133 | static struct usb_device_id id_table_3port [] = { |
59 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ | 134 | { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ |
60 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ | 135 | { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ |
136 | { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ | ||
61 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ | 137 | { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ |
62 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ | 138 | { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ |
63 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ | 139 | { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ |
64 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless AirCard 595U */ | ||
65 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ | 140 | { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */ |
141 | { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U*/ | ||
142 | |||
66 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ | 143 | { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ |
67 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ | 144 | { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ |
68 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ | 145 | { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ |
69 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ | 146 | { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ |
70 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ | 147 | { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ |
148 | { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ | ||
149 | { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ | ||
150 | { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ | ||
151 | { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ | ||
152 | { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880E */ | ||
153 | { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881E */ | ||
71 | { } | 154 | { } |
72 | }; | 155 | }; |
73 | 156 | ||
74 | static struct usb_driver sierra_driver = { | 157 | static struct usb_driver sierra_driver = { |
75 | .name = "sierra", | 158 | .name = "sierra", |
76 | .probe = usb_serial_probe, | 159 | .probe = sierra_probe, |
77 | .disconnect = usb_serial_disconnect, | 160 | .disconnect = usb_serial_disconnect, |
78 | .id_table = id_table, | 161 | .id_table = id_table, |
79 | .no_dynamic_id = 1, | 162 | .no_dynamic_id = 1, |
80 | }; | 163 | }; |
81 | 164 | ||
82 | 165 | ||
83 | static int debug; | ||
84 | |||
85 | /* per port private data */ | ||
86 | #define N_IN_URB 4 | ||
87 | #define N_OUT_URB 4 | ||
88 | #define IN_BUFLEN 4096 | ||
89 | |||
90 | struct sierra_port_private { | 166 | struct sierra_port_private { |
91 | spinlock_t lock; /* lock the structure */ | 167 | spinlock_t lock; /* lock the structure */ |
92 | int outstanding_urbs; /* number of out urbs in flight */ | 168 | int outstanding_urbs; /* number of out urbs in flight */ |
@@ -421,7 +497,6 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp) | |||
421 | int i; | 497 | int i; |
422 | struct urb *urb; | 498 | struct urb *urb; |
423 | int result; | 499 | int result; |
424 | __u16 set_mode_dzero = 0x0000; | ||
425 | 500 | ||
426 | portdata = usb_get_serial_port_data(port); | 501 | portdata = usb_get_serial_port_data(port); |
427 | 502 | ||
@@ -457,12 +532,6 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp) | |||
457 | 532 | ||
458 | port->tty->low_latency = 1; | 533 | port->tty->low_latency = 1; |
459 | 534 | ||
460 | /* set mode to D0 */ | ||
461 | result = usb_control_msg(serial->dev, | ||
462 | usb_rcvctrlpipe(serial->dev, 0), | ||
463 | 0x00, 0x40, set_mode_dzero, 0, NULL, | ||
464 | 0, USB_CTRL_SET_TIMEOUT); | ||
465 | |||
466 | sierra_send_setup(port); | 535 | sierra_send_setup(port); |
467 | 536 | ||
468 | /* start up the interrupt endpoint if we have one */ | 537 | /* start up the interrupt endpoint if we have one */ |
@@ -510,6 +579,9 @@ static int sierra_startup(struct usb_serial *serial) | |||
510 | 579 | ||
511 | dbg("%s", __FUNCTION__); | 580 | dbg("%s", __FUNCTION__); |
512 | 581 | ||
582 | /*Set Device mode to D0 */ | ||
583 | sierra_set_power_state(serial->dev, 0x0000); | ||
584 | |||
513 | /* Now setup per port private data */ | 585 | /* Now setup per port private data */ |
514 | for (i = 0; i < serial->num_ports; i++) { | 586 | for (i = 0; i < serial->num_ports; i++) { |
515 | port = serial->port[i]; | 587 | port = serial->port[i]; |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index a3665659d13..4b1bd7def4a 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -60,19 +60,19 @@ static struct usb_driver usb_serial_driver = { | |||
60 | 60 | ||
61 | static int debug; | 61 | static int debug; |
62 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ | 62 | static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ |
63 | static spinlock_t table_lock; | 63 | static DEFINE_MUTEX(table_lock); |
64 | static LIST_HEAD(usb_serial_driver_list); | 64 | static LIST_HEAD(usb_serial_driver_list); |
65 | 65 | ||
66 | struct usb_serial *usb_serial_get_by_index(unsigned index) | 66 | struct usb_serial *usb_serial_get_by_index(unsigned index) |
67 | { | 67 | { |
68 | struct usb_serial *serial; | 68 | struct usb_serial *serial; |
69 | 69 | ||
70 | spin_lock(&table_lock); | 70 | mutex_lock(&table_lock); |
71 | serial = serial_table[index]; | 71 | serial = serial_table[index]; |
72 | 72 | ||
73 | if (serial) | 73 | if (serial) |
74 | kref_get(&serial->kref); | 74 | kref_get(&serial->kref); |
75 | spin_unlock(&table_lock); | 75 | mutex_unlock(&table_lock); |
76 | return serial; | 76 | return serial; |
77 | } | 77 | } |
78 | 78 | ||
@@ -84,7 +84,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po | |||
84 | dbg("%s %d", __FUNCTION__, num_ports); | 84 | dbg("%s %d", __FUNCTION__, num_ports); |
85 | 85 | ||
86 | *minor = 0; | 86 | *minor = 0; |
87 | spin_lock(&table_lock); | 87 | mutex_lock(&table_lock); |
88 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { | 88 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
89 | if (serial_table[i]) | 89 | if (serial_table[i]) |
90 | continue; | 90 | continue; |
@@ -106,10 +106,10 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po | |||
106 | serial_table[i] = serial; | 106 | serial_table[i] = serial; |
107 | serial->port[j++]->number = i; | 107 | serial->port[j++]->number = i; |
108 | } | 108 | } |
109 | spin_unlock(&table_lock); | 109 | mutex_unlock(&table_lock); |
110 | return serial; | 110 | return serial; |
111 | } | 111 | } |
112 | spin_unlock(&table_lock); | 112 | mutex_unlock(&table_lock); |
113 | return NULL; | 113 | return NULL; |
114 | } | 114 | } |
115 | 115 | ||
@@ -172,9 +172,9 @@ static void destroy_serial(struct kref *kref) | |||
172 | 172 | ||
173 | void usb_serial_put(struct usb_serial *serial) | 173 | void usb_serial_put(struct usb_serial *serial) |
174 | { | 174 | { |
175 | spin_lock(&table_lock); | 175 | mutex_lock(&table_lock); |
176 | kref_put(&serial->kref, destroy_serial); | 176 | kref_put(&serial->kref, destroy_serial); |
177 | spin_unlock(&table_lock); | 177 | mutex_unlock(&table_lock); |
178 | } | 178 | } |
179 | 179 | ||
180 | /***************************************************************************** | 180 | /***************************************************************************** |
@@ -578,6 +578,17 @@ static void kill_traffic(struct usb_serial_port *port) | |||
578 | { | 578 | { |
579 | usb_kill_urb(port->read_urb); | 579 | usb_kill_urb(port->read_urb); |
580 | usb_kill_urb(port->write_urb); | 580 | usb_kill_urb(port->write_urb); |
581 | /* | ||
582 | * This is tricky. | ||
583 | * Some drivers submit the read_urb in the | ||
584 | * handler for the write_urb or vice versa | ||
585 | * this order determines the order in which | ||
586 | * usb_kill_urb() must be used to reliably | ||
587 | * kill the URBs. As it is unknown here, | ||
588 | * both orders must be used in turn. | ||
589 | * The call below is not redundant. | ||
590 | */ | ||
591 | usb_kill_urb(port->read_urb); | ||
581 | usb_kill_urb(port->interrupt_in_urb); | 592 | usb_kill_urb(port->interrupt_in_urb); |
582 | usb_kill_urb(port->interrupt_out_urb); | 593 | usb_kill_urb(port->interrupt_out_urb); |
583 | } | 594 | } |
@@ -651,16 +662,14 @@ exit: | |||
651 | 662 | ||
652 | static struct usb_serial_driver *search_serial_device(struct usb_interface *iface) | 663 | static struct usb_serial_driver *search_serial_device(struct usb_interface *iface) |
653 | { | 664 | { |
654 | struct list_head *p; | ||
655 | const struct usb_device_id *id; | 665 | const struct usb_device_id *id; |
656 | struct usb_serial_driver *t; | 666 | struct usb_serial_driver *drv; |
657 | 667 | ||
658 | /* Check if the usb id matches a known device */ | 668 | /* Check if the usb id matches a known device */ |
659 | list_for_each(p, &usb_serial_driver_list) { | 669 | list_for_each_entry(drv, &usb_serial_driver_list, driver_list) { |
660 | t = list_entry(p, struct usb_serial_driver, driver_list); | 670 | id = get_iface_id(drv, iface); |
661 | id = get_iface_id(t, iface); | ||
662 | if (id) | 671 | if (id) |
663 | return t; | 672 | return drv; |
664 | } | 673 | } |
665 | 674 | ||
666 | return NULL; | 675 | return NULL; |
@@ -800,9 +809,6 @@ int usb_serial_probe(struct usb_interface *interface, | |||
800 | /* END HORRIBLE HACK FOR PL2303 */ | 809 | /* END HORRIBLE HACK FOR PL2303 */ |
801 | #endif | 810 | #endif |
802 | 811 | ||
803 | /* found all that we need */ | ||
804 | dev_info(&interface->dev, "%s converter detected\n", type->description); | ||
805 | |||
806 | #ifdef CONFIG_USB_SERIAL_GENERIC | 812 | #ifdef CONFIG_USB_SERIAL_GENERIC |
807 | if (type == &usb_serial_generic_device) { | 813 | if (type == &usb_serial_generic_device) { |
808 | num_ports = num_bulk_out; | 814 | num_ports = num_bulk_out; |
@@ -836,6 +842,24 @@ int usb_serial_probe(struct usb_interface *interface, | |||
836 | serial->num_interrupt_in = num_interrupt_in; | 842 | serial->num_interrupt_in = num_interrupt_in; |
837 | serial->num_interrupt_out = num_interrupt_out; | 843 | serial->num_interrupt_out = num_interrupt_out; |
838 | 844 | ||
845 | /* check that the device meets the driver's requirements */ | ||
846 | if ((type->num_interrupt_in != NUM_DONT_CARE && | ||
847 | type->num_interrupt_in != num_interrupt_in) | ||
848 | || (type->num_interrupt_out != NUM_DONT_CARE && | ||
849 | type->num_interrupt_out != num_interrupt_out) | ||
850 | || (type->num_bulk_in != NUM_DONT_CARE && | ||
851 | type->num_bulk_in != num_bulk_in) | ||
852 | || (type->num_bulk_out != NUM_DONT_CARE && | ||
853 | type->num_bulk_out != num_bulk_out)) { | ||
854 | dbg("wrong number of endpoints"); | ||
855 | kfree(serial); | ||
856 | return -EIO; | ||
857 | } | ||
858 | |||
859 | /* found all that we need */ | ||
860 | dev_info(&interface->dev, "%s converter detected\n", | ||
861 | type->description); | ||
862 | |||
839 | /* create our ports, we need as many as the max endpoints */ | 863 | /* create our ports, we need as many as the max endpoints */ |
840 | /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */ | 864 | /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */ |
841 | max_endpoints = max(num_bulk_in, num_bulk_out); | 865 | max_endpoints = max(num_bulk_in, num_bulk_out); |
@@ -1077,16 +1101,17 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) | |||
1077 | struct usb_serial_port *port; | 1101 | struct usb_serial_port *port; |
1078 | int i, r = 0; | 1102 | int i, r = 0; |
1079 | 1103 | ||
1080 | if (serial) { | 1104 | if (!serial) /* device has been disconnected */ |
1081 | for (i = 0; i < serial->num_ports; ++i) { | 1105 | return 0; |
1082 | port = serial->port[i]; | 1106 | |
1083 | if (port) | 1107 | for (i = 0; i < serial->num_ports; ++i) { |
1084 | kill_traffic(port); | 1108 | port = serial->port[i]; |
1085 | } | 1109 | if (port) |
1110 | kill_traffic(port); | ||
1086 | } | 1111 | } |
1087 | 1112 | ||
1088 | if (serial->type->suspend) | 1113 | if (serial->type->suspend) |
1089 | serial->type->suspend(serial, message); | 1114 | r = serial->type->suspend(serial, message); |
1090 | 1115 | ||
1091 | return r; | 1116 | return r; |
1092 | } | 1117 | } |
@@ -1128,7 +1153,6 @@ static int __init usb_serial_init(void) | |||
1128 | return -ENOMEM; | 1153 | return -ENOMEM; |
1129 | 1154 | ||
1130 | /* Initialize our global data */ | 1155 | /* Initialize our global data */ |
1131 | spin_lock_init(&table_lock); | ||
1132 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { | 1156 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
1133 | serial_table[i] = NULL; | 1157 | serial_table[i] = NULL; |
1134 | } | 1158 | } |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 7d84a7647e8..7ee087fed91 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -46,7 +46,6 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id | |||
46 | static int visor_calc_num_ports(struct usb_serial *serial); | 46 | static int visor_calc_num_ports(struct usb_serial *serial); |
47 | static void visor_shutdown (struct usb_serial *serial); | 47 | static void visor_shutdown (struct usb_serial *serial); |
48 | static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); | 48 | static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); |
49 | static void visor_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); | ||
50 | static void visor_write_bulk_callback (struct urb *urb); | 49 | static void visor_write_bulk_callback (struct urb *urb); |
51 | static void visor_read_bulk_callback (struct urb *urb); | 50 | static void visor_read_bulk_callback (struct urb *urb); |
52 | static void visor_read_int_callback (struct urb *urb); | 51 | static void visor_read_int_callback (struct urb *urb); |
@@ -104,6 +103,8 @@ static struct usb_device_id id_table [] = { | |||
104 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, | 103 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, |
105 | { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID), | 104 | { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID), |
106 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, | 105 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, |
106 | { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID), | ||
107 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, | ||
107 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), | 108 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), |
108 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, | 109 | .driver_info = (kernel_ulong_t)&palm_os_4_probe }, |
109 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), | 110 | { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), |
@@ -201,7 +202,6 @@ static struct usb_serial_driver handspring_device = { | |||
201 | .calc_num_ports = visor_calc_num_ports, | 202 | .calc_num_ports = visor_calc_num_ports, |
202 | .shutdown = visor_shutdown, | 203 | .shutdown = visor_shutdown, |
203 | .ioctl = visor_ioctl, | 204 | .ioctl = visor_ioctl, |
204 | .set_termios = visor_set_termios, | ||
205 | .write = visor_write, | 205 | .write = visor_write, |
206 | .write_room = visor_write_room, | 206 | .write_room = visor_write_room, |
207 | .chars_in_buffer = visor_chars_in_buffer, | 207 | .chars_in_buffer = visor_chars_in_buffer, |
@@ -232,7 +232,6 @@ static struct usb_serial_driver clie_5_device = { | |||
232 | .calc_num_ports = visor_calc_num_ports, | 232 | .calc_num_ports = visor_calc_num_ports, |
233 | .shutdown = visor_shutdown, | 233 | .shutdown = visor_shutdown, |
234 | .ioctl = visor_ioctl, | 234 | .ioctl = visor_ioctl, |
235 | .set_termios = visor_set_termios, | ||
236 | .write = visor_write, | 235 | .write = visor_write, |
237 | .write_room = visor_write_room, | 236 | .write_room = visor_write_room, |
238 | .chars_in_buffer = visor_chars_in_buffer, | 237 | .chars_in_buffer = visor_chars_in_buffer, |
@@ -260,7 +259,6 @@ static struct usb_serial_driver clie_3_5_device = { | |||
260 | .unthrottle = visor_unthrottle, | 259 | .unthrottle = visor_unthrottle, |
261 | .attach = clie_3_5_startup, | 260 | .attach = clie_3_5_startup, |
262 | .ioctl = visor_ioctl, | 261 | .ioctl = visor_ioctl, |
263 | .set_termios = visor_set_termios, | ||
264 | .write = visor_write, | 262 | .write = visor_write, |
265 | .write_room = visor_write_room, | 263 | .write_room = visor_write_room, |
266 | .chars_in_buffer = visor_chars_in_buffer, | 264 | .chars_in_buffer = visor_chars_in_buffer, |
@@ -934,66 +932,6 @@ static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsign | |||
934 | return -ENOIOCTLCMD; | 932 | return -ENOIOCTLCMD; |
935 | } | 933 | } |
936 | 934 | ||
937 | |||
938 | /* This function is all nice and good, but we don't change anything based on it :) */ | ||
939 | static void visor_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | ||
940 | { | ||
941 | unsigned int cflag; | ||
942 | |||
943 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
944 | |||
945 | if ((!port->tty) || (!port->tty->termios)) { | ||
946 | dbg("%s - no tty structures", __FUNCTION__); | ||
947 | return; | ||
948 | } | ||
949 | |||
950 | cflag = port->tty->termios->c_cflag; | ||
951 | |||
952 | /* get the byte size */ | ||
953 | switch (cflag & CSIZE) { | ||
954 | case CS5: dbg("%s - data bits = 5", __FUNCTION__); break; | ||
955 | case CS6: dbg("%s - data bits = 6", __FUNCTION__); break; | ||
956 | case CS7: dbg("%s - data bits = 7", __FUNCTION__); break; | ||
957 | default: | ||
958 | case CS8: dbg("%s - data bits = 8", __FUNCTION__); break; | ||
959 | } | ||
960 | |||
961 | /* determine the parity */ | ||
962 | if (cflag & PARENB) | ||
963 | if (cflag & PARODD) | ||
964 | dbg("%s - parity = odd", __FUNCTION__); | ||
965 | else | ||
966 | dbg("%s - parity = even", __FUNCTION__); | ||
967 | else | ||
968 | dbg("%s - parity = none", __FUNCTION__); | ||
969 | |||
970 | /* figure out the stop bits requested */ | ||
971 | if (cflag & CSTOPB) | ||
972 | dbg("%s - stop bits = 2", __FUNCTION__); | ||
973 | else | ||
974 | dbg("%s - stop bits = 1", __FUNCTION__); | ||
975 | |||
976 | |||
977 | /* figure out the flow control settings */ | ||
978 | if (cflag & CRTSCTS) | ||
979 | dbg("%s - RTS/CTS is enabled", __FUNCTION__); | ||
980 | else | ||
981 | dbg("%s - RTS/CTS is disabled", __FUNCTION__); | ||
982 | |||
983 | /* determine software flow control */ | ||
984 | if (I_IXOFF(port->tty)) | ||
985 | dbg("%s - XON/XOFF is enabled, XON = %2x, XOFF = %2x", | ||
986 | __FUNCTION__, START_CHAR(port->tty), STOP_CHAR(port->tty)); | ||
987 | else | ||
988 | dbg("%s - XON/XOFF is disabled", __FUNCTION__); | ||
989 | |||
990 | /* get the baud rate wanted */ | ||
991 | dbg("%s - baud rate = %d", __FUNCTION__, tty_get_baud_rate(port->tty)); | ||
992 | |||
993 | return; | ||
994 | } | ||
995 | |||
996 | |||
997 | static int __init visor_init (void) | 935 | static int __init visor_init (void) |
998 | { | 936 | { |
999 | int i, retval; | 937 | int i, retval; |
diff --git a/drivers/usb/serial/visor.h b/drivers/usb/serial/visor.h index 4ce6f62a6f3..57229cf6647 100644 --- a/drivers/usb/serial/visor.h +++ b/drivers/usb/serial/visor.h | |||
@@ -48,6 +48,9 @@ | |||
48 | #define SONY_CLIE_UX50_ID 0x0144 | 48 | #define SONY_CLIE_UX50_ID 0x0144 |
49 | #define SONY_CLIE_TJ25_ID 0x0169 | 49 | #define SONY_CLIE_TJ25_ID 0x0169 |
50 | 50 | ||
51 | #define ACER_VENDOR_ID 0x0502 | ||
52 | #define ACER_S10_ID 0x0001 | ||
53 | |||
51 | #define SAMSUNG_VENDOR_ID 0x04E8 | 54 | #define SAMSUNG_VENDOR_ID 0x04E8 |
52 | #define SAMSUNG_SCH_I330_ID 0x8001 | 55 | #define SAMSUNG_SCH_I330_ID 0x8001 |
53 | #define SAMSUNG_SPH_I500_ID 0x6601 | 56 | #define SAMSUNG_SPH_I500_ID 0x6601 |