aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/aircable.c19
-rw-r--r--drivers/usb/serial/airprime.c355
-rw-r--r--drivers/usb/serial/ark3116.c32
-rw-r--r--drivers/usb/serial/belkin_sa.c69
-rw-r--r--drivers/usb/serial/ch341.c10
-rw-r--r--drivers/usb/serial/console.c34
-rw-r--r--drivers/usb/serial/cp2101.c74
-rw-r--r--drivers/usb/serial/cyberjack.c47
-rw-r--r--drivers/usb/serial/cypress_m8.c117
-rw-r--r--drivers/usb/serial/digi_acceleport.c127
-rw-r--r--drivers/usb/serial/empeg.c78
-rw-r--r--drivers/usb/serial/ftdi_sio.c211
-rw-r--r--drivers/usb/serial/garmin_gps.c58
-rw-r--r--drivers/usb/serial/generic.c39
-rw-r--r--drivers/usb/serial/io_edgeport.c175
-rw-r--r--drivers/usb/serial/io_ti.c109
-rw-r--r--drivers/usb/serial/ipaq.c48
-rw-r--r--drivers/usb/serial/ipw.c15
-rw-r--r--drivers/usb/serial/ir-usb.c81
-rw-r--r--drivers/usb/serial/iuu_phoenix.c43
-rw-r--r--drivers/usb/serial/keyspan.c138
-rw-r--r--drivers/usb/serial/keyspan.h39
-rw-r--r--drivers/usb/serial/keyspan_pda.c69
-rw-r--r--drivers/usb/serial/kl5kusb105.c74
-rw-r--r--drivers/usb/serial/kobil_sct.c80
-rw-r--r--drivers/usb/serial/mct_u232.c121
-rw-r--r--drivers/usb/serial/mos7720.c87
-rw-r--r--drivers/usb/serial/mos7840.c165
-rw-r--r--drivers/usb/serial/navman.c10
-rw-r--r--drivers/usb/serial/omninet.c26
-rw-r--r--drivers/usb/serial/option.c105
-rw-r--r--drivers/usb/serial/oti6858.c119
-rw-r--r--drivers/usb/serial/pl2303.c76
-rw-r--r--drivers/usb/serial/safe_serial.c14
-rw-r--r--drivers/usb/serial/sierra.c93
-rw-r--r--drivers/usb/serial/spcp8x5.c69
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c203
-rw-r--r--drivers/usb/serial/usb-serial.c82
-rw-r--r--drivers/usb/serial/usb_debug.c5
-rw-r--r--drivers/usb/serial/visor.c66
-rw-r--r--drivers/usb/serial/whiteheat.c102
41 files changed, 1790 insertions, 1694 deletions
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index db6f97a93c02..79ea98c66fa8 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work)
272 * 64 bytes, to ensure I do not get throttled. 272 * 64 bytes, to ensure I do not get throttled.
273 * Ask USB mailing list for better aproach. 273 * Ask USB mailing list for better aproach.
274 */ 274 */
275 tty = port->tty; 275 tty = port->port.tty;
276 276
277 if (!tty) { 277 if (!tty) {
278 schedule_work(&priv->rx_work); 278 schedule_work(&priv->rx_work);
@@ -378,13 +378,14 @@ static void aircable_shutdown(struct usb_serial *serial)
378 } 378 }
379} 379}
380 380
381static int aircable_write_room(struct usb_serial_port *port) 381static int aircable_write_room(struct tty_struct *tty)
382{ 382{
383 struct usb_serial_port *port = tty->driver_data;
383 struct aircable_private *priv = usb_get_serial_port_data(port); 384 struct aircable_private *priv = usb_get_serial_port_data(port);
384 return serial_buf_data_avail(priv->tx_buf); 385 return serial_buf_data_avail(priv->tx_buf);
385} 386}
386 387
387static int aircable_write(struct usb_serial_port *port, 388static int aircable_write(struct tty_struct *tty, struct usb_serial_port *port,
388 const unsigned char *source, int count) 389 const unsigned char *source, int count)
389{ 390{
390 struct aircable_private *priv = usb_get_serial_port_data(port); 391 struct aircable_private *priv = usb_get_serial_port_data(port);
@@ -466,7 +467,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
466 467
467 if (status) { 468 if (status) {
468 dbg("%s - urb status = %d", __func__, status); 469 dbg("%s - urb status = %d", __func__, status);
469 if (!port->open_count) { 470 if (!port->port.count) {
470 dbg("%s - port is closed, exiting.", __func__); 471 dbg("%s - port is closed, exiting.", __func__);
471 return; 472 return;
472 } 473 }
@@ -494,7 +495,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
494 usb_serial_debug_data(debug, &port->dev, __func__, 495 usb_serial_debug_data(debug, &port->dev, __func__,
495 urb->actual_length, urb->transfer_buffer); 496 urb->actual_length, urb->transfer_buffer);
496 497
497 tty = port->tty; 498 tty = port->port.tty;
498 if (tty && urb->actual_length) { 499 if (tty && urb->actual_length) {
499 if (urb->actual_length <= 2) { 500 if (urb->actual_length <= 2) {
500 /* This is an incomplete package */ 501 /* This is an incomplete package */
@@ -528,7 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
528 } 529 }
529 530
530 /* Schedule the next read _if_ we are still open */ 531 /* Schedule the next read _if_ we are still open */
531 if (port->open_count) { 532 if (port->port.count) {
532 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 533 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
533 usb_rcvbulkpipe(port->serial->dev, 534 usb_rcvbulkpipe(port->serial->dev,
534 port->bulk_in_endpointAddress), 535 port->bulk_in_endpointAddress),
@@ -547,8 +548,9 @@ static void aircable_read_bulk_callback(struct urb *urb)
547} 548}
548 549
549/* Based on ftdi_sio.c throttle */ 550/* Based on ftdi_sio.c throttle */
550static void aircable_throttle(struct usb_serial_port *port) 551static void aircable_throttle(struct tty_struct *tty)
551{ 552{
553 struct usb_serial_port *port = tty->driver_data;
552 struct aircable_private *priv = usb_get_serial_port_data(port); 554 struct aircable_private *priv = usb_get_serial_port_data(port);
553 unsigned long flags; 555 unsigned long flags;
554 556
@@ -560,8 +562,9 @@ static void aircable_throttle(struct usb_serial_port *port)
560} 562}
561 563
562/* Based on ftdi_sio.c unthrottle */ 564/* Based on ftdi_sio.c unthrottle */
563static void aircable_unthrottle(struct usb_serial_port *port) 565static void aircable_unthrottle(struct tty_struct *tty)
564{ 566{
567 struct usb_serial_port *port = tty->driver_data;
565 struct aircable_private *priv = usb_get_serial_port_data(port); 568 struct aircable_private *priv = usb_get_serial_port_data(port);
566 int actually_throttled; 569 int actually_throttled;
567 unsigned long flags; 570 unsigned long flags;
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
new file mode 100644
index 000000000000..b3f1d1e82468
--- /dev/null
+++ b/drivers/usb/serial/airprime.c
@@ -0,0 +1,355 @@
1/*
2 * AirPrime CDMA Wireless Serial USB driver
3 *
4 * Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/tty_flip.h>
15#include <linux/module.h>
16#include <linux/usb.h>
17#include <linux/usb/serial.h>
18
19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { },
22};
23MODULE_DEVICE_TABLE(usb, id_table);
24
25#define URB_TRANSFER_BUFFER_SIZE 4096
26#define NUM_READ_URBS 4
27#define NUM_WRITE_URBS 4
28#define NUM_BULK_EPS 3
29#define MAX_BULK_EPS 6
30
31/* if overridden by the user, then use their value for the size of the
32 * read and write urbs, and the number of endpoints */
33static int buffer_size = URB_TRANSFER_BUFFER_SIZE;
34static int endpoints = NUM_BULK_EPS;
35static int debug;
36struct airprime_private {
37 spinlock_t lock;
38 int outstanding_urbs;
39 int throttled;
40 struct urb *read_urbp[NUM_READ_URBS];
41
42 /* Settings for the port */
43 int rts_state; /* Handshaking pins (outputs) */
44 int dtr_state;
45 int cts_state; /* Handshaking pins (inputs) */
46 int dsr_state;
47 int dcd_state;
48 int ri_state;
49};
50
51static int airprime_send_setup(struct usb_serial_port *port)
52{
53 struct usb_serial *serial = port->serial;
54 struct airprime_private *priv;
55
56 dbg("%s", __func__);
57
58 if (port->number != 0)
59 return 0;
60
61 priv = usb_get_serial_port_data(port);
62
63 if (port->port.tty) {
64 int val = 0;
65 if (priv->dtr_state)
66 val |= 0x01;
67 if (priv->rts_state)
68 val |= 0x02;
69
70 return usb_control_msg(serial->dev,
71 usb_rcvctrlpipe(serial->dev, 0),
72 0x22, 0x21, val, 0, NULL, 0,
73 USB_CTRL_SET_TIMEOUT);
74 }
75
76 return 0;
77}
78
79static void airprime_read_bulk_callback(struct urb *urb)
80{
81 struct usb_serial_port *port = urb->context;
82 unsigned char *data = urb->transfer_buffer;
83 struct tty_struct *tty;
84 int result;
85 int status = urb->status;
86
87 dbg("%s - port %d", __func__, port->number);
88
89 if (status) {
90 dbg("%s - nonzero read bulk status received: %d",
91 __func__, status);
92 return;
93 }
94 usb_serial_debug_data(debug, &port->dev, __func__,
95 urb->actual_length, data);
96
97 tty = port->port.tty;
98 if (tty && urb->actual_length) {
99 tty_insert_flip_string(tty, data, urb->actual_length);
100 tty_flip_buffer_push(tty);
101 }
102
103 result = usb_submit_urb(urb, GFP_ATOMIC);
104 if (result)
105 dev_err(&port->dev,
106 "%s - failed resubmitting read urb, error %d\n",
107 __func__, result);
108 return;
109}
110
111static void airprime_write_bulk_callback(struct urb *urb)
112{
113 struct usb_serial_port *port = urb->context;
114 struct airprime_private *priv = usb_get_serial_port_data(port);
115 int status = urb->status;
116 unsigned long flags;
117
118 dbg("%s - port %d", __func__, port->number);
119
120 /* free up the transfer buffer, as usb_free_urb() does not do this */
121 kfree(urb->transfer_buffer);
122
123 if (status)
124 dbg("%s - nonzero write bulk status received: %d",
125 __func__, status);
126 spin_lock_irqsave(&priv->lock, flags);
127 --priv->outstanding_urbs;
128 spin_unlock_irqrestore(&priv->lock, flags);
129
130 usb_serial_port_softint(port);
131}
132
133static int airprime_open(struct tty_struct *tty, struct usb_serial_port *port,
134 struct file *filp)
135{
136 struct airprime_private *priv = usb_get_serial_port_data(port);
137 struct usb_serial *serial = port->serial;
138 struct urb *urb;
139 char *buffer = NULL;
140 int i;
141 int result = 0;
142
143 dbg("%s - port %d", __func__, port->number);
144
145 /* initialize our private data structure if it isn't already created */
146 if (!priv) {
147 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
148 if (!priv) {
149 result = -ENOMEM;
150 goto out;
151 }
152 spin_lock_init(&priv->lock);
153 usb_set_serial_port_data(port, priv);
154 }
155
156 /* Set some sane defaults */
157 priv->rts_state = 1;
158 priv->dtr_state = 1;
159
160 for (i = 0; i < NUM_READ_URBS; ++i) {
161 buffer = kmalloc(buffer_size, GFP_KERNEL);
162 if (!buffer) {
163 dev_err(&port->dev, "%s - out of memory.\n",
164 __func__);
165 result = -ENOMEM;
166 goto errout;
167 }
168 urb = usb_alloc_urb(0, GFP_KERNEL);
169 if (!urb) {
170 kfree(buffer);
171 dev_err(&port->dev, "%s - no more urbs?\n",
172 __func__);
173 result = -ENOMEM;
174 goto errout;
175 }
176 usb_fill_bulk_urb(urb, serial->dev,
177 usb_rcvbulkpipe(serial->dev,
178 port->bulk_out_endpointAddress),
179 buffer, buffer_size,
180 airprime_read_bulk_callback, port);
181 result = usb_submit_urb(urb, GFP_KERNEL);
182 if (result) {
183 usb_free_urb(urb);
184 kfree(buffer);
185 dev_err(&port->dev,
186 "%s - failed submitting read urb %d for port %d, error %d\n",
187 __func__, i, port->number, result);
188 goto errout;
189 }
190 /* remember this urb so we can kill it when the
191 port is closed */
192 priv->read_urbp[i] = urb;
193 }
194
195 airprime_send_setup(port);
196
197 goto out;
198
199 errout:
200 /* some error happened, cancel any submitted urbs and clean up
201 anything that got allocated successfully */
202
203 while (i-- != 0) {
204 urb = priv->read_urbp[i];
205 buffer = urb->transfer_buffer;
206 usb_kill_urb(urb);
207 usb_free_urb(urb);
208 kfree(buffer);
209 }
210
211 out:
212 return result;
213}
214
215static void airprime_close(struct tty_struct *tty,
216 struct usb_serial_port *port, struct file *filp)
217{
218 struct airprime_private *priv = usb_get_serial_port_data(port);
219 int i;
220
221 dbg("%s - port %d", __func__, port->number);
222
223 priv->rts_state = 0;
224 priv->dtr_state = 0;
225
226 mutex_lock(&port->serial->disc_mutex);
227 if (!port->serial->disconnected)
228 airprime_send_setup(port);
229 mutex_unlock(&port->serial->disc_mutex);
230
231 for (i = 0; i < NUM_READ_URBS; ++i) {
232 usb_kill_urb(priv->read_urbp[i]);
233 kfree(priv->read_urbp[i]->transfer_buffer);
234 usb_free_urb(priv->read_urbp[i]);
235 }
236
237 /* free up private structure */
238 kfree(priv);
239 usb_set_serial_port_data(port, NULL);
240}
241
242static int airprime_write(struct tty_struct *tty, struct usb_serial_port *port,
243 const unsigned char *buf, int count)
244{
245 struct airprime_private *priv = usb_get_serial_port_data(port);
246 struct usb_serial *serial = port->serial;
247 struct urb *urb;
248 unsigned char *buffer;
249 unsigned long flags;
250 int status;
251 dbg("%s - port %d", __func__, port->number);
252
253 spin_lock_irqsave(&priv->lock, flags);
254 if (priv->outstanding_urbs > NUM_WRITE_URBS) {
255 spin_unlock_irqrestore(&priv->lock, flags);
256 dbg("%s - write limit hit\n", __func__);
257 return 0;
258 }
259 spin_unlock_irqrestore(&priv->lock, flags);
260 buffer = kmalloc(count, GFP_ATOMIC);
261 if (!buffer) {
262 dev_err(&port->dev, "out of memory\n");
263 return -ENOMEM;
264 }
265 urb = usb_alloc_urb(0, GFP_ATOMIC);
266 if (!urb) {
267 dev_err(&port->dev, "no more free urbs\n");
268 kfree(buffer);
269 return -ENOMEM;
270 }
271 memcpy(buffer, buf, count);
272
273 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
274
275 usb_fill_bulk_urb(urb, serial->dev,
276 usb_sndbulkpipe(serial->dev,
277 port->bulk_out_endpointAddress),
278 buffer, count,
279 airprime_write_bulk_callback, port);
280
281 /* send it down the pipe */
282 status = usb_submit_urb(urb, GFP_ATOMIC);
283 if (status) {
284 dev_err(&port->dev,
285 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
286 __func__, status);
287 count = status;
288 kfree(buffer);
289 } else {
290 spin_lock_irqsave(&priv->lock, flags);
291 ++priv->outstanding_urbs;
292 spin_unlock_irqrestore(&priv->lock, flags);
293 }
294 /* we are done with this urb, so let the host driver
295 * really free it when it is finished with it */
296 usb_free_urb(urb);
297 return count;
298}
299
300static struct usb_driver airprime_driver = {
301 .name = "airprime",
302 .probe = usb_serial_probe,
303 .disconnect = usb_serial_disconnect,
304 .id_table = id_table,
305 .no_dynamic_id = 1,
306};
307
308static struct usb_serial_driver airprime_device = {
309 .driver = {
310 .owner = THIS_MODULE,
311 .name = "airprime",
312 },
313 .usb_driver = &airprime_driver,
314 .id_table = id_table,
315 .open = airprime_open,
316 .close = airprime_close,
317 .write = airprime_write,
318};
319
320static int __init airprime_init(void)
321{
322 int retval;
323
324 airprime_device.num_ports = endpoints;
325 if (endpoints < 0 || endpoints >= MAX_BULK_EPS)
326 airprime_device.num_ports = NUM_BULK_EPS;
327
328 retval = usb_serial_register(&airprime_device);
329 if (retval)
330 return retval;
331 retval = usb_register(&airprime_driver);
332 if (retval)
333 usb_serial_deregister(&airprime_device);
334 return retval;
335}
336
337static void __exit airprime_exit(void)
338{
339 dbg("%s", __func__);
340
341 usb_deregister(&airprime_driver);
342 usb_serial_deregister(&airprime_device);
343}
344
345module_init(airprime_init);
346module_exit(airprime_exit);
347MODULE_LICENSE("GPL");
348
349module_param(debug, bool, S_IRUGO | S_IWUSR);
350MODULE_PARM_DESC(debug, "Debug enabled");
351module_param(buffer_size, int, 0);
352MODULE_PARM_DESC(buffer_size,
353 "Size of the transfer buffers in bytes (default 4096)");
354module_param(endpoints, int, 0);
355MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)");
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 77895c8f8f31..aec61880f36c 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -158,12 +158,13 @@ cleanup:
158 return -ENOMEM; 158 return -ENOMEM;
159} 159}
160 160
161static void ark3116_set_termios(struct usb_serial_port *port, 161static void ark3116_set_termios(struct tty_struct *tty,
162 struct usb_serial_port *port,
162 struct ktermios *old_termios) 163 struct ktermios *old_termios)
163{ 164{
164 struct usb_serial *serial = port->serial; 165 struct usb_serial *serial = port->serial;
165 struct ark3116_private *priv = usb_get_serial_port_data(port); 166 struct ark3116_private *priv = usb_get_serial_port_data(port);
166 struct ktermios *termios = port->tty->termios; 167 struct ktermios *termios = tty->termios;
167 unsigned int cflag = termios->c_cflag; 168 unsigned int cflag = termios->c_cflag;
168 unsigned long flags; 169 unsigned long flags;
169 int baud; 170 int baud;
@@ -177,8 +178,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
177 178
178 spin_lock_irqsave(&priv->lock, flags); 179 spin_lock_irqsave(&priv->lock, flags);
179 if (!priv->termios_initialized) { 180 if (!priv->termios_initialized) {
180 *(port->tty->termios) = tty_std_termios; 181 *termios = tty_std_termios;
181 port->tty->termios->c_cflag = B9600 | CS8 182 termios->c_cflag = B9600 | CS8
182 | CREAD | HUPCL | CLOCAL; 183 | CREAD | HUPCL | CLOCAL;
183 termios->c_ispeed = 9600; 184 termios->c_ispeed = 9600;
184 termios->c_ospeed = 9600; 185 termios->c_ospeed = 9600;
@@ -192,7 +193,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
192 buf = kmalloc(1, GFP_KERNEL); 193 buf = kmalloc(1, GFP_KERNEL);
193 if (!buf) { 194 if (!buf) {
194 dbg("error kmalloc"); 195 dbg("error kmalloc");
195 *port->tty->termios = *old_termios; 196 *termios = *old_termios;
196 return; 197 return;
197 } 198 }
198 199
@@ -243,7 +244,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
243 } 244 }
244 245
245 /* set baudrate */ 246 /* set baudrate */
246 baud = tty_get_baud_rate(port->tty); 247 baud = tty_get_baud_rate(tty);
247 248
248 switch (baud) { 249 switch (baud) {
249 case 75: 250 case 75:
@@ -262,11 +263,11 @@ static void ark3116_set_termios(struct usb_serial_port *port,
262 case 230400: 263 case 230400:
263 case 460800: 264 case 460800:
264 /* Report the resulting rate back to the caller */ 265 /* Report the resulting rate back to the caller */
265 tty_encode_baud_rate(port->tty, baud, baud); 266 tty_encode_baud_rate(tty, baud, baud);
266 break; 267 break;
267 /* set 9600 as default (if given baudrate is invalid for example) */ 268 /* set 9600 as default (if given baudrate is invalid for example) */
268 default: 269 default:
269 tty_encode_baud_rate(port->tty, 9600, 9600); 270 tty_encode_baud_rate(tty, 9600, 9600);
270 case 0: 271 case 0:
271 baud = 9600; 272 baud = 9600;
272 } 273 }
@@ -317,7 +318,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
317 return; 318 return;
318} 319}
319 320
320static int ark3116_open(struct usb_serial_port *port, struct file *filp) 321static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port,
322 struct file *filp)
321{ 323{
322 struct ktermios tmp_termios; 324 struct ktermios tmp_termios;
323 struct usb_serial *serial = port->serial; 325 struct usb_serial *serial = port->serial;
@@ -332,7 +334,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
332 return -ENOMEM; 334 return -ENOMEM;
333 } 335 }
334 336
335 result = usb_serial_generic_open(port, filp); 337 result = usb_serial_generic_open(tty, port, filp);
336 if (result) 338 if (result)
337 goto err_out; 339 goto err_out;
338 340
@@ -362,8 +364,8 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
362 ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf); 364 ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf);
363 365
364 /* initialise termios */ 366 /* initialise termios */
365 if (port->tty) 367 if (tty)
366 ark3116_set_termios(port, &tmp_termios); 368 ark3116_set_termios(tty, port, &tmp_termios);
367 369
368err_out: 370err_out:
369 kfree(buf); 371 kfree(buf);
@@ -371,9 +373,10 @@ err_out:
371 return result; 373 return result;
372} 374}
373 375
374static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, 376static int ark3116_ioctl(struct tty_struct *tty, struct file *file,
375 unsigned int cmd, unsigned long arg) 377 unsigned int cmd, unsigned long arg)
376{ 378{
379 struct usb_serial_port *port = tty->driver_data;
377 struct serial_struct serstruct; 380 struct serial_struct serstruct;
378 void __user *user_arg = (void __user *)arg; 381 void __user *user_arg = (void __user *)arg;
379 382
@@ -403,8 +406,9 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
403 return -ENOIOCTLCMD; 406 return -ENOIOCTLCMD;
404} 407}
405 408
406static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file) 409static int ark3116_tiocmget(struct tty_struct *tty, struct file *file)
407{ 410{
411 struct usb_serial_port *port = tty->driver_data;
408 struct usb_serial *serial = port->serial; 412 struct usb_serial *serial = port->serial;
409 char *buf; 413 char *buf;
410 char temp; 414 char temp;
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 0a322fc53d6e..1a762692c739 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -89,14 +89,13 @@ static int debug;
89/* function prototypes for a Belkin USB Serial Adapter F5U103 */ 89/* function prototypes for a Belkin USB Serial Adapter F5U103 */
90static int belkin_sa_startup (struct usb_serial *serial); 90static int belkin_sa_startup (struct usb_serial *serial);
91static void belkin_sa_shutdown (struct usb_serial *serial); 91static void belkin_sa_shutdown (struct usb_serial *serial);
92static int belkin_sa_open (struct usb_serial_port *port, struct file *filp); 92static int belkin_sa_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
93static void belkin_sa_close (struct usb_serial_port *port, struct file *filp); 93static void belkin_sa_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
94static void belkin_sa_read_int_callback (struct urb *urb); 94static void belkin_sa_read_int_callback (struct urb *urb);
95static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios * old); 95static void belkin_sa_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
96static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 96static void belkin_sa_break_ctl (struct tty_struct *tty, int break_state );
97static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state ); 97static int belkin_sa_tiocmget (struct tty_struct *tty, struct file *file);
98static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file); 98static int belkin_sa_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
99static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
100 99
101 100
102static struct usb_device_id id_table_combined [] = { 101static struct usb_device_id id_table_combined [] = {
@@ -132,7 +131,6 @@ static struct usb_serial_driver belkin_device = {
132 .open = belkin_sa_open, 131 .open = belkin_sa_open,
133 .close = belkin_sa_close, 132 .close = belkin_sa_close,
134 .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */ 133 .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */
135 .ioctl = belkin_sa_ioctl,
136 .set_termios = belkin_sa_set_termios, 134 .set_termios = belkin_sa_set_termios,
137 .break_ctl = belkin_sa_break_ctl, 135 .break_ctl = belkin_sa_break_ctl,
138 .tiocmget = belkin_sa_tiocmget, 136 .tiocmget = belkin_sa_tiocmget,
@@ -190,7 +188,7 @@ static int belkin_sa_startup (struct usb_serial *serial)
190} 188}
191 189
192 190
193static void belkin_sa_shutdown (struct usb_serial *serial) 191static void belkin_sa_shutdown(struct usb_serial *serial)
194{ 192{
195 struct belkin_sa_private *priv; 193 struct belkin_sa_private *priv;
196 int i; 194 int i;
@@ -206,7 +204,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
206} 204}
207 205
208 206
209static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) 207static int belkin_sa_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp)
210{ 208{
211 int retval = 0; 209 int retval = 0;
212 210
@@ -235,7 +233,8 @@ exit:
235} /* belkin_sa_open */ 233} /* belkin_sa_open */
236 234
237 235
238static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) 236static void belkin_sa_close (struct tty_struct *tty,
237 struct usb_serial_port *port, struct file *filp)
239{ 238{
240 dbg("%s port %d", __func__, port->number); 239 dbg("%s port %d", __func__, port->number);
241 240
@@ -246,7 +245,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
246} /* belkin_sa_close */ 245} /* belkin_sa_close */
247 246
248 247
249static void belkin_sa_read_int_callback (struct urb *urb) 248static void belkin_sa_read_int_callback(struct urb *urb)
250{ 249{
251 struct usb_serial_port *port = urb->context; 250 struct usb_serial_port *port = urb->context;
252 struct belkin_sa_private *priv; 251 struct belkin_sa_private *priv;
@@ -311,7 +310,7 @@ static void belkin_sa_read_int_callback (struct urb *urb)
311 * to look in to this before committing any code. 310 * to look in to this before committing any code.
312 */ 311 */
313 if (priv->last_lsr & BELKIN_SA_LSR_ERR) { 312 if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
314 tty = port->tty; 313 tty = port->port.tty;
315 /* Overrun Error */ 314 /* Overrun Error */
316 if (priv->last_lsr & BELKIN_SA_LSR_OE) { 315 if (priv->last_lsr & BELKIN_SA_LSR_OE) {
317 } 316 }
@@ -334,7 +333,8 @@ exit:
334 __func__, retval); 333 __func__, retval);
335} 334}
336 335
337static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) 336static void belkin_sa_set_termios(struct tty_struct *tty,
337 struct usb_serial_port *port, struct ktermios *old_termios)
338{ 338{
339 struct usb_serial *serial = port->serial; 339 struct usb_serial *serial = port->serial;
340 struct belkin_sa_private *priv = usb_get_serial_port_data(port); 340 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
@@ -347,7 +347,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
347 unsigned long control_state; 347 unsigned long control_state;
348 int bad_flow_control; 348 int bad_flow_control;
349 speed_t baud; 349 speed_t baud;
350 struct ktermios *termios = port->tty->termios; 350 struct ktermios *termios = tty->termios;
351 351
352 iflag = termios->c_iflag; 352 iflag = termios->c_iflag;
353 cflag = termios->c_cflag; 353 cflag = termios->c_cflag;
@@ -377,7 +377,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
377 } 377 }
378 } 378 }
379 379
380 baud = tty_get_baud_rate(port->tty); 380 baud = tty_get_baud_rate(tty);
381 if (baud) { 381 if (baud) {
382 urb_value = BELKIN_SA_BAUD(baud); 382 urb_value = BELKIN_SA_BAUD(baud);
383 /* Clip to maximum speed */ 383 /* Clip to maximum speed */
@@ -387,7 +387,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
387 baud = BELKIN_SA_BAUD(urb_value); 387 baud = BELKIN_SA_BAUD(urb_value);
388 388
389 /* Report the actual baud rate back to the caller */ 389 /* Report the actual baud rate back to the caller */
390 tty_encode_baud_rate(port->tty, baud, baud); 390 tty_encode_baud_rate(tty, baud, baud);
391 if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) 391 if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
392 err("Set baudrate error"); 392 err("Set baudrate error");
393 } else { 393 } else {
@@ -463,8 +463,9 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
463} /* belkin_sa_set_termios */ 463} /* belkin_sa_set_termios */
464 464
465 465
466static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state ) 466static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
467{ 467{
468 struct usb_serial_port *port = tty->driver_data;
468 struct usb_serial *serial = port->serial; 469 struct usb_serial *serial = port->serial;
469 470
470 if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) 471 if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
@@ -472,8 +473,9 @@ static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
472} 473}
473 474
474 475
475static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file) 476static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file)
476{ 477{
478 struct usb_serial_port *port = tty->driver_data;
477 struct belkin_sa_private *priv = usb_get_serial_port_data(port); 479 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
478 unsigned long control_state; 480 unsigned long control_state;
479 unsigned long flags; 481 unsigned long flags;
@@ -488,9 +490,10 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
488} 490}
489 491
490 492
491static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, 493static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,
492 unsigned int set, unsigned int clear) 494 unsigned int set, unsigned int clear)
493{ 495{
496 struct usb_serial_port *port = tty->driver_data;
494 struct usb_serial *serial = port->serial; 497 struct usb_serial *serial = port->serial;
495 struct belkin_sa_private *priv = usb_get_serial_port_data(port); 498 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
496 unsigned long control_state; 499 unsigned long control_state;
@@ -540,29 +543,7 @@ exit:
540} 543}
541 544
542 545
543static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 546static int __init belkin_sa_init(void)
544{
545 switch (cmd) {
546 case TIOCMIWAIT:
547 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
548 /* TODO */
549 return( 0 );
550
551 case TIOCGICOUNT:
552 /* return count of modemline transitions */
553 /* TODO */
554 return 0;
555
556 default:
557 dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
558 return(-ENOIOCTLCMD);
559 break;
560 }
561 return 0;
562} /* belkin_sa_ioctl */
563
564
565static int __init belkin_sa_init (void)
566{ 547{
567 int retval; 548 int retval;
568 retval = usb_serial_register(&belkin_device); 549 retval = usb_serial_register(&belkin_device);
@@ -583,7 +564,7 @@ failed_usb_serial_register:
583static void __exit belkin_sa_exit (void) 564static void __exit belkin_sa_exit (void)
584{ 565{
585 usb_deregister (&belkin_driver); 566 usb_deregister (&belkin_driver);
586 usb_serial_deregister (&belkin_device); 567 usb_serial_deregister(&belkin_device);
587} 568}
588 569
589 570
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 1f7c86bd8297..f61e3ca64305 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -232,7 +232,8 @@ error: kfree(priv);
232} 232}
233 233
234/* open this device, set default parameters */ 234/* open this device, set default parameters */
235static int ch341_open(struct usb_serial_port *port, struct file *filp) 235static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
236 struct file *filp)
236{ 237{
237 struct usb_serial *serial = port->serial; 238 struct usb_serial *serial = port->serial;
238 struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); 239 struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]);
@@ -256,7 +257,7 @@ static int ch341_open(struct usb_serial_port *port, struct file *filp)
256 if (r) 257 if (r)
257 goto out; 258 goto out;
258 259
259 r = usb_serial_generic_open(port, filp); 260 r = usb_serial_generic_open(tty, port, filp);
260 261
261out: return r; 262out: return r;
262} 263}
@@ -264,11 +265,10 @@ out: return r;
264/* Old_termios contains the original termios settings and 265/* Old_termios contains the original termios settings and
265 * tty->termios contains the new setting to be used. 266 * tty->termios contains the new setting to be used.
266 */ 267 */
267static void ch341_set_termios(struct usb_serial_port *port, 268static void ch341_set_termios(struct tty_struct *tty,
268 struct ktermios *old_termios) 269 struct usb_serial_port *port, struct ktermios *old_termios)
269{ 270{
270 struct ch341_private *priv = usb_get_serial_port_data(port); 271 struct ch341_private *priv = usb_get_serial_port_data(port);
271 struct tty_struct *tty = port->tty;
272 unsigned baud_rate; 272 unsigned baud_rate;
273 273
274 dbg("ch341_set_termios()"); 274 dbg("ch341_set_termios()");
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 201184c3fb87..940f5de68980 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -145,12 +145,12 @@ static int usb_console_setup(struct console *co, char *options)
145 } 145 }
146 146
147 port = serial->port[0]; 147 port = serial->port[0];
148 port->tty = NULL; 148 port->port.tty = NULL;
149 149
150 info->port = port; 150 info->port = port;
151 151
152 ++port->open_count; 152 ++port->port.count;
153 if (port->open_count == 1) { 153 if (port->port.count == 1) {
154 if (serial->type->set_termios) { 154 if (serial->type->set_termios) {
155 /* 155 /*
156 * allocate a fake tty so the driver can initialize 156 * allocate a fake tty so the driver can initialize
@@ -171,15 +171,15 @@ static int usb_console_setup(struct console *co, char *options)
171 } 171 }
172 memset(&dummy, 0, sizeof(struct ktermios)); 172 memset(&dummy, 0, sizeof(struct ktermios));
173 tty->termios = termios; 173 tty->termios = termios;
174 port->tty = tty; 174 port->port.tty = tty;
175 } 175 }
176 176
177 /* only call the device specific open if this 177 /* only call the device specific open if this
178 * is the first time the port is opened */ 178 * is the first time the port is opened */
179 if (serial->type->open) 179 if (serial->type->open)
180 retval = serial->type->open(port, NULL); 180 retval = serial->type->open(NULL, port, NULL);
181 else 181 else
182 retval = usb_serial_generic_open(port, NULL); 182 retval = usb_serial_generic_open(NULL, port, NULL);
183 183
184 if (retval) { 184 if (retval) {
185 err("could not open USB console port"); 185 err("could not open USB console port");
@@ -188,9 +188,9 @@ static int usb_console_setup(struct console *co, char *options)
188 188
189 if (serial->type->set_termios) { 189 if (serial->type->set_termios) {
190 termios->c_cflag = cflag; 190 termios->c_cflag = cflag;
191 serial->type->set_termios(port, &dummy); 191 serial->type->set_termios(NULL, port, &dummy);
192 192
193 port->tty = NULL; 193 port->port.tty = NULL;
194 kfree(termios); 194 kfree(termios);
195 kfree(tty); 195 kfree(tty);
196 } 196 }
@@ -203,11 +203,11 @@ out:
203 return retval; 203 return retval;
204free_termios: 204free_termios:
205 kfree(termios); 205 kfree(termios);
206 port->tty = NULL; 206 port->port.tty = NULL;
207free_tty: 207free_tty:
208 kfree(tty); 208 kfree(tty);
209reset_open_count: 209reset_open_count:
210 port->open_count = 0; 210 port->port.count = 0;
211goto out; 211goto out;
212} 212}
213 213
@@ -227,7 +227,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
227 227
228 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 228 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
229 229
230 if (!port->open_count) { 230 if (!port->port.count) {
231 dbg ("%s - port not opened", __func__); 231 dbg ("%s - port not opened", __func__);
232 return; 232 return;
233 } 233 }
@@ -245,17 +245,17 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
245 } 245 }
246 /* pass on to the driver specific version of this function if it is available */ 246 /* pass on to the driver specific version of this function if it is available */
247 if (serial->type->write) 247 if (serial->type->write)
248 retval = serial->type->write(port, buf, i); 248 retval = serial->type->write(NULL, port, buf, i);
249 else 249 else
250 retval = usb_serial_generic_write(port, buf, i); 250 retval = usb_serial_generic_write(NULL, port, buf, i);
251 dbg("%s - return value : %d", __func__, retval); 251 dbg("%s - return value : %d", __func__, retval);
252 if (lf) { 252 if (lf) {
253 /* append CR after LF */ 253 /* append CR after LF */
254 unsigned char cr = 13; 254 unsigned char cr = 13;
255 if (serial->type->write) 255 if (serial->type->write)
256 retval = serial->type->write(port, &cr, 1); 256 retval = serial->type->write(NULL, port, &cr, 1);
257 else 257 else
258 retval = usb_serial_generic_write(port, &cr, 1); 258 retval = usb_serial_generic_write(NULL, port, &cr, 1);
259 dbg("%s - return value : %d", __func__, retval); 259 dbg("%s - return value : %d", __func__, retval);
260 } 260 }
261 buf += i; 261 buf += i;
@@ -306,8 +306,8 @@ void usb_serial_console_exit (void)
306{ 306{
307 if (usbcons_info.port) { 307 if (usbcons_info.port) {
308 unregister_console(&usbcons); 308 unregister_console(&usbcons);
309 if (usbcons_info.port->open_count) 309 if (usbcons_info.port->port.count)
310 usbcons_info.port->open_count--; 310 usbcons_info.port->port.count--;
311 usbcons_info.port = NULL; 311 usbcons_info.port = NULL;
312 } 312 }
313} 313}
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 2bc5576c443a..46c33fc9f6ce 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -37,15 +37,18 @@
37/* 37/*
38 * Function Prototypes 38 * Function Prototypes
39 */ 39 */
40static int cp2101_open(struct usb_serial_port*, struct file*); 40static int cp2101_open(struct tty_struct *, struct usb_serial_port *,
41static void cp2101_cleanup(struct usb_serial_port*); 41 struct file *);
42static void cp2101_close(struct usb_serial_port*, struct file*); 42static void cp2101_cleanup(struct usb_serial_port *);
43static void cp2101_get_termios(struct usb_serial_port*); 43static void cp2101_close(struct tty_struct *, struct usb_serial_port *,
44static void cp2101_set_termios(struct usb_serial_port*, struct ktermios*); 44 struct file*);
45static int cp2101_tiocmget (struct usb_serial_port *, struct file *); 45static void cp2101_get_termios(struct tty_struct *);
46static int cp2101_tiocmset (struct usb_serial_port *, struct file *, 46static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *,
47 struct ktermios*);
48static int cp2101_tiocmget (struct tty_struct *, struct file *);
49static int cp2101_tiocmset (struct tty_struct *, struct file *,
47 unsigned int, unsigned int); 50 unsigned int, unsigned int);
48static void cp2101_break_ctl(struct usb_serial_port*, int); 51static void cp2101_break_ctl(struct tty_struct *, int);
49static int cp2101_startup (struct usb_serial *); 52static int cp2101_startup (struct usb_serial *);
50static void cp2101_shutdown(struct usb_serial*); 53static void cp2101_shutdown(struct usb_serial*);
51 54
@@ -182,7 +185,7 @@ static struct usb_serial_driver cp2101_device = {
182 * 'data' is a pointer to a pre-allocated array of integers large 185 * 'data' is a pointer to a pre-allocated array of integers large
183 * enough to hold 'size' bytes (with 4 bytes to each integer) 186 * enough to hold 'size' bytes (with 4 bytes to each integer)
184 */ 187 */
185static int cp2101_get_config(struct usb_serial_port* port, u8 request, 188static int cp2101_get_config(struct usb_serial_port *port, u8 request,
186 unsigned int *data, int size) 189 unsigned int *data, int size)
187{ 190{
188 struct usb_serial *serial = port->serial; 191 struct usb_serial *serial = port->serial;
@@ -228,7 +231,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
228 * Values less than 16 bits wide are sent directly 231 * Values less than 16 bits wide are sent directly
229 * 'size' is specified in bytes. 232 * 'size' is specified in bytes.
230 */ 233 */
231static int cp2101_set_config(struct usb_serial_port* port, u8 request, 234static int cp2101_set_config(struct usb_serial_port *port, u8 request,
232 unsigned int *data, int size) 235 unsigned int *data, int size)
233{ 236{
234 struct usb_serial *serial = port->serial; 237 struct usb_serial *serial = port->serial;
@@ -283,13 +286,14 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
283 * Convenience function for calling cp2101_set_config on single data values 286 * Convenience function for calling cp2101_set_config on single data values
284 * without requiring an integer pointer 287 * without requiring an integer pointer
285 */ 288 */
286static inline int cp2101_set_config_single(struct usb_serial_port* port, 289static inline int cp2101_set_config_single(struct usb_serial_port *port,
287 u8 request, unsigned int data) 290 u8 request, unsigned int data)
288{ 291{
289 return cp2101_set_config(port, request, &data, 2); 292 return cp2101_set_config(port, request, &data, 2);
290} 293}
291 294
292static int cp2101_open (struct usb_serial_port *port, struct file *filp) 295static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port,
296 struct file *filp)
293{ 297{
294 struct usb_serial *serial = port->serial; 298 struct usb_serial *serial = port->serial;
295 int result; 299 int result;
@@ -318,10 +322,10 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp)
318 } 322 }
319 323
320 /* Configure the termios structure */ 324 /* Configure the termios structure */
321 cp2101_get_termios(port); 325 cp2101_get_termios(tty);
322 326
323 /* Set the DTR and RTS pins low */ 327 /* Set the DTR and RTS pins low */
324 cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0); 328 cp2101_tiocmset(tty, NULL, TIOCM_DTR | TIOCM_RTS, 0);
325 329
326 return 0; 330 return 0;
327} 331}
@@ -341,7 +345,8 @@ static void cp2101_cleanup (struct usb_serial_port *port)
341 } 345 }
342} 346}
343 347
344static void cp2101_close (struct usb_serial_port *port, struct file * filp) 348static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port,
349 struct file * filp)
345{ 350{
346 dbg("%s - port %d", __func__, port->number); 351 dbg("%s - port %d", __func__, port->number);
347 352
@@ -362,19 +367,15 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp)
362 * from the device, corrects any unsupported values, and configures the 367 * from the device, corrects any unsupported values, and configures the
363 * termios structure to reflect the state of the device 368 * termios structure to reflect the state of the device
364 */ 369 */
365static void cp2101_get_termios (struct usb_serial_port *port) 370static void cp2101_get_termios (struct tty_struct *tty)
366{ 371{
372 struct usb_serial_port *port = tty->driver_data;
367 unsigned int cflag, modem_ctl[4]; 373 unsigned int cflag, modem_ctl[4];
368 unsigned int baud; 374 unsigned int baud;
369 unsigned int bits; 375 unsigned int bits;
370 376
371 dbg("%s - port %d", __func__, port->number); 377 dbg("%s - port %d", __func__, port->number);
372 378
373 if (!port->tty || !port->tty->termios) {
374 dbg("%s - no tty structures", __func__);
375 return;
376 }
377
378 cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); 379 cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2);
379 /* Convert to baudrate */ 380 /* Convert to baudrate */
380 if (baud) 381 if (baud)
@@ -382,8 +383,8 @@ static void cp2101_get_termios (struct usb_serial_port *port)
382 383
383 dbg("%s - baud rate = %d", __func__, baud); 384 dbg("%s - baud rate = %d", __func__, baud);
384 385
385 tty_encode_baud_rate(port->tty, baud, baud); 386 tty_encode_baud_rate(tty, baud, baud);
386 cflag = port->tty->termios->c_cflag; 387 cflag = tty->termios->c_cflag;
387 388
388 cp2101_get_config(port, CP2101_BITS, &bits, 2); 389 cp2101_get_config(port, CP2101_BITS, &bits, 2);
389 cflag &= ~CSIZE; 390 cflag &= ~CSIZE;
@@ -491,11 +492,11 @@ static void cp2101_get_termios (struct usb_serial_port *port)
491 cflag &= ~CRTSCTS; 492 cflag &= ~CRTSCTS;
492 } 493 }
493 494
494 port->tty->termios->c_cflag = cflag; 495 tty->termios->c_cflag = cflag;
495} 496}
496 497
497static void cp2101_set_termios (struct usb_serial_port *port, 498static void cp2101_set_termios (struct tty_struct *tty,
498 struct ktermios *old_termios) 499 struct usb_serial_port *port, struct ktermios *old_termios)
499{ 500{
500 unsigned int cflag, old_cflag; 501 unsigned int cflag, old_cflag;
501 unsigned int baud = 0, bits; 502 unsigned int baud = 0, bits;
@@ -503,15 +504,13 @@ static void cp2101_set_termios (struct usb_serial_port *port,
503 504
504 dbg("%s - port %d", __func__, port->number); 505 dbg("%s - port %d", __func__, port->number);
505 506
506 if (!port->tty || !port->tty->termios) { 507 if (!tty)
507 dbg("%s - no tty structures", __func__);
508 return; 508 return;
509 }
510 port->tty->termios->c_cflag &= ~CMSPAR;
511 509
512 cflag = port->tty->termios->c_cflag; 510 tty->termios->c_cflag &= ~CMSPAR;
511 cflag = tty->termios->c_cflag;
513 old_cflag = old_termios->c_cflag; 512 old_cflag = old_termios->c_cflag;
514 baud = tty_get_baud_rate(port->tty); 513 baud = tty_get_baud_rate(tty);
515 514
516 /* If the baud rate is to be updated*/ 515 /* If the baud rate is to be updated*/
517 if (baud != tty_termios_baud_rate(old_termios)) { 516 if (baud != tty_termios_baud_rate(old_termios)) {
@@ -554,7 +553,7 @@ static void cp2101_set_termios (struct usb_serial_port *port,
554 } 553 }
555 } 554 }
556 /* Report back the resulting baud rate */ 555 /* Report back the resulting baud rate */
557 tty_encode_baud_rate(port->tty, baud, baud); 556 tty_encode_baud_rate(tty, baud, baud);
558 557
559 /* If the number of data bits is to be updated */ 558 /* If the number of data bits is to be updated */
560 if ((cflag & CSIZE) != (old_cflag & CSIZE)) { 559 if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
@@ -651,9 +650,10 @@ static void cp2101_set_termios (struct usb_serial_port *port,
651 650
652} 651}
653 652
654static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, 653static int cp2101_tiocmset (struct tty_struct *tty, struct file *file,
655 unsigned int set, unsigned int clear) 654 unsigned int set, unsigned int clear)
656{ 655{
656 struct usb_serial_port *port = tty->driver_data;
657 unsigned int control = 0; 657 unsigned int control = 0;
658 658
659 dbg("%s - port %d", __func__, port->number); 659 dbg("%s - port %d", __func__, port->number);
@@ -681,8 +681,9 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file,
681 681
682} 682}
683 683
684static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) 684static int cp2101_tiocmget (struct tty_struct *tty, struct file *file)
685{ 685{
686 struct usb_serial_port *port = tty->driver_data;
686 unsigned int control; 687 unsigned int control;
687 int result; 688 int result;
688 689
@@ -702,8 +703,9 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file)
702 return result; 703 return result;
703} 704}
704 705
705static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) 706static void cp2101_break_ctl (struct tty_struct *tty, int break_state)
706{ 707{
708 struct usb_serial_port *port = tty->driver_data;
707 unsigned int state; 709 unsigned int state;
708 710
709 dbg("%s - port %d", __func__, port->number); 711 dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index c164e2cf2752..546178ea6f2d 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -57,15 +57,18 @@ static int debug;
57#define CYBERJACK_PRODUCT_ID 0x0100 57#define CYBERJACK_PRODUCT_ID 0x0100
58 58
59/* Function prototypes */ 59/* Function prototypes */
60static int cyberjack_startup (struct usb_serial *serial); 60static int cyberjack_startup(struct usb_serial *serial);
61static void cyberjack_shutdown (struct usb_serial *serial); 61static void cyberjack_shutdown(struct usb_serial *serial);
62static int cyberjack_open (struct usb_serial_port *port, struct file *filp); 62static int cyberjack_open(struct tty_struct *tty,
63static void cyberjack_close (struct usb_serial_port *port, struct file *filp); 63 struct usb_serial_port *port, struct file *filp);
64static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count); 64static void cyberjack_close(struct tty_struct *tty,
65static int cyberjack_write_room( struct usb_serial_port *port ); 65 struct usb_serial_port *port, struct file *filp);
66static void cyberjack_read_int_callback (struct urb *urb); 66static int cyberjack_write(struct tty_struct *tty,
67static void cyberjack_read_bulk_callback (struct urb *urb); 67 struct usb_serial_port *port, const unsigned char *buf, int count);
68static void cyberjack_write_bulk_callback (struct urb *urb); 68static int cyberjack_write_room( struct tty_struct *tty);
69static void cyberjack_read_int_callback(struct urb *urb);
70static void cyberjack_read_bulk_callback(struct urb *urb);
71static void cyberjack_write_bulk_callback(struct urb *urb);
69 72
70static struct usb_device_id id_table [] = { 73static struct usb_device_id id_table [] = {
71 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) }, 74 { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
@@ -111,7 +114,7 @@ struct cyberjack_private {
111}; 114};
112 115
113/* do some startup allocations not currently performed by usb_serial_probe() */ 116/* do some startup allocations not currently performed by usb_serial_probe() */
114static int cyberjack_startup (struct usb_serial *serial) 117static int cyberjack_startup(struct usb_serial *serial)
115{ 118{
116 struct cyberjack_private *priv; 119 struct cyberjack_private *priv;
117 int i; 120 int i;
@@ -145,7 +148,7 @@ static int cyberjack_startup (struct usb_serial *serial)
145 return( 0 ); 148 return( 0 );
146} 149}
147 150
148static void cyberjack_shutdown (struct usb_serial *serial) 151static void cyberjack_shutdown(struct usb_serial *serial)
149{ 152{
150 int i; 153 int i;
151 154
@@ -159,7 +162,8 @@ static void cyberjack_shutdown (struct usb_serial *serial)
159 } 162 }
160} 163}
161 164
162static int cyberjack_open (struct usb_serial_port *port, struct file *filp) 165static int cyberjack_open(struct tty_struct *tty,
166 struct usb_serial_port *port, struct file *filp)
163{ 167{
164 struct cyberjack_private *priv; 168 struct cyberjack_private *priv;
165 unsigned long flags; 169 unsigned long flags;
@@ -174,7 +178,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
174 * the data through, otherwise it is scheduled, and with high 178 * the data through, otherwise it is scheduled, and with high
175 * data rates (like with OHCI) data can get lost. 179 * data rates (like with OHCI) data can get lost.
176 */ 180 */
177 port->tty->low_latency = 1; 181 if (tty)
182 tty->low_latency = 1;
178 183
179 priv = usb_get_serial_port_data(port); 184 priv = usb_get_serial_port_data(port);
180 spin_lock_irqsave(&priv->lock, flags); 185 spin_lock_irqsave(&priv->lock, flags);
@@ -186,7 +191,8 @@ static int cyberjack_open (struct usb_serial_port *port, struct file *filp)
186 return result; 191 return result;
187} 192}
188 193
189static void cyberjack_close (struct usb_serial_port *port, struct file *filp) 194static void cyberjack_close(struct tty_struct *tty,
195 struct usb_serial_port *port, struct file *filp)
190{ 196{
191 dbg("%s - port %d", __func__, port->number); 197 dbg("%s - port %d", __func__, port->number);
192 198
@@ -197,7 +203,8 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
197 } 203 }
198} 204}
199 205
200static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count) 206static int cyberjack_write(struct tty_struct *tty,
207 struct usb_serial_port *port, const unsigned char *buf, int count)
201{ 208{
202 struct usb_serial *serial = port->serial; 209 struct usb_serial *serial = port->serial;
203 struct cyberjack_private *priv = usb_get_serial_port_data(port); 210 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -292,13 +299,13 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
292 return (count); 299 return (count);
293} 300}
294 301
295static int cyberjack_write_room( struct usb_serial_port *port ) 302static int cyberjack_write_room(struct tty_struct *tty)
296{ 303{
297 /* FIXME: .... */ 304 /* FIXME: .... */
298 return CYBERJACK_LOCAL_BUF_SIZE; 305 return CYBERJACK_LOCAL_BUF_SIZE;
299} 306}
300 307
301static void cyberjack_read_int_callback( struct urb *urb ) 308static void cyberjack_read_int_callback(struct urb *urb)
302{ 309{
303 struct usb_serial_port *port = urb->context; 310 struct usb_serial_port *port = urb->context;
304 struct cyberjack_private *priv = usb_get_serial_port_data(port); 311 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -355,7 +362,7 @@ resubmit:
355 dbg("%s - usb_submit_urb(int urb)", __func__); 362 dbg("%s - usb_submit_urb(int urb)", __func__);
356} 363}
357 364
358static void cyberjack_read_bulk_callback (struct urb *urb) 365static void cyberjack_read_bulk_callback(struct urb *urb)
359{ 366{
360 struct usb_serial_port *port = urb->context; 367 struct usb_serial_port *port = urb->context;
361 struct cyberjack_private *priv = usb_get_serial_port_data(port); 368 struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -374,7 +381,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
374 return; 381 return;
375 } 382 }
376 383
377 tty = port->tty; 384 tty = port->port.tty;
378 if (!tty) { 385 if (!tty) {
379 dbg("%s - ignoring since device not open\n", __func__); 386 dbg("%s - ignoring since device not open\n", __func__);
380 return; 387 return;
@@ -407,7 +414,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
407 } 414 }
408} 415}
409 416
410static void cyberjack_write_bulk_callback (struct urb *urb) 417static void cyberjack_write_bulk_callback(struct urb *urb)
411{ 418{
412 struct usb_serial_port *port = urb->context; 419 struct usb_serial_port *port = urb->context;
413 struct cyberjack_private *priv = usb_get_serial_port_data(port); 420 struct cyberjack_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 0230d3c0888a..6999d3372d85 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -167,18 +167,18 @@ static int cypress_earthmate_startup (struct usb_serial *serial);
167static int cypress_hidcom_startup (struct usb_serial *serial); 167static int cypress_hidcom_startup (struct usb_serial *serial);
168static int cypress_ca42v2_startup (struct usb_serial *serial); 168static int cypress_ca42v2_startup (struct usb_serial *serial);
169static void cypress_shutdown (struct usb_serial *serial); 169static void cypress_shutdown (struct usb_serial *serial);
170static int cypress_open (struct usb_serial_port *port, struct file *filp); 170static int cypress_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
171static void cypress_close (struct usb_serial_port *port, struct file *filp); 171static void cypress_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
172static int cypress_write (struct usb_serial_port *port, const unsigned char *buf, int count); 172static int cypress_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
173static void cypress_send (struct usb_serial_port *port); 173static void cypress_send (struct usb_serial_port *port);
174static int cypress_write_room (struct usb_serial_port *port); 174static int cypress_write_room (struct tty_struct *tty);
175static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 175static int cypress_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
176static void cypress_set_termios (struct usb_serial_port *port, struct ktermios * old); 176static void cypress_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
177static int cypress_tiocmget (struct usb_serial_port *port, struct file *file); 177static int cypress_tiocmget (struct tty_struct *tty, struct file *file);
178static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 178static int cypress_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
179static int cypress_chars_in_buffer (struct usb_serial_port *port); 179static int cypress_chars_in_buffer (struct tty_struct *tty);
180static void cypress_throttle (struct usb_serial_port *port); 180static void cypress_throttle (struct tty_struct *tty);
181static void cypress_unthrottle (struct usb_serial_port *port); 181static void cypress_unthrottle (struct tty_struct *tty);
182static void cypress_set_dead (struct usb_serial_port *port); 182static void cypress_set_dead (struct usb_serial_port *port);
183static void cypress_read_int_callback (struct urb *urb); 183static void cypress_read_int_callback (struct urb *urb);
184static void cypress_write_int_callback (struct urb *urb); 184static void cypress_write_int_callback (struct urb *urb);
@@ -322,8 +322,10 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
322 322
323 323
324/* This function can either set or retrieve the current serial line settings */ 324/* This function can either set or retrieve the current serial line settings */
325static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits, 325static int cypress_serial_control (struct tty_struct *tty,
326 int parity_enable, int parity_type, int reset, int cypress_request_type) 326 struct usb_serial_port *port, speed_t baud_rate, int data_bits,
327 int stop_bits, int parity_enable, int parity_type, int reset,
328 int cypress_request_type)
327{ 329{
328 int new_baudrate = 0, retval = 0, tries = 0; 330 int new_baudrate = 0, retval = 0, tries = 0;
329 struct cypress_private *priv; 331 struct cypress_private *priv;
@@ -395,7 +397,7 @@ static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_ra
395 spin_unlock_irqrestore(&priv->lock, flags); 397 spin_unlock_irqrestore(&priv->lock, flags);
396 /* If we asked for a speed change encode it */ 398 /* If we asked for a speed change encode it */
397 if (baud_rate) 399 if (baud_rate)
398 tty_encode_baud_rate(port->tty, 400 tty_encode_baud_rate(tty,
399 new_baudrate, new_baudrate); 401 new_baudrate, new_baudrate);
400 } 402 }
401 break; 403 break;
@@ -611,7 +613,8 @@ static void cypress_shutdown (struct usb_serial *serial)
611} 613}
612 614
613 615
614static int cypress_open (struct usb_serial_port *port, struct file *filp) 616static int cypress_open(struct tty_struct *tty,
617 struct usb_serial_port *port, struct file *filp)
615{ 618{
616 struct cypress_private *priv = usb_get_serial_port_data(port); 619 struct cypress_private *priv = usb_get_serial_port_data(port);
617 struct usb_serial *serial = port->serial; 620 struct usb_serial *serial = port->serial;
@@ -636,14 +639,15 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
636 spin_unlock_irqrestore(&priv->lock, flags); 639 spin_unlock_irqrestore(&priv->lock, flags);
637 640
638 /* setting to zero could cause data loss */ 641 /* setting to zero could cause data loss */
639 port->tty->low_latency = 1; 642 if (tty)
643 tty->low_latency = 1;
640 644
641 /* raise both lines and set termios */ 645 /* raise both lines and set termios */
642 spin_lock_irqsave(&priv->lock, flags); 646 spin_lock_irqsave(&priv->lock, flags);
643 priv->line_control = CONTROL_DTR | CONTROL_RTS; 647 priv->line_control = CONTROL_DTR | CONTROL_RTS;
644 priv->cmd_ctrl = 1; 648 priv->cmd_ctrl = 1;
645 spin_unlock_irqrestore(&priv->lock, flags); 649 spin_unlock_irqrestore(&priv->lock, flags);
646 result = cypress_write(port, NULL, 0); 650 result = cypress_write(tty, port, NULL, 0);
647 651
648 if (result) { 652 if (result) {
649 dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result); 653 dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result);
@@ -651,7 +655,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
651 } else 655 } else
652 dbg("%s - success setting the control lines", __func__); 656 dbg("%s - success setting the control lines", __func__);
653 657
654 cypress_set_termios(port, &priv->tmp_termios); 658 if (tty)
659 cypress_set_termios(tty, port, &priv->tmp_termios);
655 660
656 /* setup the port and start reading from the device */ 661 /* setup the port and start reading from the device */
657 if(!port->interrupt_in_urb){ 662 if(!port->interrupt_in_urb){
@@ -674,7 +679,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
674} /* cypress_open */ 679} /* cypress_open */
675 680
676 681
677static void cypress_close(struct usb_serial_port *port, struct file * filp) 682static void cypress_close(struct tty_struct *tty,
683 struct usb_serial_port *port, struct file * filp)
678{ 684{
679 struct cypress_private *priv = usb_get_serial_port_data(port); 685 struct cypress_private *priv = usb_get_serial_port_data(port);
680 unsigned int c_cflag; 686 unsigned int c_cflag;
@@ -688,7 +694,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
688 spin_lock_irq(&priv->lock); 694 spin_lock_irq(&priv->lock);
689 timeout = CYPRESS_CLOSING_WAIT; 695 timeout = CYPRESS_CLOSING_WAIT;
690 init_waitqueue_entry(&wait, current); 696 init_waitqueue_entry(&wait, current);
691 add_wait_queue(&port->tty->write_wait, &wait); 697 add_wait_queue(&tty->write_wait, &wait);
692 for (;;) { 698 for (;;) {
693 set_current_state(TASK_INTERRUPTIBLE); 699 set_current_state(TASK_INTERRUPTIBLE);
694 if (cypress_buf_data_avail(priv->buf) == 0 700 if (cypress_buf_data_avail(priv->buf) == 0
@@ -701,7 +707,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
701 spin_lock_irq(&priv->lock); 707 spin_lock_irq(&priv->lock);
702 } 708 }
703 set_current_state(TASK_RUNNING); 709 set_current_state(TASK_RUNNING);
704 remove_wait_queue(&port->tty->write_wait, &wait); 710 remove_wait_queue(&tty->write_wait, &wait);
705 /* clear out any remaining data in the buffer */ 711 /* clear out any remaining data in the buffer */
706 cypress_buf_clear(priv->buf); 712 cypress_buf_clear(priv->buf);
707 spin_unlock_irq(&priv->lock); 713 spin_unlock_irq(&priv->lock);
@@ -713,19 +719,21 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
713 return; 719 return;
714 } 720 }
715 /* wait for characters to drain from device */ 721 /* wait for characters to drain from device */
716 bps = tty_get_baud_rate(port->tty); 722 if (tty) {
717 if (bps > 1200) 723 bps = tty_get_baud_rate(tty);
718 timeout = max((HZ*2560)/bps,HZ/10); 724 if (bps > 1200)
719 else 725 timeout = max((HZ*2560)/bps,HZ/10);
720 timeout = 2*HZ; 726 else
721 schedule_timeout_interruptible(timeout); 727 timeout = 2*HZ;
728 schedule_timeout_interruptible(timeout);
729 }
722 730
723 dbg("%s - stopping urbs", __func__); 731 dbg("%s - stopping urbs", __func__);
724 usb_kill_urb (port->interrupt_in_urb); 732 usb_kill_urb (port->interrupt_in_urb);
725 usb_kill_urb (port->interrupt_out_urb); 733 usb_kill_urb (port->interrupt_out_urb);
726 734
727 if (port->tty) { 735 if (tty) {
728 c_cflag = port->tty->termios->c_cflag; 736 c_cflag = tty->termios->c_cflag;
729 if (c_cflag & HUPCL) { 737 if (c_cflag & HUPCL) {
730 /* drop dtr and rts */ 738 /* drop dtr and rts */
731 priv = usb_get_serial_port_data(port); 739 priv = usb_get_serial_port_data(port);
@@ -733,7 +741,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
733 priv->line_control = 0; 741 priv->line_control = 0;
734 priv->cmd_ctrl = 1; 742 priv->cmd_ctrl = 1;
735 spin_unlock_irq(&priv->lock); 743 spin_unlock_irq(&priv->lock);
736 cypress_write(port, NULL, 0); 744 cypress_write(tty, port, NULL, 0);
737 } 745 }
738 } 746 }
739 747
@@ -744,7 +752,8 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
744} /* cypress_close */ 752} /* cypress_close */
745 753
746 754
747static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, int count) 755static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
756 const unsigned char *buf, int count)
748{ 757{
749 struct cypress_private *priv = usb_get_serial_port_data(port); 758 struct cypress_private *priv = usb_get_serial_port_data(port);
750 unsigned long flags; 759 unsigned long flags;
@@ -878,8 +887,9 @@ send:
878 887
879 888
880/* returns how much space is available in the soft buffer */ 889/* returns how much space is available in the soft buffer */
881static int cypress_write_room(struct usb_serial_port *port) 890static int cypress_write_room(struct tty_struct *tty)
882{ 891{
892 struct usb_serial_port *port = tty->driver_data;
883 struct cypress_private *priv = usb_get_serial_port_data(port); 893 struct cypress_private *priv = usb_get_serial_port_data(port);
884 int room = 0; 894 int room = 0;
885 unsigned long flags; 895 unsigned long flags;
@@ -895,8 +905,9 @@ static int cypress_write_room(struct usb_serial_port *port)
895} 905}
896 906
897 907
898static int cypress_tiocmget (struct usb_serial_port *port, struct file *file) 908static int cypress_tiocmget(struct tty_struct *tty, struct file *file)
899{ 909{
910 struct usb_serial_port *port = tty->driver_data;
900 struct cypress_private *priv = usb_get_serial_port_data(port); 911 struct cypress_private *priv = usb_get_serial_port_data(port);
901 __u8 status, control; 912 __u8 status, control;
902 unsigned int result = 0; 913 unsigned int result = 0;
@@ -922,9 +933,10 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
922} 933}
923 934
924 935
925static int cypress_tiocmset (struct usb_serial_port *port, struct file *file, 936static int cypress_tiocmset(struct tty_struct *tty, struct file *file,
926 unsigned int set, unsigned int clear) 937 unsigned int set, unsigned int clear)
927{ 938{
939 struct usb_serial_port *port = tty->driver_data;
928 struct cypress_private *priv = usb_get_serial_port_data(port); 940 struct cypress_private *priv = usb_get_serial_port_data(port);
929 unsigned long flags; 941 unsigned long flags;
930 942
@@ -942,12 +954,14 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
942 priv->cmd_ctrl = 1; 954 priv->cmd_ctrl = 1;
943 spin_unlock_irqrestore(&priv->lock, flags); 955 spin_unlock_irqrestore(&priv->lock, flags);
944 956
945 return cypress_write(port, NULL, 0); 957 return cypress_write(tty, port, NULL, 0);
946} 958}
947 959
948 960
949static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 961static int cypress_ioctl(struct tty_struct *tty, struct file * file,
962 unsigned int cmd, unsigned long arg)
950{ 963{
964 struct usb_serial_port *port = tty->driver_data;
951 struct cypress_private *priv = usb_get_serial_port_data(port); 965 struct cypress_private *priv = usb_get_serial_port_data(port);
952 966
953 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 967 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
@@ -983,22 +997,18 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
983 } 997 }
984 } 998 }
985 return 0; 999 return 0;
986 break;
987 default: 1000 default:
988 break; 1001 break;
989 } 1002 }
990
991 dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); 1003 dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd);
992
993 return -ENOIOCTLCMD; 1004 return -ENOIOCTLCMD;
994} /* cypress_ioctl */ 1005} /* cypress_ioctl */
995 1006
996 1007
997static void cypress_set_termios (struct usb_serial_port *port, 1008static void cypress_set_termios(struct tty_struct *tty,
998 struct ktermios *old_termios) 1009 struct usb_serial_port *port, struct ktermios *old_termios)
999{ 1010{
1000 struct cypress_private *priv = usb_get_serial_port_data(port); 1011 struct cypress_private *priv = usb_get_serial_port_data(port);
1001 struct tty_struct *tty;
1002 int data_bits, stop_bits, parity_type, parity_enable; 1012 int data_bits, stop_bits, parity_type, parity_enable;
1003 unsigned cflag, iflag; 1013 unsigned cflag, iflag;
1004 unsigned long flags; 1014 unsigned long flags;
@@ -1007,8 +1017,6 @@ static void cypress_set_termios (struct usb_serial_port *port,
1007 1017
1008 dbg("%s - port %d", __func__, port->number); 1018 dbg("%s - port %d", __func__, port->number);
1009 1019
1010 tty = port->tty;
1011
1012 spin_lock_irqsave(&priv->lock, flags); 1020 spin_lock_irqsave(&priv->lock, flags);
1013 if (!priv->termios_initialized) { 1021 if (!priv->termios_initialized) {
1014 if (priv->chiptype == CT_EARTHMATE) { 1022 if (priv->chiptype == CT_EARTHMATE) {
@@ -1096,13 +1104,13 @@ static void cypress_set_termios (struct usb_serial_port *port,
1096 "%d data_bits (+5)", __func__, stop_bits, 1104 "%d data_bits (+5)", __func__, stop_bits,
1097 parity_enable, parity_type, data_bits); 1105 parity_enable, parity_type, data_bits);
1098 1106
1099 cypress_serial_control(port, tty_get_baud_rate(tty), data_bits, stop_bits, 1107 cypress_serial_control(tty, port, tty_get_baud_rate(tty), data_bits, stop_bits,
1100 parity_enable, parity_type, 0, CYPRESS_SET_CONFIG); 1108 parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
1101 1109
1102 /* we perform a CYPRESS_GET_CONFIG so that the current settings are 1110 /* we perform a CYPRESS_GET_CONFIG so that the current settings are
1103 * filled into the private structure this should confirm that all is 1111 * filled into the private structure this should confirm that all is
1104 * working if it returns what we just set */ 1112 * working if it returns what we just set */
1105 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); 1113 cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
1106 1114
1107 /* Here we can define custom tty settings for devices; the main tty 1115 /* Here we can define custom tty settings for devices; the main tty
1108 * termios flag base comes from empeg.c */ 1116 * termios flag base comes from empeg.c */
@@ -1142,14 +1150,15 @@ static void cypress_set_termios (struct usb_serial_port *port,
1142 /* if necessary, set lines */ 1150 /* if necessary, set lines */
1143 if (linechange) { 1151 if (linechange) {
1144 priv->cmd_ctrl = 1; 1152 priv->cmd_ctrl = 1;
1145 cypress_write(port, NULL, 0); 1153 cypress_write(tty, port, NULL, 0);
1146 } 1154 }
1147} /* cypress_set_termios */ 1155} /* cypress_set_termios */
1148 1156
1149 1157
1150/* returns amount of data still left in soft buffer */ 1158/* returns amount of data still left in soft buffer */
1151static int cypress_chars_in_buffer(struct usb_serial_port *port) 1159static int cypress_chars_in_buffer(struct tty_struct *tty)
1152{ 1160{
1161 struct usb_serial_port *port = tty->driver_data;
1153 struct cypress_private *priv = usb_get_serial_port_data(port); 1162 struct cypress_private *priv = usb_get_serial_port_data(port);
1154 int chars = 0; 1163 int chars = 0;
1155 unsigned long flags; 1164 unsigned long flags;
@@ -1165,8 +1174,9 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port)
1165} 1174}
1166 1175
1167 1176
1168static void cypress_throttle (struct usb_serial_port *port) 1177static void cypress_throttle(struct tty_struct *tty)
1169{ 1178{
1179 struct usb_serial_port *port = tty->driver_data;
1170 struct cypress_private *priv = usb_get_serial_port_data(port); 1180 struct cypress_private *priv = usb_get_serial_port_data(port);
1171 unsigned long flags; 1181 unsigned long flags;
1172 1182
@@ -1178,8 +1188,9 @@ static void cypress_throttle (struct usb_serial_port *port)
1178} 1188}
1179 1189
1180 1190
1181static void cypress_unthrottle (struct usb_serial_port *port) 1191static void cypress_unthrottle(struct tty_struct *tty)
1182{ 1192{
1193 struct usb_serial_port *port = tty->driver_data;
1183 struct cypress_private *priv = usb_get_serial_port_data(port); 1194 struct cypress_private *priv = usb_get_serial_port_data(port);
1184 int actually_throttled, result; 1195 int actually_throttled, result;
1185 unsigned long flags; 1196 unsigned long flags;
@@ -1251,7 +1262,7 @@ static void cypress_read_int_callback(struct urb *urb)
1251 } 1262 }
1252 spin_unlock_irqrestore(&priv->lock, flags); 1263 spin_unlock_irqrestore(&priv->lock, flags);
1253 1264
1254 tty = port->tty; 1265 tty = port->port.tty;
1255 if (!tty) { 1266 if (!tty) {
1256 dbg("%s - bad tty pointer - exiting", __func__); 1267 dbg("%s - bad tty pointer - exiting", __func__);
1257 return; 1268 return;
@@ -1327,7 +1338,7 @@ static void cypress_read_int_callback(struct urb *urb)
1327 data[i]); 1338 data[i]);
1328 tty_insert_flip_char(tty, data[i], tty_flag); 1339 tty_insert_flip_char(tty, data[i], tty_flag);
1329 } 1340 }
1330 tty_flip_buffer_push(port->tty); 1341 tty_flip_buffer_push(port->port.tty);
1331 } 1342 }
1332 1343
1333 spin_lock_irqsave(&priv->lock, flags); 1344 spin_lock_irqsave(&priv->lock, flags);
@@ -1339,7 +1350,7 @@ continue_read:
1339 1350
1340 /* Continue trying to always read... unless the port has closed. */ 1351 /* Continue trying to always read... unless the port has closed. */
1341 1352
1342 if (port->open_count > 0 && priv->comm_is_ok) { 1353 if (port->port.count > 0 && priv->comm_is_ok) {
1343 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, 1354 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
1344 usb_rcvintpipe(port->serial->dev, 1355 usb_rcvintpipe(port->serial->dev,
1345 port->interrupt_in_endpointAddress), 1356 port->interrupt_in_endpointAddress),
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 28bc6fcf44f0..dc92dbfc962e 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -15,7 +15,7 @@
15* Al Borchers (borchers@steinerpoint.com) 15* Al Borchers (borchers@steinerpoint.com)
16* 16*
17* (12/03/2001) gkh 17* (12/03/2001) gkh
18* switched to using port->open_count instead of private version. 18* switched to using port->port.count instead of private version.
19* Removed port->active 19* Removed port->active
20* 20*
21* (04/08/2001) gb 21* (04/08/2001) gb
@@ -441,22 +441,23 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
441 unsigned int modem_signals, int interruptible); 441 unsigned int modem_signals, int interruptible);
442static int digi_transmit_idle(struct usb_serial_port *port, 442static int digi_transmit_idle(struct usb_serial_port *port,
443 unsigned long timeout); 443 unsigned long timeout);
444static void digi_rx_throttle (struct usb_serial_port *port); 444static void digi_rx_throttle (struct tty_struct *tty);
445static void digi_rx_unthrottle (struct usb_serial_port *port); 445static void digi_rx_unthrottle (struct tty_struct *tty);
446static void digi_set_termios(struct usb_serial_port *port, 446static void digi_set_termios(struct tty_struct *tty,
447 struct ktermios *old_termios); 447 struct usb_serial_port *port, struct ktermios *old_termios);
448static void digi_break_ctl(struct usb_serial_port *port, int break_state); 448static void digi_break_ctl(struct tty_struct *tty, int break_state);
449static int digi_ioctl(struct usb_serial_port *port, struct file *file, 449static int digi_tiocmget(struct tty_struct *tty, struct file *file);
450 unsigned int cmd, unsigned long arg); 450static int digi_tiocmset(struct tty_struct *tty, struct file *file,
451static int digi_tiocmget(struct usb_serial_port *port, struct file *file);
452static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
453 unsigned int set, unsigned int clear); 451 unsigned int set, unsigned int clear);
454static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count); 452static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
453 const unsigned char *buf, int count);
455static void digi_write_bulk_callback(struct urb *urb); 454static void digi_write_bulk_callback(struct urb *urb);
456static int digi_write_room(struct usb_serial_port *port); 455static int digi_write_room(struct tty_struct *tty);
457static int digi_chars_in_buffer(struct usb_serial_port *port); 456static int digi_chars_in_buffer(struct tty_struct *tty);
458static int digi_open(struct usb_serial_port *port, struct file *filp); 457static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
459static void digi_close(struct usb_serial_port *port, struct file *filp); 458 struct file *filp);
459static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
460 struct file *filp);
460static int digi_startup_device(struct usb_serial *serial); 461static int digi_startup_device(struct usb_serial *serial);
461static int digi_startup(struct usb_serial *serial); 462static int digi_startup(struct usb_serial *serial);
462static void digi_shutdown(struct usb_serial *serial); 463static void digi_shutdown(struct usb_serial *serial);
@@ -516,7 +517,6 @@ static struct usb_serial_driver digi_acceleport_2_device = {
516 .chars_in_buffer = digi_chars_in_buffer, 517 .chars_in_buffer = digi_chars_in_buffer,
517 .throttle = digi_rx_throttle, 518 .throttle = digi_rx_throttle,
518 .unthrottle = digi_rx_unthrottle, 519 .unthrottle = digi_rx_unthrottle,
519 .ioctl = digi_ioctl,
520 .set_termios = digi_set_termios, 520 .set_termios = digi_set_termios,
521 .break_ctl = digi_break_ctl, 521 .break_ctl = digi_break_ctl,
522 .tiocmget = digi_tiocmget, 522 .tiocmget = digi_tiocmget,
@@ -543,7 +543,6 @@ static struct usb_serial_driver digi_acceleport_4_device = {
543 .chars_in_buffer = digi_chars_in_buffer, 543 .chars_in_buffer = digi_chars_in_buffer,
544 .throttle = digi_rx_throttle, 544 .throttle = digi_rx_throttle,
545 .unthrottle = digi_rx_unthrottle, 545 .unthrottle = digi_rx_unthrottle,
546 .ioctl = digi_ioctl,
547 .set_termios = digi_set_termios, 546 .set_termios = digi_set_termios,
548 .break_ctl = digi_break_ctl, 547 .break_ctl = digi_break_ctl,
549 .tiocmget = digi_tiocmget, 548 .tiocmget = digi_tiocmget,
@@ -604,7 +603,7 @@ static void digi_wakeup_write_lock(struct work_struct *work)
604 603
605static void digi_wakeup_write(struct usb_serial_port *port) 604static void digi_wakeup_write(struct usb_serial_port *port)
606{ 605{
607 tty_wakeup(port->tty); 606 tty_wakeup(port->port.tty);
608} 607}
609 608
610 609
@@ -856,9 +855,10 @@ static int digi_transmit_idle(struct usb_serial_port *port,
856} 855}
857 856
858 857
859static void digi_rx_throttle(struct usb_serial_port *port) 858static void digi_rx_throttle(struct tty_struct *tty)
860{ 859{
861 unsigned long flags; 860 unsigned long flags;
861 struct usb_serial_port *port = tty->driver_data;
862 struct digi_port *priv = usb_get_serial_port_data(port); 862 struct digi_port *priv = usb_get_serial_port_data(port);
863 863
864 864
@@ -872,10 +872,11 @@ static void digi_rx_throttle(struct usb_serial_port *port)
872} 872}
873 873
874 874
875static void digi_rx_unthrottle(struct usb_serial_port *port) 875static void digi_rx_unthrottle(struct tty_struct *tty)
876{ 876{
877 int ret = 0; 877 int ret = 0;
878 unsigned long flags; 878 unsigned long flags;
879 struct usb_serial_port *port = tty->driver_data;
879 struct digi_port *priv = usb_get_serial_port_data(port); 880 struct digi_port *priv = usb_get_serial_port_data(port);
880 881
881 dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num); 882 dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num);
@@ -900,12 +901,10 @@ static void digi_rx_unthrottle(struct usb_serial_port *port)
900} 901}
901 902
902 903
903static void digi_set_termios(struct usb_serial_port *port, 904static void digi_set_termios(struct tty_struct *tty,
904 struct ktermios *old_termios) 905 struct usb_serial_port *port, struct ktermios *old_termios)
905{ 906{
906
907 struct digi_port *priv = usb_get_serial_port_data(port); 907 struct digi_port *priv = usb_get_serial_port_data(port);
908 struct tty_struct *tty = port->tty;
909 unsigned int iflag = tty->termios->c_iflag; 908 unsigned int iflag = tty->termios->c_iflag;
910 unsigned int cflag = tty->termios->c_cflag; 909 unsigned int cflag = tty->termios->c_cflag;
911 unsigned int old_iflag = old_termios->c_iflag; 910 unsigned int old_iflag = old_termios->c_iflag;
@@ -1088,8 +1087,9 @@ static void digi_set_termios(struct usb_serial_port *port,
1088} 1087}
1089 1088
1090 1089
1091static void digi_break_ctl(struct usb_serial_port *port, int break_state) 1090static void digi_break_ctl(struct tty_struct *tty, int break_state)
1092{ 1091{
1092 struct usb_serial_port *port = tty->driver_data;
1093 unsigned char buf[4]; 1093 unsigned char buf[4];
1094 1094
1095 buf[0] = DIGI_CMD_BREAK_CONTROL; 1095 buf[0] = DIGI_CMD_BREAK_CONTROL;
@@ -1100,8 +1100,9 @@ static void digi_break_ctl(struct usb_serial_port *port, int break_state)
1100} 1100}
1101 1101
1102 1102
1103static int digi_tiocmget(struct usb_serial_port *port, struct file *file) 1103static int digi_tiocmget(struct tty_struct *tty, struct file *file)
1104{ 1104{
1105 struct usb_serial_port *port = tty->driver_data;
1105 struct digi_port *priv = usb_get_serial_port_data(port); 1106 struct digi_port *priv = usb_get_serial_port_data(port);
1106 unsigned int val; 1107 unsigned int val;
1107 unsigned long flags; 1108 unsigned long flags;
@@ -1115,9 +1116,10 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file)
1115} 1116}
1116 1117
1117 1118
1118static int digi_tiocmset(struct usb_serial_port *port, struct file *file, 1119static int digi_tiocmset(struct tty_struct *tty, struct file *file,
1119 unsigned int set, unsigned int clear) 1120 unsigned int set, unsigned int clear)
1120{ 1121{
1122 struct usb_serial_port *port = tty->driver_data;
1121 struct digi_port *priv = usb_get_serial_port_data(port); 1123 struct digi_port *priv = usb_get_serial_port_data(port);
1122 unsigned int val; 1124 unsigned int val;
1123 unsigned long flags; 1125 unsigned long flags;
@@ -1131,27 +1133,8 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
1131} 1133}
1132 1134
1133 1135
1134static int digi_ioctl(struct usb_serial_port *port, struct file *file, 1136static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
1135 unsigned int cmd, unsigned long arg) 1137 const unsigned char *buf, int count)
1136{
1137 struct digi_port *priv = usb_get_serial_port_data(port);
1138 dbg("digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd);
1139
1140 switch (cmd) {
1141 case TIOCMIWAIT:
1142 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
1143 /* TODO */
1144 return 0;
1145 case TIOCGICOUNT:
1146 /* return count of modemline transitions */
1147 /* TODO */
1148 return 0;
1149 }
1150 return -ENOIOCTLCMD;
1151
1152}
1153
1154static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count)
1155{ 1138{
1156 1139
1157 int ret,data_len,new_len; 1140 int ret,data_len,new_len;
@@ -1261,7 +1244,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1261 /* try to send any buffered data on this port, if it is open */ 1244 /* try to send any buffered data on this port, if it is open */
1262 spin_lock(&priv->dp_port_lock); 1245 spin_lock(&priv->dp_port_lock);
1263 priv->dp_write_urb_in_use = 0; 1246 priv->dp_write_urb_in_use = 0;
1264 if (port->open_count && port->write_urb->status != -EINPROGRESS 1247 if (port->port.count && port->write_urb->status != -EINPROGRESS
1265 && priv->dp_out_buf_len > 0) { 1248 && priv->dp_out_buf_len > 0) {
1266 *((unsigned char *)(port->write_urb->transfer_buffer)) 1249 *((unsigned char *)(port->write_urb->transfer_buffer))
1267 = (unsigned char)DIGI_CMD_SEND_DATA; 1250 = (unsigned char)DIGI_CMD_SEND_DATA;
@@ -1288,11 +1271,11 @@ static void digi_write_bulk_callback(struct urb *urb)
1288 __func__, ret, priv->dp_port_num); 1271 __func__, ret, priv->dp_port_num);
1289} 1272}
1290 1273
1291static int digi_write_room(struct usb_serial_port *port) 1274static int digi_write_room(struct tty_struct *tty)
1292{ 1275{
1293 1276 struct usb_serial_port *port = tty->driver_data;
1294 int room;
1295 struct digi_port *priv = usb_get_serial_port_data(port); 1277 struct digi_port *priv = usb_get_serial_port_data(port);
1278 int room;
1296 unsigned long flags = 0; 1279 unsigned long flags = 0;
1297 1280
1298 spin_lock_irqsave(&priv->dp_port_lock, flags); 1281 spin_lock_irqsave(&priv->dp_port_lock, flags);
@@ -1308,12 +1291,11 @@ static int digi_write_room(struct usb_serial_port *port)
1308 1291
1309} 1292}
1310 1293
1311static int digi_chars_in_buffer(struct usb_serial_port *port) 1294static int digi_chars_in_buffer(struct tty_struct *tty)
1312{ 1295{
1313 1296 struct usb_serial_port *port = tty->driver_data;
1314 struct digi_port *priv = usb_get_serial_port_data(port); 1297 struct digi_port *priv = usb_get_serial_port_data(port);
1315 1298
1316
1317 if (port->write_urb->status == -EINPROGRESS 1299 if (port->write_urb->status == -EINPROGRESS
1318 || priv->dp_write_urb_in_use) { 1300 || priv->dp_write_urb_in_use) {
1319 dbg("digi_chars_in_buffer: port=%d, chars=%d", 1301 dbg("digi_chars_in_buffer: port=%d, chars=%d",
@@ -1329,7 +1311,8 @@ static int digi_chars_in_buffer(struct usb_serial_port *port)
1329} 1311}
1330 1312
1331 1313
1332static int digi_open(struct usb_serial_port *port, struct file *filp) 1314static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
1315 struct file *filp)
1333{ 1316{
1334 int ret; 1317 int ret;
1335 unsigned char buf[32]; 1318 unsigned char buf[32];
@@ -1338,7 +1321,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
1338 unsigned long flags = 0; 1321 unsigned long flags = 0;
1339 1322
1340 dbg("digi_open: TOP: port=%d, open_count=%d", 1323 dbg("digi_open: TOP: port=%d, open_count=%d",
1341 priv->dp_port_num, port->open_count); 1324 priv->dp_port_num, port->port.count);
1342 1325
1343 /* be sure the device is started up */ 1326 /* be sure the device is started up */
1344 if (digi_startup_device(port->serial) != 0) 1327 if (digi_startup_device(port->serial) != 0)
@@ -1380,9 +1363,11 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
1380 dbg("digi_open: write oob failed, ret=%d", ret); 1363 dbg("digi_open: write oob failed, ret=%d", ret);
1381 1364
1382 /* set termios settings */ 1365 /* set termios settings */
1383 not_termios.c_cflag = ~port->tty->termios->c_cflag; 1366 if (tty) {
1384 not_termios.c_iflag = ~port->tty->termios->c_iflag; 1367 not_termios.c_cflag = ~tty->termios->c_cflag;
1385 digi_set_termios(port, &not_termios); 1368 not_termios.c_iflag = ~tty->termios->c_iflag;
1369 digi_set_termios(tty, port, &not_termios);
1370 }
1386 1371
1387 /* set DTR and RTS */ 1372 /* set DTR and RTS */
1388 digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1); 1373 digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1);
@@ -1391,16 +1376,16 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
1391} 1376}
1392 1377
1393 1378
1394static void digi_close(struct usb_serial_port *port, struct file *filp) 1379static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
1380 struct file *filp)
1395{ 1381{
1396 DEFINE_WAIT(wait); 1382 DEFINE_WAIT(wait);
1397 int ret; 1383 int ret;
1398 unsigned char buf[32]; 1384 unsigned char buf[32];
1399 struct tty_struct *tty = port->tty;
1400 struct digi_port *priv = usb_get_serial_port_data(port); 1385 struct digi_port *priv = usb_get_serial_port_data(port);
1401 1386
1402 dbg("digi_close: TOP: port=%d, open_count=%d", 1387 dbg("digi_close: TOP: port=%d, open_count=%d",
1403 priv->dp_port_num, port->open_count); 1388 priv->dp_port_num, port->port.count);
1404 1389
1405 mutex_lock(&port->serial->disc_mutex); 1390 mutex_lock(&port->serial->disc_mutex);
1406 /* if disconnected, just clear flags */ 1391 /* if disconnected, just clear flags */
@@ -1663,7 +1648,7 @@ static int digi_read_inb_callback(struct urb *urb)
1663{ 1648{
1664 1649
1665 struct usb_serial_port *port = urb->context; 1650 struct usb_serial_port *port = urb->context;
1666 struct tty_struct *tty = port->tty; 1651 struct tty_struct *tty = port->port.tty;
1667 struct digi_port *priv = usb_get_serial_port_data(port); 1652 struct digi_port *priv = usb_get_serial_port_data(port);
1668 int opcode = ((unsigned char *)urb->transfer_buffer)[0]; 1653 int opcode = ((unsigned char *)urb->transfer_buffer)[0];
1669 int len = ((unsigned char *)urb->transfer_buffer)[1]; 1654 int len = ((unsigned char *)urb->transfer_buffer)[1];
@@ -1675,7 +1660,7 @@ static int digi_read_inb_callback(struct urb *urb)
1675 1660
1676 /* do not process callbacks on closed ports */ 1661 /* do not process callbacks on closed ports */
1677 /* but do continue the read chain */ 1662 /* but do continue the read chain */
1678 if (port->open_count == 0) 1663 if (port->port.count == 0)
1679 return 0; 1664 return 0;
1680 1665
1681 /* short/multiple packet check */ 1666 /* short/multiple packet check */
@@ -1785,17 +1770,17 @@ static int digi_read_oob_callback(struct urb *urb)
1785 if (val & DIGI_READ_INPUT_SIGNALS_CTS) { 1770 if (val & DIGI_READ_INPUT_SIGNALS_CTS) {
1786 priv->dp_modem_signals |= TIOCM_CTS; 1771 priv->dp_modem_signals |= TIOCM_CTS;
1787 /* port must be open to use tty struct */ 1772 /* port must be open to use tty struct */
1788 if (port->open_count 1773 if (port->port.count
1789 && port->tty->termios->c_cflag & CRTSCTS) { 1774 && port->port.tty->termios->c_cflag & CRTSCTS) {
1790 port->tty->hw_stopped = 0; 1775 port->port.tty->hw_stopped = 0;
1791 digi_wakeup_write(port); 1776 digi_wakeup_write(port);
1792 } 1777 }
1793 } else { 1778 } else {
1794 priv->dp_modem_signals &= ~TIOCM_CTS; 1779 priv->dp_modem_signals &= ~TIOCM_CTS;
1795 /* port must be open to use tty struct */ 1780 /* port must be open to use tty struct */
1796 if (port->open_count 1781 if (port->port.count
1797 && port->tty->termios->c_cflag & CRTSCTS) { 1782 && port->port.tty->termios->c_cflag & CRTSCTS) {
1798 port->tty->hw_stopped = 1; 1783 port->port.tty->hw_stopped = 1;
1799 } 1784 }
1800 } 1785 }
1801 if (val & DIGI_READ_INPUT_SIGNALS_DSR) 1786 if (val & DIGI_READ_INPUT_SIGNALS_DSR)
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index c5ec309a3cb1..47ebdf5fad8e 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -31,7 +31,7 @@
31 * Moved MOD_DEC_USE_COUNT to end of empeg_close(). 31 * Moved MOD_DEC_USE_COUNT to end of empeg_close().
32 * 32 *
33 * (12/03/2000) gb 33 * (12/03/2000) gb
34 * Added port->tty->ldisc.set_termios(port->tty, NULL) to empeg_open() 34 * Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to empeg_open()
35 * This notifies the tty driver that the termios have changed. 35 * This notifies the tty driver that the termios have changed.
36 * 36 *
37 * (11/13/2000) gb 37 * (11/13/2000) gb
@@ -77,22 +77,18 @@ static int debug;
77#define EMPEG_PRODUCT_ID 0x0001 77#define EMPEG_PRODUCT_ID 0x0001
78 78
79/* function prototypes for an empeg-car player */ 79/* function prototypes for an empeg-car player */
80static int empeg_open (struct usb_serial_port *port, struct file *filp); 80static int empeg_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
81static void empeg_close (struct usb_serial_port *port, struct file *filp); 81static void empeg_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
82static int empeg_write (struct usb_serial_port *port, 82static int empeg_write (struct tty_struct *tty, struct usb_serial_port *port,
83 const unsigned char *buf, 83 const unsigned char *buf,
84 int count); 84 int count);
85static int empeg_write_room (struct usb_serial_port *port); 85static int empeg_write_room (struct tty_struct *tty);
86static int empeg_chars_in_buffer (struct usb_serial_port *port); 86static int empeg_chars_in_buffer (struct tty_struct *tty);
87static void empeg_throttle (struct usb_serial_port *port); 87static void empeg_throttle (struct tty_struct *tty);
88static void empeg_unthrottle (struct usb_serial_port *port); 88static void empeg_unthrottle (struct tty_struct *tty);
89static int empeg_startup (struct usb_serial *serial); 89static int empeg_startup (struct usb_serial *serial);
90static void empeg_shutdown (struct usb_serial *serial); 90static void empeg_shutdown (struct usb_serial *serial);
91static int empeg_ioctl (struct usb_serial_port *port, 91static void empeg_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
92 struct file * file,
93 unsigned int cmd,
94 unsigned long arg);
95static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios);
96static void empeg_write_bulk_callback (struct urb *urb); 92static void empeg_write_bulk_callback (struct urb *urb);
97static void empeg_read_bulk_callback (struct urb *urb); 93static void empeg_read_bulk_callback (struct urb *urb);
98 94
@@ -125,7 +121,6 @@ static struct usb_serial_driver empeg_device = {
125 .unthrottle = empeg_unthrottle, 121 .unthrottle = empeg_unthrottle,
126 .attach = empeg_startup, 122 .attach = empeg_startup,
127 .shutdown = empeg_shutdown, 123 .shutdown = empeg_shutdown,
128 .ioctl = empeg_ioctl,
129 .set_termios = empeg_set_termios, 124 .set_termios = empeg_set_termios,
130 .write = empeg_write, 125 .write = empeg_write,
131 .write_room = empeg_write_room, 126 .write_room = empeg_write_room,
@@ -145,7 +140,8 @@ static int bytes_out;
145/****************************************************************************** 140/******************************************************************************
146 * Empeg specific driver functions 141 * Empeg specific driver functions
147 ******************************************************************************/ 142 ******************************************************************************/
148static int empeg_open (struct usb_serial_port *port, struct file *filp) 143static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
144 struct file *filp)
149{ 145{
150 struct usb_serial *serial = port->serial; 146 struct usb_serial *serial = port->serial;
151 int result = 0; 147 int result = 0;
@@ -153,7 +149,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
153 dbg("%s - port %d", __func__, port->number); 149 dbg("%s - port %d", __func__, port->number);
154 150
155 /* Force default termio settings */ 151 /* Force default termio settings */
156 empeg_set_termios (port, NULL) ; 152 empeg_set_termios (tty, port, NULL) ;
157 153
158 bytes_in = 0; 154 bytes_in = 0;
159 bytes_out = 0; 155 bytes_out = 0;
@@ -178,7 +174,8 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
178} 174}
179 175
180 176
181static void empeg_close (struct usb_serial_port *port, struct file * filp) 177static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
178 struct file * filp)
182{ 179{
183 dbg("%s - port %d", __func__, port->number); 180 dbg("%s - port %d", __func__, port->number);
184 181
@@ -189,7 +186,7 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
189} 186}
190 187
191 188
192static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count) 189static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count)
193{ 190{
194 struct usb_serial *serial = port->serial; 191 struct usb_serial *serial = port->serial;
195 struct urb *urb; 192 struct urb *urb;
@@ -203,7 +200,6 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
203 dbg("%s - port %d", __func__, port->number); 200 dbg("%s - port %d", __func__, port->number);
204 201
205 while (count > 0) { 202 while (count > 0) {
206
207 /* try to find a free urb in our list of them */ 203 /* try to find a free urb in our list of them */
208 urb = NULL; 204 urb = NULL;
209 205
@@ -262,15 +258,14 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
262 bytes_out += transfer_size; 258 bytes_out += transfer_size;
263 259
264 } 260 }
265
266exit: 261exit:
267 return bytes_sent; 262 return bytes_sent;
268
269} 263}
270 264
271 265
272static int empeg_write_room (struct usb_serial_port *port) 266static int empeg_write_room(struct tty_struct *tty)
273{ 267{
268 struct usb_serial_port *port = tty->driver_data;
274 unsigned long flags; 269 unsigned long flags;
275 int i; 270 int i;
276 int room = 0; 271 int room = 0;
@@ -278,25 +273,22 @@ static int empeg_write_room (struct usb_serial_port *port)
278 dbg("%s - port %d", __func__, port->number); 273 dbg("%s - port %d", __func__, port->number);
279 274
280 spin_lock_irqsave (&write_urb_pool_lock, flags); 275 spin_lock_irqsave (&write_urb_pool_lock, flags);
281
282 /* tally up the number of bytes available */ 276 /* tally up the number of bytes available */
283 for (i = 0; i < NUM_URBS; ++i) { 277 for (i = 0; i < NUM_URBS; ++i) {
284 if (write_urb_pool[i]->status != -EINPROGRESS) { 278 if (write_urb_pool[i]->status != -EINPROGRESS) {
285 room += URB_TRANSFER_BUFFER_SIZE; 279 room += URB_TRANSFER_BUFFER_SIZE;
286 } 280 }
287 } 281 }
288
289 spin_unlock_irqrestore (&write_urb_pool_lock, flags); 282 spin_unlock_irqrestore (&write_urb_pool_lock, flags);
290
291 dbg("%s - returns %d", __func__, room); 283 dbg("%s - returns %d", __func__, room);
292 284 return room;
293 return (room);
294 285
295} 286}
296 287
297 288
298static int empeg_chars_in_buffer (struct usb_serial_port *port) 289static int empeg_chars_in_buffer(struct tty_struct *tty)
299{ 290{
291 struct usb_serial_port *port = tty->driver_data;
300 unsigned long flags; 292 unsigned long flags;
301 int i; 293 int i;
302 int chars = 0; 294 int chars = 0;
@@ -356,7 +348,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
356 348
357 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 349 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
358 350
359 tty = port->tty; 351 tty = port->port.tty;
360 352
361 if (urb->actual_length) { 353 if (urb->actual_length) {
362 tty_buffer_request_room(tty, urb->actual_length); 354 tty_buffer_request_room(tty, urb->actual_length);
@@ -386,27 +378,24 @@ static void empeg_read_bulk_callback (struct urb *urb)
386} 378}
387 379
388 380
389static void empeg_throttle (struct usb_serial_port *port) 381static void empeg_throttle(struct tty_struct *tty)
390{ 382{
383 struct usb_serial_port *port = tty->driver_data;
391 dbg("%s - port %d", __func__, port->number); 384 dbg("%s - port %d", __func__, port->number);
392 usb_kill_urb(port->read_urb); 385 usb_kill_urb(port->read_urb);
393} 386}
394 387
395 388
396static void empeg_unthrottle (struct usb_serial_port *port) 389static void empeg_unthrottle(struct tty_struct *tty)
397{ 390{
391 struct usb_serial_port *port = tty->driver_data;
398 int result; 392 int result;
399
400 dbg("%s - port %d", __func__, port->number); 393 dbg("%s - port %d", __func__, port->number);
401 394
402 port->read_urb->dev = port->serial->dev; 395 port->read_urb->dev = port->serial->dev;
403
404 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 396 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
405
406 if (result) 397 if (result)
407 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); 398 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
408
409 return;
410} 399}
411 400
412 401
@@ -436,17 +425,10 @@ static void empeg_shutdown (struct usb_serial *serial)
436} 425}
437 426
438 427
439static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 428static void empeg_set_termios(struct tty_struct *tty,
440{ 429 struct usb_serial_port *port, struct ktermios *old_termios)
441 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
442
443 return -ENOIOCTLCMD;
444}
445
446
447static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
448{ 430{
449 struct ktermios *termios = port->tty->termios; 431 struct ktermios *termios = tty->termios;
450 dbg("%s - port %d", __func__, port->number); 432 dbg("%s - port %d", __func__, port->number);
451 433
452 /* 434 /*
@@ -491,8 +473,8 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol
491 * this is bad as it opens up the possibility of dropping bytes 473 * this is bad as it opens up the possibility of dropping bytes
492 * on the floor. We don't want to drop bytes on the floor. :) 474 * on the floor. We don't want to drop bytes on the floor. :)
493 */ 475 */
494 port->tty->low_latency = 1; 476 tty->low_latency = 1;
495 tty_encode_baud_rate(port->tty, 115200, 115200); 477 tty_encode_baud_rate(tty, 115200, 115200);
496} 478}
497 479
498 480
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0ff4a3971e45..abbb447e5375 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -682,21 +682,21 @@ static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_i
682static void ftdi_shutdown (struct usb_serial *serial); 682static void ftdi_shutdown (struct usb_serial *serial);
683static int ftdi_sio_port_probe (struct usb_serial_port *port); 683static int ftdi_sio_port_probe (struct usb_serial_port *port);
684static int ftdi_sio_port_remove (struct usb_serial_port *port); 684static int ftdi_sio_port_remove (struct usb_serial_port *port);
685static int ftdi_open (struct usb_serial_port *port, struct file *filp); 685static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
686static void ftdi_close (struct usb_serial_port *port, struct file *filp); 686static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
687static int ftdi_write (struct usb_serial_port *port, const unsigned char *buf, int count); 687static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
688static int ftdi_write_room (struct usb_serial_port *port); 688static int ftdi_write_room (struct tty_struct *tty);
689static int ftdi_chars_in_buffer (struct usb_serial_port *port); 689static int ftdi_chars_in_buffer (struct tty_struct *tty);
690static void ftdi_write_bulk_callback (struct urb *urb); 690static void ftdi_write_bulk_callback (struct urb *urb);
691static void ftdi_read_bulk_callback (struct urb *urb); 691static void ftdi_read_bulk_callback (struct urb *urb);
692static void ftdi_process_read (struct work_struct *work); 692static void ftdi_process_read (struct work_struct *work);
693static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios * old); 693static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
694static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); 694static int ftdi_tiocmget (struct tty_struct *tty, struct file *file);
695static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); 695static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear);
696static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 696static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
697static void ftdi_break_ctl (struct usb_serial_port *port, int break_state ); 697static void ftdi_break_ctl (struct tty_struct *tty, int break_state );
698static void ftdi_throttle (struct usb_serial_port *port); 698static void ftdi_throttle (struct tty_struct *tty);
699static void ftdi_unthrottle (struct usb_serial_port *port); 699static void ftdi_unthrottle (struct tty_struct *tty);
700 700
701static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); 701static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base);
702static unsigned short int ftdi_232am_baud_to_divisor (int baud); 702static unsigned short int ftdi_232am_baud_to_divisor (int baud);
@@ -843,42 +843,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
843} 843}
844 844
845 845
846static __u32 get_ftdi_divisor(struct usb_serial_port * port); 846static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port)
847
848
849static int change_speed(struct usb_serial_port *port)
850{
851 struct ftdi_private *priv = usb_get_serial_port_data(port);
852 char *buf;
853 __u16 urb_value;
854 __u16 urb_index;
855 __u32 urb_index_value;
856 int rv;
857
858 buf = kmalloc(1, GFP_NOIO);
859 if (!buf)
860 return -ENOMEM;
861
862 urb_index_value = get_ftdi_divisor(port);
863 urb_value = (__u16)urb_index_value;
864 urb_index = (__u16)(urb_index_value >> 16);
865 if (priv->interface) { /* FT2232C */
866 urb_index = (__u16)((urb_index << 8) | priv->interface);
867 }
868
869 rv = usb_control_msg(port->serial->dev,
870 usb_sndctrlpipe(port->serial->dev, 0),
871 FTDI_SIO_SET_BAUDRATE_REQUEST,
872 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
873 urb_value, urb_index,
874 buf, 0, WDR_SHORT_TIMEOUT);
875
876 kfree(buf);
877 return rv;
878}
879
880
881static __u32 get_ftdi_divisor(struct usb_serial_port * port)
882{ /* get_ftdi_divisor */ 847{ /* get_ftdi_divisor */
883 struct ftdi_private *priv = usb_get_serial_port_data(port); 848 struct ftdi_private *priv = usb_get_serial_port_data(port);
884 __u32 div_value = 0; 849 __u32 div_value = 0;
@@ -910,7 +875,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
910 875
911 /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ 876 /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */
912 877
913 baud = tty_get_baud_rate(port->tty); 878 baud = tty_get_baud_rate(tty);
914 dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); 879 dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
915 880
916 /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ 881 /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */
@@ -976,10 +941,42 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
976 ftdi_chip_name[priv->chip_type]); 941 ftdi_chip_name[priv->chip_type]);
977 } 942 }
978 943
979 tty_encode_baud_rate(port->tty, baud, baud); 944 tty_encode_baud_rate(tty, baud, baud);
980 return(div_value); 945 return(div_value);
981} 946}
982 947
948static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
949{
950 struct ftdi_private *priv = usb_get_serial_port_data(port);
951 char *buf;
952 __u16 urb_value;
953 __u16 urb_index;
954 __u32 urb_index_value;
955 int rv;
956
957 buf = kmalloc(1, GFP_NOIO);
958 if (!buf)
959 return -ENOMEM;
960
961 urb_index_value = get_ftdi_divisor(tty, port);
962 urb_value = (__u16)urb_index_value;
963 urb_index = (__u16)(urb_index_value >> 16);
964 if (priv->interface) { /* FT2232C */
965 urb_index = (__u16)((urb_index << 8) | priv->interface);
966 }
967
968 rv = usb_control_msg(port->serial->dev,
969 usb_sndctrlpipe(port->serial->dev, 0),
970 FTDI_SIO_SET_BAUDRATE_REQUEST,
971 FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
972 urb_value, urb_index,
973 buf, 0, WDR_SHORT_TIMEOUT);
974
975 kfree(buf);
976 return rv;
977}
978
979
983 980
984static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) 981static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo)
985{ 982{
@@ -998,7 +995,8 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _
998} /* get_serial_info */ 995} /* get_serial_info */
999 996
1000 997
1001static int set_serial_info(struct usb_serial_port * port, struct serial_struct __user * newinfo) 998static int set_serial_info(struct tty_struct *tty,
999 struct usb_serial_port * port, struct serial_struct __user * newinfo)
1002{ /* set_serial_info */ 1000{ /* set_serial_info */
1003 struct ftdi_private *priv = usb_get_serial_port_data(port); 1001 struct ftdi_private *priv = usb_get_serial_port_data(port);
1004 struct serial_struct new_serial; 1002 struct serial_struct new_serial;
@@ -1030,30 +1028,29 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
1030 (new_serial.flags & ASYNC_FLAGS)); 1028 (new_serial.flags & ASYNC_FLAGS));
1031 priv->custom_divisor = new_serial.custom_divisor; 1029 priv->custom_divisor = new_serial.custom_divisor;
1032 1030
1033 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1031 tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1034 1032
1035check_and_exit: 1033check_and_exit:
1036 if ((old_priv.flags & ASYNC_SPD_MASK) != 1034 if ((old_priv.flags & ASYNC_SPD_MASK) !=
1037 (priv->flags & ASYNC_SPD_MASK)) { 1035 (priv->flags & ASYNC_SPD_MASK)) {
1038 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1036 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1039 port->tty->alt_speed = 57600; 1037 tty->alt_speed = 57600;
1040 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 1038 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1041 port->tty->alt_speed = 115200; 1039 tty->alt_speed = 115200;
1042 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 1040 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
1043 port->tty->alt_speed = 230400; 1041 tty->alt_speed = 230400;
1044 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 1042 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
1045 port->tty->alt_speed = 460800; 1043 tty->alt_speed = 460800;
1046 else 1044 else
1047 port->tty->alt_speed = 0; 1045 tty->alt_speed = 0;
1048 } 1046 }
1049 if (((old_priv.flags & ASYNC_SPD_MASK) != 1047 if (((old_priv.flags & ASYNC_SPD_MASK) !=
1050 (priv->flags & ASYNC_SPD_MASK)) || 1048 (priv->flags & ASYNC_SPD_MASK)) ||
1051 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1049 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1052 (old_priv.custom_divisor != priv->custom_divisor))) { 1050 (old_priv.custom_divisor != priv->custom_divisor))) {
1053 change_speed(port); 1051 change_speed(tty, port);
1054 } 1052 }
1055 1053 return 0;
1056 return (0);
1057 1054
1058} /* set_serial_info */ 1055} /* set_serial_info */
1059 1056
@@ -1415,7 +1412,8 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1415 return 0; 1412 return 0;
1416} 1413}
1417 1414
1418static int ftdi_open (struct usb_serial_port *port, struct file *filp) 1415static int ftdi_open(struct tty_struct *tty,
1416 struct usb_serial_port *port, struct file *filp)
1419{ /* ftdi_open */ 1417{ /* ftdi_open */
1420 struct usb_device *dev = port->serial->dev; 1418 struct usb_device *dev = port->serial->dev;
1421 struct ftdi_private *priv = usb_get_serial_port_data(port); 1419 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1433,8 +1431,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1433 priv->rx_bytes = 0; 1431 priv->rx_bytes = 0;
1434 spin_unlock_irqrestore(&priv->rx_lock, flags); 1432 spin_unlock_irqrestore(&priv->rx_lock, flags);
1435 1433
1436 if (port->tty) 1434 if (tty)
1437 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1435 tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1438 1436
1439 /* No error checking for this (will get errors later anyway) */ 1437 /* No error checking for this (will get errors later anyway) */
1440 /* See ftdi_sio.h for description of what is reset */ 1438 /* See ftdi_sio.h for description of what is reset */
@@ -1448,8 +1446,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1448 This is same behaviour as serial.c/rs_open() - Kuba */ 1446 This is same behaviour as serial.c/rs_open() - Kuba */
1449 1447
1450 /* ftdi_set_termios will send usb control messages */ 1448 /* ftdi_set_termios will send usb control messages */
1451 if (port->tty) 1449 if (tty)
1452 ftdi_set_termios(port, port->tty->termios); 1450 ftdi_set_termios(tty, port, tty->termios);
1453 1451
1454 /* FIXME: Flow control might be enabled, so it should be checked - 1452 /* FIXME: Flow control might be enabled, so it should be checked -
1455 we have no control of defaults! */ 1453 we have no control of defaults! */
@@ -1485,9 +1483,10 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1485 * 1483 *
1486 */ 1484 */
1487 1485
1488static void ftdi_close (struct usb_serial_port *port, struct file *filp) 1486static void ftdi_close(struct tty_struct *tty,
1487 struct usb_serial_port *port, struct file *filp)
1489{ /* ftdi_close */ 1488{ /* ftdi_close */
1490 unsigned int c_cflag = port->tty->termios->c_cflag; 1489 unsigned int c_cflag = tty->termios->c_cflag;
1491 struct ftdi_private *priv = usb_get_serial_port_data(port); 1490 struct ftdi_private *priv = usb_get_serial_port_data(port);
1492 char buf[1]; 1491 char buf[1];
1493 1492
@@ -1527,7 +1526,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1527 * 1526 *
1528 * The new devices do not require this byte 1527 * The new devices do not require this byte
1529 */ 1528 */
1530static int ftdi_write (struct usb_serial_port *port, 1529static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1531 const unsigned char *buf, int count) 1530 const unsigned char *buf, int count)
1532{ /* ftdi_write */ 1531{ /* ftdi_write */
1533 struct ftdi_private *priv = usb_get_serial_port_data(port); 1532 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1686,8 +1685,9 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1686} /* ftdi_write_bulk_callback */ 1685} /* ftdi_write_bulk_callback */
1687 1686
1688 1687
1689static int ftdi_write_room( struct usb_serial_port *port ) 1688static int ftdi_write_room(struct tty_struct *tty)
1690{ 1689{
1690 struct usb_serial_port *port = tty->driver_data;
1691 struct ftdi_private *priv = usb_get_serial_port_data(port); 1691 struct ftdi_private *priv = usb_get_serial_port_data(port);
1692 int room; 1692 int room;
1693 unsigned long flags; 1693 unsigned long flags;
@@ -1707,11 +1707,11 @@ static int ftdi_write_room( struct usb_serial_port *port )
1707 } 1707 }
1708 spin_unlock_irqrestore(&priv->tx_lock, flags); 1708 spin_unlock_irqrestore(&priv->tx_lock, flags);
1709 return room; 1709 return room;
1710} /* ftdi_write_room */ 1710}
1711
1712 1711
1713static int ftdi_chars_in_buffer (struct usb_serial_port *port) 1712static int ftdi_chars_in_buffer(struct tty_struct *tty)
1714{ /* ftdi_chars_in_buffer */ 1713{
1714 struct usb_serial_port *port = tty->driver_data;
1715 struct ftdi_private *priv = usb_get_serial_port_data(port); 1715 struct ftdi_private *priv = usb_get_serial_port_data(port);
1716 int buffered; 1716 int buffered;
1717 unsigned long flags; 1717 unsigned long flags;
@@ -1726,12 +1726,10 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port)
1726 buffered = 0; 1726 buffered = 0;
1727 } 1727 }
1728 return buffered; 1728 return buffered;
1729} /* ftdi_chars_in_buffer */ 1729}
1730
1731
1732 1730
1733static void ftdi_read_bulk_callback (struct urb *urb) 1731static void ftdi_read_bulk_callback(struct urb *urb)
1734{ /* ftdi_read_bulk_callback */ 1732{
1735 struct usb_serial_port *port = urb->context; 1733 struct usb_serial_port *port = urb->context;
1736 struct tty_struct *tty; 1734 struct tty_struct *tty;
1737 struct ftdi_private *priv; 1735 struct ftdi_private *priv;
@@ -1747,10 +1745,10 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1747 1745
1748 dbg("%s - port %d", __func__, port->number); 1746 dbg("%s - port %d", __func__, port->number);
1749 1747
1750 if (port->open_count <= 0) 1748 if (port->port.count <= 0)
1751 return; 1749 return;
1752 1750
1753 tty = port->tty; 1751 tty = port->port.tty;
1754 if (!tty) { 1752 if (!tty) {
1755 dbg("%s - bad tty pointer - exiting",__func__); 1753 dbg("%s - bad tty pointer - exiting",__func__);
1756 return; 1754 return;
@@ -1803,10 +1801,10 @@ static void ftdi_process_read (struct work_struct *work)
1803 1801
1804 dbg("%s - port %d", __func__, port->number); 1802 dbg("%s - port %d", __func__, port->number);
1805 1803
1806 if (port->open_count <= 0) 1804 if (port->port.count <= 0)
1807 return; 1805 return;
1808 1806
1809 tty = port->tty; 1807 tty = port->port.tty;
1810 if (!tty) { 1808 if (!tty) {
1811 dbg("%s - bad tty pointer - exiting",__func__); 1809 dbg("%s - bad tty pointer - exiting",__func__);
1812 return; 1810 return;
@@ -1954,7 +1952,7 @@ static void ftdi_process_read (struct work_struct *work)
1954 } 1952 }
1955 spin_unlock_irqrestore(&priv->rx_lock, flags); 1953 spin_unlock_irqrestore(&priv->rx_lock, flags);
1956 /* if the port is closed stop trying to read */ 1954 /* if the port is closed stop trying to read */
1957 if (port->open_count > 0){ 1955 if (port->port.count > 0){
1958 /* delay processing of remainder */ 1956 /* delay processing of remainder */
1959 schedule_delayed_work(&priv->rx_work, 1); 1957 schedule_delayed_work(&priv->rx_work, 1);
1960 } else { 1958 } else {
@@ -1967,7 +1965,7 @@ static void ftdi_process_read (struct work_struct *work)
1967 priv->rx_processed = 0; 1965 priv->rx_processed = 0;
1968 1966
1969 /* if the port is closed stop trying to read */ 1967 /* if the port is closed stop trying to read */
1970 if (port->open_count > 0){ 1968 if (port->port.count > 0){
1971 /* Continue trying to always read */ 1969 /* Continue trying to always read */
1972 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 1970 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
1973 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 1971 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
@@ -1983,8 +1981,9 @@ static void ftdi_process_read (struct work_struct *work)
1983} /* ftdi_process_read */ 1981} /* ftdi_process_read */
1984 1982
1985 1983
1986static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) 1984static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
1987{ 1985{
1986 struct usb_serial_port *port = tty->driver_data;
1988 struct ftdi_private *priv = usb_get_serial_port_data(port); 1987 struct ftdi_private *priv = usb_get_serial_port_data(port);
1989 __u16 urb_value = 0; 1988 __u16 urb_value = 0;
1990 char buf[1]; 1989 char buf[1];
@@ -2018,11 +2017,12 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
2018 * WARNING: set_termios calls this with old_termios in kernel space 2017 * WARNING: set_termios calls this with old_termios in kernel space
2019 */ 2018 */
2020 2019
2021static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) 2020static void ftdi_set_termios(struct tty_struct *tty,
2021 struct usb_serial_port *port, struct ktermios *old_termios)
2022{ /* ftdi_termios */ 2022{ /* ftdi_termios */
2023 struct usb_device *dev = port->serial->dev; 2023 struct usb_device *dev = port->serial->dev;
2024 struct ftdi_private *priv = usb_get_serial_port_data(port); 2024 struct ftdi_private *priv = usb_get_serial_port_data(port);
2025 struct ktermios *termios = port->tty->termios; 2025 struct ktermios *termios = tty->termios;
2026 unsigned int cflag = termios->c_cflag; 2026 unsigned int cflag = termios->c_cflag;
2027 __u16 urb_value; /* will hold the new flags */ 2027 __u16 urb_value; /* will hold the new flags */
2028 char buf[1]; /* Perhaps I should dynamically alloc this? */ 2028 char buf[1]; /* Perhaps I should dynamically alloc this? */
@@ -2037,7 +2037,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
2037 /* Force baud rate if this device requires it, unless it is set to B0. */ 2037 /* Force baud rate if this device requires it, unless it is set to B0. */
2038 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { 2038 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
2039 dbg("%s: forcing baud rate for this device", __func__); 2039 dbg("%s: forcing baud rate for this device", __func__);
2040 tty_encode_baud_rate(port->tty, priv->force_baud, 2040 tty_encode_baud_rate(tty, priv->force_baud,
2041 priv->force_baud); 2041 priv->force_baud);
2042 } 2042 }
2043 2043
@@ -2104,7 +2104,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
2104 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2104 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2105 } else { 2105 } else {
2106 /* set the baudrate determined before */ 2106 /* set the baudrate determined before */
2107 if (change_speed(port)) { 2107 if (change_speed(tty, port)) {
2108 err("%s urb failed to set baudrate", __func__); 2108 err("%s urb failed to set baudrate", __func__);
2109 } 2109 }
2110 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2110 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
@@ -2168,11 +2168,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
2168 2168
2169 } 2169 }
2170 return; 2170 return;
2171} /* ftdi_termios */ 2171}
2172
2173 2172
2174static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) 2173static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
2175{ 2174{
2175 struct usb_serial_port *port = tty->driver_data;
2176 struct ftdi_private *priv = usb_get_serial_port_data(port); 2176 struct ftdi_private *priv = usb_get_serial_port_data(port);
2177 unsigned char buf[2]; 2177 unsigned char buf[2];
2178 int ret; 2178 int ret;
@@ -2221,15 +2221,18 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2221 priv->last_dtr_rts; 2221 priv->last_dtr_rts;
2222} 2222}
2223 2223
2224static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 2224static int ftdi_tiocmset(struct tty_struct *tty, struct file * file,
2225 unsigned int set, unsigned int clear)
2225{ 2226{
2227 struct usb_serial_port *port = tty->driver_data;
2226 dbg("%s TIOCMSET", __func__); 2228 dbg("%s TIOCMSET", __func__);
2227 return update_mctrl(port, set, clear); 2229 return update_mctrl(port, set, clear);
2228} 2230}
2229 2231
2230 2232
2231static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 2233static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
2232{ 2234{
2235 struct usb_serial_port *port = tty->driver_data;
2233 struct ftdi_private *priv = usb_get_serial_port_data(port); 2236 struct ftdi_private *priv = usb_get_serial_port_data(port);
2234 2237
2235 dbg("%s cmd 0x%04x", __func__, cmd); 2238 dbg("%s cmd 0x%04x", __func__, cmd);
@@ -2241,7 +2244,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2241 return get_serial_info(port, (struct serial_struct __user *) arg); 2244 return get_serial_info(port, (struct serial_struct __user *) arg);
2242 2245
2243 case TIOCSSERIAL: /* sets serial port data */ 2246 case TIOCSSERIAL: /* sets serial port data */
2244 return set_serial_info(port, (struct serial_struct __user *) arg); 2247 return set_serial_info(tty, port, (struct serial_struct __user *) arg);
2245 2248
2246 /* 2249 /*
2247 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 2250 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
@@ -2280,25 +2283,20 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2280 */ 2283 */
2281 } 2284 }
2282 } 2285 }
2283 return(0); 2286 return 0;
2284 break;
2285 default: 2287 default:
2286 break; 2288 break;
2287
2288 } 2289 }
2289
2290
2291 /* This is not necessarily an error - turns out the higher layers will do 2290 /* This is not necessarily an error - turns out the higher layers will do
2292 * some ioctls itself (see comment above) 2291 * some ioctls itself (see comment above)
2293 */ 2292 */
2294 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); 2293 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
2294 return -ENOIOCTLCMD;
2295}
2295 2296
2296 return(-ENOIOCTLCMD); 2297static void ftdi_throttle(struct tty_struct *tty)
2297} /* ftdi_ioctl */
2298
2299
2300static void ftdi_throttle (struct usb_serial_port *port)
2301{ 2298{
2299 struct usb_serial_port *port = tty->driver_data;
2302 struct ftdi_private *priv = usb_get_serial_port_data(port); 2300 struct ftdi_private *priv = usb_get_serial_port_data(port);
2303 unsigned long flags; 2301 unsigned long flags;
2304 2302
@@ -2310,8 +2308,9 @@ static void ftdi_throttle (struct usb_serial_port *port)
2310} 2308}
2311 2309
2312 2310
2313static void ftdi_unthrottle (struct usb_serial_port *port) 2311static void ftdi_unthrottle(struct tty_struct *tty)
2314{ 2312{
2313 struct usb_serial_port *port = tty->driver_data;
2315 struct ftdi_private *priv = usb_get_serial_port_data(port); 2314 struct ftdi_private *priv = usb_get_serial_port_data(port);
2316 int actually_throttled; 2315 int actually_throttled;
2317 unsigned long flags; 2316 unsigned long flags;
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 8ce5a56a48e3..06cfa43c6f02 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -275,7 +275,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf)
275static void send_to_tty(struct usb_serial_port *port, 275static void send_to_tty(struct usb_serial_port *port,
276 char *data, unsigned int actual_length) 276 char *data, unsigned int actual_length)
277{ 277{
278 struct tty_struct *tty = port->tty; 278 struct tty_struct *tty = port->port.tty;
279 279
280 if (tty && actual_length) { 280 if (tty && actual_length) {
281 281
@@ -970,7 +970,8 @@ static int garmin_init_session(struct usb_serial_port *port)
970 970
971 971
972 972
973static int garmin_open (struct usb_serial_port *port, struct file *filp) 973static int garmin_open (struct tty_struct *tty,
974 struct usb_serial_port *port, struct file *filp)
974{ 975{
975 unsigned long flags; 976 unsigned long flags;
976 int status = 0; 977 int status = 0;
@@ -983,8 +984,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
983 * through, otherwise it is scheduled, and with high data rates (like 984 * through, otherwise it is scheduled, and with high data rates (like
984 * with OHCI) data can get lost. 985 * with OHCI) data can get lost.
985 */ 986 */
986 if (port->tty) 987 if (tty)
987 port->tty->low_latency = 1; 988 tty->low_latency = 1;
988 989
989 spin_lock_irqsave(&garmin_data_p->lock, flags); 990 spin_lock_irqsave(&garmin_data_p->lock, flags);
990 garmin_data_p->mode = initial_mode; 991 garmin_data_p->mode = initial_mode;
@@ -998,17 +999,16 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
998 usb_kill_urb (port->write_urb); 999 usb_kill_urb (port->write_urb);
999 usb_kill_urb (port->read_urb); 1000 usb_kill_urb (port->read_urb);
1000 1001
1001 if (garmin_data_p->state == STATE_RESET) { 1002 if (garmin_data_p->state == STATE_RESET)
1002 status = garmin_init_session(port); 1003 status = garmin_init_session(port);
1003 }
1004 1004
1005 garmin_data_p->state = STATE_ACTIVE; 1005 garmin_data_p->state = STATE_ACTIVE;
1006
1007 return status; 1006 return status;
1008} 1007}
1009 1008
1010 1009
1011static void garmin_close (struct usb_serial_port *port, struct file * filp) 1010static void garmin_close(struct tty_struct *tty,
1011 struct usb_serial_port *port, struct file * filp)
1012{ 1012{
1013 struct usb_serial *serial = port->serial; 1013 struct usb_serial *serial = port->serial;
1014 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1014 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
@@ -1042,7 +1042,6 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
1042 mutex_unlock(&port->serial->disc_mutex); 1042 mutex_unlock(&port->serial->disc_mutex);
1043} 1043}
1044 1044
1045
1046static void garmin_write_bulk_callback (struct urb *urb) 1045static void garmin_write_bulk_callback (struct urb *urb)
1047{ 1046{
1048 unsigned long flags; 1047 unsigned long flags;
@@ -1145,10 +1144,8 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1145 return count; 1144 return count;
1146} 1145}
1147 1146
1148 1147static int garmin_write (struct tty_struct *tty, struct usb_serial_port *port,
1149 1148 const unsigned char *buf, int count)
1150static int garmin_write (struct usb_serial_port *port,
1151 const unsigned char *buf, int count)
1152{ 1149{
1153 int pktid, pktsiz, len; 1150 int pktid, pktsiz, len;
1154 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1151 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
@@ -1158,7 +1155,6 @@ static int garmin_write (struct usb_serial_port *port,
1158 1155
1159 /* check for our private packets */ 1156 /* check for our private packets */
1160 if (count >= GARMIN_PKTHDR_LENGTH) { 1157 if (count >= GARMIN_PKTHDR_LENGTH) {
1161
1162 len = PRIVPKTSIZ; 1158 len = PRIVPKTSIZ;
1163 if (count < len) 1159 if (count < len)
1164 len = count; 1160 len = count;
@@ -1226,8 +1222,9 @@ static int garmin_write (struct usb_serial_port *port,
1226} 1222}
1227 1223
1228 1224
1229static int garmin_write_room (struct usb_serial_port *port) 1225static int garmin_write_room(struct tty_struct *tty)
1230{ 1226{
1227 struct usb_serial_port *port = tty->driver_data;
1231 /* 1228 /*
1232 * Report back the bytes currently available in the output buffer. 1229 * Report back the bytes currently available in the output buffer.
1233 */ 1230 */
@@ -1236,20 +1233,6 @@ static int garmin_write_room (struct usb_serial_port *port)
1236} 1233}
1237 1234
1238 1235
1239static int garmin_chars_in_buffer (struct usb_serial_port *port)
1240{
1241 /*
1242 * Report back the number of bytes currently in our input buffer.
1243 * Will this lock up the driver - the buffer contains an incomplete
1244 * package which will not be written to the device until it
1245 * has been completed ?
1246 */
1247 //struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1248 //return garmin_data_p->insize;
1249 return 0;
1250}
1251
1252
1253static void garmin_read_process(struct garmin_data * garmin_data_p, 1236static void garmin_read_process(struct garmin_data * garmin_data_p,
1254 unsigned char *data, unsigned data_length) 1237 unsigned char *data, unsigned data_length)
1255{ 1238{
@@ -1468,10 +1451,11 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)
1468} 1451}
1469 1452
1470 1453
1471static void garmin_throttle (struct usb_serial_port *port) 1454static void garmin_throttle(struct tty_struct *tty)
1472{ 1455{
1473 unsigned long flags; 1456 struct usb_serial_port *port = tty->driver_data;
1474 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1457 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1458 unsigned long flags;
1475 1459
1476 dbg("%s - port %d", __func__, port->number); 1460 dbg("%s - port %d", __func__, port->number);
1477 /* set flag, data received will be put into a queue 1461 /* set flag, data received will be put into a queue
@@ -1482,10 +1466,11 @@ static void garmin_throttle (struct usb_serial_port *port)
1482} 1466}
1483 1467
1484 1468
1485static void garmin_unthrottle (struct usb_serial_port *port) 1469static void garmin_unthrottle (struct tty_struct *tty)
1486{ 1470{
1487 unsigned long flags; 1471 struct usb_serial_port *port = tty->driver_data;
1488 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1472 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1473 unsigned long flags;
1489 int status; 1474 int status;
1490 1475
1491 dbg("%s - port %d", __func__, port->number); 1476 dbg("%s - port %d", __func__, port->number);
@@ -1507,8 +1492,6 @@ static void garmin_unthrottle (struct usb_serial_port *port)
1507 } 1492 }
1508} 1493}
1509 1494
1510
1511
1512/* 1495/*
1513 * The timer is currently only used to send queued packets to 1496 * The timer is currently only used to send queued packets to
1514 * the tty in cases where the protocol provides no own handshaking 1497 * the tty in cases where the protocol provides no own handshaking
@@ -1526,7 +1509,7 @@ static void timeout_handler(unsigned long data)
1526 1509
1527 1510
1528 1511
1529static int garmin_attach (struct usb_serial *serial) 1512static int garmin_attach(struct usb_serial *serial)
1530{ 1513{
1531 int status = 0; 1514 int status = 0;
1532 struct usb_serial_port *port = serial->port[0]; 1515 struct usb_serial_port *port = serial->port[0];
@@ -1556,7 +1539,7 @@ static int garmin_attach (struct usb_serial *serial)
1556} 1539}
1557 1540
1558 1541
1559static void garmin_shutdown (struct usb_serial *serial) 1542static void garmin_shutdown(struct usb_serial *serial)
1560{ 1543{
1561 struct usb_serial_port *port = serial->port[0]; 1544 struct usb_serial_port *port = serial->port[0];
1562 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1545 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
@@ -1588,7 +1571,6 @@ static struct usb_serial_driver garmin_device = {
1588 .shutdown = garmin_shutdown, 1571 .shutdown = garmin_shutdown,
1589 .write = garmin_write, 1572 .write = garmin_write,
1590 .write_room = garmin_write_room, 1573 .write_room = garmin_write_room,
1591 .chars_in_buffer = garmin_chars_in_buffer,
1592 .write_bulk_callback = garmin_write_bulk_callback, 1574 .write_bulk_callback = garmin_write_bulk_callback,
1593 .read_bulk_callback = garmin_read_bulk_callback, 1575 .read_bulk_callback = garmin_read_bulk_callback,
1594 .read_int_callback = garmin_read_int_callback, 1576 .read_int_callback = garmin_read_int_callback,
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 537f12a027c2..5128018c2766 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -112,7 +112,8 @@ void usb_serial_generic_deregister (void)
112#endif 112#endif
113} 113}
114 114
115int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) 115int usb_serial_generic_open(struct tty_struct *tty,
116 struct usb_serial_port *port, struct file *filp)
116{ 117{
117 struct usb_serial *serial = port->serial; 118 struct usb_serial *serial = port->serial;
118 int result = 0; 119 int result = 0;
@@ -123,8 +124,8 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
123 /* force low_latency on so that our tty_push actually forces the data through, 124 /* force low_latency on so that our tty_push actually forces the data through,
124 otherwise it is scheduled, and with high data rates (like with OHCI) data 125 otherwise it is scheduled, and with high data rates (like with OHCI) data
125 can get lost. */ 126 can get lost. */
126 if (port->tty) 127 if (tty)
127 port->tty->low_latency = 1; 128 tty->low_latency = 1;
128 129
129 /* clear the throttle flags */ 130 /* clear the throttle flags */
130 spin_lock_irqsave(&port->lock, flags); 131 spin_lock_irqsave(&port->lock, flags);
@@ -152,7 +153,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
152} 153}
153EXPORT_SYMBOL_GPL(usb_serial_generic_open); 154EXPORT_SYMBOL_GPL(usb_serial_generic_open);
154 155
155static void generic_cleanup (struct usb_serial_port *port) 156static void generic_cleanup(struct usb_serial_port *port)
156{ 157{
157 struct usb_serial *serial = port->serial; 158 struct usb_serial *serial = port->serial;
158 159
@@ -182,7 +183,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
182#endif 183#endif
183 for (i = 0; i < serial->num_ports; i++) { 184 for (i = 0; i < serial->num_ports; i++) {
184 port = serial->port[i]; 185 port = serial->port[i];
185 if (port->open_count && port->read_urb) { 186 if (port->port.count && port->read_urb) {
186 r = usb_submit_urb(port->read_urb, GFP_NOIO); 187 r = usb_submit_urb(port->read_urb, GFP_NOIO);
187 if (r < 0) 188 if (r < 0)
188 c++; 189 c++;
@@ -192,13 +193,15 @@ int usb_serial_generic_resume(struct usb_serial *serial)
192 return c ? -EIO : 0; 193 return c ? -EIO : 0;
193} 194}
194 195
195void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp) 196void usb_serial_generic_close(struct tty_struct *tty,
197 struct usb_serial_port *port, struct file * filp)
196{ 198{
197 dbg("%s - port %d", __func__, port->number); 199 dbg("%s - port %d", __func__, port->number);
198 generic_cleanup (port); 200 generic_cleanup (port);
199} 201}
200 202
201int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count) 203int usb_serial_generic_write(struct tty_struct *tty,
204 struct usb_serial_port *port, const unsigned char *buf, int count)
202{ 205{
203 struct usb_serial *serial = port->serial; 206 struct usb_serial *serial = port->serial;
204 int result; 207 int result;
@@ -255,8 +258,9 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
255 return 0; 258 return 0;
256} 259}
257 260
258int usb_serial_generic_write_room (struct usb_serial_port *port) 261int usb_serial_generic_write_room (struct tty_struct *tty)
259{ 262{
263 struct usb_serial_port *port = tty->driver_data;
260 struct usb_serial *serial = port->serial; 264 struct usb_serial *serial = port->serial;
261 int room = 0; 265 int room = 0;
262 266
@@ -272,8 +276,9 @@ int usb_serial_generic_write_room (struct usb_serial_port *port)
272 return room; 276 return room;
273} 277}
274 278
275int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) 279int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
276{ 280{
281 struct usb_serial_port *port = tty->driver_data;
277 struct usb_serial *serial = port->serial; 282 struct usb_serial *serial = port->serial;
278 int chars = 0; 283 int chars = 0;
279 284
@@ -286,7 +291,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
286 } 291 }
287 292
288 dbg("%s - returns %d", __func__, chars); 293 dbg("%s - returns %d", __func__, chars);
289 return (chars); 294 return chars;
290} 295}
291 296
292 297
@@ -311,10 +316,10 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
311} 316}
312 317
313/* Push data to tty layer and resubmit the bulk read URB */ 318/* Push data to tty layer and resubmit the bulk read URB */
314static void flush_and_resubmit_read_urb (struct usb_serial_port *port) 319static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
315{ 320{
316 struct urb *urb = port->read_urb; 321 struct urb *urb = port->read_urb;
317 struct tty_struct *tty = port->tty; 322 struct tty_struct *tty = port->port.tty;
318 int room; 323 int room;
319 324
320 /* Push data to tty */ 325 /* Push data to tty */
@@ -329,7 +334,7 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port)
329 resubmit_read_urb(port, GFP_ATOMIC); 334 resubmit_read_urb(port, GFP_ATOMIC);
330} 335}
331 336
332void usb_serial_generic_read_bulk_callback (struct urb *urb) 337void usb_serial_generic_read_bulk_callback(struct urb *urb)
333{ 338{
334 struct usb_serial_port *port = urb->context; 339 struct usb_serial_port *port = urb->context;
335 unsigned char *data = urb->transfer_buffer; 340 unsigned char *data = urb->transfer_buffer;
@@ -357,7 +362,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
357} 362}
358EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback); 363EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
359 364
360void usb_serial_generic_write_bulk_callback (struct urb *urb) 365void usb_serial_generic_write_bulk_callback(struct urb *urb)
361{ 366{
362 struct usb_serial_port *port = urb->context; 367 struct usb_serial_port *port = urb->context;
363 int status = urb->status; 368 int status = urb->status;
@@ -374,8 +379,9 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb)
374} 379}
375EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); 380EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
376 381
377void usb_serial_generic_throttle (struct usb_serial_port *port) 382void usb_serial_generic_throttle(struct tty_struct *tty)
378{ 383{
384 struct usb_serial_port *port = tty->driver_data;
379 unsigned long flags; 385 unsigned long flags;
380 386
381 dbg("%s - port %d", __func__, port->number); 387 dbg("%s - port %d", __func__, port->number);
@@ -387,8 +393,9 @@ void usb_serial_generic_throttle (struct usb_serial_port *port)
387 spin_unlock_irqrestore(&port->lock, flags); 393 spin_unlock_irqrestore(&port->lock, flags);
388} 394}
389 395
390void usb_serial_generic_unthrottle (struct usb_serial_port *port) 396void usb_serial_generic_unthrottle(struct tty_struct *tty)
391{ 397{
398 struct usb_serial_port *port = tty->driver_data;
392 int was_throttled; 399 int was_throttled;
393 unsigned long flags; 400 unsigned long flags;
394 401
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 2fd449bcfa35..29346d79df7b 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -206,18 +206,18 @@ static void edge_bulk_out_data_callback (struct urb *urb);
206static void edge_bulk_out_cmd_callback (struct urb *urb); 206static void edge_bulk_out_cmd_callback (struct urb *urb);
207 207
208/* function prototypes for the usbserial callbacks */ 208/* function prototypes for the usbserial callbacks */
209static int edge_open (struct usb_serial_port *port, struct file *filp); 209static int edge_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
210static void edge_close (struct usb_serial_port *port, struct file *filp); 210static void edge_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
211static int edge_write (struct usb_serial_port *port, const unsigned char *buf, int count); 211static int edge_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
212static int edge_write_room (struct usb_serial_port *port); 212static int edge_write_room (struct tty_struct *tty);
213static int edge_chars_in_buffer (struct usb_serial_port *port); 213static int edge_chars_in_buffer (struct tty_struct *tty);
214static void edge_throttle (struct usb_serial_port *port); 214static void edge_throttle (struct tty_struct *tty);
215static void edge_unthrottle (struct usb_serial_port *port); 215static void edge_unthrottle (struct tty_struct *tty);
216static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); 216static void edge_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
217static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg); 217static int edge_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
218static void edge_break (struct usb_serial_port *port, int break_state); 218static void edge_break (struct tty_struct *tty, int break_state);
219static int edge_tiocmget (struct usb_serial_port *port, struct file *file); 219static int edge_tiocmget (struct tty_struct *tty, struct file *file);
220static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 220static int edge_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
221static int edge_startup (struct usb_serial *serial); 221static int edge_startup (struct usb_serial *serial);
222static void edge_shutdown (struct usb_serial *serial); 222static void edge_shutdown (struct usb_serial *serial);
223 223
@@ -233,7 +233,8 @@ static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8
233static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param); 233static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param);
234static int calc_baud_rate_divisor (int baud_rate, int *divisor); 234static int calc_baud_rate_divisor (int baud_rate, int *divisor);
235static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate); 235static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate);
236static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios); 236static void change_port_settings (struct tty_struct *tty, struct edgeport_port *edge_port,
237 struct ktermios *old_termios);
237static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue); 238static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue);
238static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength); 239static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength);
239static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port); 240static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port);
@@ -639,8 +640,8 @@ static void edge_interrupt_callback (struct urb *urb)
639 dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits); 640 dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits);
640 641
641 /* tell the tty driver that something has changed */ 642 /* tell the tty driver that something has changed */
642 if (edge_port->port->tty) 643 if (edge_port->port->port.tty)
643 tty_wakeup(edge_port->port->tty); 644 tty_wakeup(edge_port->port->port.tty);
644 645
645 // Since we have more credit, check if more data can be sent 646 // Since we have more credit, check if more data can be sent
646 send_more_port_data(edge_serial, edge_port); 647 send_more_port_data(edge_serial, edge_port);
@@ -737,7 +738,7 @@ static void edge_bulk_out_data_callback (struct urb *urb)
737 __func__, status); 738 __func__, status);
738 } 739 }
739 740
740 tty = edge_port->port->tty; 741 tty = edge_port->port->port.tty;
741 742
742 if (tty && edge_port->open) { 743 if (tty && edge_port->open) {
743 /* let the tty driver wakeup if it has a special write_wakeup function */ 744 /* let the tty driver wakeup if it has a special write_wakeup function */
@@ -781,7 +782,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
781 } 782 }
782 783
783 /* Get pointer to tty */ 784 /* Get pointer to tty */
784 tty = edge_port->port->tty; 785 tty = edge_port->port->port.tty;
785 786
786 /* tell the tty driver that something has changed */ 787 /* tell the tty driver that something has changed */
787 if (tty && edge_port->open) 788 if (tty && edge_port->open)
@@ -803,7 +804,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
803 * If successful, we return 0 804 * If successful, we return 0
804 * Otherwise we return a negative error number. 805 * Otherwise we return a negative error number.
805 *****************************************************************************/ 806 *****************************************************************************/
806static int edge_open (struct usb_serial_port *port, struct file * filp) 807static int edge_open(struct tty_struct *tty,
808 struct usb_serial_port *port, struct file * filp)
807{ 809{
808 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 810 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
809 struct usb_serial *serial; 811 struct usb_serial *serial;
@@ -815,16 +817,15 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
815 if (edge_port == NULL) 817 if (edge_port == NULL)
816 return -ENODEV; 818 return -ENODEV;
817 819
818 if (port->tty) 820 if (tty)
819 port->tty->low_latency = low_latency; 821 tty->low_latency = low_latency;
820 822
821 /* see if we've set up our endpoint info yet (can't set it up in edge_startup 823 /* see if we've set up our endpoint info yet (can't set it up in edge_startup
822 as the structures were not set up at that time.) */ 824 as the structures were not set up at that time.) */
823 serial = port->serial; 825 serial = port->serial;
824 edge_serial = usb_get_serial_data(serial); 826 edge_serial = usb_get_serial_data(serial);
825 if (edge_serial == NULL) { 827 if (edge_serial == NULL)
826 return -ENODEV; 828 return -ENODEV;
827 }
828 if (edge_serial->interrupt_in_buffer == NULL) { 829 if (edge_serial->interrupt_in_buffer == NULL) {
829 struct usb_serial_port *port0 = serial->port[0]; 830 struct usb_serial_port *port0 = serial->port[0];
830 831
@@ -908,7 +909,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
908 909
909 if (!edge_port->txfifo.fifo) { 910 if (!edge_port->txfifo.fifo) {
910 dbg("%s - no memory", __func__); 911 dbg("%s - no memory", __func__);
911 edge_close (port, filp); 912 edge_close (tty, port, filp);
912 return -ENOMEM; 913 return -ENOMEM;
913 } 914 }
914 915
@@ -918,7 +919,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
918 919
919 if (!edge_port->write_urb) { 920 if (!edge_port->write_urb) {
920 dbg("%s - no memory", __func__); 921 dbg("%s - no memory", __func__);
921 edge_close (port, filp); 922 edge_close (tty, port, filp);
922 return -ENOMEM; 923 return -ENOMEM;
923 } 924 }
924 925
@@ -1038,7 +1039,8 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
1038 * edge_close 1039 * edge_close
1039 * this function is called by the tty driver when a port is closed 1040 * this function is called by the tty driver when a port is closed
1040 *****************************************************************************/ 1041 *****************************************************************************/
1041static void edge_close (struct usb_serial_port *port, struct file * filp) 1042static void edge_close(struct tty_struct *tty,
1043 struct usb_serial_port *port, struct file * filp)
1042{ 1044{
1043 struct edgeport_serial *edge_serial; 1045 struct edgeport_serial *edge_serial;
1044 struct edgeport_port *edge_port; 1046 struct edgeport_port *edge_port;
@@ -1106,7 +1108,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1106 * If successful, we return the number of bytes written, otherwise we return 1108 * If successful, we return the number of bytes written, otherwise we return
1107 * a negative error number. 1109 * a negative error number.
1108 *****************************************************************************/ 1110 *****************************************************************************/
1109static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) 1111static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1112 const unsigned char *data, int count)
1110{ 1113{
1111 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1114 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1112 struct TxFifo *fifo; 1115 struct TxFifo *fifo;
@@ -1308,8 +1311,9 @@ exit_send:
1308 * (the txCredits), 1311 * (the txCredits),
1309 * Otherwise we return a negative error number. 1312 * Otherwise we return a negative error number.
1310 *****************************************************************************/ 1313 *****************************************************************************/
1311static int edge_write_room (struct usb_serial_port *port) 1314static int edge_write_room(struct tty_struct *tty)
1312{ 1315{
1316 struct usb_serial_port *port = tty->driver_data;
1313 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1317 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1314 int room; 1318 int room;
1315 unsigned long flags; 1319 unsigned long flags;
@@ -1347,8 +1351,9 @@ static int edge_write_room (struct usb_serial_port *port)
1347 * system, 1351 * system,
1348 * Otherwise we return a negative error number. 1352 * Otherwise we return a negative error number.
1349 *****************************************************************************/ 1353 *****************************************************************************/
1350static int edge_chars_in_buffer (struct usb_serial_port *port) 1354static int edge_chars_in_buffer(struct tty_struct *tty)
1351{ 1355{
1356 struct usb_serial_port *port = tty->driver_data;
1352 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1357 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1353 int num_chars; 1358 int num_chars;
1354 unsigned long flags; 1359 unsigned long flags;
@@ -1381,10 +1386,10 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
1381 * this function is called by the tty driver when it wants to stop the data 1386 * this function is called by the tty driver when it wants to stop the data
1382 * being read from the port. 1387 * being read from the port.
1383 *****************************************************************************/ 1388 *****************************************************************************/
1384static void edge_throttle (struct usb_serial_port *port) 1389static void edge_throttle(struct tty_struct *tty)
1385{ 1390{
1391 struct usb_serial_port *port = tty->driver_data;
1386 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1392 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1387 struct tty_struct *tty;
1388 int status; 1393 int status;
1389 1394
1390 dbg("%s - port %d", __func__, port->number); 1395 dbg("%s - port %d", __func__, port->number);
@@ -1397,16 +1402,10 @@ static void edge_throttle (struct usb_serial_port *port)
1397 return; 1402 return;
1398 } 1403 }
1399 1404
1400 tty = port->tty;
1401 if (!tty) {
1402 dbg ("%s - no tty available", __func__);
1403 return;
1404 }
1405
1406 /* if we are implementing XON/XOFF, send the stop character */ 1405 /* if we are implementing XON/XOFF, send the stop character */
1407 if (I_IXOFF(tty)) { 1406 if (I_IXOFF(tty)) {
1408 unsigned char stop_char = STOP_CHAR(tty); 1407 unsigned char stop_char = STOP_CHAR(tty);
1409 status = edge_write (port, &stop_char, 1); 1408 status = edge_write (tty, port, &stop_char, 1);
1410 if (status <= 0) { 1409 if (status <= 0) {
1411 return; 1410 return;
1412 } 1411 }
@@ -1430,10 +1429,10 @@ static void edge_throttle (struct usb_serial_port *port)
1430 * this function is called by the tty driver when it wants to resume the data 1429 * this function is called by the tty driver when it wants to resume the data
1431 * being read from the port (called after SerialThrottle is called) 1430 * being read from the port (called after SerialThrottle is called)
1432 *****************************************************************************/ 1431 *****************************************************************************/
1433static void edge_unthrottle (struct usb_serial_port *port) 1432static void edge_unthrottle(struct tty_struct *tty)
1434{ 1433{
1434 struct usb_serial_port *port = tty->driver_data;
1435 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1435 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1436 struct tty_struct *tty;
1437 int status; 1436 int status;
1438 1437
1439 dbg("%s - port %d", __func__, port->number); 1438 dbg("%s - port %d", __func__, port->number);
@@ -1446,31 +1445,18 @@ static void edge_unthrottle (struct usb_serial_port *port)
1446 return; 1445 return;
1447 } 1446 }
1448 1447
1449 tty = port->tty;
1450 if (!tty) {
1451 dbg ("%s - no tty available", __func__);
1452 return;
1453 }
1454
1455 /* if we are implementing XON/XOFF, send the start character */ 1448 /* if we are implementing XON/XOFF, send the start character */
1456 if (I_IXOFF(tty)) { 1449 if (I_IXOFF(tty)) {
1457 unsigned char start_char = START_CHAR(tty); 1450 unsigned char start_char = START_CHAR(tty);
1458 status = edge_write (port, &start_char, 1); 1451 status = edge_write(tty, port, &start_char, 1);
1459 if (status <= 0) { 1452 if (status <= 0)
1460 return; 1453 return;
1461 }
1462 } 1454 }
1463
1464 /* if we are implementing RTS/CTS, toggle that line */ 1455 /* if we are implementing RTS/CTS, toggle that line */
1465 if (tty->termios->c_cflag & CRTSCTS) { 1456 if (tty->termios->c_cflag & CRTSCTS) {
1466 edge_port->shadowMCR |= MCR_RTS; 1457 edge_port->shadowMCR |= MCR_RTS;
1467 status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); 1458 send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
1468 if (status != 0) {
1469 return;
1470 }
1471 } 1459 }
1472
1473 return;
1474} 1460}
1475 1461
1476 1462
@@ -1478,11 +1464,10 @@ static void edge_unthrottle (struct usb_serial_port *port)
1478 * SerialSetTermios 1464 * SerialSetTermios
1479 * this function is called by the tty driver when it wants to change the termios structure 1465 * this function is called by the tty driver when it wants to change the termios structure
1480 *****************************************************************************/ 1466 *****************************************************************************/
1481static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) 1467static void edge_set_termios(struct tty_struct *tty,
1468 struct usb_serial_port *port, struct ktermios *old_termios)
1482{ 1469{
1483 /* FIXME: This function appears unused ?? */
1484 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1470 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1485 struct tty_struct *tty = port->tty;
1486 unsigned int cflag; 1471 unsigned int cflag;
1487 1472
1488 cflag = tty->termios->c_cflag; 1473 cflag = tty->termios->c_cflag;
@@ -1502,9 +1487,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
1502 } 1487 }
1503 1488
1504 /* change the port settings to the new ones specified */ 1489 /* change the port settings to the new ones specified */
1505 change_port_settings (edge_port, old_termios); 1490 change_port_settings(tty, edge_port, old_termios);
1506
1507 return;
1508} 1491}
1509 1492
1510 1493
@@ -1536,25 +1519,9 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va
1536 return 0; 1519 return 0;
1537} 1520}
1538 1521
1539static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int __user *value) 1522static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
1540{
1541 unsigned int result = 0;
1542 struct tty_struct *tty = edge_port->port->tty;
1543
1544 if (!tty)
1545 return -ENOIOCTLCMD;
1546
1547 result = tty->read_cnt;
1548
1549 dbg("%s(%d) = %d", __func__, edge_port->port->number, result);
1550 if (copy_to_user(value, &result, sizeof(int)))
1551 return -EFAULT;
1552 //return 0;
1553 return -ENOIOCTLCMD;
1554}
1555
1556static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
1557{ 1523{
1524 struct usb_serial_port *port = tty->driver_data;
1558 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1525 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1559 unsigned int mcr; 1526 unsigned int mcr;
1560 1527
@@ -1582,8 +1549,9 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
1582 return 0; 1549 return 0;
1583} 1550}
1584 1551
1585static int edge_tiocmget(struct usb_serial_port *port, struct file *file) 1552static int edge_tiocmget(struct tty_struct *tty, struct file *file)
1586{ 1553{
1554 struct usb_serial_port *port = tty->driver_data;
1587 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1555 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1588 unsigned int result = 0; 1556 unsigned int result = 0;
1589 unsigned int msr; 1557 unsigned int msr;
@@ -1624,9 +1592,6 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
1624 tmp.baud_base = 9600; 1592 tmp.baud_base = 9600;
1625 tmp.close_delay = 5*HZ; 1593 tmp.close_delay = 5*HZ;
1626 tmp.closing_wait = 30*HZ; 1594 tmp.closing_wait = 30*HZ;
1627// tmp.custom_divisor = state->custom_divisor;
1628// tmp.hub6 = state->hub6;
1629// tmp.io_type = state->io_type;
1630 1595
1631 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1596 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1632 return -EFAULT; 1597 return -EFAULT;
@@ -1639,8 +1604,10 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
1639 * SerialIoctl 1604 * SerialIoctl
1640 * this function handles any ioctl calls to the driver 1605 * this function handles any ioctl calls to the driver
1641 *****************************************************************************/ 1606 *****************************************************************************/
1642static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) 1607static int edge_ioctl(struct tty_struct *tty, struct file *file,
1608 unsigned int cmd, unsigned long arg)
1643{ 1609{
1610 struct usb_serial_port *port = tty->driver_data;
1644 DEFINE_WAIT(wait); 1611 DEFINE_WAIT(wait);
1645 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1612 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1646 struct async_icount cnow; 1613 struct async_icount cnow;
@@ -1650,25 +1617,14 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
1650 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1617 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
1651 1618
1652 switch (cmd) { 1619 switch (cmd) {
1653 // return number of bytes available
1654 case TIOCINQ:
1655 dbg("%s (%d) TIOCINQ", __func__, port->number);
1656 return get_number_bytes_avail(edge_port, (unsigned int __user *) arg);
1657 break;
1658
1659 case TIOCSERGETLSR: 1620 case TIOCSERGETLSR:
1660 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1621 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1661 return get_lsr_info(edge_port, (unsigned int __user *) arg); 1622 return get_lsr_info(edge_port, (unsigned int __user *) arg);
1662 return 0;
1663 1623
1664 case TIOCGSERIAL: 1624 case TIOCGSERIAL:
1665 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 1625 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
1666 return get_serial_info(edge_port, (struct serial_struct __user *) arg); 1626 return get_serial_info(edge_port, (struct serial_struct __user *) arg);
1667 1627
1668 case TIOCSSERIAL:
1669 dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
1670 break;
1671
1672 case TIOCMIWAIT: 1628 case TIOCMIWAIT:
1673 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 1629 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
1674 cprev = edge_port->icount; 1630 cprev = edge_port->icount;
@@ -1723,8 +1679,9 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
1723 * SerialBreak 1679 * SerialBreak
1724 * this function sends a break to the port 1680 * this function sends a break to the port
1725 *****************************************************************************/ 1681 *****************************************************************************/
1726static void edge_break (struct usb_serial_port *port, int break_state) 1682static void edge_break (struct tty_struct *tty, int break_state)
1727{ 1683{
1684 struct usb_serial_port *port = tty->driver_data;
1728 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1685 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1729 struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial); 1686 struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
1730 int status; 1687 int status;
@@ -1866,7 +1823,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
1866 port = edge_serial->serial->port[edge_serial->rxPort]; 1823 port = edge_serial->serial->port[edge_serial->rxPort];
1867 edge_port = usb_get_serial_port_data(port); 1824 edge_port = usb_get_serial_port_data(port);
1868 if (edge_port->open) { 1825 if (edge_port->open) {
1869 tty = edge_port->port->tty; 1826 tty = edge_port->port->port.tty;
1870 if (tty) { 1827 if (tty) {
1871 dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort); 1828 dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort);
1872 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); 1829 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
@@ -1941,8 +1898,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1941 handle_new_msr (edge_port, byte2); 1898 handle_new_msr (edge_port, byte2);
1942 1899
1943 /* send the current line settings to the port so we are in sync with any further termios calls */ 1900 /* send the current line settings to the port so we are in sync with any further termios calls */
1944 if (edge_port->port->tty) 1901 /* FIXME: locking on tty */
1945 change_port_settings (edge_port, edge_port->port->tty->termios); 1902 if (edge_port->port->port.tty)
1903 change_port_settings(edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios);
1946 1904
1947 /* we have completed the open */ 1905 /* we have completed the open */
1948 edge_port->openPending = false; 1906 edge_port->openPending = false;
@@ -2078,8 +2036,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l
2078 } 2036 }
2079 2037
2080 /* Place LSR data byte into Rx buffer */ 2038 /* Place LSR data byte into Rx buffer */
2081 if (lsrData && edge_port->port->tty) 2039 if (lsrData && edge_port->port->port.tty)
2082 edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1); 2040 edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
2083 2041
2084 /* update input line counters */ 2042 /* update input line counters */
2085 icount = &edge_port->icount; 2043 icount = &edge_port->icount;
@@ -2473,13 +2431,11 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
2473 * This routine is called to set the UART on the device to match the specified 2431 * This routine is called to set the UART on the device to match the specified
2474 * new settings. 2432 * new settings.
2475 *****************************************************************************/ 2433 *****************************************************************************/
2476#ifndef CMSPAR 2434
2477#define CMSPAR 0 2435static void change_port_settings(struct tty_struct *tty,
2478#endif 2436 struct edgeport_port *edge_port, struct ktermios *old_termios)
2479static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios)
2480{ 2437{
2481 struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); 2438 struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
2482 struct tty_struct *tty;
2483 int baud; 2439 int baud;
2484 unsigned cflag; 2440 unsigned cflag;
2485 __u8 mask = 0xff; 2441 __u8 mask = 0xff;
@@ -2498,13 +2454,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2498 return; 2454 return;
2499 } 2455 }
2500 2456
2501 tty = edge_port->port->tty;
2502 if ((!tty) ||
2503 (!tty->termios)) {
2504 dbg("%s - no tty structures", __func__);
2505 return;
2506 }
2507
2508 cflag = tty->termios->c_cflag; 2457 cflag = tty->termios->c_cflag;
2509 2458
2510 switch (cflag & CSIZE) { 2459 switch (cflag & CSIZE) {
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index a58822a14a87..7cf383a2a556 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -243,9 +243,9 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
243static void stop_read(struct edgeport_port *edge_port); 243static void stop_read(struct edgeport_port *edge_port);
244static int restart_read(struct edgeport_port *edge_port); 244static int restart_read(struct edgeport_port *edge_port);
245 245
246static void edge_set_termios(struct usb_serial_port *port, 246static void edge_set_termios(struct tty_struct *tty,
247 struct ktermios *old_termios); 247 struct usb_serial_port *port, struct ktermios *old_termios);
248static void edge_send(struct usb_serial_port *port); 248static void edge_send(struct tty_struct *tty);
249 249
250/* sysfs attributes */ 250/* sysfs attributes */
251static int edge_create_sysfs_attrs(struct usb_serial_port *port); 251static int edge_create_sysfs_attrs(struct usb_serial_port *port);
@@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
572 int flush) 572 int flush)
573{ 573{
574 int baud_rate; 574 int baud_rate;
575 struct tty_struct *tty = port->port->tty; 575 struct tty_struct *tty = port->port->port.tty;
576 wait_queue_t wait; 576 wait_queue_t wait;
577 unsigned long flags; 577 unsigned long flags;
578 578
@@ -1554,7 +1554,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1554 /* Save the new modem status */ 1554 /* Save the new modem status */
1555 edge_port->shadow_msr = msr & 0xf0; 1555 edge_port->shadow_msr = msr & 0xf0;
1556 1556
1557 tty = edge_port->port->tty; 1557 tty = edge_port->port->port.tty;
1558 /* handle CTS flow control */ 1558 /* handle CTS flow control */
1559 if (tty && C_CRTSCTS(tty)) { 1559 if (tty && C_CRTSCTS(tty)) {
1560 if (msr & EDGEPORT_MSR_CTS) { 1560 if (msr & EDGEPORT_MSR_CTS) {
@@ -1587,9 +1587,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1587 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); 1587 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
1588 1588
1589 /* Place LSR data byte into Rx buffer */ 1589 /* Place LSR data byte into Rx buffer */
1590 if (lsr_data && edge_port->port->tty) 1590 if (lsr_data && edge_port->port->port.tty)
1591 edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, 1591 edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
1592 &data, 1);
1593 1592
1594 /* update input line counters */ 1593 /* update input line counters */
1595 icount = &edge_port->icount; 1594 icount = &edge_port->icount;
@@ -1750,7 +1749,7 @@ static void edge_bulk_in_callback(struct urb *urb)
1750 ++data; 1749 ++data;
1751 } 1750 }
1752 1751
1753 tty = edge_port->port->tty; 1752 tty = edge_port->port->port.tty;
1754 if (tty && urb->actual_length) { 1753 if (tty && urb->actual_length) {
1755 usb_serial_debug_data(debug, &edge_port->port->dev, 1754 usb_serial_debug_data(debug, &edge_port->port->dev,
1756 __func__, urb->actual_length, data); 1755 __func__, urb->actual_length, data);
@@ -1819,10 +1818,11 @@ static void edge_bulk_out_callback(struct urb *urb)
1819 } 1818 }
1820 1819
1821 /* send any buffered data */ 1820 /* send any buffered data */
1822 edge_send(port); 1821 edge_send(port->port.tty);
1823} 1822}
1824 1823
1825static int edge_open(struct usb_serial_port *port, struct file *filp) 1824static int edge_open(struct tty_struct *tty,
1825 struct usb_serial_port *port, struct file *filp)
1826{ 1826{
1827 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1827 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1828 struct edgeport_serial *edge_serial; 1828 struct edgeport_serial *edge_serial;
@@ -1838,7 +1838,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
1838 if (edge_port == NULL) 1838 if (edge_port == NULL)
1839 return -ENODEV; 1839 return -ENODEV;
1840 1840
1841 port->tty->low_latency = low_latency; 1841 if (tty)
1842 tty->low_latency = low_latency;
1842 1843
1843 port_number = port->number - port->serial->minor; 1844 port_number = port->number - port->serial->minor;
1844 switch (port_number) { 1845 switch (port_number) {
@@ -1874,7 +1875,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
1874 } 1875 }
1875 1876
1876 /* set up the port settings */ 1877 /* set up the port settings */
1877 edge_set_termios(port, port->tty->termios); 1878 if (tty)
1879 edge_set_termios(tty, port, port->port.tty->termios);
1878 1880
1879 /* open up the port */ 1881 /* open up the port */
1880 1882
@@ -2000,7 +2002,8 @@ release_es_lock:
2000 return status; 2002 return status;
2001} 2003}
2002 2004
2003static void edge_close(struct usb_serial_port *port, struct file *filp) 2005static void edge_close(struct tty_struct *tty,
2006 struct usb_serial_port *port, struct file *filp)
2004{ 2007{
2005 struct edgeport_serial *edge_serial; 2008 struct edgeport_serial *edge_serial;
2006 struct edgeport_port *edge_port; 2009 struct edgeport_port *edge_port;
@@ -2048,8 +2051,8 @@ static void edge_close(struct usb_serial_port *port, struct file *filp)
2048 dbg("%s - exited", __func__); 2051 dbg("%s - exited", __func__);
2049} 2052}
2050 2053
2051static int edge_write(struct usb_serial_port *port, const unsigned char *data, 2054static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
2052 int count) 2055 const unsigned char *data, int count)
2053{ 2056{
2054 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2057 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2055 unsigned long flags; 2058 unsigned long flags;
@@ -2070,16 +2073,16 @@ static int edge_write(struct usb_serial_port *port, const unsigned char *data,
2070 count = edge_buf_put(edge_port->ep_out_buf, data, count); 2073 count = edge_buf_put(edge_port->ep_out_buf, data, count);
2071 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2074 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2072 2075
2073 edge_send(port); 2076 edge_send(tty);
2074 2077
2075 return count; 2078 return count;
2076} 2079}
2077 2080
2078static void edge_send(struct usb_serial_port *port) 2081static void edge_send(struct tty_struct *tty)
2079{ 2082{
2083 struct usb_serial_port *port = tty->driver_data;
2080 int count, result; 2084 int count, result;
2081 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2085 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2082 struct tty_struct *tty = port->tty;
2083 unsigned long flags; 2086 unsigned long flags;
2084 2087
2085 2088
@@ -2133,8 +2136,9 @@ static void edge_send(struct usb_serial_port *port)
2133 tty_wakeup(tty); 2136 tty_wakeup(tty);
2134} 2137}
2135 2138
2136static int edge_write_room(struct usb_serial_port *port) 2139static int edge_write_room(struct tty_struct *tty)
2137{ 2140{
2141 struct usb_serial_port *port = tty->driver_data;
2138 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2142 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2139 int room = 0; 2143 int room = 0;
2140 unsigned long flags; 2144 unsigned long flags;
@@ -2154,8 +2158,9 @@ static int edge_write_room(struct usb_serial_port *port)
2154 return room; 2158 return room;
2155} 2159}
2156 2160
2157static int edge_chars_in_buffer(struct usb_serial_port *port) 2161static int edge_chars_in_buffer(struct tty_struct *tty)
2158{ 2162{
2163 struct usb_serial_port *port = tty->driver_data;
2159 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2164 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2160 int chars = 0; 2165 int chars = 0;
2161 unsigned long flags; 2166 unsigned long flags;
@@ -2175,10 +2180,10 @@ static int edge_chars_in_buffer(struct usb_serial_port *port)
2175 return chars; 2180 return chars;
2176} 2181}
2177 2182
2178static void edge_throttle(struct usb_serial_port *port) 2183static void edge_throttle(struct tty_struct *tty)
2179{ 2184{
2185 struct usb_serial_port *port = tty->driver_data;
2180 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2186 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2181 struct tty_struct *tty = port->tty;
2182 int status; 2187 int status;
2183 2188
2184 dbg("%s - port %d", __func__, port->number); 2189 dbg("%s - port %d", __func__, port->number);
@@ -2189,11 +2194,10 @@ static void edge_throttle(struct usb_serial_port *port)
2189 /* if we are implementing XON/XOFF, send the stop character */ 2194 /* if we are implementing XON/XOFF, send the stop character */
2190 if (I_IXOFF(tty)) { 2195 if (I_IXOFF(tty)) {
2191 unsigned char stop_char = STOP_CHAR(tty); 2196 unsigned char stop_char = STOP_CHAR(tty);
2192 status = edge_write(port, &stop_char, 1); 2197 status = edge_write(tty, port, &stop_char, 1);
2193 if (status <= 0) 2198 if (status <= 0) {
2194 dev_err(&port->dev, 2199 dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status);
2195 "%s - failed to write stop character, %d\n", 2200 }
2196 __func__, status);
2197 } 2201 }
2198 2202
2199 /* if we are implementing RTS/CTS, stop reads */ 2203 /* if we are implementing RTS/CTS, stop reads */
@@ -2203,10 +2207,10 @@ static void edge_throttle(struct usb_serial_port *port)
2203 2207
2204} 2208}
2205 2209
2206static void edge_unthrottle(struct usb_serial_port *port) 2210static void edge_unthrottle(struct tty_struct *tty)
2207{ 2211{
2212 struct usb_serial_port *port = tty->driver_data;
2208 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2213 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2209 struct tty_struct *tty = port->tty;
2210 int status; 2214 int status;
2211 2215
2212 dbg("%s - port %d", __func__, port->number); 2216 dbg("%s - port %d", __func__, port->number);
@@ -2217,11 +2221,10 @@ static void edge_unthrottle(struct usb_serial_port *port)
2217 /* if we are implementing XON/XOFF, send the start character */ 2221 /* if we are implementing XON/XOFF, send the start character */
2218 if (I_IXOFF(tty)) { 2222 if (I_IXOFF(tty)) {
2219 unsigned char start_char = START_CHAR(tty); 2223 unsigned char start_char = START_CHAR(tty);
2220 status = edge_write(port, &start_char, 1); 2224 status = edge_write(tty, port, &start_char, 1);
2221 if (status <= 0) 2225 if (status <= 0) {
2222 dev_err(&port->dev, 2226 dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
2223 "%s - failed to write start character, %d\n", 2227 }
2224 __func__, status);
2225 } 2228 }
2226 /* if we are implementing RTS/CTS, restart reads */ 2229 /* if we are implementing RTS/CTS, restart reads */
2227 /* are the Edgeport will assert the RTS line */ 2230 /* are the Edgeport will assert the RTS line */
@@ -2271,11 +2274,10 @@ static int restart_read(struct edgeport_port *edge_port)
2271 return status; 2274 return status;
2272} 2275}
2273 2276
2274static void change_port_settings(struct edgeport_port *edge_port, 2277static void change_port_settings(struct tty_struct *tty,
2275 struct ktermios *old_termios) 2278 struct edgeport_port *edge_port, struct ktermios *old_termios)
2276{ 2279{
2277 struct ump_uart_config *config; 2280 struct ump_uart_config *config;
2278 struct tty_struct *tty;
2279 int baud; 2281 int baud;
2280 unsigned cflag; 2282 unsigned cflag;
2281 int status; 2283 int status;
@@ -2284,9 +2286,7 @@ static void change_port_settings(struct edgeport_port *edge_port,
2284 2286
2285 dbg("%s - port %d", __func__, edge_port->port->number); 2287 dbg("%s - port %d", __func__, edge_port->port->number);
2286 2288
2287 tty = edge_port->port->tty; 2289 config = kmalloc (sizeof (*config), GFP_KERNEL);
2288
2289 config = kmalloc(sizeof(*config), GFP_KERNEL);
2290 if (!config) { 2290 if (!config) {
2291 *tty->termios = *old_termios; 2291 *tty->termios = *old_termios;
2292 dev_err(&edge_port->port->dev, "%s - out of memory\n", 2292 dev_err(&edge_port->port->dev, "%s - out of memory\n",
@@ -2419,11 +2419,13 @@ static void change_port_settings(struct edgeport_port *edge_port,
2419 return; 2419 return;
2420} 2420}
2421 2421
2422static void edge_set_termios(struct usb_serial_port *port, 2422static void edge_set_termios(struct tty_struct *tty,
2423 struct ktermios *old_termios) 2423 struct usb_serial_port *port, struct ktermios *old_termios)
2424{ 2424{
2425 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2425 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2426 struct tty_struct *tty = port->tty; 2426 unsigned int cflag;
2427
2428 cflag = tty->termios->c_cflag;
2427 2429
2428 dbg("%s - clfag %08x iflag %08x", __func__, 2430 dbg("%s - clfag %08x iflag %08x", __func__,
2429 tty->termios->c_cflag, tty->termios->c_iflag); 2431 tty->termios->c_cflag, tty->termios->c_iflag);
@@ -2434,12 +2436,14 @@ static void edge_set_termios(struct usb_serial_port *port,
2434 if (edge_port == NULL) 2436 if (edge_port == NULL)
2435 return; 2437 return;
2436 /* change the port settings to the new ones specified */ 2438 /* change the port settings to the new ones specified */
2437 change_port_settings(edge_port, old_termios); 2439 change_port_settings(tty, edge_port, old_termios);
2440 return;
2438} 2441}
2439 2442
2440static int edge_tiocmset(struct usb_serial_port *port, struct file *file, 2443static int edge_tiocmset(struct tty_struct *tty, struct file *file,
2441 unsigned int set, unsigned int clear) 2444 unsigned int set, unsigned int clear)
2442{ 2445{
2446 struct usb_serial_port *port = tty->driver_data;
2443 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2447 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2444 unsigned int mcr; 2448 unsigned int mcr;
2445 unsigned long flags; 2449 unsigned long flags;
@@ -2469,8 +2473,9 @@ static int edge_tiocmset(struct usb_serial_port *port, struct file *file,
2469 return 0; 2473 return 0;
2470} 2474}
2471 2475
2472static int edge_tiocmget(struct usb_serial_port *port, struct file *file) 2476static int edge_tiocmget(struct tty_struct *tty, struct file *file)
2473{ 2477{
2478 struct usb_serial_port *port = tty->driver_data;
2474 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2479 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2475 unsigned int result = 0; 2480 unsigned int result = 0;
2476 unsigned int msr; 2481 unsigned int msr;
@@ -2522,9 +2527,10 @@ static int get_serial_info(struct edgeport_port *edge_port,
2522 return 0; 2527 return 0;
2523} 2528}
2524 2529
2525static int edge_ioctl(struct usb_serial_port *port, struct file *file, 2530static int edge_ioctl(struct tty_struct *tty, struct file *file,
2526 unsigned int cmd, unsigned long arg) 2531 unsigned int cmd, unsigned long arg)
2527{ 2532{
2533 struct usb_serial_port *port = tty->driver_data;
2528 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2534 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2529 struct async_icount cnow; 2535 struct async_icount cnow;
2530 struct async_icount cprev; 2536 struct async_icount cprev;
@@ -2569,18 +2575,19 @@ static int edge_ioctl(struct usb_serial_port *port, struct file *file,
2569 return -ENOIOCTLCMD; 2575 return -ENOIOCTLCMD;
2570} 2576}
2571 2577
2572static void edge_break(struct usb_serial_port *port, int on) 2578static void edge_break(struct tty_struct *tty, int break_state)
2573{ 2579{
2580 struct usb_serial_port *port = tty->driver_data;
2574 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2581 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2575 int status; 2582 int status;
2576 int bv = 0; /* Off */ 2583 int bv = 0; /* Off */
2577 2584
2578 dbg("%s - state = %d", __func__, on); 2585 dbg("%s - state = %d", __func__, break_state);
2579 2586
2580 /* chase the port close */ 2587 /* chase the port close */
2581 chase_port(edge_port, 0, 0); 2588 chase_port(edge_port, 0, 0);
2582 2589
2583 if (on == -1) 2590 if (break_state == -1)
2584 bv = 1; /* On */ 2591 bv = 1; /* On */
2585 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); 2592 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
2586 if (status) 2593 if (status)
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 80d9ec5570d6..a7784642d6a1 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -74,19 +74,21 @@ static int connect_retries = KP_RETRIES;
74static int initial_wait; 74static int initial_wait;
75 75
76/* Function prototypes for an ipaq */ 76/* Function prototypes for an ipaq */
77static int ipaq_open (struct usb_serial_port *port, struct file *filp); 77static int ipaq_open(struct tty_struct *tty,
78static void ipaq_close (struct usb_serial_port *port, struct file *filp); 78 struct usb_serial_port *port, struct file *filp);
79static int ipaq_startup (struct usb_serial *serial); 79static void ipaq_close(struct tty_struct *tty,
80static void ipaq_shutdown (struct usb_serial *serial); 80 struct usb_serial_port *port, struct file *filp);
81static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, 81static int ipaq_startup(struct usb_serial *serial);
82 int count); 82static void ipaq_shutdown(struct usb_serial *serial);
83static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
84 const unsigned char *buf, int count);
83static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, 85static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
84 int count); 86 int count);
85static void ipaq_write_gather(struct usb_serial_port *port); 87static void ipaq_write_gather(struct usb_serial_port *port);
86static void ipaq_read_bulk_callback (struct urb *urb); 88static void ipaq_read_bulk_callback (struct urb *urb);
87static void ipaq_write_bulk_callback(struct urb *urb); 89static void ipaq_write_bulk_callback(struct urb *urb);
88static int ipaq_write_room(struct usb_serial_port *port); 90static int ipaq_write_room(struct tty_struct *tty);
89static int ipaq_chars_in_buffer(struct usb_serial_port *port); 91static int ipaq_chars_in_buffer(struct tty_struct *tty);
90static void ipaq_destroy_lists(struct usb_serial_port *port); 92static void ipaq_destroy_lists(struct usb_serial_port *port);
91 93
92 94
@@ -591,7 +593,8 @@ static spinlock_t write_list_lock;
591static int bytes_in; 593static int bytes_in;
592static int bytes_out; 594static int bytes_out;
593 595
594static int ipaq_open(struct usb_serial_port *port, struct file *filp) 596static int ipaq_open(struct tty_struct *tty,
597 struct usb_serial_port *port, struct file *filp)
595{ 598{
596 struct usb_serial *serial = port->serial; 599 struct usb_serial *serial = port->serial;
597 struct ipaq_private *priv; 600 struct ipaq_private *priv;
@@ -637,10 +640,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
637 * discipline instead of queueing. 640 * discipline instead of queueing.
638 */ 641 */
639 642
640 port->tty->low_latency = 1; 643 if (tty) {
641 port->tty->raw = 1; 644 tty->low_latency = 1;
642 port->tty->real_raw = 1; 645 /* FIXME: These two are bogus */
643 646 tty->raw = 1;
647 tty->real_raw = 1;
648 }
644 /* 649 /*
645 * Lose the small buffers usbserial provides. Make larger ones. 650 * Lose the small buffers usbserial provides. Make larger ones.
646 */ 651 */
@@ -714,7 +719,8 @@ error:
714} 719}
715 720
716 721
717static void ipaq_close(struct usb_serial_port *port, struct file *filp) 722static void ipaq_close(struct tty_struct *tty,
723 struct usb_serial_port *port, struct file *filp)
718{ 724{
719 struct ipaq_private *priv = usb_get_serial_port_data(port); 725 struct ipaq_private *priv = usb_get_serial_port_data(port);
720 726
@@ -751,7 +757,7 @@ static void ipaq_read_bulk_callback(struct urb *urb)
751 757
752 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 758 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
753 759
754 tty = port->tty; 760 tty = port->port.tty;
755 if (tty && urb->actual_length) { 761 if (tty && urb->actual_length) {
756 tty_buffer_request_room(tty, urb->actual_length); 762 tty_buffer_request_room(tty, urb->actual_length);
757 tty_insert_flip_string(tty, data, urb->actual_length); 763 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -770,8 +776,8 @@ static void ipaq_read_bulk_callback(struct urb *urb)
770 return; 776 return;
771} 777}
772 778
773static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf, 779static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
774 int count) 780 const unsigned char *buf, int count)
775{ 781{
776 const unsigned char *current_position = buf; 782 const unsigned char *current_position = buf;
777 int bytes_sent = 0; 783 int bytes_sent = 0;
@@ -905,16 +911,18 @@ static void ipaq_write_bulk_callback(struct urb *urb)
905 usb_serial_port_softint(port); 911 usb_serial_port_softint(port);
906} 912}
907 913
908static int ipaq_write_room(struct usb_serial_port *port) 914static int ipaq_write_room(struct tty_struct *tty)
909{ 915{
916 struct usb_serial_port *port = tty->driver_data;
910 struct ipaq_private *priv = usb_get_serial_port_data(port); 917 struct ipaq_private *priv = usb_get_serial_port_data(port);
911 918
912 dbg("%s - freelen %d", __func__, priv->free_len); 919 dbg("%s - freelen %d", __func__, priv->free_len);
913 return priv->free_len; 920 return priv->free_len;
914} 921}
915 922
916static int ipaq_chars_in_buffer(struct usb_serial_port *port) 923static int ipaq_chars_in_buffer(struct tty_struct *tty)
917{ 924{
925 struct usb_serial_port *port = tty->driver_data;
918 struct ipaq_private *priv = usb_get_serial_port_data(port); 926 struct ipaq_private *priv = usb_get_serial_port_data(port);
919 927
920 dbg("%s - queuelen %d", __func__, priv->queue_len); 928 dbg("%s - queuelen %d", __func__, priv->queue_len);
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index bc85ca5c1c37..a89ebfe9e915 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -179,7 +179,7 @@ static void ipw_read_bulk_callback(struct urb *urb)
179 179
180 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 180 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
181 181
182 tty = port->tty; 182 tty = port->port.tty;
183 if (tty && urb->actual_length) { 183 if (tty && urb->actual_length) {
184 tty_buffer_request_room(tty, urb->actual_length); 184 tty_buffer_request_room(tty, urb->actual_length);
185 tty_insert_flip_string(tty, data, urb->actual_length); 185 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -199,7 +199,8 @@ static void ipw_read_bulk_callback(struct urb *urb)
199 return; 199 return;
200} 200}
201 201
202static int ipw_open(struct usb_serial_port *port, struct file *filp) 202static int ipw_open(struct tty_struct *tty,
203 struct usb_serial_port *port, struct file *filp)
203{ 204{
204 struct usb_device *dev = port->serial->dev; 205 struct usb_device *dev = port->serial->dev;
205 u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; 206 u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT;
@@ -212,8 +213,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
212 if (!buf_flow_init) 213 if (!buf_flow_init)
213 return -ENOMEM; 214 return -ENOMEM;
214 215
215 if (port->tty) 216 if (tty)
216 port->tty->low_latency = 1; 217 tty->low_latency = 1;
217 218
218 /* --1: Tell the modem to initialize (we think) From sniffs this is always the 219 /* --1: Tell the modem to initialize (we think) From sniffs this is always the
219 * first thing that gets sent to the modem during opening of the device */ 220 * first thing that gets sent to the modem during opening of the device */
@@ -301,7 +302,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
301 return 0; 302 return 0;
302} 303}
303 304
304static void ipw_close(struct usb_serial_port *port, struct file * filp) 305static void ipw_close(struct tty_struct *tty,
306 struct usb_serial_port *port, struct file * filp)
305{ 307{
306 struct usb_device *dev = port->serial->dev; 308 struct usb_device *dev = port->serial->dev;
307 int result; 309 int result;
@@ -384,7 +386,8 @@ static void ipw_write_bulk_callback(struct urb *urb)
384 usb_serial_port_softint(port); 386 usb_serial_port_softint(port);
385} 387}
386 388
387static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count) 389static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port,
390 const unsigned char *buf, int count)
388{ 391{
389 struct usb_device *dev = port->serial->dev; 392 struct usb_device *dev = port->serial->dev;
390 int ret; 393 int ret;
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 0063c11c8081..e59155c6607d 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -85,15 +85,17 @@ static int buffer_size;
85/* if overridden by the user, then use the specified number of XBOFs */ 85/* if overridden by the user, then use the specified number of XBOFs */
86static int xbof = -1; 86static int xbof = -1;
87 87
88static int ir_startup(struct usb_serial *serial); 88static int ir_startup (struct usb_serial *serial);
89static int ir_open(struct usb_serial_port *port, struct file *filep); 89static int ir_open(struct tty_struct *tty, struct usb_serial_port *port,
90static void ir_close(struct usb_serial_port *port, struct file *filep); 90 struct file *filep);
91static int ir_write(struct usb_serial_port *port, 91static void ir_close(struct tty_struct *tty, struct usb_serial_port *port,
92 const unsigned char *buf, int count); 92 struct file *filep);
93static void ir_write_bulk_callback(struct urb *urb); 93static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
94static void ir_read_bulk_callback(struct urb *urb); 94 const unsigned char *buf, int count);
95static void ir_set_termios(struct usb_serial_port *port, 95static void ir_write_bulk_callback (struct urb *urb);
96 struct ktermios *old_termios); 96static void ir_read_bulk_callback (struct urb *urb);
97static void ir_set_termios(struct tty_struct *tty,
98 struct usb_serial_port *port, struct ktermios *old_termios);
97 99
98/* Not that this lot means you can only have one per system */ 100/* Not that this lot means you can only have one per system */
99static u8 ir_baud; 101static u8 ir_baud;
@@ -295,7 +297,8 @@ static int ir_startup(struct usb_serial *serial)
295 return 0; 297 return 0;
296} 298}
297 299
298static int ir_open(struct usb_serial_port *port, struct file *filp) 300static int ir_open(struct tty_struct *tty,
301 struct usb_serial_port *port, struct file *filp)
299{ 302{
300 char *buffer; 303 char *buffer;
301 int result = 0; 304 int result = 0;
@@ -343,7 +346,8 @@ static int ir_open(struct usb_serial_port *port, struct file *filp)
343 return result; 346 return result;
344} 347}
345 348
346static void ir_close(struct usb_serial_port *port, struct file *filp) 349static void ir_close(struct tty_struct *tty,
350 struct usb_serial_port *port, struct file * filp)
347{ 351{
348 dbg("%s - port %d", __func__, port->number); 352 dbg("%s - port %d", __func__, port->number);
349 353
@@ -351,8 +355,8 @@ static void ir_close(struct usb_serial_port *port, struct file *filp)
351 usb_kill_urb(port->read_urb); 355 usb_kill_urb(port->read_urb);
352} 356}
353 357
354static int ir_write(struct usb_serial_port *port, 358static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
355 const unsigned char *buf, int count) 359 const unsigned char *buf, int count)
356{ 360{
357 unsigned char *transfer_buffer; 361 unsigned char *transfer_buffer;
358 int result; 362 int result;
@@ -360,11 +364,6 @@ static int ir_write(struct usb_serial_port *port,
360 364
361 dbg("%s - port = %d, count = %d", __func__, port->number, count); 365 dbg("%s - port = %d, count = %d", __func__, port->number, count);
362 366
363 if (!port->tty) {
364 dev_err(&port->dev, "%s - no tty???\n", __func__);
365 return 0;
366 }
367
368 if (count == 0) 367 if (count == 0)
369 return 0; 368 return 0;
370 369
@@ -450,14 +449,13 @@ static void ir_read_bulk_callback(struct urb *urb)
450 449
451 dbg("%s - port %d", __func__, port->number); 450 dbg("%s - port %d", __func__, port->number);
452 451
453 if (!port->open_count) { 452 if (!port->port.count) {
454 dbg("%s - port closed.", __func__); 453 dbg("%s - port closed.", __func__);
455 return; 454 return;
456 } 455 }
457 456
458 switch (status) { 457 switch (status) {
459 case 0: /* Successful */ 458 case 0: /* Successful */
460
461 /* 459 /*
462 * The first byte of the packet we get from the device 460 * The first byte of the packet we get from the device
463 * contains a busy indicator and baud rate change. 461 * contains a busy indicator and baud rate change.
@@ -465,19 +463,11 @@ static void ir_read_bulk_callback(struct urb *urb)
465 */ 463 */
466 if ((*data & 0x0f) > 0) 464 if ((*data & 0x0f) > 0)
467 ir_baud = *data & 0x0f; 465 ir_baud = *data & 0x0f;
468 466 usb_serial_debug_data(debug, &port->dev, __func__,
469 usb_serial_debug_data( 467 urb->actual_length, data);
470 debug, 468 tty = port->port.tty;
471 &port->dev,
472 __func__,
473 urb->actual_length,
474 data);
475
476 tty = port->tty;
477
478 if (tty_buffer_request_room(tty, urb->actual_length - 1)) { 469 if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
479 tty_insert_flip_string(tty, data + 1, 470 tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
480 urb->actual_length - 1);
481 tty_flip_buffer_push(tty); 471 tty_flip_buffer_push(tty);
482 } 472 }
483 473
@@ -488,11 +478,10 @@ static void ir_read_bulk_callback(struct urb *urb)
488 */ 478 */
489 479
490 case -EPROTO: /* taking inspiration from pl2303.c */ 480 case -EPROTO: /* taking inspiration from pl2303.c */
491 481 /* Continue trying to always read */
492 /* Continue trying to always read */
493 usb_fill_bulk_urb( 482 usb_fill_bulk_urb(
494 port->read_urb, 483 port->read_urb,
495 port->serial->dev, 484 port->serial->dev,
496 usb_rcvbulkpipe(port->serial->dev, 485 usb_rcvbulkpipe(port->serial->dev,
497 port->bulk_in_endpointAddress), 486 port->bulk_in_endpointAddress),
498 port->read_urb->transfer_buffer, 487 port->read_urb->transfer_buffer,
@@ -502,23 +491,19 @@ static void ir_read_bulk_callback(struct urb *urb)
502 491
503 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 492 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
504 if (result) 493 if (result)
505 dev_err(&port->dev, 494 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
506 "%s - failed resubmitting read urb, error %d\n",
507 __func__, result); 495 __func__, result);
508 break; 496 break ;
509
510 default: 497 default:
511 dbg("%s - nonzero read bulk status received: %d", 498 dbg("%s - nonzero read bulk status received: %d",
512 __func__, 499 __func__, status);
513 status); 500 break ;
514 break;
515 } 501 }
516
517 return; 502 return;
518} 503}
519 504
520static void ir_set_termios(struct usb_serial_port *port, 505static void ir_set_termios(struct tty_struct *tty,
521 struct ktermios *old_termios) 506 struct usb_serial_port *port, struct ktermios *old_termios)
522{ 507{
523 unsigned char *transfer_buffer; 508 unsigned char *transfer_buffer;
524 int result; 509 int result;
@@ -527,7 +512,7 @@ static void ir_set_termios(struct usb_serial_port *port,
527 512
528 dbg("%s - port %d", __func__, port->number); 513 dbg("%s - port %d", __func__, port->number);
529 514
530 baud = tty_get_baud_rate(port->tty); 515 baud = tty_get_baud_rate(tty);
531 516
532 /* 517 /*
533 * FIXME, we should compare the baud request against the 518 * FIXME, we should compare the baud request against the
@@ -600,8 +585,8 @@ static void ir_set_termios(struct usb_serial_port *port,
600 __func__, result); 585 __func__, result);
601 586
602 /* Only speed changes are supported */ 587 /* Only speed changes are supported */
603 tty_termios_copy_hw(port->tty->termios, old_termios); 588 tty_termios_copy_hw(tty->termios, old_termios);
604 tty_encode_baud_rate(port->tty, baud, baud); 589 tty_encode_baud_rate(tty, baud, baud);
605} 590}
606 591
607static int __init ir_init(void) 592static int __init ir_init(void)
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index a01e987c7d32..d65414888349 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -144,9 +144,10 @@ static void iuu_shutdown(struct usb_serial *serial)
144 } 144 }
145} 145}
146 146
147static int iuu_tiocmset(struct usb_serial_port *port, struct file *file, 147static int iuu_tiocmset(struct tty_struct *tty, struct file *file,
148 unsigned int set, unsigned int clear) 148 unsigned int set, unsigned int clear)
149{ 149{
150 struct usb_serial_port *port = tty->driver_data;
150 struct iuu_private *priv = usb_get_serial_port_data(port); 151 struct iuu_private *priv = usb_get_serial_port_data(port);
151 unsigned long flags; 152 unsigned long flags;
152 153
@@ -171,8 +172,9 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
171 * When no card , the reader respond with TIOCM_CD 172 * When no card , the reader respond with TIOCM_CD
172 * This is known as CD autodetect mechanism 173 * This is known as CD autodetect mechanism
173 */ 174 */
174static int iuu_tiocmget(struct usb_serial_port *port, struct file *file) 175static int iuu_tiocmget(struct tty_struct *tty, struct file *file)
175{ 176{
177 struct usb_serial_port *port = tty->driver_data;
176 struct iuu_private *priv = usb_get_serial_port_data(port); 178 struct iuu_private *priv = usb_get_serial_port_data(port);
177 unsigned long flags; 179 unsigned long flags;
178 int rc; 180 int rc;
@@ -630,7 +632,7 @@ static void read_buf_callback(struct urb *urb)
630 } 632 }
631 633
632 dbg("%s - %i chars to write", __func__, urb->actual_length); 634 dbg("%s - %i chars to write", __func__, urb->actual_length);
633 tty = port->tty; 635 tty = port->port.tty;
634 if (data == NULL) 636 if (data == NULL)
635 dbg("%s - data is NULL !!!", __func__); 637 dbg("%s - data is NULL !!!", __func__);
636 if (tty && urb->actual_length && data) { 638 if (tty && urb->actual_length && data) {
@@ -752,11 +754,10 @@ static void iuu_uart_read_callback(struct urb *urb)
752 /* if nothing to write call again rxcmd */ 754 /* if nothing to write call again rxcmd */
753 dbg("%s - rxcmd recall", __func__); 755 dbg("%s - rxcmd recall", __func__);
754 iuu_led_activity_off(urb); 756 iuu_led_activity_off(urb);
755 return;
756} 757}
757 758
758static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf, 759static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
759 int count) 760 const u8 *buf, int count)
760{ 761{
761 struct iuu_private *priv = usb_get_serial_port_data(port); 762 struct iuu_private *priv = usb_get_serial_port_data(port);
762 unsigned long flags; 763 unsigned long flags;
@@ -948,7 +949,8 @@ static int set_control_lines(struct usb_device *dev, u8 value)
948 return 0; 949 return 0;
949} 950}
950 951
951static void iuu_close(struct usb_serial_port *port, struct file *filp) 952static void iuu_close(struct tty_struct *tty,
953 struct usb_serial_port *port, struct file *filp)
952{ 954{
953 /* iuu_led (port,255,0,0,0); */ 955 /* iuu_led (port,255,0,0,0); */
954 struct usb_serial *serial; 956 struct usb_serial *serial;
@@ -964,8 +966,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
964 966
965 iuu_uart_off(port); 967 iuu_uart_off(port);
966 if (serial->dev) { 968 if (serial->dev) {
967 if (port->tty) { 969 if (tty) {
968 c_cflag = port->tty->termios->c_cflag; 970 c_cflag = tty->termios->c_cflag;
969 if (c_cflag & HUPCL) { 971 if (c_cflag & HUPCL) {
970 /* drop DTR and RTS */ 972 /* drop DTR and RTS */
971 priv = usb_get_serial_port_data(port); 973 priv = usb_get_serial_port_data(port);
@@ -989,7 +991,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
989 } 991 }
990} 992}
991 993
992static int iuu_open(struct usb_serial_port *port, struct file *filp) 994static int iuu_open(struct tty_struct *tty,
995 struct usb_serial_port *port, struct file *filp)
993{ 996{
994 struct usb_serial *serial = port->serial; 997 struct usb_serial *serial = port->serial;
995 u8 *buf; 998 u8 *buf;
@@ -1036,15 +1039,17 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
1036 1039
1037 /* set the termios structure */ 1040 /* set the termios structure */
1038 spin_lock_irqsave(&priv->lock, flags); 1041 spin_lock_irqsave(&priv->lock, flags);
1039 if (!priv->termios_initialized) { 1042 if (tty && !priv->termios_initialized) {
1040 *(port->tty->termios) = tty_std_termios; 1043 *(tty->termios) = tty_std_termios;
1041 port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600 1044 tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
1042 | TIOCM_CTS | CSTOPB | PARENB; 1045 | TIOCM_CTS | CSTOPB | PARENB;
1043 port->tty->termios->c_lflag = 0; 1046 tty->termios->c_ispeed = 9600;
1044 port->tty->termios->c_oflag = 0; 1047 tty->termios->c_ospeed = 9600;
1045 port->tty->termios->c_iflag = 0; 1048 tty->termios->c_lflag = 0;
1049 tty->termios->c_oflag = 0;
1050 tty->termios->c_iflag = 0;
1046 priv->termios_initialized = 1; 1051 priv->termios_initialized = 1;
1047 port->tty->low_latency = 1; 1052 tty->low_latency = 1;
1048 priv->poll = 0; 1053 priv->poll = 0;
1049 } 1054 }
1050 spin_unlock_irqrestore(&priv->lock, flags); 1055 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1148,7 +1153,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
1148 if (result) { 1153 if (result) {
1149 dev_err(&port->dev, "%s - failed submitting read urb," 1154 dev_err(&port->dev, "%s - failed submitting read urb,"
1150 " error %d\n", __func__, result); 1155 " error %d\n", __func__, result);
1151 iuu_close(port, NULL); 1156 iuu_close(tty, port, NULL);
1152 return -EPROTO; 1157 return -EPROTO;
1153 } else { 1158 } else {
1154 dbg("%s - rxcmd OK", __func__); 1159 dbg("%s - rxcmd OK", __func__);
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 11e439b90eac..a371c41bb3ab 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -244,20 +244,9 @@ static void __exit keyspan_exit (void)
244module_init(keyspan_init); 244module_init(keyspan_init);
245module_exit(keyspan_exit); 245module_exit(keyspan_exit);
246 246
247static void keyspan_rx_throttle (struct usb_serial_port *port) 247static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
248{
249 dbg("%s - port %d", __func__, port->number);
250}
251
252
253static void keyspan_rx_unthrottle (struct usb_serial_port *port)
254{
255 dbg("%s - port %d", __func__, port->number);
256}
257
258
259static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
260{ 248{
249 struct usb_serial_port *port = tty->driver_data;
261 struct keyspan_port_private *p_priv; 250 struct keyspan_port_private *p_priv;
262 251
263 dbg("%s", __func__); 252 dbg("%s", __func__);
@@ -273,14 +262,13 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
273} 262}
274 263
275 264
276static void keyspan_set_termios (struct usb_serial_port *port, 265static void keyspan_set_termios (struct tty_struct *tty,
277 struct ktermios *old_termios) 266 struct usb_serial_port *port, struct ktermios *old_termios)
278{ 267{
279 int baud_rate, device_port; 268 int baud_rate, device_port;
280 struct keyspan_port_private *p_priv; 269 struct keyspan_port_private *p_priv;
281 const struct keyspan_device_details *d_details; 270 const struct keyspan_device_details *d_details;
282 unsigned int cflag; 271 unsigned int cflag;
283 struct tty_struct *tty = port->tty;
284 272
285 dbg("%s", __func__); 273 dbg("%s", __func__);
286 274
@@ -312,12 +300,11 @@ static void keyspan_set_termios (struct usb_serial_port *port,
312 keyspan_send_setup(port, 0); 300 keyspan_send_setup(port, 0);
313} 301}
314 302
315static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file) 303static int keyspan_tiocmget(struct tty_struct *tty, struct file *file)
316{ 304{
305 struct usb_serial_port *port = tty->driver_data;
306 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
317 unsigned int value; 307 unsigned int value;
318 struct keyspan_port_private *p_priv;
319
320 p_priv = usb_get_serial_port_data(port);
321 308
322 value = ((p_priv->rts_state) ? TIOCM_RTS : 0) | 309 value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
323 ((p_priv->dtr_state) ? TIOCM_DTR : 0) | 310 ((p_priv->dtr_state) ? TIOCM_DTR : 0) |
@@ -329,18 +316,16 @@ static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file)
329 return value; 316 return value;
330} 317}
331 318
332static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file, 319static int keyspan_tiocmset(struct tty_struct *tty, struct file *file,
333 unsigned int set, unsigned int clear) 320 unsigned int set, unsigned int clear)
334{ 321{
335 struct keyspan_port_private *p_priv; 322 struct usb_serial_port *port = tty->driver_data;
336 323 struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
337 p_priv = usb_get_serial_port_data(port);
338 324
339 if (set & TIOCM_RTS) 325 if (set & TIOCM_RTS)
340 p_priv->rts_state = 1; 326 p_priv->rts_state = 1;
341 if (set & TIOCM_DTR) 327 if (set & TIOCM_DTR)
342 p_priv->dtr_state = 1; 328 p_priv->dtr_state = 1;
343
344 if (clear & TIOCM_RTS) 329 if (clear & TIOCM_RTS)
345 p_priv->rts_state = 0; 330 p_priv->rts_state = 0;
346 if (clear & TIOCM_DTR) 331 if (clear & TIOCM_DTR)
@@ -349,16 +334,10 @@ static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
349 return 0; 334 return 0;
350} 335}
351 336
352static int keyspan_ioctl(struct usb_serial_port *port, struct file *file, 337/* Write function is similar for the four protocols used
353 unsigned int cmd, unsigned long arg) 338 with only a minor change for usa90 (usa19hs) required */
354{ 339static int keyspan_write(struct tty_struct *tty,
355 return -ENOIOCTLCMD; 340 struct usb_serial_port *port, const unsigned char *buf, int count)
356}
357
358 /* Write function is similar for the four protocols used
359 with only a minor change for usa90 (usa19hs) required */
360static int keyspan_write(struct usb_serial_port *port,
361 const unsigned char *buf, int count)
362{ 341{
363 struct keyspan_port_private *p_priv; 342 struct keyspan_port_private *p_priv;
364 const struct keyspan_device_details *d_details; 343 const struct keyspan_device_details *d_details;
@@ -448,7 +427,7 @@ static void usa26_indat_callback(struct urb *urb)
448 } 427 }
449 428
450 port = urb->context; 429 port = urb->context;
451 tty = port->tty; 430 tty = port->port.tty;
452 if (tty && urb->actual_length) { 431 if (tty && urb->actual_length) {
453 /* 0x80 bit is error flag */ 432 /* 0x80 bit is error flag */
454 if ((data[0] & 0x80) == 0) { 433 if ((data[0] & 0x80) == 0) {
@@ -479,7 +458,7 @@ static void usa26_indat_callback(struct urb *urb)
479 458
480 /* Resubmit urb so we continue receiving */ 459 /* Resubmit urb so we continue receiving */
481 urb->dev = port->serial->dev; 460 urb->dev = port->serial->dev;
482 if (port->open_count) 461 if (port->port.count)
483 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 462 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
484 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 463 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
485 } 464 }
@@ -496,7 +475,7 @@ static void usa2x_outdat_callback(struct urb *urb)
496 p_priv = usb_get_serial_port_data(port); 475 p_priv = usb_get_serial_port_data(port);
497 dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); 476 dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
498 477
499 if (port->open_count) 478 if (port->port.count)
500 usb_serial_port_softint(port); 479 usb_serial_port_softint(port);
501} 480}
502 481
@@ -567,10 +546,10 @@ static void usa26_instat_callback(struct urb *urb)
567 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 546 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
568 p_priv->ri_state = ((msg->ri) ? 1 : 0); 547 p_priv->ri_state = ((msg->ri) ? 1 : 0);
569 548
570 if (port->tty && !C_CLOCAL(port->tty) 549 if (port->port.tty && !C_CLOCAL(port->port.tty)
571 && old_dcd_state != p_priv->dcd_state) { 550 && old_dcd_state != p_priv->dcd_state) {
572 if (old_dcd_state) 551 if (old_dcd_state)
573 tty_hangup(port->tty); 552 tty_hangup(port->port.tty);
574 /* else */ 553 /* else */
575 /* wake_up_interruptible(&p_priv->open_wait); */ 554 /* wake_up_interruptible(&p_priv->open_wait); */
576 } 555 }
@@ -619,7 +598,7 @@ static void usa28_indat_callback(struct urb *urb)
619 p_priv = usb_get_serial_port_data(port); 598 p_priv = usb_get_serial_port_data(port);
620 data = urb->transfer_buffer; 599 data = urb->transfer_buffer;
621 600
622 tty = port->tty; 601 tty = port->port.tty;
623 if (urb->actual_length) { 602 if (urb->actual_length) {
624 for (i = 0; i < urb->actual_length ; ++i) { 603 for (i = 0; i < urb->actual_length ; ++i) {
625 tty_insert_flip_char(tty, data[i], 0); 604 tty_insert_flip_char(tty, data[i], 0);
@@ -629,7 +608,7 @@ static void usa28_indat_callback(struct urb *urb)
629 608
630 /* Resubmit urb so we continue receiving */ 609 /* Resubmit urb so we continue receiving */
631 urb->dev = port->serial->dev; 610 urb->dev = port->serial->dev;
632 if (port->open_count) 611 if (port->port.count)
633 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 612 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
634 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 613 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
635 } 614 }
@@ -704,10 +683,10 @@ static void usa28_instat_callback(struct urb *urb)
704 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 683 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
705 p_priv->ri_state = ((msg->ri) ? 1 : 0); 684 p_priv->ri_state = ((msg->ri) ? 1 : 0);
706 685
707 if (port->tty && !C_CLOCAL(port->tty) 686 if (port->port.tty && !C_CLOCAL(port->port.tty)
708 && old_dcd_state != p_priv->dcd_state) { 687 && old_dcd_state != p_priv->dcd_state) {
709 if (old_dcd_state) 688 if (old_dcd_state)
710 tty_hangup(port->tty); 689 tty_hangup(port->port.tty);
711 /* else */ 690 /* else */
712 /* wake_up_interruptible(&p_priv->open_wait); */ 691 /* wake_up_interruptible(&p_priv->open_wait); */
713 } 692 }
@@ -797,10 +776,10 @@ static void usa49_instat_callback(struct urb *urb)
797 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 776 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
798 p_priv->ri_state = ((msg->ri) ? 1 : 0); 777 p_priv->ri_state = ((msg->ri) ? 1 : 0);
799 778
800 if (port->tty && !C_CLOCAL(port->tty) 779 if (port->port.tty && !C_CLOCAL(port->port.tty)
801 && old_dcd_state != p_priv->dcd_state) { 780 && old_dcd_state != p_priv->dcd_state) {
802 if (old_dcd_state) 781 if (old_dcd_state)
803 tty_hangup(port->tty); 782 tty_hangup(port->port.tty);
804 /* else */ 783 /* else */
805 /* wake_up_interruptible(&p_priv->open_wait); */ 784 /* wake_up_interruptible(&p_priv->open_wait); */
806 } 785 }
@@ -839,7 +818,7 @@ static void usa49_indat_callback(struct urb *urb)
839 } 818 }
840 819
841 port = urb->context; 820 port = urb->context;
842 tty = port->tty; 821 tty = port->port.tty;
843 if (tty && urb->actual_length) { 822 if (tty && urb->actual_length) {
844 /* 0x80 bit is error flag */ 823 /* 0x80 bit is error flag */
845 if ((data[0] & 0x80) == 0) { 824 if ((data[0] & 0x80) == 0) {
@@ -866,7 +845,7 @@ static void usa49_indat_callback(struct urb *urb)
866 845
867 /* Resubmit urb so we continue receiving */ 846 /* Resubmit urb so we continue receiving */
868 urb->dev = port->serial->dev; 847 urb->dev = port->serial->dev;
869 if (port->open_count) 848 if (port->port.count)
870 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 849 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
871 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 850 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
872 } 851 }
@@ -904,7 +883,7 @@ static void usa49wg_indat_callback(struct urb *urb)
904 return; 883 return;
905 } 884 }
906 port = serial->port[data[i++]]; 885 port = serial->port[data[i++]];
907 tty = port->tty; 886 tty = port->port.tty;
908 len = data[i++]; 887 len = data[i++];
909 888
910 /* 0x80 bit is error flag */ 889 /* 0x80 bit is error flag */
@@ -912,7 +891,7 @@ static void usa49wg_indat_callback(struct urb *urb)
912 /* no error on any byte */ 891 /* no error on any byte */
913 i++; 892 i++;
914 for (x = 1; x < len ; ++x) 893 for (x = 1; x < len ; ++x)
915 if (port->open_count) 894 if (port->port.count)
916 tty_insert_flip_char(tty, 895 tty_insert_flip_char(tty,
917 data[i++], 0); 896 data[i++], 0);
918 else 897 else
@@ -930,13 +909,13 @@ static void usa49wg_indat_callback(struct urb *urb)
930 if (stat & RXERROR_PARITY) 909 if (stat & RXERROR_PARITY)
931 flag |= TTY_PARITY; 910 flag |= TTY_PARITY;
932 /* XXX should handle break (0x10) */ 911 /* XXX should handle break (0x10) */
933 if (port->open_count) 912 if (port->port.count)
934 tty_insert_flip_char(tty, 913 tty_insert_flip_char(tty,
935 data[i+1], flag); 914 data[i+1], flag);
936 i += 2; 915 i += 2;
937 } 916 }
938 } 917 }
939 if (port->open_count) 918 if (port->port.count)
940 tty_flip_buffer_push(tty); 919 tty_flip_buffer_push(tty);
941 } 920 }
942 } 921 }
@@ -978,7 +957,7 @@ static void usa90_indat_callback(struct urb *urb)
978 port = urb->context; 957 port = urb->context;
979 p_priv = usb_get_serial_port_data(port); 958 p_priv = usb_get_serial_port_data(port);
980 959
981 tty = port->tty; 960 tty = port->port.tty;
982 if (urb->actual_length) { 961 if (urb->actual_length) {
983 962
984 /* if current mode is DMA, looks like usa28 format 963 /* if current mode is DMA, looks like usa28 format
@@ -1021,7 +1000,7 @@ static void usa90_indat_callback(struct urb *urb)
1021 1000
1022 /* Resubmit urb so we continue receiving */ 1001 /* Resubmit urb so we continue receiving */
1023 urb->dev = port->serial->dev; 1002 urb->dev = port->serial->dev;
1024 if (port->open_count) 1003 if (port->port.count)
1025 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { 1004 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
1026 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 1005 dbg("%s - resubmit read urb failed. (%d)", __func__, err);
1027 } 1006 }
@@ -1064,10 +1043,10 @@ static void usa90_instat_callback(struct urb *urb)
1064 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 1043 p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
1065 p_priv->ri_state = ((msg->ri) ? 1 : 0); 1044 p_priv->ri_state = ((msg->ri) ? 1 : 0);
1066 1045
1067 if (port->tty && !C_CLOCAL(port->tty) 1046 if (port->port.tty && !C_CLOCAL(port->port.tty)
1068 && old_dcd_state != p_priv->dcd_state) { 1047 && old_dcd_state != p_priv->dcd_state) {
1069 if (old_dcd_state) 1048 if (old_dcd_state)
1070 tty_hangup(port->tty); 1049 tty_hangup(port->port.tty);
1071 /* else */ 1050 /* else */
1072 /* wake_up_interruptible(&p_priv->open_wait); */ 1051 /* wake_up_interruptible(&p_priv->open_wait); */
1073 } 1052 }
@@ -1139,10 +1118,10 @@ static void usa67_instat_callback(struct urb *urb)
1139 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); 1118 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
1140 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 1119 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
1141 1120
1142 if (port->tty && !C_CLOCAL(port->tty) 1121 if (port->port.tty && !C_CLOCAL(port->port.tty)
1143 && old_dcd_state != p_priv->dcd_state) { 1122 && old_dcd_state != p_priv->dcd_state) {
1144 if (old_dcd_state) 1123 if (old_dcd_state)
1145 tty_hangup(port->tty); 1124 tty_hangup(port->port.tty);
1146 /* else */ 1125 /* else */
1147 /* wake_up_interruptible(&p_priv->open_wait); */ 1126 /* wake_up_interruptible(&p_priv->open_wait); */
1148 } 1127 }
@@ -1177,8 +1156,9 @@ static void usa67_glocont_callback(struct urb *urb)
1177 } 1156 }
1178} 1157}
1179 1158
1180static int keyspan_write_room (struct usb_serial_port *port) 1159static int keyspan_write_room(struct tty_struct *tty)
1181{ 1160{
1161 struct usb_serial_port *port = tty->driver_data;
1182 struct keyspan_port_private *p_priv; 1162 struct keyspan_port_private *p_priv;
1183 const struct keyspan_device_details *d_details; 1163 const struct keyspan_device_details *d_details;
1184 int flip; 1164 int flip;
@@ -1210,13 +1190,8 @@ static int keyspan_write_room (struct usb_serial_port *port)
1210} 1190}
1211 1191
1212 1192
1213static int keyspan_chars_in_buffer (struct usb_serial_port *port) 1193static int keyspan_open(struct tty_struct *tty,
1214{ 1194 struct usb_serial_port *port, struct file *filp)
1215 return 0;
1216}
1217
1218
1219static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1220{ 1195{
1221 struct keyspan_port_private *p_priv; 1196 struct keyspan_port_private *p_priv;
1222 struct keyspan_serial_private *s_priv; 1197 struct keyspan_serial_private *s_priv;
@@ -1225,7 +1200,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1225 int i, err; 1200 int i, err;
1226 int baud_rate, device_port; 1201 int baud_rate, device_port;
1227 struct urb *urb; 1202 struct urb *urb;
1228 unsigned int cflag; 1203 unsigned int cflag = 0;
1229 1204
1230 s_priv = usb_get_serial_data(serial); 1205 s_priv = usb_get_serial_data(serial);
1231 p_priv = usb_get_serial_port_data(port); 1206 p_priv = usb_get_serial_port_data(port);
@@ -1271,19 +1246,19 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1271 /* get the terminal config for the setup message now so we don't 1246 /* get the terminal config for the setup message now so we don't
1272 * need to send 2 of them */ 1247 * need to send 2 of them */
1273 1248
1274 cflag = port->tty->termios->c_cflag;
1275 device_port = port->number - port->serial->minor; 1249 device_port = port->number - port->serial->minor;
1276 1250 if (tty) {
1277 /* Baud rate calculation takes baud rate as an integer 1251 cflag = tty->termios->c_cflag;
1278 so other rates can be generated if desired. */ 1252 /* Baud rate calculation takes baud rate as an integer
1279 baud_rate = tty_get_baud_rate(port->tty); 1253 so other rates can be generated if desired. */
1280 /* If no match or invalid, leave as default */ 1254 baud_rate = tty_get_baud_rate(tty);
1281 if (baud_rate >= 0 1255 /* If no match or invalid, leave as default */
1282 && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, 1256 if (baud_rate >= 0
1283 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { 1257 && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
1284 p_priv->baud = baud_rate; 1258 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1259 p_priv->baud = baud_rate;
1260 }
1285 } 1261 }
1286
1287 /* set CTS/RTS handshake etc. */ 1262 /* set CTS/RTS handshake etc. */
1288 p_priv->cflag = cflag; 1263 p_priv->cflag = cflag;
1289 p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none; 1264 p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
@@ -1301,7 +1276,8 @@ static inline void stop_urb(struct urb *urb)
1301 usb_kill_urb(urb); 1276 usb_kill_urb(urb);
1302} 1277}
1303 1278
1304static void keyspan_close(struct usb_serial_port *port, struct file *filp) 1279static void keyspan_close(struct tty_struct *tty,
1280 struct usb_serial_port *port, struct file *filp)
1305{ 1281{
1306 int i; 1282 int i;
1307 struct usb_serial *serial = port->serial; 1283 struct usb_serial *serial = port->serial;
@@ -1338,7 +1314,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
1338 stop_urb(p_priv->out_urbs[i]); 1314 stop_urb(p_priv->out_urbs[i]);
1339 } 1315 }
1340 } 1316 }
1341 port->tty = NULL; 1317 port->port.tty = NULL;
1342} 1318}
1343 1319
1344 /* download the firmware to a pre-renumeration device */ 1320 /* download the firmware to a pre-renumeration device */
@@ -2427,7 +2403,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2427 } 2403 }
2428 /* Sending intermediate configs */ 2404 /* Sending intermediate configs */
2429 else { 2405 else {
2430 if (port->open_count) 2406 if (port->port.count)
2431 msg.portEnabled = 1; 2407 msg.portEnabled = 1;
2432 msg.txBreak = (p_priv->break_on); 2408 msg.txBreak = (p_priv->break_on);
2433 } 2409 }
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 8bf72639b148..38b4582e0734 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -35,17 +35,18 @@
35 35
36 36
37/* Function prototypes for Keyspan serial converter */ 37/* Function prototypes for Keyspan serial converter */
38static int keyspan_open (struct usb_serial_port *port, 38static int keyspan_open (struct tty_struct *tty,
39 struct usb_serial_port *port,
39 struct file *filp); 40 struct file *filp);
40static void keyspan_close (struct usb_serial_port *port, 41static void keyspan_close (struct tty_struct *tty,
42 struct usb_serial_port *port,
41 struct file *filp); 43 struct file *filp);
42static int keyspan_startup (struct usb_serial *serial); 44static int keyspan_startup (struct usb_serial *serial);
43static void keyspan_shutdown (struct usb_serial *serial); 45static void keyspan_shutdown (struct usb_serial *serial);
44static void keyspan_rx_throttle (struct usb_serial_port *port); 46static int keyspan_write_room (struct tty_struct *tty);
45static void keyspan_rx_unthrottle (struct usb_serial_port *port);
46static int keyspan_write_room (struct usb_serial_port *port);
47 47
48static int keyspan_write (struct usb_serial_port *port, 48static int keyspan_write (struct tty_struct *tty,
49 struct usb_serial_port *port,
49 const unsigned char *buf, 50 const unsigned char *buf,
50 int count); 51 int count);
51 52
@@ -53,18 +54,14 @@ static void keyspan_send_setup (struct usb_serial_port *port,
53 int reset_port); 54 int reset_port);
54 55
55 56
56static int keyspan_chars_in_buffer (struct usb_serial_port *port); 57static void keyspan_set_termios (struct tty_struct *tty,
57static int keyspan_ioctl (struct usb_serial_port *port, 58 struct usb_serial_port *port,
58 struct file *file,
59 unsigned int cmd,
60 unsigned long arg);
61static void keyspan_set_termios (struct usb_serial_port *port,
62 struct ktermios *old); 59 struct ktermios *old);
63static void keyspan_break_ctl (struct usb_serial_port *port, 60static void keyspan_break_ctl (struct tty_struct *tty,
64 int break_state); 61 int break_state);
65static int keyspan_tiocmget (struct usb_serial_port *port, 62static int keyspan_tiocmget (struct tty_struct *tty,
66 struct file *file); 63 struct file *file);
67static int keyspan_tiocmset (struct usb_serial_port *port, 64static int keyspan_tiocmset (struct tty_struct *tty,
68 struct file *file, unsigned int set, 65 struct file *file, unsigned int set,
69 unsigned int clear); 66 unsigned int clear);
70static int keyspan_fake_startup (struct usb_serial *serial); 67static int keyspan_fake_startup (struct usb_serial *serial);
@@ -567,10 +564,6 @@ static struct usb_serial_driver keyspan_1port_device = {
567 .close = keyspan_close, 564 .close = keyspan_close,
568 .write = keyspan_write, 565 .write = keyspan_write,
569 .write_room = keyspan_write_room, 566 .write_room = keyspan_write_room,
570 .chars_in_buffer = keyspan_chars_in_buffer,
571 .throttle = keyspan_rx_throttle,
572 .unthrottle = keyspan_rx_unthrottle,
573 .ioctl = keyspan_ioctl,
574 .set_termios = keyspan_set_termios, 567 .set_termios = keyspan_set_termios,
575 .break_ctl = keyspan_break_ctl, 568 .break_ctl = keyspan_break_ctl,
576 .tiocmget = keyspan_tiocmget, 569 .tiocmget = keyspan_tiocmget,
@@ -591,10 +584,6 @@ static struct usb_serial_driver keyspan_2port_device = {
591 .close = keyspan_close, 584 .close = keyspan_close,
592 .write = keyspan_write, 585 .write = keyspan_write,
593 .write_room = keyspan_write_room, 586 .write_room = keyspan_write_room,
594 .chars_in_buffer = keyspan_chars_in_buffer,
595 .throttle = keyspan_rx_throttle,
596 .unthrottle = keyspan_rx_unthrottle,
597 .ioctl = keyspan_ioctl,
598 .set_termios = keyspan_set_termios, 587 .set_termios = keyspan_set_termios,
599 .break_ctl = keyspan_break_ctl, 588 .break_ctl = keyspan_break_ctl,
600 .tiocmget = keyspan_tiocmget, 589 .tiocmget = keyspan_tiocmget,
@@ -615,10 +604,6 @@ static struct usb_serial_driver keyspan_4port_device = {
615 .close = keyspan_close, 604 .close = keyspan_close,
616 .write = keyspan_write, 605 .write = keyspan_write,
617 .write_room = keyspan_write_room, 606 .write_room = keyspan_write_room,
618 .chars_in_buffer = keyspan_chars_in_buffer,
619 .throttle = keyspan_rx_throttle,
620 .unthrottle = keyspan_rx_unthrottle,
621 .ioctl = keyspan_ioctl,
622 .set_termios = keyspan_set_termios, 607 .set_termios = keyspan_set_termios,
623 .break_ctl = keyspan_break_ctl, 608 .break_ctl = keyspan_break_ctl,
624 .tiocmget = keyspan_tiocmget, 609 .tiocmget = keyspan_tiocmget,
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 60b3e22bd633..24a08ac2e4ee 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -171,7 +171,7 @@ static void keyspan_pda_wakeup_write(struct work_struct *work)
171 container_of(work, struct keyspan_pda_private, wakeup_work); 171 container_of(work, struct keyspan_pda_private, wakeup_work);
172 struct usb_serial_port *port = priv->port; 172 struct usb_serial_port *port = priv->port;
173 173
174 tty_wakeup(port->tty); 174 tty_wakeup(port->port.tty);
175} 175}
176 176
177static void keyspan_pda_request_unthrottle(struct work_struct *work) 177static void keyspan_pda_request_unthrottle(struct work_struct *work)
@@ -203,7 +203,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
203static void keyspan_pda_rx_interrupt (struct urb *urb) 203static void keyspan_pda_rx_interrupt (struct urb *urb)
204{ 204{
205 struct usb_serial_port *port = urb->context; 205 struct usb_serial_port *port = urb->context;
206 struct tty_struct *tty = port->tty; 206 struct tty_struct *tty = port->port.tty;
207 unsigned char *data = urb->transfer_buffer; 207 unsigned char *data = urb->transfer_buffer;
208 int i; 208 int i;
209 int retval; 209 int retval;
@@ -266,7 +266,7 @@ exit:
266} 266}
267 267
268 268
269static void keyspan_pda_rx_throttle (struct usb_serial_port *port) 269static void keyspan_pda_rx_throttle(struct tty_struct *tty)
270{ 270{
271 /* stop receiving characters. We just turn off the URB request, and 271 /* stop receiving characters. We just turn off the URB request, and
272 let chars pile up in the device. If we're doing hardware 272 let chars pile up in the device. If we're doing hardware
@@ -274,14 +274,15 @@ static void keyspan_pda_rx_throttle (struct usb_serial_port *port)
274 fills up. If we're doing XON/XOFF, this would be a good time to 274 fills up. If we're doing XON/XOFF, this would be a good time to
275 send an XOFF, although it might make sense to foist that off 275 send an XOFF, although it might make sense to foist that off
276 upon the device too. */ 276 upon the device too. */
277 277 struct usb_serial_port *port = tty->driver_data;
278 dbg("keyspan_pda_rx_throttle port %d", port->number); 278 dbg("keyspan_pda_rx_throttle port %d", port->number);
279 usb_kill_urb(port->interrupt_in_urb); 279 usb_kill_urb(port->interrupt_in_urb);
280} 280}
281 281
282 282
283static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port) 283static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
284{ 284{
285 struct usb_serial_port *port = tty->driver_data;
285 /* just restart the receive interrupt URB */ 286 /* just restart the receive interrupt URB */
286 dbg("keyspan_pda_rx_unthrottle port %d", port->number); 287 dbg("keyspan_pda_rx_unthrottle port %d", port->number);
287 port->interrupt_in_urb->dev = port->serial->dev; 288 port->interrupt_in_urb->dev = port->serial->dev;
@@ -330,8 +331,9 @@ static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud)
330} 331}
331 332
332 333
333static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state) 334static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)
334{ 335{
336 struct usb_serial_port *port = tty->driver_data;
335 struct usb_serial *serial = port->serial; 337 struct usb_serial *serial = port->serial;
336 int value; 338 int value;
337 int result; 339 int result;
@@ -354,8 +356,8 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state
354} 356}
355 357
356 358
357static void keyspan_pda_set_termios (struct usb_serial_port *port, 359static void keyspan_pda_set_termios(struct tty_struct *tty,
358 struct ktermios *old_termios) 360 struct usb_serial_port *port, struct ktermios *old_termios)
359{ 361{
360 struct usb_serial *serial = port->serial; 362 struct usb_serial *serial = port->serial;
361 speed_t speed; 363 speed_t speed;
@@ -380,7 +382,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port,
380 382
381 For now, just do baud. */ 383 For now, just do baud. */
382 384
383 speed = tty_get_baud_rate(port->tty); 385 speed = tty_get_baud_rate(tty);
384 speed = keyspan_pda_setbaud(serial, speed); 386 speed = keyspan_pda_setbaud(serial, speed);
385 387
386 if (speed == 0) { 388 if (speed == 0) {
@@ -390,8 +392,8 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port,
390 } 392 }
391 /* Only speed can change so copy the old h/w parameters 393 /* Only speed can change so copy the old h/w parameters
392 then encode the new speed */ 394 then encode the new speed */
393 tty_termios_copy_hw(port->tty->termios, old_termios); 395 tty_termios_copy_hw(tty->termios, old_termios);
394 tty_encode_baud_rate(port->tty, speed, speed); 396 tty_encode_baud_rate(tty, speed, speed);
395} 397}
396 398
397 399
@@ -425,8 +427,9 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial,
425 return rc; 427 return rc;
426} 428}
427 429
428static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file) 430static int keyspan_pda_tiocmget(struct tty_struct *tty, struct file *file)
429{ 431{
432 struct usb_serial_port *port = tty->driver_data;
430 struct usb_serial *serial = port->serial; 433 struct usb_serial *serial = port->serial;
431 int rc; 434 int rc;
432 unsigned char status; 435 unsigned char status;
@@ -445,9 +448,10 @@ static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file)
445 return value; 448 return value;
446} 449}
447 450
448static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file, 451static int keyspan_pda_tiocmset(struct tty_struct *tty, struct file *file,
449 unsigned int set, unsigned int clear) 452 unsigned int set, unsigned int clear)
450{ 453{
454 struct usb_serial_port *port = tty->driver_data;
451 struct usb_serial *serial = port->serial; 455 struct usb_serial *serial = port->serial;
452 int rc; 456 int rc;
453 unsigned char status; 457 unsigned char status;
@@ -469,23 +473,8 @@ static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file,
469 return rc; 473 return rc;
470} 474}
471 475
472static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file, 476static int keyspan_pda_write(struct tty_struct *tty,
473 unsigned int cmd, unsigned long arg) 477 struct usb_serial_port *port, const unsigned char *buf, int count)
474{
475 switch (cmd) {
476 case TIOCMIWAIT:
477 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
478 /* TODO */
479 case TIOCGICOUNT:
480 /* return count of modemline transitions */
481 return 0; /* TODO */
482 }
483
484 return -ENOIOCTLCMD;
485}
486
487static int keyspan_pda_write(struct usb_serial_port *port,
488 const unsigned char *buf, int count)
489{ 478{
490 struct usb_serial *serial = port->serial; 479 struct usb_serial *serial = port->serial;
491 int request_unthrottle = 0; 480 int request_unthrottle = 0;
@@ -607,22 +596,21 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb)
607} 596}
608 597
609 598
610static int keyspan_pda_write_room (struct usb_serial_port *port) 599static int keyspan_pda_write_room(struct tty_struct *tty)
611{ 600{
601 struct usb_serial_port *port = tty->driver_data;
612 struct keyspan_pda_private *priv; 602 struct keyspan_pda_private *priv;
613
614 priv = usb_get_serial_port_data(port); 603 priv = usb_get_serial_port_data(port);
615
616 /* used by n_tty.c for processing of tabs and such. Giving it our 604 /* used by n_tty.c for processing of tabs and such. Giving it our
617 conservative guess is probably good enough, but needs testing by 605 conservative guess is probably good enough, but needs testing by
618 running a console through the device. */ 606 running a console through the device. */
619
620 return (priv->tx_room); 607 return (priv->tx_room);
621} 608}
622 609
623 610
624static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) 611static int keyspan_pda_chars_in_buffer(struct tty_struct *tty)
625{ 612{
613 struct usb_serial_port *port = tty->driver_data;
626 struct keyspan_pda_private *priv; 614 struct keyspan_pda_private *priv;
627 unsigned long flags; 615 unsigned long flags;
628 int ret = 0; 616 int ret = 0;
@@ -640,7 +628,8 @@ static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
640} 628}
641 629
642 630
643static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) 631static int keyspan_pda_open(struct tty_struct *tty,
632 struct usb_serial_port *port, struct file *filp)
644{ 633{
645 struct usb_serial *serial = port->serial; 634 struct usb_serial *serial = port->serial;
646 unsigned char room; 635 unsigned char room;
@@ -672,7 +661,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
672 661
673 /* the normal serial device seems to always turn on DTR and RTS here, 662 /* the normal serial device seems to always turn on DTR and RTS here,
674 so do the same */ 663 so do the same */
675 if (port->tty->termios->c_cflag & CBAUD) 664 if (tty && (tty->termios->c_cflag & CBAUD))
676 keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) ); 665 keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) );
677 else 666 else
678 keyspan_pda_set_modem_info(serial, 0); 667 keyspan_pda_set_modem_info(serial, 0);
@@ -690,13 +679,14 @@ error:
690} 679}
691 680
692 681
693static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp) 682static void keyspan_pda_close(struct tty_struct *tty,
683 struct usb_serial_port *port, struct file *filp)
694{ 684{
695 struct usb_serial *serial = port->serial; 685 struct usb_serial *serial = port->serial;
696 686
697 if (serial->dev) { 687 if (serial->dev) {
698 /* the normal serial device seems to always shut off DTR and RTS now */ 688 /* the normal serial device seems to always shut off DTR and RTS now */
699 if (port->tty->termios->c_cflag & HUPCL) 689 if (tty->termios->c_cflag & HUPCL)
700 keyspan_pda_set_modem_info(serial, 0); 690 keyspan_pda_set_modem_info(serial, 0);
701 691
702 /* shutdown our bulk reads and writes */ 692 /* shutdown our bulk reads and writes */
@@ -832,7 +822,6 @@ static struct usb_serial_driver keyspan_pda_device = {
832 .chars_in_buffer = keyspan_pda_chars_in_buffer, 822 .chars_in_buffer = keyspan_pda_chars_in_buffer,
833 .throttle = keyspan_pda_rx_throttle, 823 .throttle = keyspan_pda_rx_throttle,
834 .unthrottle = keyspan_pda_rx_unthrottle, 824 .unthrottle = keyspan_pda_rx_unthrottle,
835 .ioctl = keyspan_pda_ioctl,
836 .set_termios = keyspan_pda_set_termios, 825 .set_termios = keyspan_pda_set_termios,
837 .break_ctl = keyspan_pda_break_ctl, 826 .break_ctl = keyspan_pda_break_ctl,
838 .tiocmget = keyspan_pda_tiocmget, 827 .tiocmget = keyspan_pda_tiocmget,
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 79787eda9524..4a38ec8f5fe3 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -74,29 +74,33 @@ static int debug;
74 */ 74 */
75static int klsi_105_startup (struct usb_serial *serial); 75static int klsi_105_startup (struct usb_serial *serial);
76static void klsi_105_shutdown (struct usb_serial *serial); 76static void klsi_105_shutdown (struct usb_serial *serial);
77static int klsi_105_open (struct usb_serial_port *port, 77static int klsi_105_open (struct tty_struct *tty,
78 struct usb_serial_port *port,
78 struct file *filp); 79 struct file *filp);
79static void klsi_105_close (struct usb_serial_port *port, 80static void klsi_105_close (struct tty_struct *tty,
81 struct usb_serial_port *port,
80 struct file *filp); 82 struct file *filp);
81static int klsi_105_write (struct usb_serial_port *port, 83static int klsi_105_write (struct tty_struct *tty,
84 struct usb_serial_port *port,
82 const unsigned char *buf, 85 const unsigned char *buf,
83 int count); 86 int count);
84static void klsi_105_write_bulk_callback (struct urb *urb); 87static void klsi_105_write_bulk_callback (struct urb *urb);
85static int klsi_105_chars_in_buffer (struct usb_serial_port *port); 88static int klsi_105_chars_in_buffer (struct tty_struct *tty);
86static int klsi_105_write_room (struct usb_serial_port *port); 89static int klsi_105_write_room (struct tty_struct *tty);
87 90
88static void klsi_105_read_bulk_callback (struct urb *urb); 91static void klsi_105_read_bulk_callback (struct urb *urb);
89static void klsi_105_set_termios (struct usb_serial_port *port, 92static void klsi_105_set_termios (struct tty_struct *tty,
93 struct usb_serial_port *port,
90 struct ktermios *old); 94 struct ktermios *old);
91static void klsi_105_throttle (struct usb_serial_port *port); 95static void klsi_105_throttle (struct tty_struct *tty);
92static void klsi_105_unthrottle (struct usb_serial_port *port); 96static void klsi_105_unthrottle (struct tty_struct *tty);
93/* 97/*
94static void klsi_105_break_ctl (struct usb_serial_port *port, 98static void klsi_105_break_ctl (struct tty_struct *tty,
95 int break_state ); 99 int break_state );
96 */ 100 */
97static int klsi_105_tiocmget (struct usb_serial_port *port, 101static int klsi_105_tiocmget (struct tty_struct *tty,
98 struct file *file); 102 struct file *file);
99static int klsi_105_tiocmset (struct usb_serial_port *port, 103static int klsi_105_tiocmset (struct tty_struct *tty,
100 struct file *file, unsigned int set, 104 struct file *file, unsigned int set,
101 unsigned int clear); 105 unsigned int clear);
102 106
@@ -361,7 +365,8 @@ static void klsi_105_shutdown (struct usb_serial *serial)
361 } 365 }
362} /* klsi_105_shutdown */ 366} /* klsi_105_shutdown */
363 367
364static int klsi_105_open (struct usb_serial_port *port, struct file *filp) 368static int klsi_105_open(struct tty_struct *tty,
369 struct usb_serial_port *port, struct file *filp)
365{ 370{
366 struct klsi_105_private *priv = usb_get_serial_port_data(port); 371 struct klsi_105_private *priv = usb_get_serial_port_data(port);
367 int retval = 0; 372 int retval = 0;
@@ -375,7 +380,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
375 380
376 /* force low_latency on so that our tty_push actually forces 381 /* force low_latency on so that our tty_push actually forces
377 * the data through 382 * the data through
378 * port->tty->low_latency = 1; */ 383 * tty->low_latency = 1; */
379 384
380 /* Do a defined restart: 385 /* Do a defined restart:
381 * Set up sane default baud rate and send the 'READ_ON' 386 * Set up sane default baud rate and send the 'READ_ON'
@@ -393,12 +398,12 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
393 398
394 /* set up termios structure */ 399 /* set up termios structure */
395 spin_lock_irqsave (&priv->lock, flags); 400 spin_lock_irqsave (&priv->lock, flags);
396 priv->termios.c_iflag = port->tty->termios->c_iflag; 401 priv->termios.c_iflag = tty->termios->c_iflag;
397 priv->termios.c_oflag = port->tty->termios->c_oflag; 402 priv->termios.c_oflag = tty->termios->c_oflag;
398 priv->termios.c_cflag = port->tty->termios->c_cflag; 403 priv->termios.c_cflag = tty->termios->c_cflag;
399 priv->termios.c_lflag = port->tty->termios->c_lflag; 404 priv->termios.c_lflag = tty->termios->c_lflag;
400 for (i=0; i<NCCS; i++) 405 for (i=0; i<NCCS; i++)
401 priv->termios.c_cc[i] = port->tty->termios->c_cc[i]; 406 priv->termios.c_cc[i] = tty->termios->c_cc[i];
402 priv->cfg.pktlen = cfg.pktlen; 407 priv->cfg.pktlen = cfg.pktlen;
403 priv->cfg.baudrate = cfg.baudrate; 408 priv->cfg.baudrate = cfg.baudrate;
404 priv->cfg.databits = cfg.databits; 409 priv->cfg.databits = cfg.databits;
@@ -452,7 +457,8 @@ exit:
452} /* klsi_105_open */ 457} /* klsi_105_open */
453 458
454 459
455static void klsi_105_close (struct usb_serial_port *port, struct file *filp) 460static void klsi_105_close(struct tty_struct *tty,
461 struct usb_serial_port *port, struct file *filp)
456{ 462{
457 struct klsi_105_private *priv = usb_get_serial_port_data(port); 463 struct klsi_105_private *priv = usb_get_serial_port_data(port);
458 int rc; 464 int rc;
@@ -493,8 +499,8 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
493#define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */ 499#define KLSI_105_DATA_OFFSET 2 /* in the bulk urb data block */
494 500
495 501
496static int klsi_105_write (struct usb_serial_port *port, 502static int klsi_105_write(struct tty_struct *tty,
497 const unsigned char *buf, int count) 503 struct usb_serial_port *port, const unsigned char *buf, int count)
498{ 504{
499 struct klsi_105_private *priv = usb_get_serial_port_data(port); 505 struct klsi_105_private *priv = usb_get_serial_port_data(port);
500 int result, size; 506 int result, size;
@@ -584,8 +590,9 @@ static void klsi_105_write_bulk_callback ( struct urb *urb)
584 590
585 591
586/* return number of characters currently in the writing process */ 592/* return number of characters currently in the writing process */
587static int klsi_105_chars_in_buffer (struct usb_serial_port *port) 593static int klsi_105_chars_in_buffer (struct tty_struct *tty)
588{ 594{
595 struct usb_serial_port *port = tty->driver_data;
589 int chars = 0; 596 int chars = 0;
590 int i; 597 int i;
591 unsigned long flags; 598 unsigned long flags;
@@ -605,8 +612,9 @@ static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
605 return (chars); 612 return (chars);
606} 613}
607 614
608static int klsi_105_write_room (struct usb_serial_port *port) 615static int klsi_105_write_room (struct tty_struct *tty)
609{ 616{
617 struct usb_serial_port *port = tty->driver_data;
610 unsigned long flags; 618 unsigned long flags;
611 int i; 619 int i;
612 int room = 0; 620 int room = 0;
@@ -660,7 +668,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
660 } else { 668 } else {
661 int bytes_sent = ((__u8 *) data)[0] + 669 int bytes_sent = ((__u8 *) data)[0] +
662 ((unsigned int) ((__u8 *) data)[1] << 8); 670 ((unsigned int) ((__u8 *) data)[1] << 8);
663 tty = port->tty; 671 tty = port->port.tty;
664 /* we should immediately resubmit the URB, before attempting 672 /* we should immediately resubmit the URB, before attempting
665 * to pass the data on to the tty layer. But that needs locking 673 * to pass the data on to the tty layer. But that needs locking
666 * against re-entry an then mixed-up data because of 674 * against re-entry an then mixed-up data because of
@@ -699,11 +707,11 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
699} /* klsi_105_read_bulk_callback */ 707} /* klsi_105_read_bulk_callback */
700 708
701 709
702static void klsi_105_set_termios (struct usb_serial_port *port, 710static void klsi_105_set_termios (struct tty_struct *tty,
711 struct usb_serial_port *port,
703 struct ktermios *old_termios) 712 struct ktermios *old_termios)
704{ 713{
705 struct klsi_105_private *priv = usb_get_serial_port_data(port); 714 struct klsi_105_private *priv = usb_get_serial_port_data(port);
706 struct tty_struct *tty = port->tty;
707 unsigned int iflag = tty->termios->c_iflag; 715 unsigned int iflag = tty->termios->c_iflag;
708 unsigned int old_iflag = old_termios->c_iflag; 716 unsigned int old_iflag = old_termios->c_iflag;
709 unsigned int cflag = tty->termios->c_cflag; 717 unsigned int cflag = tty->termios->c_cflag;
@@ -863,8 +871,9 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
863 871
864 872
865#if 0 873#if 0
866static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) 874static void mct_u232_break_ctl( struct tty_struct *tty, int break_state )
867{ 875{
876 struct usb_serial_port *port = tty->driver_data;
868 struct usb_serial *serial = port->serial; 877 struct usb_serial *serial = port->serial;
869 struct mct_u232_private *priv = (struct mct_u232_private *)port->private; 878 struct mct_u232_private *priv = (struct mct_u232_private *)port->private;
870 unsigned char lcr = priv->last_lcr; 879 unsigned char lcr = priv->last_lcr;
@@ -878,8 +887,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
878} /* mct_u232_break_ctl */ 887} /* mct_u232_break_ctl */
879#endif 888#endif
880 889
881static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) 890static int klsi_105_tiocmget (struct tty_struct *tty, struct file *file)
882{ 891{
892 struct usb_serial_port *port = tty->driver_data;
883 struct klsi_105_private *priv = usb_get_serial_port_data(port); 893 struct klsi_105_private *priv = usb_get_serial_port_data(port);
884 unsigned long flags; 894 unsigned long flags;
885 int rc; 895 int rc;
@@ -900,7 +910,7 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
900 return (int)line_state; 910 return (int)line_state;
901} 911}
902 912
903static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file, 913static int klsi_105_tiocmset (struct tty_struct *tty, struct file *file,
904 unsigned int set, unsigned int clear) 914 unsigned int set, unsigned int clear)
905{ 915{
906 int retval = -EINVAL; 916 int retval = -EINVAL;
@@ -929,14 +939,16 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
929 return retval; 939 return retval;
930} 940}
931 941
932static void klsi_105_throttle (struct usb_serial_port *port) 942static void klsi_105_throttle (struct tty_struct *tty)
933{ 943{
944 struct usb_serial_port *port = tty->driver_data;
934 dbg("%s - port %d", __func__, port->number); 945 dbg("%s - port %d", __func__, port->number);
935 usb_kill_urb(port->read_urb); 946 usb_kill_urb(port->read_urb);
936} 947}
937 948
938static void klsi_105_unthrottle (struct usb_serial_port *port) 949static void klsi_105_unthrottle (struct tty_struct *tty)
939{ 950{
951 struct usb_serial_port *port = tty->driver_data;
940 int result; 952 int result;
941 953
942 dbg("%s - port %d", __func__, port->number); 954 dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 693f00da7c03..40c67f0096b1 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -70,19 +70,22 @@ static int debug;
70/* Function prototypes */ 70/* Function prototypes */
71static int kobil_startup (struct usb_serial *serial); 71static int kobil_startup (struct usb_serial *serial);
72static void kobil_shutdown (struct usb_serial *serial); 72static void kobil_shutdown (struct usb_serial *serial);
73static int kobil_open (struct usb_serial_port *port, struct file *filp); 73static int kobil_open (struct tty_struct *tty,
74static void kobil_close (struct usb_serial_port *port, struct file *filp); 74 struct usb_serial_port *port, struct file *filp);
75static int kobil_write (struct usb_serial_port *port, 75static void kobil_close (struct tty_struct *tty, struct usb_serial_port *port,
76 struct file *filp);
77static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
76 const unsigned char *buf, int count); 78 const unsigned char *buf, int count);
77static int kobil_write_room(struct usb_serial_port *port); 79static int kobil_write_room(struct tty_struct *tty);
78static int kobil_ioctl(struct usb_serial_port *port, struct file *file, 80static int kobil_ioctl(struct tty_struct *tty, struct file *file,
79 unsigned int cmd, unsigned long arg); 81 unsigned int cmd, unsigned long arg);
80static int kobil_tiocmget(struct usb_serial_port *port, struct file *file); 82static int kobil_tiocmget(struct tty_struct *tty, struct file *file);
81static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, 83static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
82 unsigned int set, unsigned int clear); 84 unsigned int set, unsigned int clear);
83static void kobil_read_int_callback( struct urb *urb ); 85static void kobil_read_int_callback( struct urb *urb );
84static void kobil_write_callback( struct urb *purb ); 86static void kobil_write_callback( struct urb *purb );
85static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old); 87static void kobil_set_termios(struct tty_struct *tty,
88 struct usb_serial_port *port, struct ktermios *old);
86 89
87 90
88static struct usb_device_id id_table [] = { 91static struct usb_device_id id_table [] = {
@@ -201,8 +204,8 @@ static void kobil_shutdown (struct usb_serial *serial)
201 dbg("%s - port %d", __func__, serial->port[0]->number); 204 dbg("%s - port %d", __func__, serial->port[0]->number);
202 205
203 for (i=0; i < serial->num_ports; ++i) { 206 for (i=0; i < serial->num_ports; ++i) {
204 while (serial->port[i]->open_count > 0) { 207 while (serial->port[i]->port.count > 0) {
205 kobil_close (serial->port[i], NULL); 208 kobil_close (NULL, serial->port[i], NULL);
206 } 209 }
207 kfree(usb_get_serial_port_data(serial->port[i])); 210 kfree(usb_get_serial_port_data(serial->port[i]));
208 usb_set_serial_port_data(serial->port[i], NULL); 211 usb_set_serial_port_data(serial->port[i], NULL);
@@ -210,7 +213,8 @@ static void kobil_shutdown (struct usb_serial *serial)
210} 213}
211 214
212 215
213static int kobil_open (struct usb_serial_port *port, struct file *filp) 216static int kobil_open(struct tty_struct *tty,
217 struct usb_serial_port *port, struct file *filp)
214{ 218{
215 int result = 0; 219 int result = 0;
216 struct kobil_private *priv; 220 struct kobil_private *priv;
@@ -229,14 +233,15 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
229 * the data through, otherwise it is scheduled, and with high 233 * the data through, otherwise it is scheduled, and with high
230 * data rates (like with OHCI) data can get lost. 234 * data rates (like with OHCI) data can get lost.
231 */ 235 */
232 port->tty->low_latency = 1; 236 if (tty) {
233 237 tty->low_latency = 1;
234 // without this, every push_tty_char is echoed :-( 238
235 port->tty->termios->c_lflag = 0; 239 /* Default to echo off and other sane device settings */
236 port->tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); 240 tty->termios->c_lflag = 0;
237 port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; 241 tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
238 port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) 242 tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
239 243 tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D)
244 }
240 // allocate memory for transfer buffer 245 // allocate memory for transfer buffer
241 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); 246 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
242 if (! transfer_buffer) { 247 if (! transfer_buffer) {
@@ -330,7 +335,8 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
330} 335}
331 336
332 337
333static void kobil_close (struct usb_serial_port *port, struct file *filp) 338static void kobil_close(struct tty_struct *tty,
339 struct usb_serial_port *port, struct file *filp)
334{ 340{
335 dbg("%s - port %d", __func__, port->number); 341 dbg("%s - port %d", __func__, port->number);
336 342
@@ -360,7 +366,7 @@ static void kobil_read_int_callback(struct urb *urb)
360 return; 366 return;
361 } 367 }
362 368
363 tty = port->tty; 369 tty = port->port.tty;
364 if (urb->actual_length) { 370 if (urb->actual_length) {
365 371
366 // BEGIN DEBUG 372 // BEGIN DEBUG
@@ -395,7 +401,7 @@ static void kobil_write_callback( struct urb *purb )
395} 401}
396 402
397 403
398static int kobil_write (struct usb_serial_port *port, 404static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port,
399 const unsigned char *buf, int count) 405 const unsigned char *buf, int count)
400{ 406{
401 int length = 0; 407 int length = 0;
@@ -417,12 +423,9 @@ static int kobil_write (struct usb_serial_port *port,
417 423
418 // Copy data to buffer 424 // Copy data to buffer
419 memcpy (priv->buf + priv->filled, buf, count); 425 memcpy (priv->buf + priv->filled, buf, count);
420
421 usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); 426 usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled);
422
423 priv->filled = priv->filled + count; 427 priv->filled = priv->filled + count;
424 428
425
426 // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol. 429 // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol.
427 if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || 430 if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) ||
428 ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { 431 ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
@@ -478,15 +481,17 @@ static int kobil_write (struct usb_serial_port *port,
478} 481}
479 482
480 483
481static int kobil_write_room (struct usb_serial_port *port) 484static int kobil_write_room (struct tty_struct *tty)
482{ 485{
483 //dbg("%s - port %d", __func__, port->number); 486 //dbg("%s - port %d", __func__, port->number);
487 /* FIXME */
484 return 8; 488 return 8;
485} 489}
486 490
487 491
488static int kobil_tiocmget(struct usb_serial_port *port, struct file *file) 492static int kobil_tiocmget(struct tty_struct *tty, struct file *file)
489{ 493{
494 struct usb_serial_port *port = tty->driver_data;
490 struct kobil_private * priv; 495 struct kobil_private * priv;
491 int result; 496 int result;
492 unsigned char *transfer_buffer; 497 unsigned char *transfer_buffer;
@@ -524,9 +529,10 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file)
524 return result; 529 return result;
525} 530}
526 531
527static int kobil_tiocmset(struct usb_serial_port *port, struct file *file, 532static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
528 unsigned int set, unsigned int clear) 533 unsigned int set, unsigned int clear)
529{ 534{
535 struct usb_serial_port *port = tty->driver_data;
530 struct kobil_private * priv; 536 struct kobil_private * priv;
531 int result; 537 int result;
532 int dtr = 0; 538 int dtr = 0;
@@ -590,12 +596,13 @@ static int kobil_tiocmset(struct usb_serial_port *port, struct file *file,
590 return (result < 0) ? result : 0; 596 return (result < 0) ? result : 0;
591} 597}
592 598
593static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old) 599static void kobil_set_termios(struct tty_struct *tty,
600 struct usb_serial_port *port, struct ktermios *old)
594{ 601{
595 struct kobil_private * priv; 602 struct kobil_private * priv;
596 int result; 603 int result;
597 unsigned short urb_val = 0; 604 unsigned short urb_val = 0;
598 int c_cflag = port->tty->termios->c_cflag; 605 int c_cflag = tty->termios->c_cflag;
599 speed_t speed; 606 speed_t speed;
600 void * settings; 607 void * settings;
601 608
@@ -604,7 +611,7 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
604 // This device doesn't support ioctl calls 611 // This device doesn't support ioctl calls
605 return; 612 return;
606 613
607 switch (speed = tty_get_baud_rate(port->tty)) { 614 switch (speed = tty_get_baud_rate(tty)) {
608 case 1200: 615 case 1200:
609 urb_val = SUSBCR_SBR_1200; 616 urb_val = SUSBCR_SBR_1200;
610 break; 617 break;
@@ -634,8 +641,8 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
634 urb_val |= SUSBCR_SPASB_NoParity; 641 urb_val |= SUSBCR_SPASB_NoParity;
635 strcat(settings, "No Parity"); 642 strcat(settings, "No Parity");
636 } 643 }
637 port->tty->termios->c_cflag &= ~CMSPAR; 644 tty->termios->c_cflag &= ~CMSPAR;
638 tty_encode_baud_rate(port->tty, speed, speed); 645 tty_encode_baud_rate(tty, speed, speed);
639 646
640 result = usb_control_msg( port->serial->dev, 647 result = usb_control_msg( port->serial->dev,
641 usb_rcvctrlpipe(port->serial->dev, 0 ), 648 usb_rcvctrlpipe(port->serial->dev, 0 ),
@@ -650,8 +657,9 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
650 kfree(settings); 657 kfree(settings);
651} 658}
652 659
653static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 660static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
654{ 661{
662 struct usb_serial_port *port = tty->driver_data;
655 struct kobil_private * priv = usb_get_serial_port_data(port); 663 struct kobil_private * priv = usb_get_serial_port_data(port);
656 unsigned char *transfer_buffer; 664 unsigned char *transfer_buffer;
657 int transfer_buffer_length = 8; 665 int transfer_buffer_length = 8;
@@ -662,7 +670,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne
662 return 0; 670 return 0;
663 671
664 switch (cmd) { 672 switch (cmd) {
665 case TCFLSH: // 0x540B 673 case TCFLSH:
666 transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); 674 transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
667 if (! transfer_buffer) 675 if (! transfer_buffer)
668 return -ENOBUFS; 676 return -ENOBUFS;
@@ -680,7 +688,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigne
680 688
681 dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); 689 dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result);
682 kfree(transfer_buffer); 690 kfree(transfer_buffer);
683 return (result < 0) ? -EFAULT : 0; 691 return (result < 0) ? -EIO: 0;
684 default: 692 default:
685 return -ENOIOCTLCMD; 693 return -ENOIOCTLCMD;
686 } 694 }
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 5fc2cef30e39..7bce4302a5f9 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -92,26 +92,25 @@ static int debug;
92 */ 92 */
93static int mct_u232_startup (struct usb_serial *serial); 93static int mct_u232_startup (struct usb_serial *serial);
94static void mct_u232_shutdown (struct usb_serial *serial); 94static void mct_u232_shutdown (struct usb_serial *serial);
95static int mct_u232_open (struct usb_serial_port *port, 95static int mct_u232_open (struct tty_struct *tty,
96 struct usb_serial_port *port,
96 struct file *filp); 97 struct file *filp);
97static void mct_u232_close (struct usb_serial_port *port, 98static void mct_u232_close (struct tty_struct *tty,
99 struct usb_serial_port *port,
98 struct file *filp); 100 struct file *filp);
99static void mct_u232_read_int_callback (struct urb *urb); 101static void mct_u232_read_int_callback (struct urb *urb);
100static void mct_u232_set_termios (struct usb_serial_port *port, 102static void mct_u232_set_termios (struct tty_struct *tty,
103 struct usb_serial_port *port,
101 struct ktermios * old); 104 struct ktermios * old);
102static int mct_u232_ioctl (struct usb_serial_port *port, 105static void mct_u232_break_ctl (struct tty_struct *tty,
103 struct file * file,
104 unsigned int cmd,
105 unsigned long arg);
106static void mct_u232_break_ctl (struct usb_serial_port *port,
107 int break_state ); 106 int break_state );
108static int mct_u232_tiocmget (struct usb_serial_port *port, 107static int mct_u232_tiocmget (struct tty_struct *tty,
109 struct file *file); 108 struct file *file);
110static int mct_u232_tiocmset (struct usb_serial_port *port, 109static int mct_u232_tiocmset (struct tty_struct *tty,
111 struct file *file, unsigned int set, 110 struct file *file, unsigned int set,
112 unsigned int clear); 111 unsigned int clear);
113static void mct_u232_throttle (struct usb_serial_port *port); 112static void mct_u232_throttle (struct tty_struct *tty);
114static void mct_u232_unthrottle (struct usb_serial_port *port); 113static void mct_u232_unthrottle (struct tty_struct *tty);
115 114
116 115
117/* 116/*
@@ -149,7 +148,6 @@ static struct usb_serial_driver mct_u232_device = {
149 .throttle = mct_u232_throttle, 148 .throttle = mct_u232_throttle,
150 .unthrottle = mct_u232_unthrottle, 149 .unthrottle = mct_u232_unthrottle,
151 .read_int_callback = mct_u232_read_int_callback, 150 .read_int_callback = mct_u232_read_int_callback,
152 .ioctl = mct_u232_ioctl,
153 .set_termios = mct_u232_set_termios, 151 .set_termios = mct_u232_set_termios,
154 .break_ctl = mct_u232_break_ctl, 152 .break_ctl = mct_u232_break_ctl,
155 .tiocmget = mct_u232_tiocmget, 153 .tiocmget = mct_u232_tiocmget,
@@ -224,8 +222,8 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value
224 } 222 }
225} 223}
226 224
227static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port, 225static int mct_u232_set_baud_rate(struct tty_struct *tty,
228 speed_t value) 226 struct usb_serial *serial, struct usb_serial_port *port, speed_t value)
229{ 227{
230 __le32 divisor; 228 __le32 divisor;
231 int rc; 229 int rc;
@@ -243,7 +241,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p
243 if (rc < 0) /*FIXME: What value speed results */ 241 if (rc < 0) /*FIXME: What value speed results */
244 err("Set BAUD RATE %d failed (error = %d)", value, rc); 242 err("Set BAUD RATE %d failed (error = %d)", value, rc);
245 else 243 else
246 tty_encode_baud_rate(port->tty, speed, speed); 244 tty_encode_baud_rate(tty, speed, speed);
247 dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); 245 dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor);
248 246
249 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which 247 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which
@@ -272,7 +270,7 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p
272 err("Sending USB device request code %d failed (error = %d)", 270 err("Sending USB device request code %d failed (error = %d)",
273 MCT_U232_SET_UNKNOWN1_REQUEST, rc); 271 MCT_U232_SET_UNKNOWN1_REQUEST, rc);
274 272
275 if (port && C_CRTSCTS(port->tty)) { 273 if (port && C_CRTSCTS(tty)) {
276 cts_enable_byte = 1; 274 cts_enable_byte = 1;
277 } 275 }
278 276
@@ -411,7 +409,8 @@ static void mct_u232_shutdown (struct usb_serial *serial)
411 } 409 }
412} /* mct_u232_shutdown */ 410} /* mct_u232_shutdown */
413 411
414static int mct_u232_open (struct usb_serial_port *port, struct file *filp) 412static int mct_u232_open (struct tty_struct *tty,
413 struct usb_serial_port *port, struct file *filp)
415{ 414{
416 struct usb_serial *serial = port->serial; 415 struct usb_serial *serial = port->serial;
417 struct mct_u232_private *priv = usb_get_serial_port_data(port); 416 struct mct_u232_private *priv = usb_get_serial_port_data(port);
@@ -437,7 +436,7 @@ static int mct_u232_open (struct usb_serial_port *port, struct file *filp)
437 * either. 436 * either.
438 */ 437 */
439 spin_lock_irqsave(&priv->lock, flags); 438 spin_lock_irqsave(&priv->lock, flags);
440 if (port->tty->termios->c_cflag & CBAUD) 439 if (tty && (tty->termios->c_cflag & CBAUD))
441 priv->control_state = TIOCM_DTR | TIOCM_RTS; 440 priv->control_state = TIOCM_DTR | TIOCM_RTS;
442 else 441 else
443 priv->control_state = 0; 442 priv->control_state = 0;
@@ -481,15 +480,16 @@ error:
481} /* mct_u232_open */ 480} /* mct_u232_open */
482 481
483 482
484static void mct_u232_close (struct usb_serial_port *port, struct file *filp) 483static void mct_u232_close(struct tty_struct *tty,
484 struct usb_serial_port *port, struct file *filp)
485{ 485{
486 unsigned int c_cflag; 486 unsigned int c_cflag;
487 unsigned int control_state; 487 unsigned int control_state;
488 struct mct_u232_private *priv = usb_get_serial_port_data(port); 488 struct mct_u232_private *priv = usb_get_serial_port_data(port);
489 dbg("%s port %d", __func__, port->number); 489 dbg("%s port %d", __func__, port->number);
490 490
491 if (port->tty) { 491 if (tty) {
492 c_cflag = port->tty->termios->c_cflag; 492 c_cflag = tty->termios->c_cflag;
493 mutex_lock(&port->serial->disc_mutex); 493 mutex_lock(&port->serial->disc_mutex);
494 if (c_cflag & HUPCL && !port->serial->disconnected) { 494 if (c_cflag & HUPCL && !port->serial->disconnected) {
495 /* drop DTR and RTS */ 495 /* drop DTR and RTS */
@@ -553,7 +553,7 @@ static void mct_u232_read_int_callback (struct urb *urb)
553 */ 553 */
554 if (urb->transfer_buffer_length > 2) { 554 if (urb->transfer_buffer_length > 2) {
555 int i; 555 int i;
556 tty = port->tty; 556 tty = port->port.tty;
557 if (urb->actual_length) { 557 if (urb->actual_length) {
558 for (i = 0; i < urb->actual_length ; ++i) { 558 for (i = 0; i < urb->actual_length ; ++i) {
559 tty_insert_flip_char(tty, data[i], 0); 559 tty_insert_flip_char(tty, data[i], 0);
@@ -583,7 +583,7 @@ static void mct_u232_read_int_callback (struct urb *urb)
583 * to look in to this before committing any code. 583 * to look in to this before committing any code.
584 */ 584 */
585 if (priv->last_lsr & MCT_U232_LSR_ERR) { 585 if (priv->last_lsr & MCT_U232_LSR_ERR) {
586 tty = port->tty; 586 tty = port->port.tty;
587 /* Overrun Error */ 587 /* Overrun Error */
588 if (priv->last_lsr & MCT_U232_LSR_OE) { 588 if (priv->last_lsr & MCT_U232_LSR_OE) {
589 } 589 }
@@ -606,12 +606,13 @@ exit:
606 __func__, retval); 606 __func__, retval);
607} /* mct_u232_read_int_callback */ 607} /* mct_u232_read_int_callback */
608 608
609static void mct_u232_set_termios (struct usb_serial_port *port, 609static void mct_u232_set_termios (struct tty_struct *tty,
610 struct usb_serial_port *port,
610 struct ktermios *old_termios) 611 struct ktermios *old_termios)
611{ 612{
612 struct usb_serial *serial = port->serial; 613 struct usb_serial *serial = port->serial;
613 struct mct_u232_private *priv = usb_get_serial_port_data(port); 614 struct mct_u232_private *priv = usb_get_serial_port_data(port);
614 struct ktermios *termios = port->tty->termios; 615 struct ktermios *termios = tty->termios;
615 unsigned int cflag = termios->c_cflag; 616 unsigned int cflag = termios->c_cflag;
616 unsigned int old_cflag = old_termios->c_cflag; 617 unsigned int old_cflag = old_termios->c_cflag;
617 unsigned long flags; 618 unsigned long flags;
@@ -638,7 +639,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
638 mct_u232_set_modem_ctrl(serial, control_state); 639 mct_u232_set_modem_ctrl(serial, control_state);
639 } 640 }
640 641
641 mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty)); 642 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));
642 643
643 if ((cflag & CBAUD) == B0 ) { 644 if ((cflag & CBAUD) == B0 ) {
644 dbg("%s: baud is B0", __func__); 645 dbg("%s: baud is B0", __func__);
@@ -689,8 +690,9 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
689 spin_unlock_irqrestore(&priv->lock, flags); 690 spin_unlock_irqrestore(&priv->lock, flags);
690} /* mct_u232_set_termios */ 691} /* mct_u232_set_termios */
691 692
692static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) 693static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
693{ 694{
695 struct usb_serial_port *port = tty->driver_data;
694 struct usb_serial *serial = port->serial; 696 struct usb_serial *serial = port->serial;
695 struct mct_u232_private *priv = usb_get_serial_port_data(port); 697 struct mct_u232_private *priv = usb_get_serial_port_data(port);
696 unsigned char lcr; 698 unsigned char lcr;
@@ -709,8 +711,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
709} /* mct_u232_break_ctl */ 711} /* mct_u232_break_ctl */
710 712
711 713
712static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file) 714static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file)
713{ 715{
716 struct usb_serial_port *port = tty->driver_data;
714 struct mct_u232_private *priv = usb_get_serial_port_data(port); 717 struct mct_u232_private *priv = usb_get_serial_port_data(port);
715 unsigned int control_state; 718 unsigned int control_state;
716 unsigned long flags; 719 unsigned long flags;
@@ -724,9 +727,10 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
724 return control_state; 727 return control_state;
725} 728}
726 729
727static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file, 730static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
728 unsigned int set, unsigned int clear) 731 unsigned int set, unsigned int clear)
729{ 732{
733 struct usb_serial_port *port = tty->driver_data;
730 struct usb_serial *serial = port->serial; 734 struct usb_serial *serial = port->serial;
731 struct mct_u232_private *priv = usb_get_serial_port_data(port); 735 struct mct_u232_private *priv = usb_get_serial_port_data(port);
732 unsigned int control_state; 736 unsigned int control_state;
@@ -751,73 +755,46 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
751 return mct_u232_set_modem_ctrl(serial, control_state); 755 return mct_u232_set_modem_ctrl(serial, control_state);
752} 756}
753 757
754static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file, 758static void mct_u232_throttle(struct tty_struct *tty)
755 unsigned int cmd, unsigned long arg)
756{
757 dbg("%scmd=0x%x", __func__, cmd);
758
759 /* Based on code from acm.c and others */
760 switch (cmd) {
761 case TIOCMIWAIT:
762 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
763 /* TODO */
764 return( 0 );
765
766 case TIOCGICOUNT:
767 /* return count of modemline transitions */
768 /* TODO */
769 return 0;
770
771 default:
772 dbg("%s: arg not supported - 0x%04x", __func__,cmd);
773 return(-ENOIOCTLCMD);
774 break;
775 }
776 return 0;
777} /* mct_u232_ioctl */
778
779static void mct_u232_throttle (struct usb_serial_port *port)
780{ 759{
760 struct usb_serial_port *port = tty->driver_data;
781 struct mct_u232_private *priv = usb_get_serial_port_data(port); 761 struct mct_u232_private *priv = usb_get_serial_port_data(port);
782 unsigned long flags; 762 unsigned long flags;
783 unsigned int control_state; 763 unsigned int control_state;
784 struct tty_struct *tty;
785 764
786 tty = port->tty;
787 dbg("%s - port %d", __func__, port->number); 765 dbg("%s - port %d", __func__, port->number);
788 766
789 spin_lock_irqsave(&priv->lock, flags); 767 spin_lock_irqsave(&priv->lock, flags);
790 priv->rx_flags |= THROTTLED; 768 priv->rx_flags |= THROTTLED;
791 if (C_CRTSCTS(tty)) { 769 if (C_CRTSCTS(tty)) {
792 priv->control_state &= ~TIOCM_RTS; 770 priv->control_state &= ~TIOCM_RTS;
793 control_state = priv->control_state; 771 control_state = priv->control_state;
794 spin_unlock_irqrestore(&priv->lock, flags); 772 spin_unlock_irqrestore(&priv->lock, flags);
795 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 773 (void) mct_u232_set_modem_ctrl(port->serial, control_state);
796 } else { 774 } else {
797 spin_unlock_irqrestore(&priv->lock, flags); 775 spin_unlock_irqrestore(&priv->lock, flags);
798 } 776 }
799} 777}
800 778
801 779
802static void mct_u232_unthrottle (struct usb_serial_port *port) 780static void mct_u232_unthrottle(struct tty_struct *tty)
803{ 781{
782 struct usb_serial_port *port = tty->driver_data;
804 struct mct_u232_private *priv = usb_get_serial_port_data(port); 783 struct mct_u232_private *priv = usb_get_serial_port_data(port);
805 unsigned long flags; 784 unsigned long flags;
806 unsigned int control_state; 785 unsigned int control_state;
807 struct tty_struct *tty;
808 786
809 dbg("%s - port %d", __func__, port->number); 787 dbg("%s - port %d", __func__, port->number);
810 788
811 tty = port->tty;
812 spin_lock_irqsave(&priv->lock, flags); 789 spin_lock_irqsave(&priv->lock, flags);
813 if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) { 790 if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) {
814 priv->rx_flags &= ~THROTTLED; 791 priv->rx_flags &= ~THROTTLED;
815 priv->control_state |= TIOCM_RTS; 792 priv->control_state |= TIOCM_RTS;
816 control_state = priv->control_state; 793 control_state = priv->control_state;
817 spin_unlock_irqrestore(&priv->lock, flags); 794 spin_unlock_irqrestore(&priv->lock, flags);
818 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 795 (void) mct_u232_set_modem_ctrl(port->serial, control_state);
819 } else { 796 } else {
820 spin_unlock_irqrestore(&priv->lock, flags); 797 spin_unlock_irqrestore(&priv->lock, flags);
821 } 798 }
822} 799}
823 800
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 50f1fe263338..d47f0814ce2d 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -218,7 +218,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
218 218
219 data = urb->transfer_buffer; 219 data = urb->transfer_buffer;
220 220
221 tty = port->tty; 221 tty = port->port.tty;
222 if (tty && urb->actual_length) { 222 if (tty && urb->actual_length) {
223 tty_buffer_request_room(tty, urb->actual_length); 223 tty_buffer_request_room(tty, urb->actual_length);
224 tty_insert_flip_string(tty, data, urb->actual_length); 224 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -264,7 +264,7 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
264 264
265 dbg("Entering ........."); 265 dbg("Entering .........");
266 266
267 tty = mos7720_port->port->tty; 267 tty = mos7720_port->port->port.tty;
268 268
269 if (tty && mos7720_port->open) 269 if (tty && mos7720_port->open)
270 tty_wakeup(tty); 270 tty_wakeup(tty);
@@ -320,7 +320,8 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
320 return status; 320 return status;
321} 321}
322 322
323static int mos7720_open(struct usb_serial_port *port, struct file * filp) 323static int mos7720_open(struct tty_struct *tty,
324 struct usb_serial_port *port, struct file * filp)
324{ 325{
325 struct usb_serial *serial; 326 struct usb_serial *serial;
326 struct usb_serial_port *port0; 327 struct usb_serial_port *port0;
@@ -443,14 +444,12 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
443 data = 0x0c; 444 data = 0x0c;
444 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); 445 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
445 446
446//Matrix
447
448 /* force low_latency on so that our tty_push actually forces * 447 /* force low_latency on so that our tty_push actually forces *
449 * the data through,otherwise it is scheduled, and with * 448 * the data through,otherwise it is scheduled, and with *
450 * high data rates (like with OHCI) data can get lost. */ 449 * high data rates (like with OHCI) data can get lost. */
451 450
452 if (port->tty) 451 if (tty)
453 port->tty->low_latency = 1; 452 tty->low_latency = 1;
454 453
455 /* see if we've set up our endpoint info yet * 454 /* see if we've set up our endpoint info yet *
456 * (can't set it up in mos7720_startup as the * 455 * (can't set it up in mos7720_startup as the *
@@ -515,8 +514,9 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
515 * system, 514 * system,
516 * Otherwise we return a negative error number. 515 * Otherwise we return a negative error number.
517 */ 516 */
518static int mos7720_chars_in_buffer(struct usb_serial_port *port) 517static int mos7720_chars_in_buffer(struct tty_struct *tty)
519{ 518{
519 struct usb_serial_port *port = tty->driver_data;
520 int i; 520 int i;
521 int chars = 0; 521 int chars = 0;
522 struct moschip_port *mos7720_port; 522 struct moschip_port *mos7720_port;
@@ -537,7 +537,8 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port)
537 return chars; 537 return chars;
538} 538}
539 539
540static void mos7720_close(struct usb_serial_port *port, struct file *filp) 540static void mos7720_close(struct tty_struct *tty,
541 struct usb_serial_port *port, struct file *filp)
541{ 542{
542 struct usb_serial *serial; 543 struct usb_serial *serial;
543 struct moschip_port *mos7720_port; 544 struct moschip_port *mos7720_port;
@@ -588,8 +589,9 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp)
588 dbg("Leaving %s", __func__); 589 dbg("Leaving %s", __func__);
589} 590}
590 591
591static void mos7720_break(struct usb_serial_port *port, int break_state) 592static void mos7720_break(struct tty_struct *tty, int break_state)
592{ 593{
594 struct usb_serial_port *port = tty->driver_data;
593 unsigned char data; 595 unsigned char data;
594 struct usb_serial *serial; 596 struct usb_serial *serial;
595 struct moschip_port *mos7720_port; 597 struct moschip_port *mos7720_port;
@@ -621,8 +623,9 @@ static void mos7720_break(struct usb_serial_port *port, int break_state)
621 * If successful, we return the amount of room that we have for this port 623 * If successful, we return the amount of room that we have for this port
622 * Otherwise we return a negative error number. 624 * Otherwise we return a negative error number.
623 */ 625 */
624static int mos7720_write_room(struct usb_serial_port *port) 626static int mos7720_write_room(struct tty_struct *tty)
625{ 627{
628 struct usb_serial_port *port = tty->driver_data;
626 struct moschip_port *mos7720_port; 629 struct moschip_port *mos7720_port;
627 int room = 0; 630 int room = 0;
628 int i; 631 int i;
@@ -645,8 +648,8 @@ static int mos7720_write_room(struct usb_serial_port *port)
645 return room; 648 return room;
646} 649}
647 650
648static int mos7720_write(struct usb_serial_port *port, 651static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
649 const unsigned char *data, int count) 652 const unsigned char *data, int count)
650{ 653{
651 int status; 654 int status;
652 int i; 655 int i;
@@ -719,10 +722,10 @@ exit:
719 return bytes_sent; 722 return bytes_sent;
720} 723}
721 724
722static void mos7720_throttle(struct usb_serial_port *port) 725static void mos7720_throttle(struct tty_struct *tty)
723{ 726{
727 struct usb_serial_port *port = tty->driver_data;
724 struct moschip_port *mos7720_port; 728 struct moschip_port *mos7720_port;
725 struct tty_struct *tty;
726 int status; 729 int status;
727 730
728 dbg("%s- port %d\n", __func__, port->number); 731 dbg("%s- port %d\n", __func__, port->number);
@@ -739,16 +742,10 @@ static void mos7720_throttle(struct usb_serial_port *port)
739 742
740 dbg("%s: Entering ..........", __func__); 743 dbg("%s: Entering ..........", __func__);
741 744
742 tty = port->tty;
743 if (!tty) {
744 dbg("%s - no tty available", __func__);
745 return;
746 }
747
748 /* if we are implementing XON/XOFF, send the stop character */ 745 /* if we are implementing XON/XOFF, send the stop character */
749 if (I_IXOFF(tty)) { 746 if (I_IXOFF(tty)) {
750 unsigned char stop_char = STOP_CHAR(tty); 747 unsigned char stop_char = STOP_CHAR(tty);
751 status = mos7720_write(port, &stop_char, 1); 748 status = mos7720_write(tty, port, &stop_char, 1);
752 if (status <= 0) 749 if (status <= 0)
753 return; 750 return;
754 } 751 }
@@ -764,11 +761,11 @@ static void mos7720_throttle(struct usb_serial_port *port)
764 } 761 }
765} 762}
766 763
767static void mos7720_unthrottle(struct usb_serial_port *port) 764static void mos7720_unthrottle(struct tty_struct *tty)
768{ 765{
769 struct tty_struct *tty; 766 struct usb_serial_port *port = tty->driver_data;
770 int status;
771 struct moschip_port *mos7720_port = usb_get_serial_port_data(port); 767 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
768 int status;
772 769
773 if (mos7720_port == NULL) 770 if (mos7720_port == NULL)
774 return; 771 return;
@@ -780,16 +777,10 @@ static void mos7720_unthrottle(struct usb_serial_port *port)
780 777
781 dbg("%s: Entering ..........", __func__); 778 dbg("%s: Entering ..........", __func__);
782 779
783 tty = port->tty;
784 if (!tty) {
785 dbg("%s - no tty available", __func__);
786 return;
787 }
788
789 /* if we are implementing XON/XOFF, send the start character */ 780 /* if we are implementing XON/XOFF, send the start character */
790 if (I_IXOFF(tty)) { 781 if (I_IXOFF(tty)) {
791 unsigned char start_char = START_CHAR(tty); 782 unsigned char start_char = START_CHAR(tty);
792 status = mos7720_write(port, &start_char, 1); 783 status = mos7720_write(tty, port, &start_char, 1);
793 if (status <= 0) 784 if (status <= 0)
794 return; 785 return;
795 } 786 }
@@ -1011,12 +1002,12 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
1011 * This routine is called to set the UART on the device to match 1002 * This routine is called to set the UART on the device to match
1012 * the specified new settings. 1003 * the specified new settings.
1013 */ 1004 */
1014static void change_port_settings(struct moschip_port *mos7720_port, 1005static void change_port_settings(struct tty_struct *tty,
1006 struct moschip_port *mos7720_port,
1015 struct ktermios *old_termios) 1007 struct ktermios *old_termios)
1016{ 1008{
1017 struct usb_serial_port *port; 1009 struct usb_serial_port *port;
1018 struct usb_serial *serial; 1010 struct usb_serial *serial;
1019 struct tty_struct *tty;
1020 int baud; 1011 int baud;
1021 unsigned cflag; 1012 unsigned cflag;
1022 unsigned iflag; 1013 unsigned iflag;
@@ -1042,8 +1033,6 @@ static void change_port_settings(struct moschip_port *mos7720_port,
1042 return; 1033 return;
1043 } 1034 }
1044 1035
1045 tty = mos7720_port->port->tty;
1046
1047 dbg("%s: Entering ..........", __func__); 1036 dbg("%s: Entering ..........", __func__);
1048 1037
1049 lData = UART_LCR_WLEN8; 1038 lData = UART_LCR_WLEN8;
@@ -1198,14 +1187,13 @@ static void change_port_settings(struct moschip_port *mos7720_port,
1198 * this function is called by the tty driver when it wants to change the 1187 * this function is called by the tty driver when it wants to change the
1199 * termios structure. 1188 * termios structure.
1200 */ 1189 */
1201static void mos7720_set_termios(struct usb_serial_port *port, 1190static void mos7720_set_termios(struct tty_struct *tty,
1202 struct ktermios *old_termios) 1191 struct usb_serial_port *port, struct ktermios *old_termios)
1203{ 1192{
1204 int status; 1193 int status;
1205 unsigned int cflag; 1194 unsigned int cflag;
1206 struct usb_serial *serial; 1195 struct usb_serial *serial;
1207 struct moschip_port *mos7720_port; 1196 struct moschip_port *mos7720_port;
1208 struct tty_struct *tty;
1209 1197
1210 serial = port->serial; 1198 serial = port->serial;
1211 1199
@@ -1214,9 +1202,6 @@ static void mos7720_set_termios(struct usb_serial_port *port,
1214 if (mos7720_port == NULL) 1202 if (mos7720_port == NULL)
1215 return; 1203 return;
1216 1204
1217 tty = port->tty;
1218
1219
1220 if (!mos7720_port->open) { 1205 if (!mos7720_port->open) {
1221 dbg("%s - port not opened", __func__); 1206 dbg("%s - port not opened", __func__);
1222 return; 1207 return;
@@ -1237,7 +1222,7 @@ static void mos7720_set_termios(struct usb_serial_port *port,
1237 dbg("%s - port %d", __func__, port->number); 1222 dbg("%s - port %d", __func__, port->number);
1238 1223
1239 /* change the port settings to the new ones specified */ 1224 /* change the port settings to the new ones specified */
1240 change_port_settings(mos7720_port, old_termios); 1225 change_port_settings(tty, mos7720_port, old_termios);
1241 1226
1242 if(!port->read_urb) { 1227 if(!port->read_urb) {
1243 dbg("%s","URB KILLED !!!!!\n"); 1228 dbg("%s","URB KILLED !!!!!\n");
@@ -1264,13 +1249,13 @@ static void mos7720_set_termios(struct usb_serial_port *port,
1264 * transmit holding register is empty. This functionality 1249 * transmit holding register is empty. This functionality
1265 * allows an RS485 driver to be written in user space. 1250 * allows an RS485 driver to be written in user space.
1266 */ 1251 */
1267static int get_lsr_info(struct moschip_port *mos7720_port, 1252static int get_lsr_info(struct tty_struct *tty, struct moschip_port *mos7720_port,
1268 unsigned int __user *value) 1253 unsigned int __user *value)
1269{ 1254{
1270 int count; 1255 int count;
1271 unsigned int result = 0; 1256 unsigned int result = 0;
1272 1257
1273 count = mos7720_chars_in_buffer(mos7720_port->port); 1258 count = mos7720_chars_in_buffer(tty);
1274 if (count == 0) { 1259 if (count == 0) {
1275 dbg("%s -- Empty", __func__); 1260 dbg("%s -- Empty", __func__);
1276 result = TIOCSER_TEMT; 1261 result = TIOCSER_TEMT;
@@ -1290,7 +1275,7 @@ static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1290 unsigned int __user *value) 1275 unsigned int __user *value)
1291{ 1276{
1292 unsigned int result = 0; 1277 unsigned int result = 0;
1293 struct tty_struct *tty = mos7720_port->port->tty; 1278 struct tty_struct *tty = mos7720_port->port->port.tty;
1294 1279
1295 if (!tty) 1280 if (!tty)
1296 return -ENOIOCTLCMD; 1281 return -ENOIOCTLCMD;
@@ -1407,9 +1392,10 @@ static int get_serial_info(struct moschip_port *mos7720_port,
1407 return 0; 1392 return 0;
1408} 1393}
1409 1394
1410static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, 1395static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
1411 unsigned int cmd, unsigned long arg) 1396 unsigned int cmd, unsigned long arg)
1412{ 1397{
1398 struct usb_serial_port *port = tty->driver_data;
1413 struct moschip_port *mos7720_port; 1399 struct moschip_port *mos7720_port;
1414 struct async_icount cnow; 1400 struct async_icount cnow;
1415 struct async_icount cprev; 1401 struct async_icount cprev;
@@ -1431,9 +1417,10 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1431 1417
1432 case TIOCSERGETLSR: 1418 case TIOCSERGETLSR:
1433 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1419 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1434 return get_lsr_info(mos7720_port, (unsigned int __user *)arg); 1420 return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg);
1435 return 0; 1421 return 0;
1436 1422
1423 /* FIXME: These should be using the mode methods */
1437 case TIOCMBIS: 1424 case TIOCMBIS:
1438 case TIOCMBIC: 1425 case TIOCMBIC:
1439 case TIOCMSET: 1426 case TIOCMSET:
@@ -1452,10 +1439,6 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1452 return get_serial_info(mos7720_port, 1439 return get_serial_info(mos7720_port,
1453 (struct serial_struct __user *)arg); 1440 (struct serial_struct __user *)arg);
1454 1441
1455 case TIOCSSERIAL:
1456 dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
1457 break;
1458
1459 case TIOCMIWAIT: 1442 case TIOCMIWAIT:
1460 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 1443 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
1461 cprev = mos7720_port->icount; 1444 cprev = mos7720_port->icount;
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 78f2f6db494d..2b1fded6619d 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -710,7 +710,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
710 dbg("%s", "Entering ........... \n"); 710 dbg("%s", "Entering ........... \n");
711 711
712 if (urb->actual_length) { 712 if (urb->actual_length) {
713 tty = mos7840_port->port->tty; 713 tty = mos7840_port->port->port.tty;
714 if (tty) { 714 if (tty) {
715 tty_buffer_request_room(tty, urb->actual_length); 715 tty_buffer_request_room(tty, urb->actual_length);
716 tty_insert_flip_string(tty, data, urb->actual_length); 716 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -774,7 +774,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
774 774
775 dbg("%s \n", "Entering ........."); 775 dbg("%s \n", "Entering .........");
776 776
777 tty = mos7840_port->port->tty; 777 tty = mos7840_port->port->port.tty;
778 778
779 if (tty && mos7840_port->open) 779 if (tty && mos7840_port->open)
780 tty_wakeup(tty); 780 tty_wakeup(tty);
@@ -804,7 +804,8 @@ static int mos7840_serial_probe(struct usb_serial *serial,
804 * Otherwise we return a negative error number. 804 * Otherwise we return a negative error number.
805 *****************************************************************************/ 805 *****************************************************************************/
806 806
807static int mos7840_open(struct usb_serial_port *port, struct file *filp) 807static int mos7840_open(struct tty_struct *tty,
808 struct usb_serial_port *port, struct file *filp)
808{ 809{
809 int response; 810 int response;
810 int j; 811 int j;
@@ -1008,8 +1009,8 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1008 * the data through,otherwise it is scheduled, and with * 1009 * the data through,otherwise it is scheduled, and with *
1009 * high data rates (like with OHCI) data can get lost. */ 1010 * high data rates (like with OHCI) data can get lost. */
1010 1011
1011 if (port->tty) 1012 if (tty)
1012 port->tty->low_latency = 1; 1013 tty->low_latency = 1;
1013/* Check to see if we've set up our endpoint info yet * 1014/* Check to see if we've set up our endpoint info yet *
1014 * (can't set it up in mos7840_startup as the structures * 1015 * (can't set it up in mos7840_startup as the structures *
1015 * were not set up at that time.) */ 1016 * were not set up at that time.) */
@@ -1104,11 +1105,12 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1104 * been written, but hasn't made it out the port yet) 1105 * been written, but hasn't made it out the port yet)
1105 * If successful, we return the number of bytes left to be written in the 1106 * If successful, we return the number of bytes left to be written in the
1106 * system, 1107 * system,
1107 * Otherwise we return a negative error number. 1108 * Otherwise we return zero.
1108 *****************************************************************************/ 1109 *****************************************************************************/
1109 1110
1110static int mos7840_chars_in_buffer(struct usb_serial_port *port) 1111static int mos7840_chars_in_buffer(struct tty_struct *tty)
1111{ 1112{
1113 struct usb_serial_port *port = tty->driver_data;
1112 int i; 1114 int i;
1113 int chars = 0; 1115 int chars = 0;
1114 unsigned long flags; 1116 unsigned long flags;
@@ -1118,21 +1120,19 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1118 1120
1119 if (mos7840_port_paranoia_check(port, __func__)) { 1121 if (mos7840_port_paranoia_check(port, __func__)) {
1120 dbg("%s", "Invalid port \n"); 1122 dbg("%s", "Invalid port \n");
1121 return -1; 1123 return 0;
1122 } 1124 }
1123 1125
1124 mos7840_port = mos7840_get_port_private(port); 1126 mos7840_port = mos7840_get_port_private(port);
1125 if (mos7840_port == NULL) { 1127 if (mos7840_port == NULL) {
1126 dbg("%s \n", "mos7840_break:leaving ..........."); 1128 dbg("%s \n", "mos7840_break:leaving ...........");
1127 return -1; 1129 return 0;
1128 } 1130 }
1129 1131
1130 spin_lock_irqsave(&mos7840_port->pool_lock,flags); 1132 spin_lock_irqsave(&mos7840_port->pool_lock,flags);
1131 for (i = 0; i < NUM_URBS; ++i) { 1133 for (i = 0; i < NUM_URBS; ++i)
1132 if (mos7840_port->busy[i]) { 1134 if (mos7840_port->busy[i])
1133 chars += URB_TRANSFER_BUFFER_SIZE; 1135 chars += URB_TRANSFER_BUFFER_SIZE;
1134 }
1135 }
1136 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags); 1136 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags);
1137 dbg("%s - returns %d", __func__, chars); 1137 dbg("%s - returns %d", __func__, chars);
1138 return chars; 1138 return chars;
@@ -1149,7 +1149,8 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1149 * 3. A timeout of 3 seconds without activity has expired 1149 * 3. A timeout of 3 seconds without activity has expired
1150 * 1150 *
1151 ************************************************************************/ 1151 ************************************************************************/
1152static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) 1152static void mos7840_block_until_tx_empty(struct tty_struct *tty,
1153 struct moschip_port *mos7840_port)
1153{ 1154{
1154 int timeout = HZ / 10; 1155 int timeout = HZ / 10;
1155 int wait = 30; 1156 int wait = 30;
@@ -1157,7 +1158,7 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
1157 1158
1158 while (1) { 1159 while (1) {
1159 1160
1160 count = mos7840_chars_in_buffer(mos7840_port->port); 1161 count = mos7840_chars_in_buffer(tty);
1161 1162
1162 /* Check for Buffer status */ 1163 /* Check for Buffer status */
1163 if (count <= 0) { 1164 if (count <= 0) {
@@ -1185,7 +1186,8 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
1185 * this function is called by the tty driver when a port is closed 1186 * this function is called by the tty driver when a port is closed
1186 *****************************************************************************/ 1187 *****************************************************************************/
1187 1188
1188static void mos7840_close(struct usb_serial_port *port, struct file *filp) 1189static void mos7840_close(struct tty_struct *tty,
1190 struct usb_serial_port *port, struct file *filp)
1189{ 1191{
1190 struct usb_serial *serial; 1192 struct usb_serial *serial;
1191 struct moschip_port *mos7840_port; 1193 struct moschip_port *mos7840_port;
@@ -1226,20 +1228,17 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1226 } 1228 }
1227 } 1229 }
1228 1230
1229 if (serial->dev) { 1231 if (serial->dev)
1230 /* flush and block until tx is empty */ 1232 /* flush and block until tx is empty */
1231 mos7840_block_until_tx_empty(mos7840_port); 1233 mos7840_block_until_tx_empty(tty, mos7840_port);
1232 }
1233 1234
1234 /* While closing port, shutdown all bulk read, write * 1235 /* While closing port, shutdown all bulk read, write *
1235 * and interrupt read if they exists */ 1236 * and interrupt read if they exists */
1236 if (serial->dev) { 1237 if (serial->dev) {
1237
1238 if (mos7840_port->write_urb) { 1238 if (mos7840_port->write_urb) {
1239 dbg("%s", "Shutdown bulk write\n"); 1239 dbg("%s", "Shutdown bulk write\n");
1240 usb_kill_urb(mos7840_port->write_urb); 1240 usb_kill_urb(mos7840_port->write_urb);
1241 } 1241 }
1242
1243 if (mos7840_port->read_urb) { 1242 if (mos7840_port->read_urb) {
1244 dbg("%s", "Shutdown bulk read\n"); 1243 dbg("%s", "Shutdown bulk read\n");
1245 usb_kill_urb(mos7840_port->read_urb); 1244 usb_kill_urb(mos7840_port->read_urb);
@@ -1247,11 +1246,10 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1247 if ((&mos7840_port->control_urb)) { 1246 if ((&mos7840_port->control_urb)) {
1248 dbg("%s", "Shutdown control read\n"); 1247 dbg("%s", "Shutdown control read\n");
1249 // usb_kill_urb (mos7840_port->control_urb); 1248 // usb_kill_urb (mos7840_port->control_urb);
1250
1251 } 1249 }
1252 } 1250 }
1253// if(mos7840_port->ctrl_buf != NULL) 1251// if(mos7840_port->ctrl_buf != NULL)
1254// kfree(mos7840_port->ctrl_buf); 1252// kfree(mos7840_port->ctrl_buf);
1255 port0->open_ports--; 1253 port0->open_ports--;
1256 dbg("mos7840_num_open_ports in close%d:in port%d\n", 1254 dbg("mos7840_num_open_ports in close%d:in port%d\n",
1257 port0->open_ports, port->number); 1255 port0->open_ports, port->number);
@@ -1293,15 +1291,15 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1293 * 1291 *
1294 ************************************************************************/ 1292 ************************************************************************/
1295 1293
1296static void mos7840_block_until_chase_response(struct moschip_port 1294static void mos7840_block_until_chase_response(struct tty_struct *tty,
1297 *mos7840_port) 1295 struct moschip_port *mos7840_port)
1298{ 1296{
1299 int timeout = 1 * HZ; 1297 int timeout = 1 * HZ;
1300 int wait = 10; 1298 int wait = 10;
1301 int count; 1299 int count;
1302 1300
1303 while (1) { 1301 while (1) {
1304 count = mos7840_chars_in_buffer(mos7840_port->port); 1302 count = mos7840_chars_in_buffer(tty);
1305 1303
1306 /* Check for Buffer status */ 1304 /* Check for Buffer status */
1307 if (count <= 0) { 1305 if (count <= 0) {
@@ -1328,8 +1326,9 @@ static void mos7840_block_until_chase_response(struct moschip_port
1328 * mos7840_break 1326 * mos7840_break
1329 * this function sends a break to the port 1327 * this function sends a break to the port
1330 *****************************************************************************/ 1328 *****************************************************************************/
1331static void mos7840_break(struct usb_serial_port *port, int break_state) 1329static void mos7840_break(struct tty_struct *tty, int break_state)
1332{ 1330{
1331 struct usb_serial_port *port = tty->driver_data;
1333 unsigned char data; 1332 unsigned char data;
1334 struct usb_serial *serial; 1333 struct usb_serial *serial;
1335 struct moschip_port *mos7840_port; 1334 struct moschip_port *mos7840_port;
@@ -1354,17 +1353,14 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
1354 return; 1353 return;
1355 } 1354 }
1356 1355
1357 if (serial->dev) { 1356 if (serial->dev)
1358
1359 /* flush and block until tx is empty */ 1357 /* flush and block until tx is empty */
1360 mos7840_block_until_chase_response(mos7840_port); 1358 mos7840_block_until_chase_response(tty, mos7840_port);
1361 }
1362 1359
1363 if (break_state == -1) { 1360 if (break_state == -1)
1364 data = mos7840_port->shadowLCR | LCR_SET_BREAK; 1361 data = mos7840_port->shadowLCR | LCR_SET_BREAK;
1365 } else { 1362 else
1366 data = mos7840_port->shadowLCR & ~LCR_SET_BREAK; 1363 data = mos7840_port->shadowLCR & ~LCR_SET_BREAK;
1367 }
1368 1364
1369 mos7840_port->shadowLCR = data; 1365 mos7840_port->shadowLCR = data;
1370 dbg("mcs7840_break mos7840_port->shadowLCR is %x\n", 1366 dbg("mcs7840_break mos7840_port->shadowLCR is %x\n",
@@ -1383,8 +1379,9 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
1383 * Otherwise we return a negative error number. 1379 * Otherwise we return a negative error number.
1384 *****************************************************************************/ 1380 *****************************************************************************/
1385 1381
1386static int mos7840_write_room(struct usb_serial_port *port) 1382static int mos7840_write_room(struct tty_struct *tty)
1387{ 1383{
1384 struct usb_serial_port *port = tty->driver_data;
1388 int i; 1385 int i;
1389 int room = 0; 1386 int room = 0;
1390 unsigned long flags; 1387 unsigned long flags;
@@ -1426,7 +1423,7 @@ static int mos7840_write_room(struct usb_serial_port *port)
1426 * return a negative error number. 1423 * return a negative error number.
1427 *****************************************************************************/ 1424 *****************************************************************************/
1428 1425
1429static int mos7840_write(struct usb_serial_port *port, 1426static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1430 const unsigned char *data, int count) 1427 const unsigned char *data, int count)
1431{ 1428{
1432 int status; 1429 int status;
@@ -1555,8 +1552,7 @@ static int mos7840_write(struct usb_serial_port *port,
1555 mos7840_port->icount.tx += transfer_size; 1552 mos7840_port->icount.tx += transfer_size;
1556 smp_wmb(); 1553 smp_wmb();
1557 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); 1554 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
1558 exit: 1555exit:
1559
1560 return bytes_sent; 1556 return bytes_sent;
1561 1557
1562} 1558}
@@ -1567,10 +1563,10 @@ static int mos7840_write(struct usb_serial_port *port,
1567 * being read from the port. 1563 * being read from the port.
1568 *****************************************************************************/ 1564 *****************************************************************************/
1569 1565
1570static void mos7840_throttle(struct usb_serial_port *port) 1566static void mos7840_throttle(struct tty_struct *tty)
1571{ 1567{
1568 struct usb_serial_port *port = tty->driver_data;
1572 struct moschip_port *mos7840_port; 1569 struct moschip_port *mos7840_port;
1573 struct tty_struct *tty;
1574 int status; 1570 int status;
1575 1571
1576 if (mos7840_port_paranoia_check(port, __func__)) { 1572 if (mos7840_port_paranoia_check(port, __func__)) {
@@ -1592,32 +1588,21 @@ static void mos7840_throttle(struct usb_serial_port *port)
1592 1588
1593 dbg("%s", "Entering .......... \n"); 1589 dbg("%s", "Entering .......... \n");
1594 1590
1595 tty = port->tty;
1596 if (!tty) {
1597 dbg("%s - no tty available", __func__);
1598 return;
1599 }
1600
1601 /* if we are implementing XON/XOFF, send the stop character */ 1591 /* if we are implementing XON/XOFF, send the stop character */
1602 if (I_IXOFF(tty)) { 1592 if (I_IXOFF(tty)) {
1603 unsigned char stop_char = STOP_CHAR(tty); 1593 unsigned char stop_char = STOP_CHAR(tty);
1604 status = mos7840_write(port, &stop_char, 1); 1594 status = mos7840_write(tty, port, &stop_char, 1);
1605 if (status <= 0) { 1595 if (status <= 0)
1606 return; 1596 return;
1607 }
1608 } 1597 }
1609
1610 /* if we are implementing RTS/CTS, toggle that line */ 1598 /* if we are implementing RTS/CTS, toggle that line */
1611 if (tty->termios->c_cflag & CRTSCTS) { 1599 if (tty->termios->c_cflag & CRTSCTS) {
1612 mos7840_port->shadowMCR &= ~MCR_RTS; 1600 mos7840_port->shadowMCR &= ~MCR_RTS;
1613 status = 0; 1601 status = 0;
1614 status = 1602 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1615 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1616 mos7840_port->shadowMCR); 1603 mos7840_port->shadowMCR);
1617 1604 if (status < 0)
1618 if (status < 0) {
1619 return; 1605 return;
1620 }
1621 } 1606 }
1622 1607
1623 return; 1608 return;
@@ -1628,9 +1613,9 @@ static void mos7840_throttle(struct usb_serial_port *port)
1628 * this function is called by the tty driver when it wants to resume the data 1613 * this function is called by the tty driver when it wants to resume the data
1629 * being read from the port (called after SerialThrottle is called) 1614 * being read from the port (called after SerialThrottle is called)
1630 *****************************************************************************/ 1615 *****************************************************************************/
1631static void mos7840_unthrottle(struct usb_serial_port *port) 1616static void mos7840_unthrottle(struct tty_struct *tty)
1632{ 1617{
1633 struct tty_struct *tty; 1618 struct usb_serial_port *port = tty->driver_data;
1634 int status; 1619 int status;
1635 struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1620 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1636 1621
@@ -1649,38 +1634,28 @@ static void mos7840_unthrottle(struct usb_serial_port *port)
1649 1634
1650 dbg("%s", "Entering .......... \n"); 1635 dbg("%s", "Entering .......... \n");
1651 1636
1652 tty = port->tty;
1653 if (!tty) {
1654 dbg("%s - no tty available", __func__);
1655 return;
1656 }
1657
1658 /* if we are implementing XON/XOFF, send the start character */ 1637 /* if we are implementing XON/XOFF, send the start character */
1659 if (I_IXOFF(tty)) { 1638 if (I_IXOFF(tty)) {
1660 unsigned char start_char = START_CHAR(tty); 1639 unsigned char start_char = START_CHAR(tty);
1661 status = mos7840_write(port, &start_char, 1); 1640 status = mos7840_write(tty, port, &start_char, 1);
1662 if (status <= 0) { 1641 if (status <= 0)
1663 return; 1642 return;
1664 }
1665 } 1643 }
1666 1644
1667 /* if we are implementing RTS/CTS, toggle that line */ 1645 /* if we are implementing RTS/CTS, toggle that line */
1668 if (tty->termios->c_cflag & CRTSCTS) { 1646 if (tty->termios->c_cflag & CRTSCTS) {
1669 mos7840_port->shadowMCR |= MCR_RTS; 1647 mos7840_port->shadowMCR |= MCR_RTS;
1670 status = 0; 1648 status = 0;
1671 status = 1649 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1672 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1673 mos7840_port->shadowMCR); 1650 mos7840_port->shadowMCR);
1674 if (status < 0) { 1651 if (status < 0)
1675 return; 1652 return;
1676 }
1677 } 1653 }
1678
1679 return;
1680} 1654}
1681 1655
1682static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file) 1656static int mos7840_tiocmget(struct tty_struct *tty, struct file *file)
1683{ 1657{
1658 struct usb_serial_port *port = tty->driver_data;
1684 struct moschip_port *mos7840_port; 1659 struct moschip_port *mos7840_port;
1685 unsigned int result; 1660 unsigned int result;
1686 __u16 msr; 1661 __u16 msr;
@@ -1708,9 +1683,10 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
1708 return result; 1683 return result;
1709} 1684}
1710 1685
1711static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file, 1686static int mos7840_tiocmset(struct tty_struct *tty, struct file *file,
1712 unsigned int set, unsigned int clear) 1687 unsigned int set, unsigned int clear)
1713{ 1688{
1689 struct usb_serial_port *port = tty->driver_data;
1714 struct moschip_port *mos7840_port; 1690 struct moschip_port *mos7840_port;
1715 unsigned int mcr; 1691 unsigned int mcr;
1716 int status; 1692 int status;
@@ -1949,10 +1925,9 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1949 * the specified new settings. 1925 * the specified new settings.
1950 *****************************************************************************/ 1926 *****************************************************************************/
1951 1927
1952static void mos7840_change_port_settings(struct moschip_port *mos7840_port, 1928static void mos7840_change_port_settings(struct tty_struct *tty,
1953 struct ktermios *old_termios) 1929 struct moschip_port *mos7840_port, struct ktermios *old_termios)
1954{ 1930{
1955 struct tty_struct *tty;
1956 int baud; 1931 int baud;
1957 unsigned cflag; 1932 unsigned cflag;
1958 unsigned iflag; 1933 unsigned iflag;
@@ -1988,8 +1963,6 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
1988 return; 1963 return;
1989 } 1964 }
1990 1965
1991 tty = mos7840_port->port->tty;
1992
1993 dbg("%s", "Entering .......... \n"); 1966 dbg("%s", "Entering .......... \n");
1994 1967
1995 lData = LCR_BITS_8; 1968 lData = LCR_BITS_8;
@@ -2131,14 +2104,14 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
2131 * the termios structure 2104 * the termios structure
2132 *****************************************************************************/ 2105 *****************************************************************************/
2133 2106
2134static void mos7840_set_termios(struct usb_serial_port *port, 2107static void mos7840_set_termios(struct tty_struct *tty,
2108 struct usb_serial_port *port,
2135 struct ktermios *old_termios) 2109 struct ktermios *old_termios)
2136{ 2110{
2137 int status; 2111 int status;
2138 unsigned int cflag; 2112 unsigned int cflag;
2139 struct usb_serial *serial; 2113 struct usb_serial *serial;
2140 struct moschip_port *mos7840_port; 2114 struct moschip_port *mos7840_port;
2141 struct tty_struct *tty;
2142 dbg("mos7840_set_termios: START\n"); 2115 dbg("mos7840_set_termios: START\n");
2143 if (mos7840_port_paranoia_check(port, __func__)) { 2116 if (mos7840_port_paranoia_check(port, __func__)) {
2144 dbg("%s", "Invalid port \n"); 2117 dbg("%s", "Invalid port \n");
@@ -2157,8 +2130,6 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2157 if (mos7840_port == NULL) 2130 if (mos7840_port == NULL)
2158 return; 2131 return;
2159 2132
2160 tty = port->tty;
2161
2162 if (!mos7840_port->open) { 2133 if (!mos7840_port->open) {
2163 dbg("%s - port not opened", __func__); 2134 dbg("%s - port not opened", __func__);
2164 return; 2135 return;
@@ -2176,7 +2147,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2176 2147
2177 /* change the port settings to the new ones specified */ 2148 /* change the port settings to the new ones specified */
2178 2149
2179 mos7840_change_port_settings(mos7840_port, old_termios); 2150 mos7840_change_port_settings(tty, mos7840_port, old_termios);
2180 2151
2181 if (!mos7840_port->read_urb) { 2152 if (!mos7840_port->read_urb) {
2182 dbg("%s", "URB KILLED !!!!!\n"); 2153 dbg("%s", "URB KILLED !!!!!\n");
@@ -2205,13 +2176,13 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2205 * allows an RS485 driver to be written in user space. 2176 * allows an RS485 driver to be written in user space.
2206 *****************************************************************************/ 2177 *****************************************************************************/
2207 2178
2208static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, 2179static int mos7840_get_lsr_info(struct tty_struct *tty,
2209 unsigned int __user *value) 2180 unsigned int __user *value)
2210{ 2181{
2211 int count; 2182 int count;
2212 unsigned int result = 0; 2183 unsigned int result = 0;
2213 2184
2214 count = mos7840_chars_in_buffer(mos7840_port->port); 2185 count = mos7840_chars_in_buffer(tty);
2215 if (count == 0) { 2186 if (count == 0) {
2216 dbg("%s -- Empty", __func__); 2187 dbg("%s -- Empty", __func__);
2217 result = TIOCSER_TEMT; 2188 result = TIOCSER_TEMT;
@@ -2227,6 +2198,8 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2227 * function to set modem info 2198 * function to set modem info
2228 *****************************************************************************/ 2199 *****************************************************************************/
2229 2200
2201/* FIXME: Should be using the model control hooks */
2202
2230static int mos7840_set_modem_info(struct moschip_port *mos7840_port, 2203static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2231 unsigned int cmd, unsigned int __user *value) 2204 unsigned int cmd, unsigned int __user *value)
2232{ 2205{
@@ -2304,9 +2277,8 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2304 __u16 msr; 2277 __u16 msr;
2305 unsigned int mcr = mos7840_port->shadowMCR; 2278 unsigned int mcr = mos7840_port->shadowMCR;
2306 int status = 0; 2279 int status = 0;
2307 status = 2280 status = mos7840_get_uart_reg(mos7840_port->port,
2308 mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER, 2281 MODEM_STATUS_REGISTER, &msr);
2309 &msr);
2310 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */ 2282 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
2311 |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */ 2283 |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
2312 |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */ 2284 |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */
@@ -2359,12 +2331,12 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2359 * this function handles any ioctl calls to the driver 2331 * this function handles any ioctl calls to the driver
2360 *****************************************************************************/ 2332 *****************************************************************************/
2361 2333
2362static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, 2334static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
2363 unsigned int cmd, unsigned long arg) 2335 unsigned int cmd, unsigned long arg)
2364{ 2336{
2337 struct usb_serial_port *port = tty->driver_data;
2365 void __user *argp = (void __user *)arg; 2338 void __user *argp = (void __user *)arg;
2366 struct moschip_port *mos7840_port; 2339 struct moschip_port *mos7840_port;
2367 struct tty_struct *tty;
2368 2340
2369 struct async_icount cnow; 2341 struct async_icount cnow;
2370 struct async_icount cprev; 2342 struct async_icount cprev;
@@ -2381,8 +2353,6 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2381 if (mos7840_port == NULL) 2353 if (mos7840_port == NULL)
2382 return -1; 2354 return -1;
2383 2355
2384 tty = mos7840_port->port->tty;
2385
2386 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 2356 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
2387 2357
2388 switch (cmd) { 2358 switch (cmd) {
@@ -2390,9 +2360,10 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2390 2360
2391 case TIOCSERGETLSR: 2361 case TIOCSERGETLSR:
2392 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 2362 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
2393 return mos7840_get_lsr_info(mos7840_port, argp); 2363 return mos7840_get_lsr_info(tty, argp);
2394 return 0; 2364 return 0;
2395 2365
2366 /* FIXME: use the modem hooks and remove this */
2396 case TIOCMBIS: 2367 case TIOCMBIS:
2397 case TIOCMBIC: 2368 case TIOCMBIC:
2398 case TIOCMSET: 2369 case TIOCMSET:
@@ -2463,13 +2434,9 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2463 if (copy_to_user(argp, &icount, sizeof(icount))) 2434 if (copy_to_user(argp, &icount, sizeof(icount)))
2464 return -EFAULT; 2435 return -EFAULT;
2465 return 0; 2436 return 0;
2466
2467 case TIOCEXBAUD:
2468 return 0;
2469 default: 2437 default:
2470 break; 2438 break;
2471 } 2439 }
2472
2473 return -ENOIOCTLCMD; 2440 return -ENOIOCTLCMD;
2474} 2441}
2475 2442
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 43c8894353bf..d6736531a0fa 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -64,7 +64,7 @@ static void navman_read_int_callback(struct urb *urb)
64 usb_serial_debug_data(debug, &port->dev, __func__, 64 usb_serial_debug_data(debug, &port->dev, __func__,
65 urb->actual_length, data); 65 urb->actual_length, data);
66 66
67 tty = port->tty; 67 tty = port->port.tty;
68 if (tty && urb->actual_length) { 68 if (tty && urb->actual_length) {
69 tty_buffer_request_room(tty, urb->actual_length); 69 tty_buffer_request_room(tty, urb->actual_length);
70 tty_insert_flip_string(tty, data, urb->actual_length); 70 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -79,7 +79,8 @@ exit:
79 __func__, result); 79 __func__, result);
80} 80}
81 81
82static int navman_open(struct usb_serial_port *port, struct file *filp) 82static int navman_open(struct tty_struct *tty,
83 struct usb_serial_port *port, struct file *filp)
83{ 84{
84 int result = 0; 85 int result = 0;
85 86
@@ -96,14 +97,15 @@ static int navman_open(struct usb_serial_port *port, struct file *filp)
96 return result; 97 return result;
97} 98}
98 99
99static void navman_close(struct usb_serial_port *port, struct file *filp) 100static void navman_close(struct tty_struct *tty,
101 struct usb_serial_port *port, struct file *filp)
100{ 102{
101 dbg("%s - port %d", __func__, port->number); 103 dbg("%s - port %d", __func__, port->number);
102 104
103 usb_kill_urb(port->interrupt_in_urb); 105 usb_kill_urb(port->interrupt_in_urb);
104} 106}
105 107
106static int navman_write(struct usb_serial_port *port, 108static int navman_write(struct tty_struct *tty, struct usb_serial_port *port,
107 const unsigned char *buf, int count) 109 const unsigned char *buf, int count)
108{ 110{
109 dbg("%s - port %d", __func__, port->number); 111 dbg("%s - port %d", __func__, port->number);
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 7b7422f49478..5a2d045562f0 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -61,12 +61,12 @@ static int debug;
61#define BT_IGNITIONPRO_ID 0x2000 /* This one seems to be a re-branded ZyXEL device */ 61#define BT_IGNITIONPRO_ID 0x2000 /* This one seems to be a re-branded ZyXEL device */
62 62
63/* function prototypes */ 63/* function prototypes */
64static int omninet_open (struct usb_serial_port *port, struct file *filp); 64static int omninet_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
65static void omninet_close (struct usb_serial_port *port, struct file *filp); 65static void omninet_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
66static void omninet_read_bulk_callback (struct urb *urb); 66static void omninet_read_bulk_callback (struct urb *urb);
67static void omninet_write_bulk_callback (struct urb *urb); 67static void omninet_write_bulk_callback (struct urb *urb);
68static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); 68static int omninet_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
69static int omninet_write_room (struct usb_serial_port *port); 69static int omninet_write_room (struct tty_struct *tty);
70static void omninet_shutdown (struct usb_serial *serial); 70static void omninet_shutdown (struct usb_serial *serial);
71static int omninet_attach (struct usb_serial *serial); 71static int omninet_attach (struct usb_serial *serial);
72 72
@@ -157,7 +157,8 @@ static int omninet_attach (struct usb_serial *serial)
157 return 0; 157 return 0;
158} 158}
159 159
160static int omninet_open (struct usb_serial_port *port, struct file *filp) 160static int omninet_open(struct tty_struct *tty,
161 struct usb_serial_port *port, struct file *filp)
161{ 162{
162 struct usb_serial *serial = port->serial; 163 struct usb_serial *serial = port->serial;
163 struct usb_serial_port *wport; 164 struct usb_serial_port *wport;
@@ -166,7 +167,7 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
166 dbg("%s - port %d", __func__, port->number); 167 dbg("%s - port %d", __func__, port->number);
167 168
168 wport = serial->port[1]; 169 wport = serial->port[1];
169 wport->tty = port->tty; 170 wport->port.tty = tty; /* FIXME */
170 171
171 /* Start reading from the device */ 172 /* Start reading from the device */
172 usb_fill_bulk_urb(port->read_urb, serial->dev, 173 usb_fill_bulk_urb(port->read_urb, serial->dev,
@@ -181,7 +182,8 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
181 return result; 182 return result;
182} 183}
183 184
184static void omninet_close (struct usb_serial_port *port, struct file * filp) 185static void omninet_close(struct tty_struct *tty,
186 struct usb_serial_port *port, struct file * filp)
185{ 187{
186 dbg("%s - port %d", __func__, port->number); 188 dbg("%s - port %d", __func__, port->number);
187 usb_kill_urb(port->read_urb); 189 usb_kill_urb(port->read_urb);
@@ -221,9 +223,9 @@ static void omninet_read_bulk_callback (struct urb *urb)
221 223
222 if (urb->actual_length && header->oh_len) { 224 if (urb->actual_length && header->oh_len) {
223 for (i = 0; i < header->oh_len; i++) { 225 for (i = 0; i < header->oh_len; i++) {
224 tty_insert_flip_char(port->tty, data[OMNINET_DATAOFFSET + i], 0); 226 tty_insert_flip_char(port->port.tty, data[OMNINET_DATAOFFSET + i], 0);
225 } 227 }
226 tty_flip_buffer_push(port->tty); 228 tty_flip_buffer_push(port->port.tty);
227 } 229 }
228 230
229 /* Continue trying to always read */ 231 /* Continue trying to always read */
@@ -238,7 +240,8 @@ static void omninet_read_bulk_callback (struct urb *urb)
238 return; 240 return;
239} 241}
240 242
241static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count) 243static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
244 const unsigned char *buf, int count)
242{ 245{
243 struct usb_serial *serial = port->serial; 246 struct usb_serial *serial = port->serial;
244 struct usb_serial_port *wport = serial->port[1]; 247 struct usb_serial_port *wport = serial->port[1];
@@ -290,8 +293,9 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
290} 293}
291 294
292 295
293static int omninet_write_room (struct usb_serial_port *port) 296static int omninet_write_room (struct tty_struct *tty)
294{ 297{
298 struct usb_serial_port *port = tty->driver_data;
295 struct usb_serial *serial = port->serial; 299 struct usb_serial *serial = port->serial;
296 struct usb_serial_port *wport = serial->port[1]; 300 struct usb_serial_port *wport = serial->port[1];
297 301
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 1e936a1cbe0b..4350990abf14 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -43,29 +43,23 @@
43#include <linux/usb/serial.h> 43#include <linux/usb/serial.h>
44 44
45/* Function prototypes */ 45/* Function prototypes */
46static int option_open(struct usb_serial_port *port, struct file *filp); 46static int option_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
47static void option_close(struct usb_serial_port *port, struct file *filp); 47static void option_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
48static int option_startup(struct usb_serial *serial); 48static int option_startup(struct usb_serial *serial);
49static void option_shutdown(struct usb_serial *serial); 49static void option_shutdown(struct usb_serial *serial);
50static void option_rx_throttle(struct usb_serial_port *port); 50static int option_write_room(struct tty_struct *tty);
51static void option_rx_unthrottle(struct usb_serial_port *port);
52static int option_write_room(struct usb_serial_port *port);
53 51
54static void option_instat_callback(struct urb *urb); 52static void option_instat_callback(struct urb *urb);
55 53
56static int option_write(struct usb_serial_port *port, 54static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
57 const unsigned char *buf, int count); 55 const unsigned char *buf, int count);
58 56static int option_chars_in_buffer(struct tty_struct *tty);
59static int option_chars_in_buffer(struct usb_serial_port *port); 57static void option_set_termios(struct tty_struct *tty,
60static int option_ioctl(struct usb_serial_port *port, struct file *file, 58 struct usb_serial_port *port, struct ktermios *old);
61 unsigned int cmd, unsigned long arg); 59static int option_tiocmget(struct tty_struct *tty, struct file *file);
62static void option_set_termios(struct usb_serial_port *port, 60static int option_tiocmset(struct tty_struct *tty, struct file *file,
63 struct ktermios *old);
64static void option_break_ctl(struct usb_serial_port *port, int break_state);
65static int option_tiocmget(struct usb_serial_port *port, struct file *file);
66static int option_tiocmset(struct usb_serial_port *port, struct file *file,
67 unsigned int set, unsigned int clear); 61 unsigned int set, unsigned int clear);
68static int option_send_setup(struct usb_serial_port *port); 62static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port);
69 63
70/* Vendor and product IDs */ 64/* Vendor and product IDs */
71#define OPTION_VENDOR_ID 0x0AF0 65#define OPTION_VENDOR_ID 0x0AF0
@@ -342,11 +336,7 @@ static struct usb_serial_driver option_1port_device = {
342 .write = option_write, 336 .write = option_write,
343 .write_room = option_write_room, 337 .write_room = option_write_room,
344 .chars_in_buffer = option_chars_in_buffer, 338 .chars_in_buffer = option_chars_in_buffer,
345 .throttle = option_rx_throttle,
346 .unthrottle = option_rx_unthrottle,
347 .ioctl = option_ioctl,
348 .set_termios = option_set_termios, 339 .set_termios = option_set_termios,
349 .break_ctl = option_break_ctl,
350 .tiocmget = option_tiocmget, 340 .tiocmget = option_tiocmget,
351 .tiocmset = option_tiocmset, 341 .tiocmset = option_tiocmset,
352 .attach = option_startup, 342 .attach = option_startup,
@@ -417,33 +407,18 @@ static void __exit option_exit(void)
417module_init(option_init); 407module_init(option_init);
418module_exit(option_exit); 408module_exit(option_exit);
419 409
420static void option_rx_throttle(struct usb_serial_port *port) 410static void option_set_termios(struct tty_struct *tty,
421{ 411 struct usb_serial_port *port, struct ktermios *old_termios)
422 dbg("%s", __func__);
423}
424
425static void option_rx_unthrottle(struct usb_serial_port *port)
426{
427 dbg("%s", __func__);
428}
429
430static void option_break_ctl(struct usb_serial_port *port, int break_state)
431{
432 /* Unfortunately, I don't know how to send a break */
433 dbg("%s", __func__);
434}
435
436static void option_set_termios(struct usb_serial_port *port,
437 struct ktermios *old_termios)
438{ 412{
439 dbg("%s", __func__); 413 dbg("%s", __func__);
440 /* Doesn't support option setting */ 414 /* Doesn't support option setting */
441 tty_termios_copy_hw(port->tty->termios, old_termios); 415 tty_termios_copy_hw(tty->termios, old_termios);
442 option_send_setup(port); 416 option_send_setup(tty, port);
443} 417}
444 418
445static int option_tiocmget(struct usb_serial_port *port, struct file *file) 419static int option_tiocmget(struct tty_struct *tty, struct file *file)
446{ 420{
421 struct usb_serial_port *port = tty->driver_data;
447 unsigned int value; 422 unsigned int value;
448 struct option_port_private *portdata; 423 struct option_port_private *portdata;
449 424
@@ -459,9 +434,10 @@ static int option_tiocmget(struct usb_serial_port *port, struct file *file)
459 return value; 434 return value;
460} 435}
461 436
462static int option_tiocmset(struct usb_serial_port *port, struct file *file, 437static int option_tiocmset(struct tty_struct *tty, struct file *file,
463 unsigned int set, unsigned int clear) 438 unsigned int set, unsigned int clear)
464{ 439{
440 struct usb_serial_port *port = tty->driver_data;
465 struct option_port_private *portdata; 441 struct option_port_private *portdata;
466 442
467 portdata = usb_get_serial_port_data(port); 443 portdata = usb_get_serial_port_data(port);
@@ -476,17 +452,11 @@ static int option_tiocmset(struct usb_serial_port *port, struct file *file,
476 portdata->rts_state = 0; 452 portdata->rts_state = 0;
477 if (clear & TIOCM_DTR) 453 if (clear & TIOCM_DTR)
478 portdata->dtr_state = 0; 454 portdata->dtr_state = 0;
479 return option_send_setup(port); 455 return option_send_setup(tty, port);
480}
481
482static int option_ioctl(struct usb_serial_port *port, struct file *file,
483 unsigned int cmd, unsigned long arg)
484{
485 return -ENOIOCTLCMD;
486} 456}
487 457
488/* Write */ 458/* Write */
489static int option_write(struct usb_serial_port *port, 459static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
490 const unsigned char *buf, int count) 460 const unsigned char *buf, int count)
491{ 461{
492 struct option_port_private *portdata; 462 struct option_port_private *portdata;
@@ -562,7 +532,7 @@ static void option_indat_callback(struct urb *urb)
562 dbg("%s: nonzero status: %d on endpoint %02x.", 532 dbg("%s: nonzero status: %d on endpoint %02x.",
563 __func__, status, endpoint); 533 __func__, status, endpoint);
564 } else { 534 } else {
565 tty = port->tty; 535 tty = port->port.tty;
566 if (urb->actual_length) { 536 if (urb->actual_length) {
567 tty_buffer_request_room(tty, urb->actual_length); 537 tty_buffer_request_room(tty, urb->actual_length);
568 tty_insert_flip_string(tty, data, urb->actual_length); 538 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -572,7 +542,7 @@ static void option_indat_callback(struct urb *urb)
572 } 542 }
573 543
574 /* Resubmit urb so we continue receiving */ 544 /* Resubmit urb so we continue receiving */
575 if (port->open_count && status != -ESHUTDOWN) { 545 if (port->port.count && status != -ESHUTDOWN) {
576 err = usb_submit_urb(urb, GFP_ATOMIC); 546 err = usb_submit_urb(urb, GFP_ATOMIC);
577 if (err) 547 if (err)
578 printk(KERN_ERR "%s: resubmit read urb failed. " 548 printk(KERN_ERR "%s: resubmit read urb failed. "
@@ -638,9 +608,9 @@ static void option_instat_callback(struct urb *urb)
638 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 608 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
639 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 609 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
640 610
641 if (port->tty && !C_CLOCAL(port->tty) && 611 if (port->port.tty && !C_CLOCAL(port->port.tty) &&
642 old_dcd_state && !portdata->dcd_state) 612 old_dcd_state && !portdata->dcd_state)
643 tty_hangup(port->tty); 613 tty_hangup(port->port.tty);
644 } else { 614 } else {
645 dbg("%s: type %x req %x", __func__, 615 dbg("%s: type %x req %x", __func__,
646 req_pkt->bRequestType,req_pkt->bRequest); 616 req_pkt->bRequestType,req_pkt->bRequest);
@@ -658,8 +628,9 @@ static void option_instat_callback(struct urb *urb)
658 } 628 }
659} 629}
660 630
661static int option_write_room(struct usb_serial_port *port) 631static int option_write_room(struct tty_struct *tty)
662{ 632{
633 struct usb_serial_port *port = tty->driver_data;
663 struct option_port_private *portdata; 634 struct option_port_private *portdata;
664 int i; 635 int i;
665 int data_len = 0; 636 int data_len = 0;
@@ -678,8 +649,9 @@ static int option_write_room(struct usb_serial_port *port)
678 return data_len; 649 return data_len;
679} 650}
680 651
681static int option_chars_in_buffer(struct usb_serial_port *port) 652static int option_chars_in_buffer(struct tty_struct *tty)
682{ 653{
654 struct usb_serial_port *port = tty->driver_data;
683 struct option_port_private *portdata; 655 struct option_port_private *portdata;
684 int i; 656 int i;
685 int data_len = 0; 657 int data_len = 0;
@@ -698,7 +670,8 @@ static int option_chars_in_buffer(struct usb_serial_port *port)
698 return data_len; 670 return data_len;
699} 671}
700 672
701static int option_open(struct usb_serial_port *port, struct file *filp) 673static int option_open(struct tty_struct *tty,
674 struct usb_serial_port *port, struct file *filp)
702{ 675{
703 struct option_port_private *portdata; 676 struct option_port_private *portdata;
704 struct usb_serial *serial = port->serial; 677 struct usb_serial *serial = port->serial;
@@ -748,14 +721,16 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
748 usb_pipeout(urb->pipe), 0); */ 721 usb_pipeout(urb->pipe), 0); */
749 } 722 }
750 723
751 port->tty->low_latency = 1; 724 if (tty)
725 tty->low_latency = 1;
752 726
753 option_send_setup(port); 727 option_send_setup(tty, port);
754 728
755 return (0); 729 return (0);
756} 730}
757 731
758static void option_close(struct usb_serial_port *port, struct file *filp) 732static void option_close(struct tty_struct *tty,
733 struct usb_serial_port *port, struct file *filp)
759{ 734{
760 int i; 735 int i;
761 struct usb_serial *serial = port->serial; 736 struct usb_serial *serial = port->serial;
@@ -770,7 +745,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
770 if (serial->dev) { 745 if (serial->dev) {
771 mutex_lock(&serial->disc_mutex); 746 mutex_lock(&serial->disc_mutex);
772 if (!serial->disconnected) 747 if (!serial->disconnected)
773 option_send_setup(port); 748 option_send_setup(tty, port);
774 mutex_unlock(&serial->disc_mutex); 749 mutex_unlock(&serial->disc_mutex);
775 750
776 /* Stop reading/writing urbs */ 751 /* Stop reading/writing urbs */
@@ -779,7 +754,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
779 for (i = 0; i < N_OUT_URB; i++) 754 for (i = 0; i < N_OUT_URB; i++)
780 usb_kill_urb(portdata->out_urbs[i]); 755 usb_kill_urb(portdata->out_urbs[i]);
781 } 756 }
782 port->tty = NULL; 757 port->port.tty = NULL; /* FIXME */
783} 758}
784 759
785/* Helper functions used by option_setup_urbs */ 760/* Helper functions used by option_setup_urbs */
@@ -841,7 +816,8 @@ static void option_setup_urbs(struct usb_serial *serial)
841 * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN 816 * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
842 * CDC. 817 * CDC.
843*/ 818*/
844static int option_send_setup(struct usb_serial_port *port) 819static int option_send_setup(struct tty_struct *tty,
820 struct usb_serial_port *port)
845{ 821{
846 struct usb_serial *serial = port->serial; 822 struct usb_serial *serial = port->serial;
847 struct option_port_private *portdata; 823 struct option_port_private *portdata;
@@ -850,7 +826,7 @@ static int option_send_setup(struct usb_serial_port *port)
850 826
851 portdata = usb_get_serial_port_data(port); 827 portdata = usb_get_serial_port_data(port);
852 828
853 if (port->tty) { 829 if (tty) {
854 int val = 0; 830 int val = 0;
855 if (portdata->dtr_state) 831 if (portdata->dtr_state)
856 val |= 0x01; 832 val |= 0x01;
@@ -861,7 +837,6 @@ static int option_send_setup(struct usb_serial_port *port)
861 usb_rcvctrlpipe(serial->dev, 0), 837 usb_rcvctrlpipe(serial->dev, 0),
862 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT); 838 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT);
863 } 839 }
864
865 return 0; 840 return 0;
866} 841}
867 842
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index a9625c180dc3..069d276a5276 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -140,22 +140,23 @@ struct oti6858_control_pkt {
140 && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt) ) 140 && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt) )
141 141
142/* function prototypes */ 142/* function prototypes */
143static int oti6858_open(struct usb_serial_port *port, struct file *filp); 143static int oti6858_open(struct tty_struct *tty,
144static void oti6858_close(struct usb_serial_port *port, struct file *filp); 144 struct usb_serial_port *port, struct file *filp);
145static void oti6858_set_termios(struct usb_serial_port *port, 145static void oti6858_close(struct tty_struct *tty,
146 struct ktermios *old); 146 struct usb_serial_port *port, struct file *filp);
147static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, 147static void oti6858_set_termios(struct tty_struct *tty,
148 struct usb_serial_port *port, struct ktermios *old);
149static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
148 unsigned int cmd, unsigned long arg); 150 unsigned int cmd, unsigned long arg);
149static void oti6858_read_int_callback(struct urb *urb); 151static void oti6858_read_int_callback(struct urb *urb);
150static void oti6858_read_bulk_callback(struct urb *urb); 152static void oti6858_read_bulk_callback(struct urb *urb);
151static void oti6858_write_bulk_callback(struct urb *urb); 153static void oti6858_write_bulk_callback(struct urb *urb);
152static int oti6858_write(struct usb_serial_port *port, 154static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
153 const unsigned char *buf, int count); 155 const unsigned char *buf, int count);
154static int oti6858_write_room(struct usb_serial_port *port); 156static int oti6858_write_room(struct tty_struct *tty);
155static void oti6858_break_ctl(struct usb_serial_port *port, int break_state); 157static int oti6858_chars_in_buffer(struct tty_struct *tty);
156static int oti6858_chars_in_buffer(struct usb_serial_port *port); 158static int oti6858_tiocmget(struct tty_struct *tty, struct file *file);
157static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file); 159static int oti6858_tiocmset(struct tty_struct *tty, struct file *file,
158static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file,
159 unsigned int set, unsigned int clear); 160 unsigned int set, unsigned int clear);
160static int oti6858_startup(struct usb_serial *serial); 161static int oti6858_startup(struct usb_serial *serial);
161static void oti6858_shutdown(struct usb_serial *serial); 162static void oti6858_shutdown(struct usb_serial *serial);
@@ -184,7 +185,6 @@ static struct usb_serial_driver oti6858_device = {
184 .close = oti6858_close, 185 .close = oti6858_close,
185 .write = oti6858_write, 186 .write = oti6858_write,
186 .ioctl = oti6858_ioctl, 187 .ioctl = oti6858_ioctl,
187 .break_ctl = oti6858_break_ctl,
188 .set_termios = oti6858_set_termios, 188 .set_termios = oti6858_set_termios,
189 .tiocmget = oti6858_tiocmget, 189 .tiocmget = oti6858_tiocmget,
190 .tiocmset = oti6858_tiocmset, 190 .tiocmset = oti6858_tiocmset,
@@ -395,7 +395,7 @@ static int oti6858_startup(struct usb_serial *serial)
395 return -ENOMEM; 395 return -ENOMEM;
396} 396}
397 397
398static int oti6858_write(struct usb_serial_port *port, 398static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
399 const unsigned char *buf, int count) 399 const unsigned char *buf, int count)
400{ 400{
401 struct oti6858_private *priv = usb_get_serial_port_data(port); 401 struct oti6858_private *priv = usb_get_serial_port_data(port);
@@ -413,8 +413,9 @@ static int oti6858_write(struct usb_serial_port *port,
413 return count; 413 return count;
414} 414}
415 415
416static int oti6858_write_room(struct usb_serial_port *port) 416static int oti6858_write_room(struct tty_struct *tty)
417{ 417{
418 struct usb_serial_port *port = tty->driver_data;
418 struct oti6858_private *priv = usb_get_serial_port_data(port); 419 struct oti6858_private *priv = usb_get_serial_port_data(port);
419 int room = 0; 420 int room = 0;
420 unsigned long flags; 421 unsigned long flags;
@@ -428,8 +429,9 @@ static int oti6858_write_room(struct usb_serial_port *port)
428 return room; 429 return room;
429} 430}
430 431
431static int oti6858_chars_in_buffer(struct usb_serial_port *port) 432static int oti6858_chars_in_buffer(struct tty_struct *tty)
432{ 433{
434 struct usb_serial_port *port = tty->driver_data;
433 struct oti6858_private *priv = usb_get_serial_port_data(port); 435 struct oti6858_private *priv = usb_get_serial_port_data(port);
434 int chars = 0; 436 int chars = 0;
435 unsigned long flags; 437 unsigned long flags;
@@ -443,8 +445,8 @@ static int oti6858_chars_in_buffer(struct usb_serial_port *port)
443 return chars; 445 return chars;
444} 446}
445 447
446static void oti6858_set_termios(struct usb_serial_port *port, 448static void oti6858_set_termios(struct tty_struct *tty,
447 struct ktermios *old_termios) 449 struct usb_serial_port *port, struct ktermios *old_termios)
448{ 450{
449 struct oti6858_private *priv = usb_get_serial_port_data(port); 451 struct oti6858_private *priv = usb_get_serial_port_data(port);
450 unsigned long flags; 452 unsigned long flags;
@@ -455,22 +457,22 @@ static void oti6858_set_termios(struct usb_serial_port *port,
455 457
456 dbg("%s(port = %d)", __func__, port->number); 458 dbg("%s(port = %d)", __func__, port->number);
457 459
458 if (!port->tty || !port->tty->termios) { 460 if (!tty) {
459 dbg("%s(): no tty structures", __func__); 461 dbg("%s(): no tty structures", __func__);
460 return; 462 return;
461 } 463 }
462 464
463 spin_lock_irqsave(&priv->lock, flags); 465 spin_lock_irqsave(&priv->lock, flags);
464 if (!priv->flags.termios_initialized) { 466 if (!priv->flags.termios_initialized) {
465 *(port->tty->termios) = tty_std_termios; 467 *(tty->termios) = tty_std_termios;
466 port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; 468 tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
469 tty->termios->c_ispeed = 38400;
470 tty->termios->c_ospeed = 38400;
467 priv->flags.termios_initialized = 1; 471 priv->flags.termios_initialized = 1;
468 port->tty->termios->c_ispeed = 38400;
469 port->tty->termios->c_ospeed = 38400;
470 } 472 }
471 spin_unlock_irqrestore(&priv->lock, flags); 473 spin_unlock_irqrestore(&priv->lock, flags);
472 474
473 cflag = port->tty->termios->c_cflag; 475 cflag = tty->termios->c_cflag;
474 476
475 spin_lock_irqsave(&priv->lock, flags); 477 spin_lock_irqsave(&priv->lock, flags);
476 divisor = priv->pending_setup.divisor; 478 divisor = priv->pending_setup.divisor;
@@ -500,7 +502,7 @@ static void oti6858_set_termios(struct usb_serial_port *port,
500 * guarantee that any other baud rate will work (especially 502 * guarantee that any other baud rate will work (especially
501 * the higher ones) 503 * the higher ones)
502 */ 504 */
503 br = tty_get_baud_rate(port->tty); 505 br = tty_get_baud_rate(tty);
504 if (br == 0) { 506 if (br == 0) {
505 divisor = 0; 507 divisor = 0;
506 } else { 508 } else {
@@ -511,7 +513,7 @@ static void oti6858_set_termios(struct usb_serial_port *port,
511 new_divisor = (96000000 + 8 * br) / (16 * br); 513 new_divisor = (96000000 + 8 * br) / (16 * br);
512 real_br = 96000000 / (16 * new_divisor); 514 real_br = 96000000 / (16 * new_divisor);
513 divisor = cpu_to_le16(new_divisor); 515 divisor = cpu_to_le16(new_divisor);
514 tty_encode_baud_rate(port->tty, real_br, real_br); 516 tty_encode_baud_rate(tty, real_br, real_br);
515 } 517 }
516 518
517 frame_fmt &= ~FMT_STOP_BITS_MASK; 519 frame_fmt &= ~FMT_STOP_BITS_MASK;
@@ -564,7 +566,8 @@ static void oti6858_set_termios(struct usb_serial_port *port,
564 spin_unlock_irqrestore(&priv->lock, flags); 566 spin_unlock_irqrestore(&priv->lock, flags);
565} 567}
566 568
567static int oti6858_open(struct usb_serial_port *port, struct file *filp) 569static int oti6858_open(struct tty_struct *tty,
570 struct usb_serial_port *port, struct file *filp)
568{ 571{
569 struct oti6858_private *priv = usb_get_serial_port_data(port); 572 struct oti6858_private *priv = usb_get_serial_port_data(port);
570 struct ktermios tmp_termios; 573 struct ktermios tmp_termios;
@@ -578,7 +581,7 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
578 usb_clear_halt(serial->dev, port->write_urb->pipe); 581 usb_clear_halt(serial->dev, port->write_urb->pipe);
579 usb_clear_halt(serial->dev, port->read_urb->pipe); 582 usb_clear_halt(serial->dev, port->read_urb->pipe);
580 583
581 if (port->open_count != 1) 584 if (port->port.count != 1)
582 return 0; 585 return 0;
583 586
584 if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) { 587 if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
@@ -617,18 +620,19 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
617 if (result != 0) { 620 if (result != 0) {
618 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 621 dev_err(&port->dev, "%s(): usb_submit_urb() failed"
619 " with error %d\n", __func__, result); 622 " with error %d\n", __func__, result);
620 oti6858_close(port, NULL); 623 oti6858_close(tty, port, NULL);
621 return -EPROTO; 624 return -EPROTO;
622 } 625 }
623 626
624 /* setup termios */ 627 /* setup termios */
625 if (port->tty) 628 if (tty)
626 oti6858_set_termios(port, &tmp_termios); 629 oti6858_set_termios(tty, port, &tmp_termios);
627 630
628 return 0; 631 return 0;
629} 632}
630 633
631static void oti6858_close(struct usb_serial_port *port, struct file *filp) 634static void oti6858_close(struct tty_struct *tty,
635 struct usb_serial_port *port, struct file *filp)
632{ 636{
633 struct oti6858_private *priv = usb_get_serial_port_data(port); 637 struct oti6858_private *priv = usb_get_serial_port_data(port);
634 unsigned long flags; 638 unsigned long flags;
@@ -641,7 +645,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
641 spin_lock_irqsave(&priv->lock, flags); 645 spin_lock_irqsave(&priv->lock, flags);
642 timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */ 646 timeout = 30 * HZ; /* PL2303_CLOSING_WAIT */
643 init_waitqueue_entry(&wait, current); 647 init_waitqueue_entry(&wait, current);
644 add_wait_queue(&port->tty->write_wait, &wait); 648 add_wait_queue(&tty->write_wait, &wait);
645 dbg("%s(): entering wait loop", __func__); 649 dbg("%s(): entering wait loop", __func__);
646 for (;;) { 650 for (;;) {
647 set_current_state(TASK_INTERRUPTIBLE); 651 set_current_state(TASK_INTERRUPTIBLE);
@@ -654,7 +658,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
654 spin_lock_irqsave(&priv->lock, flags); 658 spin_lock_irqsave(&priv->lock, flags);
655 } 659 }
656 set_current_state(TASK_RUNNING); 660 set_current_state(TASK_RUNNING);
657 remove_wait_queue(&port->tty->write_wait, &wait); 661 remove_wait_queue(&tty->write_wait, &wait);
658 dbg("%s(): after wait loop", __func__); 662 dbg("%s(): after wait loop", __func__);
659 663
660 /* clear out any remaining data in the buffer */ 664 /* clear out any remaining data in the buffer */
@@ -669,7 +673,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
669 /* data is in the buffer to compute a delay */ 673 /* data is in the buffer to compute a delay */
670 /* that is not unnecessarily long) */ 674 /* that is not unnecessarily long) */
671 /* FIXME 675 /* FIXME
672 bps = tty_get_baud_rate(port->tty); 676 bps = tty_get_baud_rate(tty);
673 if (bps > 1200) 677 if (bps > 1200)
674 timeout = max((HZ*2560)/bps,HZ/10); 678 timeout = max((HZ*2560)/bps,HZ/10);
675 else 679 else
@@ -690,7 +694,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
690 usb_kill_urb(port->interrupt_in_urb); 694 usb_kill_urb(port->interrupt_in_urb);
691 695
692 /* 696 /*
693 if (port->tty && (port->tty->termios->c_cflag) & HUPCL) { 697 if (tty && (tty->termios->c_cflag) & HUPCL) {
694 // drop DTR and RTS 698 // drop DTR and RTS
695 spin_lock_irqsave(&priv->lock, flags); 699 spin_lock_irqsave(&priv->lock, flags);
696 priv->pending_setup.control &= ~CONTROL_MASK; 700 priv->pending_setup.control &= ~CONTROL_MASK;
@@ -699,9 +703,10 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
699 */ 703 */
700} 704}
701 705
702static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file, 706static int oti6858_tiocmset(struct tty_struct *tty, struct file *file,
703 unsigned int set, unsigned int clear) 707 unsigned int set, unsigned int clear)
704{ 708{
709 struct usb_serial_port *port = tty->driver_data;
705 struct oti6858_private *priv = usb_get_serial_port_data(port); 710 struct oti6858_private *priv = usb_get_serial_port_data(port);
706 unsigned long flags; 711 unsigned long flags;
707 u8 control; 712 u8 control;
@@ -732,8 +737,9 @@ static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file,
732 return 0; 737 return 0;
733} 738}
734 739
735static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file) 740static int oti6858_tiocmget(struct tty_struct *tty, struct file *file)
736{ 741{
742 struct usb_serial_port *port = tty->driver_data;
737 struct oti6858_private *priv = usb_get_serial_port_data(port); 743 struct oti6858_private *priv = usb_get_serial_port_data(port);
738 unsigned long flags; 744 unsigned long flags;
739 unsigned pin_state; 745 unsigned pin_state;
@@ -802,26 +808,15 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
802 return 0; 808 return 0;
803} 809}
804 810
805static int oti6858_ioctl(struct usb_serial_port *port, struct file *file, 811static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
806 unsigned int cmd, unsigned long arg) 812 unsigned int cmd, unsigned long arg)
807{ 813{
808 void __user *user_arg = (void __user *) arg; 814 struct usb_serial_port *port = tty->driver_data;
809 unsigned int x;
810 815
811 dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)", 816 dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)",
812 __func__, port->number, cmd, arg); 817 __func__, port->number, cmd, arg);
813 818
814 switch (cmd) { 819 switch (cmd) {
815 case TIOCMBIS:
816 if (copy_from_user(&x, user_arg, sizeof(x)))
817 return -EFAULT;
818 return oti6858_tiocmset(port, NULL, x, 0);
819
820 case TIOCMBIC:
821 if (copy_from_user(&x, user_arg, sizeof(x)))
822 return -EFAULT;
823 return oti6858_tiocmset(port, NULL, 0, x);
824
825 case TIOCMIWAIT: 820 case TIOCMIWAIT:
826 dbg("%s(): TIOCMIWAIT", __func__); 821 dbg("%s(): TIOCMIWAIT", __func__);
827 return wait_modem_info(port, arg); 822 return wait_modem_info(port, arg);
@@ -834,24 +829,6 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file,
834 return -ENOIOCTLCMD; 829 return -ENOIOCTLCMD;
835} 830}
836 831
837static void oti6858_break_ctl(struct usb_serial_port *port, int break_state)
838{
839 int state;
840
841 dbg("%s(port = %d)", __func__, port->number);
842
843 state = (break_state == 0) ? 0 : 1;
844 dbg("%s(): turning break %s", __func__, state ? "on" : "off");
845
846 /* FIXME */
847/*
848 result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
849 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
850 0, NULL, 0, 100);
851 if (result != 0)
852 dbg("%s(): error sending break", __func__);
853 */
854}
855 832
856static void oti6858_shutdown(struct usb_serial *serial) 833static void oti6858_shutdown(struct usb_serial *serial)
857{ 834{
@@ -1002,7 +979,7 @@ static void oti6858_read_bulk_callback(struct urb *urb)
1002 spin_unlock_irqrestore(&priv->lock, flags); 979 spin_unlock_irqrestore(&priv->lock, flags);
1003 980
1004 if (status != 0) { 981 if (status != 0) {
1005 if (!port->open_count) { 982 if (!port->port.count) {
1006 dbg("%s(): port is closed, exiting", __func__); 983 dbg("%s(): port is closed, exiting", __func__);
1007 return; 984 return;
1008 } 985 }
@@ -1020,14 +997,14 @@ static void oti6858_read_bulk_callback(struct urb *urb)
1020 return; 997 return;
1021 } 998 }
1022 999
1023 tty = port->tty; 1000 tty = port->port.tty;
1024 if (tty != NULL && urb->actual_length > 0) { 1001 if (tty != NULL && urb->actual_length > 0) {
1025 tty_insert_flip_string(tty, data, urb->actual_length); 1002 tty_insert_flip_string(tty, data, urb->actual_length);
1026 tty_flip_buffer_push(tty); 1003 tty_flip_buffer_push(tty);
1027 } 1004 }
1028 1005
1029 // schedule the interrupt urb if we are still open */ 1006 // schedule the interrupt urb if we are still open */
1030 if (port->open_count != 0) { 1007 if (port->port.count != 0) {
1031 port->interrupt_in_urb->dev = port->serial->dev; 1008 port->interrupt_in_urb->dev = port->serial->dev;
1032 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1009 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1033 if (result != 0) { 1010 if (result != 0) {
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 2a0dd1b50dc4..a0016725d314 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -458,8 +458,8 @@ static void pl2303_send(struct usb_serial_port *port)
458 usb_serial_port_softint(port); 458 usb_serial_port_softint(port);
459} 459}
460 460
461static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf, 461static int pl2303_write(struct tty_struct *tty, struct usb_serial_port *port,
462 int count) 462 const unsigned char *buf, int count)
463{ 463{
464 struct pl2303_private *priv = usb_get_serial_port_data(port); 464 struct pl2303_private *priv = usb_get_serial_port_data(port);
465 unsigned long flags; 465 unsigned long flags;
@@ -478,8 +478,9 @@ static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
478 return count; 478 return count;
479} 479}
480 480
481static int pl2303_write_room(struct usb_serial_port *port) 481static int pl2303_write_room(struct tty_struct *tty)
482{ 482{
483 struct usb_serial_port *port = tty->driver_data;
483 struct pl2303_private *priv = usb_get_serial_port_data(port); 484 struct pl2303_private *priv = usb_get_serial_port_data(port);
484 int room = 0; 485 int room = 0;
485 unsigned long flags; 486 unsigned long flags;
@@ -494,8 +495,9 @@ static int pl2303_write_room(struct usb_serial_port *port)
494 return room; 495 return room;
495} 496}
496 497
497static int pl2303_chars_in_buffer(struct usb_serial_port *port) 498static int pl2303_chars_in_buffer(struct tty_struct *tty)
498{ 499{
500 struct usb_serial_port *port = tty->driver_data;
499 struct pl2303_private *priv = usb_get_serial_port_data(port); 501 struct pl2303_private *priv = usb_get_serial_port_data(port);
500 int chars = 0; 502 int chars = 0;
501 unsigned long flags; 503 unsigned long flags;
@@ -510,8 +512,8 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
510 return chars; 512 return chars;
511} 513}
512 514
513static void pl2303_set_termios(struct usb_serial_port *port, 515static void pl2303_set_termios(struct tty_struct *tty,
514 struct ktermios *old_termios) 516 struct usb_serial_port *port, struct ktermios *old_termios)
515{ 517{
516 struct usb_serial *serial = port->serial; 518 struct usb_serial *serial = port->serial;
517 struct pl2303_private *priv = usb_get_serial_port_data(port); 519 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -526,11 +528,10 @@ static void pl2303_set_termios(struct usb_serial_port *port,
526 528
527 spin_lock_irqsave(&priv->lock, flags); 529 spin_lock_irqsave(&priv->lock, flags);
528 if (!priv->termios_initialized) { 530 if (!priv->termios_initialized) {
529 *(port->tty->termios) = tty_std_termios; 531 *(tty->termios) = tty_std_termios;
530 port->tty->termios->c_cflag = B9600 | CS8 | CREAD | 532 tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
531 HUPCL | CLOCAL; 533 tty->termios->c_ispeed = 9600;
532 port->tty->termios->c_ispeed = 9600; 534 tty->termios->c_ospeed = 9600;
533 port->tty->termios->c_ospeed = 9600;
534 priv->termios_initialized = 1; 535 priv->termios_initialized = 1;
535 } 536 }
536 spin_unlock_irqrestore(&priv->lock, flags); 537 spin_unlock_irqrestore(&priv->lock, flags);
@@ -539,16 +540,16 @@ static void pl2303_set_termios(struct usb_serial_port *port,
539 serial settings even to the same values as before. Thus 540 serial settings even to the same values as before. Thus
540 we actually need to filter in this specific case */ 541 we actually need to filter in this specific case */
541 542
542 if (!tty_termios_hw_change(port->tty->termios, old_termios)) 543 if (!tty_termios_hw_change(tty->termios, old_termios))
543 return; 544 return;
544 545
545 cflag = port->tty->termios->c_cflag; 546 cflag = tty->termios->c_cflag;
546 547
547 buf = kzalloc(7, GFP_KERNEL); 548 buf = kzalloc(7, GFP_KERNEL);
548 if (!buf) { 549 if (!buf) {
549 dev_err(&port->dev, "%s - out of memory.\n", __func__); 550 dev_err(&port->dev, "%s - out of memory.\n", __func__);
550 /* Report back no change occurred */ 551 /* Report back no change occurred */
551 *port->tty->termios = *old_termios; 552 *tty->termios = *old_termios;
552 return; 553 return;
553 } 554 }
554 555
@@ -569,7 +570,7 @@ static void pl2303_set_termios(struct usb_serial_port *port,
569 dbg("%s - data bits = %d", __func__, buf[6]); 570 dbg("%s - data bits = %d", __func__, buf[6]);
570 } 571 }
571 572
572 baud = tty_get_baud_rate(port->tty);; 573 baud = tty_get_baud_rate(tty);
573 dbg("%s - baud = %d", __func__, baud); 574 dbg("%s - baud = %d", __func__, baud);
574 if (baud) { 575 if (baud) {
575 buf[0] = baud & 0xff; 576 buf[0] = baud & 0xff;
@@ -646,12 +647,13 @@ static void pl2303_set_termios(struct usb_serial_port *port,
646 647
647 /* FIXME: Need to read back resulting baud rate */ 648 /* FIXME: Need to read back resulting baud rate */
648 if (baud) 649 if (baud)
649 tty_encode_baud_rate(port->tty, baud, baud); 650 tty_encode_baud_rate(tty, baud, baud);
650 651
651 kfree(buf); 652 kfree(buf);
652} 653}
653 654
654static void pl2303_close(struct usb_serial_port *port, struct file *filp) 655static void pl2303_close(struct tty_struct *tty,
656 struct usb_serial_port *port, struct file *filp)
655{ 657{
656 struct pl2303_private *priv = usb_get_serial_port_data(port); 658 struct pl2303_private *priv = usb_get_serial_port_data(port);
657 unsigned long flags; 659 unsigned long flags;
@@ -666,7 +668,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
666 spin_lock_irqsave(&priv->lock, flags); 668 spin_lock_irqsave(&priv->lock, flags);
667 timeout = PL2303_CLOSING_WAIT; 669 timeout = PL2303_CLOSING_WAIT;
668 init_waitqueue_entry(&wait, current); 670 init_waitqueue_entry(&wait, current);
669 add_wait_queue(&port->tty->write_wait, &wait); 671 add_wait_queue(&tty->write_wait, &wait);
670 for (;;) { 672 for (;;) {
671 set_current_state(TASK_INTERRUPTIBLE); 673 set_current_state(TASK_INTERRUPTIBLE);
672 if (pl2303_buf_data_avail(priv->buf) == 0 || 674 if (pl2303_buf_data_avail(priv->buf) == 0 ||
@@ -678,7 +680,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
678 spin_lock_irqsave(&priv->lock, flags); 680 spin_lock_irqsave(&priv->lock, flags);
679 } 681 }
680 set_current_state(TASK_RUNNING); 682 set_current_state(TASK_RUNNING);
681 remove_wait_queue(&port->tty->write_wait, &wait); 683 remove_wait_queue(&tty->write_wait, &wait);
682 /* clear out any remaining data in the buffer */ 684 /* clear out any remaining data in the buffer */
683 pl2303_buf_clear(priv->buf); 685 pl2303_buf_clear(priv->buf);
684 spin_unlock_irqrestore(&priv->lock, flags); 686 spin_unlock_irqrestore(&priv->lock, flags);
@@ -690,7 +692,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
690 /* for lower rates we should really know how much */ 692 /* for lower rates we should really know how much */
691 /* data is in the buffer to compute a delay */ 693 /* data is in the buffer to compute a delay */
692 /* that is not unnecessarily long) */ 694 /* that is not unnecessarily long) */
693 bps = tty_get_baud_rate(port->tty); 695 bps = tty_get_baud_rate(tty);
694 if (bps > 1200) 696 if (bps > 1200)
695 timeout = max((HZ*2560)/bps,HZ/10); 697 timeout = max((HZ*2560)/bps,HZ/10);
696 else 698 else
@@ -703,8 +705,8 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
703 usb_kill_urb(port->read_urb); 705 usb_kill_urb(port->read_urb);
704 usb_kill_urb(port->interrupt_in_urb); 706 usb_kill_urb(port->interrupt_in_urb);
705 707
706 if (port->tty) { 708 if (tty) {
707 c_cflag = port->tty->termios->c_cflag; 709 c_cflag = tty->termios->c_cflag;
708 if (c_cflag & HUPCL) { 710 if (c_cflag & HUPCL) {
709 /* drop DTR and RTS */ 711 /* drop DTR and RTS */
710 spin_lock_irqsave(&priv->lock, flags); 712 spin_lock_irqsave(&priv->lock, flags);
@@ -715,7 +717,8 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
715 } 717 }
716} 718}
717 719
718static int pl2303_open(struct usb_serial_port *port, struct file *filp) 720static int pl2303_open(struct tty_struct *tty,
721 struct usb_serial_port *port, struct file *filp)
719{ 722{
720 struct ktermios tmp_termios; 723 struct ktermios tmp_termios;
721 struct usb_serial *serial = port->serial; 724 struct usb_serial *serial = port->serial;
@@ -734,9 +737,8 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
734 } 737 }
735 738
736 /* Setup termios */ 739 /* Setup termios */
737 if (port->tty) { 740 if (tty)
738 pl2303_set_termios(port, &tmp_termios); 741 pl2303_set_termios(tty, port, &tmp_termios);
739 }
740 742
741 //FIXME: need to assert RTS and DTR if CRTSCTS off 743 //FIXME: need to assert RTS and DTR if CRTSCTS off
742 744
@@ -746,7 +748,7 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
746 if (result) { 748 if (result) {
747 dev_err(&port->dev, "%s - failed submitting read urb," 749 dev_err(&port->dev, "%s - failed submitting read urb,"
748 " error %d\n", __func__, result); 750 " error %d\n", __func__, result);
749 pl2303_close(port, NULL); 751 pl2303_close(tty, port, NULL);
750 return -EPROTO; 752 return -EPROTO;
751 } 753 }
752 754
@@ -756,15 +758,16 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
756 if (result) { 758 if (result) {
757 dev_err(&port->dev, "%s - failed submitting interrupt urb," 759 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
758 " error %d\n", __func__, result); 760 " error %d\n", __func__, result);
759 pl2303_close(port, NULL); 761 pl2303_close(tty, port, NULL);
760 return -EPROTO; 762 return -EPROTO;
761 } 763 }
762 return 0; 764 return 0;
763} 765}
764 766
765static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file, 767static int pl2303_tiocmset(struct tty_struct *tty, struct file *file,
766 unsigned int set, unsigned int clear) 768 unsigned int set, unsigned int clear)
767{ 769{
770 struct usb_serial_port *port = tty->driver_data;
768 struct pl2303_private *priv = usb_get_serial_port_data(port); 771 struct pl2303_private *priv = usb_get_serial_port_data(port);
769 unsigned long flags; 772 unsigned long flags;
770 u8 control; 773 u8 control;
@@ -787,8 +790,9 @@ static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file,
787 return set_control_lines(port->serial->dev, control); 790 return set_control_lines(port->serial->dev, control);
788} 791}
789 792
790static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file) 793static int pl2303_tiocmget(struct tty_struct *tty, struct file *file)
791{ 794{
795 struct usb_serial_port *port = tty->driver_data;
792 struct pl2303_private *priv = usb_get_serial_port_data(port); 796 struct pl2303_private *priv = usb_get_serial_port_data(port);
793 unsigned long flags; 797 unsigned long flags;
794 unsigned int mcr; 798 unsigned int mcr;
@@ -853,9 +857,10 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
853 return 0; 857 return 0;
854} 858}
855 859
856static int pl2303_ioctl(struct usb_serial_port *port, struct file *file, 860static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
857 unsigned int cmd, unsigned long arg) 861 unsigned int cmd, unsigned long arg)
858{ 862{
863 struct usb_serial_port *port = tty->driver_data;
859 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 864 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
860 865
861 switch (cmd) { 866 switch (cmd) {
@@ -871,8 +876,9 @@ static int pl2303_ioctl(struct usb_serial_port *port, struct file *file,
871 return -ENOIOCTLCMD; 876 return -ENOIOCTLCMD;
872} 877}
873 878
874static void pl2303_break_ctl(struct usb_serial_port *port, int break_state) 879static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
875{ 880{
881 struct usb_serial_port *port = tty->driver_data;
876 struct usb_serial *serial = port->serial; 882 struct usb_serial *serial = port->serial;
877 u16 state; 883 u16 state;
878 int result; 884 int result;
@@ -1001,7 +1007,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1001 1007
1002 if (status) { 1008 if (status) {
1003 dbg("%s - urb status = %d", __func__, status); 1009 dbg("%s - urb status = %d", __func__, status);
1004 if (!port->open_count) { 1010 if (!port->port.count) {
1005 dbg("%s - port is closed, exiting.", __func__); 1011 dbg("%s - port is closed, exiting.", __func__);
1006 return; 1012 return;
1007 } 1013 }
@@ -1044,7 +1050,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1044 tty_flag = TTY_FRAME; 1050 tty_flag = TTY_FRAME;
1045 dbg("%s - tty_flag = %d", __func__, tty_flag); 1051 dbg("%s - tty_flag = %d", __func__, tty_flag);
1046 1052
1047 tty = port->tty; 1053 tty = port->port.tty;
1048 if (tty && urb->actual_length) { 1054 if (tty && urb->actual_length) {
1049 tty_buffer_request_room(tty, urb->actual_length + 1); 1055 tty_buffer_request_room(tty, urb->actual_length + 1);
1050 /* overrun is special, not associated with a char */ 1056 /* overrun is special, not associated with a char */
@@ -1056,7 +1062,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1056 } 1062 }
1057 1063
1058 /* Schedule the next read _if_ we are still open */ 1064 /* Schedule the next read _if_ we are still open */
1059 if (port->open_count) { 1065 if (port->port.count) {
1060 urb->dev = port->serial->dev; 1066 urb->dev = port->serial->dev;
1061 result = usb_submit_urb(urb, GFP_ATOMIC); 1067 result = usb_submit_urb(urb, GFP_ATOMIC);
1062 if (result) 1068 if (result)
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 94bddf06ea4f..f823e4dcea1e 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -229,8 +229,8 @@ static void safe_read_bulk_callback (struct urb *urb)
229 int actual_length = data[length - 2] >> 2; 229 int actual_length = data[length - 2] >> 2;
230 if (actual_length <= (length - 2)) { 230 if (actual_length <= (length - 2)) {
231 info ("%s - actual: %d", __func__, actual_length); 231 info ("%s - actual: %d", __func__, actual_length);
232 tty_insert_flip_string(port->tty, data, actual_length); 232 tty_insert_flip_string(port->port.tty, data, actual_length);
233 tty_flip_buffer_push (port->tty); 233 tty_flip_buffer_push (port->port.tty);
234 } else { 234 } else {
235 err ("%s - inconsistent lengths %d:%d", __func__, 235 err ("%s - inconsistent lengths %d:%d", __func__,
236 actual_length, length); 236 actual_length, length);
@@ -239,8 +239,8 @@ static void safe_read_bulk_callback (struct urb *urb)
239 err ("%s - bad CRC %x", __func__, fcs); 239 err ("%s - bad CRC %x", __func__, fcs);
240 } 240 }
241 } else { 241 } else {
242 tty_insert_flip_string(port->tty, data, length); 242 tty_insert_flip_string(port->port.tty, data, length);
243 tty_flip_buffer_push (port->tty); 243 tty_flip_buffer_push (port->port.tty);
244 } 244 }
245 245
246 /* Continue trying to always read */ 246 /* Continue trying to always read */
@@ -255,7 +255,8 @@ static void safe_read_bulk_callback (struct urb *urb)
255 } 255 }
256} 256}
257 257
258static int safe_write (struct usb_serial_port *port, const unsigned char *buf, int count) 258static int safe_write(struct tty_struct *tty, struct usb_serial_port *port,
259 const unsigned char *buf, int count)
259{ 260{
260 unsigned char *data; 261 unsigned char *data;
261 int result; 262 int result;
@@ -349,8 +350,9 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i
349 return (count); 350 return (count);
350} 351}
351 352
352static int safe_write_room (struct usb_serial_port *port) 353static int safe_write_room(struct tty_struct *tty)
353{ 354{
355 struct usb_serial_port *port = tty->driver_data;
354 int room = 0; /* Default: no room */ 356 int room = 0; /* Default: no room */
355 unsigned long flags; 357 unsigned long flags;
356 358
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 29074c1ba22b..892020d48555 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -250,7 +250,8 @@ struct sierra_port_private {
250 int ri_state; 250 int ri_state;
251}; 251};
252 252
253static int sierra_send_setup(struct usb_serial_port *port) 253static int sierra_send_setup(struct tty_struct *tty,
254 struct usb_serial_port *port)
254{ 255{
255 struct usb_serial *serial = port->serial; 256 struct usb_serial *serial = port->serial;
256 struct sierra_port_private *portdata; 257 struct sierra_port_private *portdata;
@@ -260,7 +261,7 @@ static int sierra_send_setup(struct usb_serial_port *port)
260 261
261 portdata = usb_get_serial_port_data(port); 262 portdata = usb_get_serial_port_data(port);
262 263
263 if (port->tty) { 264 if (tty) {
264 int val = 0; 265 int val = 0;
265 if (portdata->dtr_state) 266 if (portdata->dtr_state)
266 val |= 0x01; 267 val |= 0x01;
@@ -284,32 +285,17 @@ static int sierra_send_setup(struct usb_serial_port *port)
284 return 0; 285 return 0;
285} 286}
286 287
287static void sierra_rx_throttle(struct usb_serial_port *port) 288static void sierra_set_termios(struct tty_struct *tty,
289 struct usb_serial_port *port, struct ktermios *old_termios)
288{ 290{
289 dbg("%s", __func__); 291 dbg("%s", __func__);
292 tty_termios_copy_hw(tty->termios, old_termios);
293 sierra_send_setup(tty, port);
290} 294}
291 295
292static void sierra_rx_unthrottle(struct usb_serial_port *port) 296static int sierra_tiocmget(struct tty_struct *tty, struct file *file)
293{
294 dbg("%s", __func__);
295}
296
297static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
298{
299 /* Unfortunately, I don't know how to send a break */
300 dbg("%s", __func__);
301}
302
303static void sierra_set_termios(struct usb_serial_port *port,
304 struct ktermios *old_termios)
305{
306 dbg("%s", __func__);
307 tty_termios_copy_hw(port->tty->termios, old_termios);
308 sierra_send_setup(port);
309}
310
311static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
312{ 297{
298 struct usb_serial_port *port = tty->driver_data;
313 unsigned int value; 299 unsigned int value;
314 struct sierra_port_private *portdata; 300 struct sierra_port_private *portdata;
315 301
@@ -325,9 +311,10 @@ static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
325 return value; 311 return value;
326} 312}
327 313
328static int sierra_tiocmset(struct usb_serial_port *port, struct file *file, 314static int sierra_tiocmset(struct tty_struct *tty, struct file *file,
329 unsigned int set, unsigned int clear) 315 unsigned int set, unsigned int clear)
330{ 316{
317 struct usb_serial_port *port = tty->driver_data;
331 struct sierra_port_private *portdata; 318 struct sierra_port_private *portdata;
332 319
333 portdata = usb_get_serial_port_data(port); 320 portdata = usb_get_serial_port_data(port);
@@ -341,13 +328,7 @@ static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
341 portdata->rts_state = 0; 328 portdata->rts_state = 0;
342 if (clear & TIOCM_DTR) 329 if (clear & TIOCM_DTR)
343 portdata->dtr_state = 0; 330 portdata->dtr_state = 0;
344 return sierra_send_setup(port); 331 return sierra_send_setup(tty, port);
345}
346
347static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
348 unsigned int cmd, unsigned long arg)
349{
350 return -ENOIOCTLCMD;
351} 332}
352 333
353static void sierra_outdat_callback(struct urb *urb) 334static void sierra_outdat_callback(struct urb *urb)
@@ -374,8 +355,8 @@ static void sierra_outdat_callback(struct urb *urb)
374} 355}
375 356
376/* Write */ 357/* Write */
377static int sierra_write(struct usb_serial_port *port, 358static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
378 const unsigned char *buf, int count) 359 const unsigned char *buf, int count)
379{ 360{
380 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 361 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
381 struct usb_serial *serial = port->serial; 362 struct usb_serial *serial = port->serial;
@@ -463,7 +444,7 @@ static void sierra_indat_callback(struct urb *urb)
463 dbg("%s: nonzero status: %d on endpoint %02x.", 444 dbg("%s: nonzero status: %d on endpoint %02x.",
464 __func__, status, endpoint); 445 __func__, status, endpoint);
465 } else { 446 } else {
466 tty = port->tty; 447 tty = port->port.tty;
467 if (urb->actual_length) { 448 if (urb->actual_length) {
468 tty_buffer_request_room(tty, urb->actual_length); 449 tty_buffer_request_room(tty, urb->actual_length);
469 tty_insert_flip_string(tty, data, urb->actual_length); 450 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -473,7 +454,7 @@ static void sierra_indat_callback(struct urb *urb)
473 } 454 }
474 455
475 /* Resubmit urb so we continue receiving */ 456 /* Resubmit urb so we continue receiving */
476 if (port->open_count && status != -ESHUTDOWN) { 457 if (port->port.count && status != -ESHUTDOWN) {
477 err = usb_submit_urb(urb, GFP_ATOMIC); 458 err = usb_submit_urb(urb, GFP_ATOMIC);
478 if (err) 459 if (err)
479 dev_err(&port->dev, "resubmit read urb failed." 460 dev_err(&port->dev, "resubmit read urb failed."
@@ -517,9 +498,9 @@ static void sierra_instat_callback(struct urb *urb)
517 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 498 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
518 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 499 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
519 500
520 if (port->tty && !C_CLOCAL(port->tty) && 501 if (port->port.tty && !C_CLOCAL(port->port.tty) &&
521 old_dcd_state && !portdata->dcd_state) 502 old_dcd_state && !portdata->dcd_state)
522 tty_hangup(port->tty); 503 tty_hangup(port->port.tty);
523 } else { 504 } else {
524 dbg("%s: type %x req %x", __func__, 505 dbg("%s: type %x req %x", __func__,
525 req_pkt->bRequestType, req_pkt->bRequest); 506 req_pkt->bRequestType, req_pkt->bRequest);
@@ -537,8 +518,9 @@ static void sierra_instat_callback(struct urb *urb)
537 } 518 }
538} 519}
539 520
540static int sierra_write_room(struct usb_serial_port *port) 521static int sierra_write_room(struct tty_struct *tty)
541{ 522{
523 struct usb_serial_port *port = tty->driver_data;
542 struct sierra_port_private *portdata = usb_get_serial_port_data(port); 524 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
543 unsigned long flags; 525 unsigned long flags;
544 526
@@ -557,22 +539,8 @@ static int sierra_write_room(struct usb_serial_port *port)
557 return 2048; 539 return 2048;
558} 540}
559 541
560static int sierra_chars_in_buffer(struct usb_serial_port *port) 542static int sierra_open(struct tty_struct *tty,
561{ 543 struct usb_serial_port *port, struct file *filp)
562 dbg("%s - port %d", __func__, port->number);
563
564 /*
565 * We can't really account for how much data we
566 * have sent out, but hasn't made it through to the
567 * device as we can't see the backend here, so just
568 * tell the tty layer that everything is flushed.
569 *
570 * FIXME: should walk the outstanding urbs info
571 */
572 return 0;
573}
574
575static int sierra_open(struct usb_serial_port *port, struct file *filp)
576{ 544{
577 struct sierra_port_private *portdata; 545 struct sierra_port_private *portdata;
578 struct usb_serial *serial = port->serial; 546 struct usb_serial *serial = port->serial;
@@ -612,9 +580,10 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
612 } 580 }
613 } 581 }
614 582
615 port->tty->low_latency = 1; 583 if (tty)
584 tty->low_latency = 1;
616 585
617 sierra_send_setup(port); 586 sierra_send_setup(tty, port);
618 587
619 /* start up the interrupt endpoint if we have one */ 588 /* start up the interrupt endpoint if we have one */
620 if (port->interrupt_in_urb) { 589 if (port->interrupt_in_urb) {
@@ -626,7 +595,8 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
626 return 0; 595 return 0;
627} 596}
628 597
629static void sierra_close(struct usb_serial_port *port, struct file *filp) 598static void sierra_close(struct tty_struct *tty,
599 struct usb_serial_port *port, struct file *filp)
630{ 600{
631 int i; 601 int i;
632 struct usb_serial *serial = port->serial; 602 struct usb_serial *serial = port->serial;
@@ -641,7 +611,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
641 if (serial->dev) { 611 if (serial->dev) {
642 mutex_lock(&serial->disc_mutex); 612 mutex_lock(&serial->disc_mutex);
643 if (!serial->disconnected) 613 if (!serial->disconnected)
644 sierra_send_setup(port); 614 sierra_send_setup(tty, port);
645 mutex_unlock(&serial->disc_mutex); 615 mutex_unlock(&serial->disc_mutex);
646 616
647 /* Stop reading/writing urbs */ 617 /* Stop reading/writing urbs */
@@ -651,7 +621,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
651 621
652 usb_kill_urb(port->interrupt_in_urb); 622 usb_kill_urb(port->interrupt_in_urb);
653 623
654 port->tty = NULL; 624 port->port.tty = NULL; /* FIXME */
655} 625}
656 626
657static int sierra_startup(struct usb_serial *serial) 627static int sierra_startup(struct usb_serial *serial)
@@ -754,12 +724,7 @@ static struct usb_serial_driver sierra_device = {
754 .close = sierra_close, 724 .close = sierra_close,
755 .write = sierra_write, 725 .write = sierra_write,
756 .write_room = sierra_write_room, 726 .write_room = sierra_write_room,
757 .chars_in_buffer = sierra_chars_in_buffer,
758 .throttle = sierra_rx_throttle,
759 .unthrottle = sierra_rx_unthrottle,
760 .ioctl = sierra_ioctl,
761 .set_termios = sierra_set_termios, 727 .set_termios = sierra_set_termios,
762 .break_ctl = sierra_break_ctl,
763 .tiocmget = sierra_tiocmget, 728 .tiocmget = sierra_tiocmget,
764 .tiocmset = sierra_tiocmset, 729 .tiocmset = sierra_tiocmset,
765 .attach = sierra_startup, 730 .attach = sierra_startup,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 55b2570b8b8b..58495f5cca1f 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -448,7 +448,8 @@ static void spcp8x5_set_workMode(struct usb_device *dev, u16 value,
448 448
449/* close the serial port. We should wait for data sending to device 1st and 449/* close the serial port. We should wait for data sending to device 1st and
450 * then kill all urb. */ 450 * then kill all urb. */
451static void spcp8x5_close(struct usb_serial_port *port, struct file *filp) 451static void spcp8x5_close(struct tty_struct *tty,
452 struct usb_serial_port *port, struct file *filp)
452{ 453{
453 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 454 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
454 unsigned long flags; 455 unsigned long flags;
@@ -464,7 +465,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
464 spin_lock_irqsave(&priv->lock, flags); 465 spin_lock_irqsave(&priv->lock, flags);
465 timeout = SPCP8x5_CLOSING_WAIT; 466 timeout = SPCP8x5_CLOSING_WAIT;
466 init_waitqueue_entry(&wait, current); 467 init_waitqueue_entry(&wait, current);
467 add_wait_queue(&port->tty->write_wait, &wait); 468 add_wait_queue(&tty->write_wait, &wait);
468 for (;;) { 469 for (;;) {
469 set_current_state(TASK_INTERRUPTIBLE); 470 set_current_state(TASK_INTERRUPTIBLE);
470 if (ringbuf_avail_data(priv->buf) == 0 || 471 if (ringbuf_avail_data(priv->buf) == 0 ||
@@ -475,7 +476,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
475 spin_lock_irqsave(&priv->lock, flags); 476 spin_lock_irqsave(&priv->lock, flags);
476 } 477 }
477 set_current_state(TASK_RUNNING); 478 set_current_state(TASK_RUNNING);
478 remove_wait_queue(&port->tty->write_wait, &wait); 479 remove_wait_queue(&tty->write_wait, &wait);
479 480
480 /* clear out any remaining data in the buffer */ 481 /* clear out any remaining data in the buffer */
481 clear_ringbuf(priv->buf); 482 clear_ringbuf(priv->buf);
@@ -486,7 +487,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
486 * flow control for data rates of 1200 bps or more, for lower rates we 487 * flow control for data rates of 1200 bps or more, for lower rates we
487 * should really know how much data is in the buffer to compute a delay 488 * should really know how much data is in the buffer to compute a delay
488 * that is not unnecessarily long) */ 489 * that is not unnecessarily long) */
489 bps = tty_get_baud_rate(port->tty); 490 bps = tty_get_baud_rate(tty);
490 if (bps > 1200) 491 if (bps > 1200)
491 timeout = max((HZ*2560) / bps, HZ/10); 492 timeout = max((HZ*2560) / bps, HZ/10);
492 else 493 else
@@ -495,8 +496,8 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
495 schedule_timeout(timeout); 496 schedule_timeout(timeout);
496 497
497 /* clear control lines */ 498 /* clear control lines */
498 if (port->tty) { 499 if (tty) {
499 c_cflag = port->tty->termios->c_cflag; 500 c_cflag = tty->termios->c_cflag;
500 if (c_cflag & HUPCL) { 501 if (c_cflag & HUPCL) {
501 spin_lock_irqsave(&priv->lock, flags); 502 spin_lock_irqsave(&priv->lock, flags);
502 priv->line_control = 0; 503 priv->line_control = 0;
@@ -518,14 +519,14 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
518} 519}
519 520
520/* set the serial param for transfer. we should check if we really need to 521/* set the serial param for transfer. we should check if we really need to
521 * transfer. then if be set flow contorl we should do this too. */ 522 * transfer. if we set flow control we should do this too. */
522static void spcp8x5_set_termios(struct usb_serial_port *port, 523static void spcp8x5_set_termios(struct tty_struct *tty,
523 struct ktermios *old_termios) 524 struct usb_serial_port *port, struct ktermios *old_termios)
524{ 525{
525 struct usb_serial *serial = port->serial; 526 struct usb_serial *serial = port->serial;
526 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 527 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
527 unsigned long flags; 528 unsigned long flags;
528 unsigned int cflag = port->tty->termios->c_cflag; 529 unsigned int cflag = tty->termios->c_cflag;
529 unsigned int old_cflag = old_termios->c_cflag; 530 unsigned int old_cflag = old_termios->c_cflag;
530 unsigned short uartdata; 531 unsigned short uartdata;
531 unsigned char buf[2] = {0, 0}; 532 unsigned char buf[2] = {0, 0};
@@ -533,21 +534,19 @@ static void spcp8x5_set_termios(struct usb_serial_port *port,
533 int i; 534 int i;
534 u8 control; 535 u8 control;
535 536
536 if ((!port->tty) || (!port->tty->termios))
537 return;
538
539 /* for the 1st time call this function */ 537 /* for the 1st time call this function */
540 spin_lock_irqsave(&priv->lock, flags); 538 spin_lock_irqsave(&priv->lock, flags);
541 if (!priv->termios_initialized) { 539 if (!priv->termios_initialized) {
542 *(port->tty->termios) = tty_std_termios; 540 *(tty->termios) = tty_std_termios;
543 port->tty->termios->c_cflag = B115200 | CS8 | CREAD | 541 tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
544 HUPCL | CLOCAL; 542 tty->termios->c_ispeed = 115200;
543 tty->termios->c_ospeed = 115200;
545 priv->termios_initialized = 1; 544 priv->termios_initialized = 1;
546 } 545 }
547 spin_unlock_irqrestore(&priv->lock, flags); 546 spin_unlock_irqrestore(&priv->lock, flags);
548 547
549 /* check that they really want us to change something */ 548 /* check that they really want us to change something */
550 if (!tty_termios_hw_change(port->tty->termios, old_termios)) 549 if (!tty_termios_hw_change(tty->termios, old_termios))
551 return; 550 return;
552 551
553 /* set DTR/RTS active */ 552 /* set DTR/RTS active */
@@ -567,7 +566,7 @@ static void spcp8x5_set_termios(struct usb_serial_port *port,
567 } 566 }
568 567
569 /* Set Baud Rate */ 568 /* Set Baud Rate */
570 baud = tty_get_baud_rate(port->tty);; 569 baud = tty_get_baud_rate(tty);;
571 switch (baud) { 570 switch (baud) {
572 case 300: buf[0] = 0x00; break; 571 case 300: buf[0] = 0x00; break;
573 case 600: buf[0] = 0x01; break; 572 case 600: buf[0] = 0x01; break;
@@ -643,7 +642,8 @@ static void spcp8x5_set_termios(struct usb_serial_port *port,
643 642
644/* open the serial port. do some usb system call. set termios and get the line 643/* open the serial port. do some usb system call. set termios and get the line
645 * status of the device. then submit the read urb */ 644 * status of the device. then submit the read urb */
646static int spcp8x5_open(struct usb_serial_port *port, struct file *filp) 645static int spcp8x5_open(struct tty_struct *tty,
646 struct usb_serial_port *port, struct file *filp)
647{ 647{
648 struct ktermios tmp_termios; 648 struct ktermios tmp_termios;
649 struct usb_serial *serial = port->serial; 649 struct usb_serial *serial = port->serial;
@@ -665,7 +665,7 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
665 return ret; 665 return ret;
666 666
667 spin_lock_irqsave(&priv->lock, flags); 667 spin_lock_irqsave(&priv->lock, flags);
668 if (port->tty->termios->c_cflag & CBAUD) 668 if (tty && (tty->termios->c_cflag & CBAUD))
669 priv->line_control = MCR_DTR | MCR_RTS; 669 priv->line_control = MCR_DTR | MCR_RTS;
670 else 670 else
671 priv->line_control = 0; 671 priv->line_control = 0;
@@ -674,8 +674,8 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
674 spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type); 674 spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type);
675 675
676 /* Setup termios */ 676 /* Setup termios */
677 if (port->tty) 677 if (tty)
678 spcp8x5_set_termios(port, &tmp_termios); 678 spcp8x5_set_termios(tty, port, &tmp_termios);
679 679
680 spcp8x5_get_msr(serial->dev, &status, priv->type); 680 spcp8x5_get_msr(serial->dev, &status, priv->type);
681 681
@@ -690,7 +690,7 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
690 port->read_urb->dev = serial->dev; 690 port->read_urb->dev = serial->dev;
691 ret = usb_submit_urb(port->read_urb, GFP_KERNEL); 691 ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
692 if (ret) { 692 if (ret) {
693 spcp8x5_close(port, NULL); 693 spcp8x5_close(tty, port, NULL);
694 return -EPROTO; 694 return -EPROTO;
695 } 695 }
696 return 0; 696 return 0;
@@ -717,7 +717,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
717 717
718 /* check the urb status */ 718 /* check the urb status */
719 if (urb->status) { 719 if (urb->status) {
720 if (!port->open_count) 720 if (!port->port.count)
721 return; 721 return;
722 if (urb->status == -EPROTO) { 722 if (urb->status == -EPROTO) {
723 /* spcp8x5 mysteriously fails with -EPROTO */ 723 /* spcp8x5 mysteriously fails with -EPROTO */
@@ -755,7 +755,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
755 tty_flag = TTY_FRAME; 755 tty_flag = TTY_FRAME;
756 dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag); 756 dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag);
757 757
758 tty = port->tty; 758 tty = port->port.tty;
759 if (tty && urb->actual_length) { 759 if (tty && urb->actual_length) {
760 tty_buffer_request_room(tty, urb->actual_length + 1); 760 tty_buffer_request_room(tty, urb->actual_length + 1);
761 /* overrun is special, not associated with a char */ 761 /* overrun is special, not associated with a char */
@@ -767,7 +767,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
767 } 767 }
768 768
769 /* Schedule the next read _if_ we are still open */ 769 /* Schedule the next read _if_ we are still open */
770 if (port->open_count) { 770 if (port->port.count) {
771 urb->dev = port->serial->dev; 771 urb->dev = port->serial->dev;
772 result = usb_submit_urb(urb , GFP_ATOMIC); 772 result = usb_submit_urb(urb , GFP_ATOMIC);
773 if (result) 773 if (result)
@@ -866,7 +866,7 @@ static void spcp8x5_write_bulk_callback(struct urb *urb)
866} 866}
867 867
868/* write data to ring buffer. and then start the write transfer */ 868/* write data to ring buffer. and then start the write transfer */
869static int spcp8x5_write(struct usb_serial_port *port, 869static int spcp8x5_write(struct tty_struct *tty, struct usb_serial_port *port,
870 const unsigned char *buf, int count) 870 const unsigned char *buf, int count)
871{ 871{
872 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 872 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
@@ -925,9 +925,10 @@ static int spcp8x5_wait_modem_info(struct usb_serial_port *port,
925 return 0; 925 return 0;
926} 926}
927 927
928static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file, 928static int spcp8x5_ioctl(struct tty_struct *tty, struct file *file,
929 unsigned int cmd, unsigned long arg) 929 unsigned int cmd, unsigned long arg)
930{ 930{
931 struct usb_serial_port *port = tty->driver_data;
931 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 932 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
932 933
933 switch (cmd) { 934 switch (cmd) {
@@ -943,9 +944,10 @@ static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file,
943 return -ENOIOCTLCMD; 944 return -ENOIOCTLCMD;
944} 945}
945 946
946static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file, 947static int spcp8x5_tiocmset(struct tty_struct *tty, struct file *file,
947 unsigned int set, unsigned int clear) 948 unsigned int set, unsigned int clear)
948{ 949{
950 struct usb_serial_port *port = tty->driver_data;
949 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 951 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
950 unsigned long flags; 952 unsigned long flags;
951 u8 control; 953 u8 control;
@@ -965,8 +967,9 @@ static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file,
965 return spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type); 967 return spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type);
966} 968}
967 969
968static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file) 970static int spcp8x5_tiocmget(struct tty_struct *tty, struct file *file)
969{ 971{
972 struct usb_serial_port *port = tty->driver_data;
970 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 973 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
971 unsigned long flags; 974 unsigned long flags;
972 unsigned int mcr; 975 unsigned int mcr;
@@ -989,8 +992,9 @@ static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file)
989} 992}
990 993
991/* get the avail space room in ring buffer */ 994/* get the avail space room in ring buffer */
992static int spcp8x5_write_room(struct usb_serial_port *port) 995static int spcp8x5_write_room(struct tty_struct *tty)
993{ 996{
997 struct usb_serial_port *port = tty->driver_data;
994 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 998 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
995 int room = 0; 999 int room = 0;
996 unsigned long flags; 1000 unsigned long flags;
@@ -1003,8 +1007,9 @@ static int spcp8x5_write_room(struct usb_serial_port *port)
1003} 1007}
1004 1008
1005/* get the number of avail data in write ring buffer */ 1009/* get the number of avail data in write ring buffer */
1006static int spcp8x5_chars_in_buffer(struct usb_serial_port *port) 1010static int spcp8x5_chars_in_buffer(struct tty_struct *tty)
1007{ 1011{
1012 struct usb_serial_port *port = tty->driver_data;
1008 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 1013 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
1009 int chars = 0; 1014 int chars = 0;
1010 unsigned long flags; 1015 unsigned long flags;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index a26a629dfc4f..48831a755fc1 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -70,6 +70,7 @@
70 70
71#include <linux/kernel.h> 71#include <linux/kernel.h>
72#include <linux/errno.h> 72#include <linux/errno.h>
73#include <linux/firmware.h>
73#include <linux/init.h> 74#include <linux/init.h>
74#include <linux/slab.h> 75#include <linux/slab.h>
75#include <linux/tty.h> 76#include <linux/tty.h>
@@ -149,21 +150,23 @@ struct ti_device {
149 150
150static int ti_startup(struct usb_serial *serial); 151static int ti_startup(struct usb_serial *serial);
151static void ti_shutdown(struct usb_serial *serial); 152static void ti_shutdown(struct usb_serial *serial);
152static int ti_open(struct usb_serial_port *port, struct file *file); 153static int ti_open(struct tty_struct *tty, struct usb_serial_port *port,
153static void ti_close(struct usb_serial_port *port, struct file *file); 154 struct file *file);
154static int ti_write(struct usb_serial_port *port, const unsigned char *data, 155static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
155 int count); 156 struct file *file);
156static int ti_write_room(struct usb_serial_port *port); 157static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
157static int ti_chars_in_buffer(struct usb_serial_port *port); 158 const unsigned char *data, int count);
158static void ti_throttle(struct usb_serial_port *port); 159static int ti_write_room(struct tty_struct *tty);
159static void ti_unthrottle(struct usb_serial_port *port); 160static int ti_chars_in_buffer(struct tty_struct *tty);
160static int ti_ioctl(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg); 161static void ti_throttle(struct tty_struct *tty);
161static void ti_set_termios(struct usb_serial_port *port, 162static void ti_unthrottle(struct tty_struct *tty);
163static int ti_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
164static void ti_set_termios(struct tty_struct *tty, struct usb_serial_port *port,
162 struct ktermios *old_termios); 165 struct ktermios *old_termios);
163static int ti_tiocmget(struct usb_serial_port *port, struct file *file); 166static int ti_tiocmget(struct tty_struct *tty, struct file *file);
164static int ti_tiocmset(struct usb_serial_port *port, struct file *file, 167static int ti_tiocmset(struct tty_struct *tty, struct file *file,
165 unsigned int set, unsigned int clear); 168 unsigned int set, unsigned int clear);
166static void ti_break(struct usb_serial_port *port, int break_state); 169static void ti_break(struct tty_struct *tty, int break_state);
167static void ti_interrupt_callback(struct urb *urb); 170static void ti_interrupt_callback(struct urb *urb);
168static void ti_bulk_in_callback(struct urb *urb); 171static void ti_bulk_in_callback(struct urb *urb);
169static void ti_bulk_out_callback(struct urb *urb); 172static void ti_bulk_out_callback(struct urb *urb);
@@ -192,8 +195,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
192static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 195static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
193 __u8 mask, __u8 byte); 196 __u8 mask, __u8 byte);
194 197
195static int ti_download_firmware(struct ti_device *tdev, char *fw_name); 198static int ti_download_firmware(struct ti_device *tdev, int type);
196
197 199
198/* circular buffer */ 200/* circular buffer */
199static struct circ_buf *ti_buf_alloc(void); 201static struct circ_buf *ti_buf_alloc(void);
@@ -430,11 +432,10 @@ static int ti_startup(struct usb_serial *serial)
430 432
431 /* if we have only 1 configuration, download firmware */ 433 /* if we have only 1 configuration, download firmware */
432 if (dev->descriptor.bNumConfigurations == 1) { 434 if (dev->descriptor.bNumConfigurations == 1) {
433
434 if (tdev->td_is_3410) 435 if (tdev->td_is_3410)
435 status = ti_download_firmware(tdev, "ti_3410.fw"); 436 status = ti_download_firmware(tdev, 3410);
436 else 437 else
437 status = ti_download_firmware(tdev, "ti_5052.fw"); 438 status = ti_download_firmware(tdev, 5052);
438 if (status) 439 if (status)
439 goto free_tdev; 440 goto free_tdev;
440 441
@@ -519,7 +520,8 @@ static void ti_shutdown(struct usb_serial *serial)
519} 520}
520 521
521 522
522static int ti_open(struct usb_serial_port *port, struct file *file) 523static int ti_open(struct tty_struct *tty,
524 struct usb_serial_port *port, struct file *file)
523{ 525{
524 struct ti_port *tport = usb_get_serial_port_data(port); 526 struct ti_port *tport = usb_get_serial_port_data(port);
525 struct ti_device *tdev; 527 struct ti_device *tdev;
@@ -543,9 +545,9 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
543 if (mutex_lock_interruptible(&tdev->td_open_close_lock)) 545 if (mutex_lock_interruptible(&tdev->td_open_close_lock))
544 return -ERESTARTSYS; 546 return -ERESTARTSYS;
545 547
546 if (port->tty) 548 if (tty)
547 port->tty->low_latency = 549 tty->low_latency =
548 (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; 550 (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
549 551
550 port_number = port->number - port->serial->minor; 552 port_number = port->number - port->serial->minor;
551 553
@@ -573,7 +575,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
573 } 575 }
574 } 576 }
575 577
576 ti_set_termios(port, port->tty->termios); 578 if (tty)
579 ti_set_termios(tty, port, tty->termios);
577 580
578 dbg("%s - sending TI_OPEN_PORT", __func__); 581 dbg("%s - sending TI_OPEN_PORT", __func__);
579 status = ti_command_out_sync(tdev, TI_OPEN_PORT, 582 status = ti_command_out_sync(tdev, TI_OPEN_PORT,
@@ -610,7 +613,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
610 usb_clear_halt(dev, port->write_urb->pipe); 613 usb_clear_halt(dev, port->write_urb->pipe);
611 usb_clear_halt(dev, port->read_urb->pipe); 614 usb_clear_halt(dev, port->read_urb->pipe);
612 615
613 ti_set_termios(port, port->tty->termios); 616 if (tty)
617 ti_set_termios(tty, port, tty->termios);
614 618
615 dbg("%s - sending TI_OPEN_PORT (2)", __func__); 619 dbg("%s - sending TI_OPEN_PORT (2)", __func__);
616 status = ti_command_out_sync(tdev, TI_OPEN_PORT, 620 status = ti_command_out_sync(tdev, TI_OPEN_PORT,
@@ -661,7 +665,8 @@ release_lock:
661} 665}
662 666
663 667
664static void ti_close(struct usb_serial_port *port, struct file *file) 668static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
669 struct file *file)
665{ 670{
666 struct ti_device *tdev; 671 struct ti_device *tdev;
667 struct ti_port *tport; 672 struct ti_port *tport;
@@ -707,8 +712,8 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
707} 712}
708 713
709 714
710static int ti_write(struct usb_serial_port *port, const unsigned char *data, 715static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
711 int count) 716 const unsigned char *data, int count)
712{ 717{
713 struct ti_port *tport = usb_get_serial_port_data(port); 718 struct ti_port *tport = usb_get_serial_port_data(port);
714 unsigned long flags; 719 unsigned long flags;
@@ -733,8 +738,9 @@ static int ti_write(struct usb_serial_port *port, const unsigned char *data,
733} 738}
734 739
735 740
736static int ti_write_room(struct usb_serial_port *port) 741static int ti_write_room(struct tty_struct *tty)
737{ 742{
743 struct usb_serial_port *port = tty->driver_data;
738 struct ti_port *tport = usb_get_serial_port_data(port); 744 struct ti_port *tport = usb_get_serial_port_data(port);
739 int room = 0; 745 int room = 0;
740 unsigned long flags; 746 unsigned long flags;
@@ -753,8 +759,9 @@ static int ti_write_room(struct usb_serial_port *port)
753} 759}
754 760
755 761
756static int ti_chars_in_buffer(struct usb_serial_port *port) 762static int ti_chars_in_buffer(struct tty_struct *tty)
757{ 763{
764 struct usb_serial_port *port = tty->driver_data;
758 struct ti_port *tport = usb_get_serial_port_data(port); 765 struct ti_port *tport = usb_get_serial_port_data(port);
759 int chars = 0; 766 int chars = 0;
760 unsigned long flags; 767 unsigned long flags;
@@ -773,32 +780,26 @@ static int ti_chars_in_buffer(struct usb_serial_port *port)
773} 780}
774 781
775 782
776static void ti_throttle(struct usb_serial_port *port) 783static void ti_throttle(struct tty_struct *tty)
777{ 784{
785 struct usb_serial_port *port = tty->driver_data;
778 struct ti_port *tport = usb_get_serial_port_data(port); 786 struct ti_port *tport = usb_get_serial_port_data(port);
779 struct tty_struct *tty;
780 787
781 dbg("%s - port %d", __func__, port->number); 788 dbg("%s - port %d", __func__, port->number);
782 789
783 if (tport == NULL) 790 if (tport == NULL)
784 return; 791 return;
785 792
786 tty = port->tty;
787 if (!tty) {
788 dbg("%s - no tty", __func__);
789 return;
790 }
791
792 if (I_IXOFF(tty) || C_CRTSCTS(tty)) 793 if (I_IXOFF(tty) || C_CRTSCTS(tty))
793 ti_stop_read(tport, tty); 794 ti_stop_read(tport, tty);
794 795
795} 796}
796 797
797 798
798static void ti_unthrottle(struct usb_serial_port *port) 799static void ti_unthrottle(struct tty_struct *tty)
799{ 800{
801 struct usb_serial_port *port = tty->driver_data;
800 struct ti_port *tport = usb_get_serial_port_data(port); 802 struct ti_port *tport = usb_get_serial_port_data(port);
801 struct tty_struct *tty;
802 int status; 803 int status;
803 804
804 dbg("%s - port %d", __func__, port->number); 805 dbg("%s - port %d", __func__, port->number);
@@ -806,12 +807,6 @@ static void ti_unthrottle(struct usb_serial_port *port)
806 if (tport == NULL) 807 if (tport == NULL)
807 return; 808 return;
808 809
809 tty = port->tty;
810 if (!tty) {
811 dbg("%s - no tty", __func__);
812 return;
813 }
814
815 if (I_IXOFF(tty) || C_CRTSCTS(tty)) { 810 if (I_IXOFF(tty) || C_CRTSCTS(tty)) {
816 status = ti_restart_read(tport, tty); 811 status = ti_restart_read(tport, tty);
817 if (status) 812 if (status)
@@ -820,9 +815,10 @@ static void ti_unthrottle(struct usb_serial_port *port)
820} 815}
821 816
822 817
823static int ti_ioctl(struct usb_serial_port *port, struct file *file, 818static int ti_ioctl(struct tty_struct *tty, struct file *file,
824 unsigned int cmd, unsigned long arg) 819 unsigned int cmd, unsigned long arg)
825{ 820{
821 struct usb_serial_port *port = tty->driver_data;
826 struct ti_port *tport = usb_get_serial_port_data(port); 822 struct ti_port *tport = usb_get_serial_port_data(port);
827 struct async_icount cnow; 823 struct async_icount cnow;
828 struct async_icount cprev; 824 struct async_icount cprev;
@@ -875,11 +871,10 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file,
875} 871}
876 872
877 873
878static void ti_set_termios(struct usb_serial_port *port, 874static void ti_set_termios(struct tty_struct *tty,
879 struct ktermios *old_termios) 875 struct usb_serial_port *port, struct ktermios *old_termios)
880{ 876{
881 struct ti_port *tport = usb_get_serial_port_data(port); 877 struct ti_port *tport = usb_get_serial_port_data(port);
882 struct tty_struct *tty = port->tty;
883 struct ti_uart_config *config; 878 struct ti_uart_config *config;
884 tcflag_t cflag,iflag; 879 tcflag_t cflag,iflag;
885 int baud; 880 int baud;
@@ -1008,8 +1003,9 @@ static void ti_set_termios(struct usb_serial_port *port,
1008} 1003}
1009 1004
1010 1005
1011static int ti_tiocmget(struct usb_serial_port *port, struct file *file) 1006static int ti_tiocmget(struct tty_struct *tty, struct file *file)
1012{ 1007{
1008 struct usb_serial_port *port = tty->driver_data;
1013 struct ti_port *tport = usb_get_serial_port_data(port); 1009 struct ti_port *tport = usb_get_serial_port_data(port);
1014 unsigned int result; 1010 unsigned int result;
1015 unsigned int msr; 1011 unsigned int msr;
@@ -1040,9 +1036,10 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file)
1040} 1036}
1041 1037
1042 1038
1043static int ti_tiocmset(struct usb_serial_port *port, struct file *file, 1039static int ti_tiocmset(struct tty_struct *tty, struct file *file,
1044 unsigned int set, unsigned int clear) 1040 unsigned int set, unsigned int clear)
1045{ 1041{
1042 struct usb_serial_port *port = tty->driver_data;
1046 struct ti_port *tport = usb_get_serial_port_data(port); 1043 struct ti_port *tport = usb_get_serial_port_data(port);
1047 unsigned int mcr; 1044 unsigned int mcr;
1048 unsigned long flags; 1045 unsigned long flags;
@@ -1074,8 +1071,9 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
1074} 1071}
1075 1072
1076 1073
1077static void ti_break(struct usb_serial_port *port, int break_state) 1074static void ti_break(struct tty_struct *tty, int break_state)
1078{ 1075{
1076 struct usb_serial_port *port = tty->driver_data;
1079 struct ti_port *tport = usb_get_serial_port_data(port); 1077 struct ti_port *tport = usb_get_serial_port_data(port);
1080 int status; 1078 int status;
1081 1079
@@ -1213,14 +1211,14 @@ static void ti_bulk_in_callback(struct urb *urb)
1213 return; 1211 return;
1214 } 1212 }
1215 1213
1216 if (port->tty && urb->actual_length) { 1214 if (port->port.tty && urb->actual_length) {
1217 usb_serial_debug_data(debug, dev, __func__, 1215 usb_serial_debug_data(debug, dev, __func__,
1218 urb->actual_length, urb->transfer_buffer); 1216 urb->actual_length, urb->transfer_buffer);
1219 1217
1220 if (!tport->tp_is_open) 1218 if (!tport->tp_is_open)
1221 dbg("%s - port closed, dropping data", __func__); 1219 dbg("%s - port closed, dropping data", __func__);
1222 else 1220 else
1223 ti_recv(&urb->dev->dev, port->tty, urb->transfer_buffer, 1221 ti_recv(&urb->dev->dev, port->port.tty, urb->transfer_buffer,
1224 urb->actual_length); 1222 urb->actual_length);
1225 1223
1226 spin_lock(&tport->tp_lock); 1224 spin_lock(&tport->tp_lock);
@@ -1302,7 +1300,7 @@ static void ti_send(struct ti_port *tport)
1302{ 1300{
1303 int count, result; 1301 int count, result;
1304 struct usb_serial_port *port = tport->tp_port; 1302 struct usb_serial_port *port = tport->tp_port;
1305 struct tty_struct *tty = port->tty; 1303 struct tty_struct *tty = port->port.tty; /* FIXME */
1306 unsigned long flags; 1304 unsigned long flags;
1307 1305
1308 1306
@@ -1442,8 +1440,9 @@ static int ti_set_serial_info(struct ti_port *tport,
1442 return -EFAULT; 1440 return -EFAULT;
1443 1441
1444 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; 1442 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS;
1445 if (port->tty) 1443 /* FIXME */
1446 port->tty->low_latency = 1444 if (port->port.tty)
1445 port->port.tty->low_latency =
1447 (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1446 (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1448 tport->tp_closing_wait = new_serial.closing_wait; 1447 tport->tp_closing_wait = new_serial.closing_wait;
1449 1448
@@ -1477,7 +1476,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1477 tport->tp_msr = msr & TI_MSR_MASK; 1476 tport->tp_msr = msr & TI_MSR_MASK;
1478 1477
1479 /* handle CTS flow control */ 1478 /* handle CTS flow control */
1480 tty = tport->tp_port->tty; 1479 tty = tport->tp_port->port.tty;
1481 if (tty && C_CRTSCTS(tty)) { 1480 if (tty && C_CRTSCTS(tty)) {
1482 if (msr & TI_MSR_CTS) { 1481 if (msr & TI_MSR_CTS) {
1483 tty->hw_stopped = 0; 1482 tty->hw_stopped = 0;
@@ -1655,65 +1654,65 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
1655 return status; 1654 return status;
1656} 1655}
1657 1656
1658 1657static int ti_do_download(struct usb_device *dev, int pipe,
1659static int ti_download_firmware(struct ti_device *tdev, 1658 u8 *buffer, int size)
1660 char *fw_name)
1661{ 1659{
1662 const struct firmware *fw;
1663 int status = 0;
1664 int buffer_size;
1665 int pos; 1660 int pos;
1666 int len; 1661 u8 cs = 0;
1667 int done; 1662 int done;
1668 __u8 cs = 0;
1669 __u8 *buffer;
1670 struct usb_device *dev = tdev->td_serial->dev;
1671 struct ti_firmware_header *header; 1663 struct ti_firmware_header *header;
1672 unsigned int pipe = usb_sndbulkpipe(dev, 1664 int status;
1673 tdev->td_serial->port[0]->bulk_out_endpointAddress); 1665 int len;
1674 1666
1675 buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); 1667 for(pos = sizeof(struct ti_firmware_header); pos < size; pos++)
1676
1677 if (request_firmware(&fw, fw_name, &dev->dev)) {
1678 dev_err(&dev->dev, "%s - failed to load firmware \"%s\"\n",
1679 __func__, fw_name);
1680 return -ENOENT;
1681 }
1682 if (fw->size > buffer_size) {
1683 dev_err(&dev->dev, "%s - firmware \"%s\" is too large\n",
1684 __func__, fw_name);
1685 release_firmware(fw);
1686 return -EINVAL;
1687 }
1688
1689 buffer = kmalloc(buffer_size, GFP_KERNEL);
1690 if (!buffer) {
1691 dev_err(&dev->dev, "%s - out of memory\n", __func__);
1692 release_firmware(fw);
1693 return -ENOMEM;
1694 }
1695
1696 memcpy(buffer, fw->data, fw->size);
1697 memset(buffer+fw->size, 0xff, buffer_size-fw->size);
1698
1699 for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++)
1700 cs = (__u8)(cs + buffer[pos]); 1668 cs = (__u8)(cs + buffer[pos]);
1701 1669
1702 header = (struct ti_firmware_header *)buffer; 1670 header = (struct ti_firmware_header *)buffer;
1703 header->wLength = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_firmware_header))); 1671 header->wLength = cpu_to_le16((__u16)(size
1672 - sizeof(struct ti_firmware_header)));
1704 header->bCheckSum = cs; 1673 header->bCheckSum = cs;
1705 1674
1706 dbg("%s - downloading firmware", __func__); 1675 dbg("%s - downloading firmware", __func__);
1707 for (pos = 0; pos < buffer_size; pos += done) { 1676 for (pos = 0; pos < size; pos += done) {
1708 len = min(buffer_size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); 1677 len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE);
1709 status = usb_bulk_msg(dev, pipe, buffer+pos, len, &done, 1000); 1678 status = usb_bulk_msg(dev, pipe, buffer + pos, len,
1679 &done, 1000);
1710 if (status) 1680 if (status)
1711 break; 1681 break;
1712 } 1682 }
1683 return status;
1684}
1713 1685
1714 kfree(buffer); 1686static int ti_download_firmware(struct ti_device *tdev, int type)
1715 release_firmware(fw); 1687{
1688 int status = -ENOMEM;
1689 int buffer_size;
1690 __u8 *buffer;
1691 struct usb_device *dev = tdev->td_serial->dev;
1692 unsigned int pipe = usb_sndbulkpipe(dev,
1693 tdev->td_serial->port[0]->bulk_out_endpointAddress);
1694 const struct firmware *fw_p;
1695 char buf[32];
1696 sprintf(buf, "ti_usb-%d.bin", type);
1716 1697
1698 if (request_firmware(&fw_p, buf, &dev->dev)) {
1699 dev_err(&dev->dev, "%s - firmware not found\n", __func__);
1700 return -ENOENT;
1701 }
1702 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) {
1703 dev_err(&dev->dev, "%s - firmware too large\n", __func__);
1704 return -ENOENT;
1705 }
1706
1707 buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header);
1708 buffer = kmalloc(buffer_size, GFP_KERNEL);
1709 if (buffer) {
1710 memcpy(buffer, fw_p->data, fw_p->size);
1711 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
1712 ti_do_download(dev, pipe, buffer, fw_p->size);
1713 kfree(buffer);
1714 }
1715 release_firmware(fw_p);
1717 if (status) { 1716 if (status) {
1718 dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); 1717 dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status);
1719 return status; 1718 return status;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 353798631903..ffaed8ace066 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -143,7 +143,7 @@ static void destroy_serial(struct kref *kref)
143 return_serial(serial); 143 return_serial(serial);
144 144
145 for (i = 0; i < serial->num_ports; ++i) 145 for (i = 0; i < serial->num_ports; ++i)
146 serial->port[i]->open_count = 0; 146 serial->port[i]->port.count = 0;
147 147
148 /* the ports are cleaned up and released in port_release() */ 148 /* the ports are cleaned up and released in port_release() */
149 for (i = 0; i < serial->num_ports; ++i) 149 for (i = 0; i < serial->num_ports; ++i)
@@ -208,14 +208,14 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
208 goto bailout_kref_put; 208 goto bailout_kref_put;
209 } 209 }
210 210
211 ++port->open_count; 211 ++port->port.count;
212 212
213 /* set up our port structure making the tty driver 213 /* set up our port structure making the tty driver
214 * remember our port object, and us it */ 214 * remember our port object, and us it */
215 tty->driver_data = port; 215 tty->driver_data = port;
216 port->tty = tty; 216 port->port.tty = tty;
217 217
218 if (port->open_count == 1) { 218 if (port->port.count == 1) {
219 219
220 /* lock this module before we call it 220 /* lock this module before we call it
221 * this may fail, which means we must bail out, 221 * this may fail, which means we must bail out,
@@ -230,7 +230,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
230 goto bailout_module_put; 230 goto bailout_module_put;
231 /* only call the device specific open if this 231 /* only call the device specific open if this
232 * is the first time the port is opened */ 232 * is the first time the port is opened */
233 retval = serial->type->open(port, filp); 233 retval = serial->type->open(tty, port, filp);
234 if (retval) 234 if (retval)
235 goto bailout_interface_put; 235 goto bailout_interface_put;
236 } 236 }
@@ -243,9 +243,9 @@ bailout_interface_put:
243bailout_module_put: 243bailout_module_put:
244 module_put(serial->type->driver.owner); 244 module_put(serial->type->driver.owner);
245bailout_mutex_unlock: 245bailout_mutex_unlock:
246 port->open_count = 0; 246 port->port.count = 0;
247 tty->driver_data = NULL; 247 tty->driver_data = NULL;
248 port->tty = NULL; 248 port->port.tty = NULL;
249 mutex_unlock(&port->mutex); 249 mutex_unlock(&port->mutex);
250bailout_kref_put: 250bailout_kref_put:
251 usb_serial_put(serial); 251 usb_serial_put(serial);
@@ -263,26 +263,26 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
263 263
264 mutex_lock(&port->mutex); 264 mutex_lock(&port->mutex);
265 265
266 if (port->open_count == 0) { 266 if (port->port.count == 0) {
267 mutex_unlock(&port->mutex); 267 mutex_unlock(&port->mutex);
268 return; 268 return;
269 } 269 }
270 270
271 --port->open_count; 271 --port->port.count;
272 if (port->open_count == 0) 272 if (port->port.count == 0)
273 /* only call the device specific close if this 273 /* only call the device specific close if this
274 * port is being closed by the last owner */ 274 * port is being closed by the last owner */
275 port->serial->type->close(port, filp); 275 port->serial->type->close(tty, port, filp);
276 276
277 if (port->open_count == (port->console? 1 : 0)) { 277 if (port->port.count == (port->console? 1 : 0)) {
278 if (port->tty) { 278 if (port->port.tty) {
279 if (port->tty->driver_data) 279 if (port->port.tty->driver_data)
280 port->tty->driver_data = NULL; 280 port->port.tty->driver_data = NULL;
281 port->tty = NULL; 281 port->port.tty = NULL;
282 } 282 }
283 } 283 }
284 284
285 if (port->open_count == 0) { 285 if (port->port.count == 0) {
286 mutex_lock(&port->serial->disc_mutex); 286 mutex_lock(&port->serial->disc_mutex);
287 if (!port->serial->disconnected) 287 if (!port->serial->disconnected)
288 usb_autopm_put_interface(port->serial->interface); 288 usb_autopm_put_interface(port->serial->interface);
@@ -304,12 +304,12 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
304 304
305 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 305 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
306 306
307 /* open_count is managed under the mutex lock for the tty so cannot 307 /* count is managed under the mutex lock for the tty so cannot
308 drop to zero until after the last close completes */ 308 drop to zero until after the last close completes */
309 WARN_ON(!port->open_count); 309 WARN_ON(!port->port.count);
310 310
311 /* pass on to the driver specific version of this function */ 311 /* pass on to the driver specific version of this function */
312 retval = port->serial->type->write(port, buf, count); 312 retval = port->serial->type->write(tty, port, buf, count);
313 313
314exit: 314exit:
315 return retval; 315 return retval;
@@ -319,9 +319,9 @@ static int serial_write_room (struct tty_struct *tty)
319{ 319{
320 struct usb_serial_port *port = tty->driver_data; 320 struct usb_serial_port *port = tty->driver_data;
321 dbg("%s - port %d", __func__, port->number); 321 dbg("%s - port %d", __func__, port->number);
322 WARN_ON(!port->open_count); 322 WARN_ON(!port->port.count);
323 /* pass on to the driver specific version of this function */ 323 /* pass on to the driver specific version of this function */
324 return port->serial->type->write_room(port); 324 return port->serial->type->write_room(tty);
325} 325}
326 326
327static int serial_chars_in_buffer (struct tty_struct *tty) 327static int serial_chars_in_buffer (struct tty_struct *tty)
@@ -329,9 +329,9 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
329 struct usb_serial_port *port = tty->driver_data; 329 struct usb_serial_port *port = tty->driver_data;
330 dbg("%s = port %d", __func__, port->number); 330 dbg("%s = port %d", __func__, port->number);
331 331
332 WARN_ON(!port->open_count); 332 WARN_ON(!port->port.count);
333 /* pass on to the driver specific version of this function */ 333 /* pass on to the driver specific version of this function */
334 return port->serial->type->chars_in_buffer(port); 334 return port->serial->type->chars_in_buffer(tty);
335} 335}
336 336
337static void serial_throttle (struct tty_struct * tty) 337static void serial_throttle (struct tty_struct * tty)
@@ -339,10 +339,10 @@ static void serial_throttle (struct tty_struct * tty)
339 struct usb_serial_port *port = tty->driver_data; 339 struct usb_serial_port *port = tty->driver_data;
340 dbg("%s - port %d", __func__, port->number); 340 dbg("%s - port %d", __func__, port->number);
341 341
342 WARN_ON(!port->open_count); 342 WARN_ON(!port->port.count);
343 /* pass on to the driver specific version of this function */ 343 /* pass on to the driver specific version of this function */
344 if (port->serial->type->throttle) 344 if (port->serial->type->throttle)
345 port->serial->type->throttle(port); 345 port->serial->type->throttle(tty);
346} 346}
347 347
348static void serial_unthrottle (struct tty_struct * tty) 348static void serial_unthrottle (struct tty_struct * tty)
@@ -350,10 +350,10 @@ static void serial_unthrottle (struct tty_struct * tty)
350 struct usb_serial_port *port = tty->driver_data; 350 struct usb_serial_port *port = tty->driver_data;
351 dbg("%s - port %d", __func__, port->number); 351 dbg("%s - port %d", __func__, port->number);
352 352
353 WARN_ON(!port->open_count); 353 WARN_ON(!port->port.count);
354 /* pass on to the driver specific version of this function */ 354 /* pass on to the driver specific version of this function */
355 if (port->serial->type->unthrottle) 355 if (port->serial->type->unthrottle)
356 port->serial->type->unthrottle(port); 356 port->serial->type->unthrottle(tty);
357} 357}
358 358
359static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) 359static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
@@ -363,12 +363,12 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
363 363
364 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 364 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
365 365
366 WARN_ON(!port->open_count); 366 WARN_ON(!port->port.count);
367 367
368 /* pass on to the driver specific version of this function if it is available */ 368 /* pass on to the driver specific version of this function if it is available */
369 if (port->serial->type->ioctl) { 369 if (port->serial->type->ioctl) {
370 lock_kernel(); 370 lock_kernel();
371 retval = port->serial->type->ioctl(port, file, cmd, arg); 371 retval = port->serial->type->ioctl(tty, file, cmd, arg);
372 unlock_kernel(); 372 unlock_kernel();
373 } 373 }
374 else 374 else
@@ -381,10 +381,10 @@ static void serial_set_termios (struct tty_struct *tty, struct ktermios * old)
381 struct usb_serial_port *port = tty->driver_data; 381 struct usb_serial_port *port = tty->driver_data;
382 dbg("%s - port %d", __func__, port->number); 382 dbg("%s - port %d", __func__, port->number);
383 383
384 WARN_ON(!port->open_count); 384 WARN_ON(!port->port.count);
385 /* pass on to the driver specific version of this function if it is available */ 385 /* pass on to the driver specific version of this function if it is available */
386 if (port->serial->type->set_termios) 386 if (port->serial->type->set_termios)
387 port->serial->type->set_termios(port, old); 387 port->serial->type->set_termios(tty, port, old);
388 else 388 else
389 tty_termios_copy_hw(tty->termios, old); 389 tty_termios_copy_hw(tty->termios, old);
390} 390}
@@ -395,11 +395,11 @@ static void serial_break (struct tty_struct *tty, int break_state)
395 395
396 dbg("%s - port %d", __func__, port->number); 396 dbg("%s - port %d", __func__, port->number);
397 397
398 WARN_ON(!port->open_count); 398 WARN_ON(!port->port.count);
399 /* pass on to the driver specific version of this function if it is available */ 399 /* pass on to the driver specific version of this function if it is available */
400 if (port->serial->type->break_ctl) { 400 if (port->serial->type->break_ctl) {
401 lock_kernel(); 401 lock_kernel();
402 port->serial->type->break_ctl(port, break_state); 402 port->serial->type->break_ctl(tty, break_state);
403 unlock_kernel(); 403 unlock_kernel();
404 } 404 }
405} 405}
@@ -457,9 +457,9 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)
457 457
458 dbg("%s - port %d", __func__, port->number); 458 dbg("%s - port %d", __func__, port->number);
459 459
460 WARN_ON(!port->open_count); 460 WARN_ON(!port->port.count);
461 if (port->serial->type->tiocmget) 461 if (port->serial->type->tiocmget)
462 return port->serial->type->tiocmget(port, file); 462 return port->serial->type->tiocmget(tty, file);
463 return -EINVAL; 463 return -EINVAL;
464} 464}
465 465
@@ -470,9 +470,9 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
470 470
471 dbg("%s - port %d", __func__, port->number); 471 dbg("%s - port %d", __func__, port->number);
472 472
473 WARN_ON(!port->open_count); 473 WARN_ON(!port->port.count);
474 if (port->serial->type->tiocmset) 474 if (port->serial->type->tiocmset)
475 return port->serial->type->tiocmset(port, file, set, clear); 475 return port->serial->type->tiocmset(tty, file, set, clear);
476 return -EINVAL; 476 return -EINVAL;
477} 477}
478 478
@@ -497,7 +497,7 @@ static void usb_serial_port_work(struct work_struct *work)
497 if (!port) 497 if (!port)
498 return; 498 return;
499 499
500 tty = port->tty; 500 tty = port->port.tty;
501 if (!tty) 501 if (!tty)
502 return; 502 return;
503 503
@@ -1010,8 +1010,8 @@ void usb_serial_disconnect(struct usb_interface *interface)
1010 for (i = 0; i < serial->num_ports; ++i) { 1010 for (i = 0; i < serial->num_ports; ++i) {
1011 port = serial->port[i]; 1011 port = serial->port[i];
1012 if (port) { 1012 if (port) {
1013 if (port->tty) 1013 if (port->port.tty)
1014 tty_hangup(port->tty); 1014 tty_hangup(port->port.tty);
1015 kill_traffic(port); 1015 kill_traffic(port);
1016 } 1016 }
1017 } 1017 }
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 9ca4d4db1ddd..fc5d9952b03b 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -31,10 +31,11 @@ static struct usb_driver debug_driver = {
31 .no_dynamic_id = 1, 31 .no_dynamic_id = 1,
32}; 32};
33 33
34int usb_debug_open(struct usb_serial_port *port, struct file *filp) 34int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
35 struct file *filp)
35{ 36{
36 port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; 37 port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
37 return usb_serial_generic_open(port, filp); 38 return usb_serial_generic_open(tty, port, filp);
38} 39}
39 40
40static struct usb_serial_driver debug_device = { 41static struct usb_serial_driver debug_device = {
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 5fc20122145f..373a3c7ea77b 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -35,17 +35,15 @@
35#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" 35#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
36 36
37/* function prototypes for a handspring visor */ 37/* function prototypes for a handspring visor */
38static int visor_open (struct usb_serial_port *port, struct file *filp); 38static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
39static void visor_close (struct usb_serial_port *port, struct file *filp); 39static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
40static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count); 40static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
41static int visor_write_room (struct usb_serial_port *port); 41static int visor_write_room (struct tty_struct *tty);
42static int visor_chars_in_buffer (struct usb_serial_port *port); 42static void visor_throttle (struct tty_struct *tty);
43static void visor_throttle (struct usb_serial_port *port); 43static void visor_unthrottle (struct tty_struct *tty);
44static void visor_unthrottle (struct usb_serial_port *port);
45static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id); 44static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id);
46static int visor_calc_num_ports(struct usb_serial *serial); 45static int visor_calc_num_ports(struct usb_serial *serial);
47static void visor_shutdown (struct usb_serial *serial); 46static void visor_shutdown (struct usb_serial *serial);
48static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
49static void visor_write_bulk_callback (struct urb *urb); 47static void visor_write_bulk_callback (struct urb *urb);
50static void visor_read_bulk_callback (struct urb *urb); 48static void visor_read_bulk_callback (struct urb *urb);
51static void visor_read_int_callback (struct urb *urb); 49static void visor_read_int_callback (struct urb *urb);
@@ -198,10 +196,8 @@ static struct usb_serial_driver handspring_device = {
198 .probe = visor_probe, 196 .probe = visor_probe,
199 .calc_num_ports = visor_calc_num_ports, 197 .calc_num_ports = visor_calc_num_ports,
200 .shutdown = visor_shutdown, 198 .shutdown = visor_shutdown,
201 .ioctl = visor_ioctl,
202 .write = visor_write, 199 .write = visor_write,
203 .write_room = visor_write_room, 200 .write_room = visor_write_room,
204 .chars_in_buffer = visor_chars_in_buffer,
205 .write_bulk_callback = visor_write_bulk_callback, 201 .write_bulk_callback = visor_write_bulk_callback,
206 .read_bulk_callback = visor_read_bulk_callback, 202 .read_bulk_callback = visor_read_bulk_callback,
207 .read_int_callback = visor_read_int_callback, 203 .read_int_callback = visor_read_int_callback,
@@ -225,10 +221,8 @@ static struct usb_serial_driver clie_5_device = {
225 .probe = visor_probe, 221 .probe = visor_probe,
226 .calc_num_ports = visor_calc_num_ports, 222 .calc_num_ports = visor_calc_num_ports,
227 .shutdown = visor_shutdown, 223 .shutdown = visor_shutdown,
228 .ioctl = visor_ioctl,
229 .write = visor_write, 224 .write = visor_write,
230 .write_room = visor_write_room, 225 .write_room = visor_write_room,
231 .chars_in_buffer = visor_chars_in_buffer,
232 .write_bulk_callback = visor_write_bulk_callback, 226 .write_bulk_callback = visor_write_bulk_callback,
233 .read_bulk_callback = visor_read_bulk_callback, 227 .read_bulk_callback = visor_read_bulk_callback,
234 .read_int_callback = visor_read_int_callback, 228 .read_int_callback = visor_read_int_callback,
@@ -249,10 +243,8 @@ static struct usb_serial_driver clie_3_5_device = {
249 .throttle = visor_throttle, 243 .throttle = visor_throttle,
250 .unthrottle = visor_unthrottle, 244 .unthrottle = visor_unthrottle,
251 .attach = clie_3_5_startup, 245 .attach = clie_3_5_startup,
252 .ioctl = visor_ioctl,
253 .write = visor_write, 246 .write = visor_write,
254 .write_room = visor_write_room, 247 .write_room = visor_write_room,
255 .chars_in_buffer = visor_chars_in_buffer,
256 .write_bulk_callback = visor_write_bulk_callback, 248 .write_bulk_callback = visor_write_bulk_callback,
257 .read_bulk_callback = visor_read_bulk_callback, 249 .read_bulk_callback = visor_read_bulk_callback,
258}; 250};
@@ -274,7 +266,7 @@ static int stats;
274/****************************************************************************** 266/******************************************************************************
275 * Handspring Visor specific driver functions 267 * Handspring Visor specific driver functions
276 ******************************************************************************/ 268 ******************************************************************************/
277static int visor_open (struct usb_serial_port *port, struct file *filp) 269static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp)
278{ 270{
279 struct usb_serial *serial = port->serial; 271 struct usb_serial *serial = port->serial;
280 struct visor_private *priv = usb_get_serial_port_data(port); 272 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -300,8 +292,8 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
300 * through, otherwise it is scheduled, and with high data rates (like 292 * through, otherwise it is scheduled, and with high data rates (like
301 * with OHCI) data can get lost. 293 * with OHCI) data can get lost.
302 */ 294 */
303 if (port->tty) 295 if (tty)
304 port->tty->low_latency = 1; 296 tty->low_latency = 1;
305 297
306 /* Start reading from the device */ 298 /* Start reading from the device */
307 usb_fill_bulk_urb (port->read_urb, serial->dev, 299 usb_fill_bulk_urb (port->read_urb, serial->dev,
@@ -329,7 +321,8 @@ exit:
329} 321}
330 322
331 323
332static void visor_close (struct usb_serial_port *port, struct file * filp) 324static void visor_close(struct tty_struct *tty,
325 struct usb_serial_port *port, struct file * filp)
333{ 326{
334 struct visor_private *priv = usb_get_serial_port_data(port); 327 struct visor_private *priv = usb_get_serial_port_data(port);
335 unsigned char *transfer_buffer; 328 unsigned char *transfer_buffer;
@@ -361,7 +354,8 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
361} 354}
362 355
363 356
364static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count) 357static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
358 const unsigned char *buf, int count)
365{ 359{
366 struct visor_private *priv = usb_get_serial_port_data(port); 360 struct visor_private *priv = usb_get_serial_port_data(port);
367 struct usb_serial *serial = port->serial; 361 struct usb_serial *serial = port->serial;
@@ -435,8 +429,9 @@ error_no_buffer:
435} 429}
436 430
437 431
438static int visor_write_room (struct usb_serial_port *port) 432static int visor_write_room (struct tty_struct *tty)
439{ 433{
434 struct usb_serial_port *port = tty->driver_data;
440 struct visor_private *priv = usb_get_serial_port_data(port); 435 struct visor_private *priv = usb_get_serial_port_data(port);
441 unsigned long flags; 436 unsigned long flags;
442 437
@@ -460,22 +455,6 @@ static int visor_write_room (struct usb_serial_port *port)
460} 455}
461 456
462 457
463static int visor_chars_in_buffer (struct usb_serial_port *port)
464{
465 dbg("%s - port %d", __func__, port->number);
466
467 /*
468 * We can't really account for how much data we
469 * have sent out, but hasn't made it through to the
470 * device, so just tell the tty layer that everything
471 * is flushed.
472 *
473 * FIXME: Should walk outstanding_urbs
474 */
475 return 0;
476}
477
478
479static void visor_write_bulk_callback (struct urb *urb) 458static void visor_write_bulk_callback (struct urb *urb)
480{ 459{
481 struct usb_serial_port *port = urb->context; 460 struct usb_serial_port *port = urb->context;
@@ -520,7 +499,7 @@ static void visor_read_bulk_callback (struct urb *urb)
520 499
521 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 500 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
522 501
523 tty = port->tty; 502 tty = port->port.tty;
524 if (tty && urb->actual_length) { 503 if (tty && urb->actual_length) {
525 available_room = tty_buffer_request_room(tty, urb->actual_length); 504 available_room = tty_buffer_request_room(tty, urb->actual_length);
526 if (available_room) { 505 if (available_room) {
@@ -591,8 +570,9 @@ exit:
591 __func__, result); 570 __func__, result);
592} 571}
593 572
594static void visor_throttle (struct usb_serial_port *port) 573static void visor_throttle (struct tty_struct *tty)
595{ 574{
575 struct usb_serial_port *port = tty->driver_data;
596 struct visor_private *priv = usb_get_serial_port_data(port); 576 struct visor_private *priv = usb_get_serial_port_data(port);
597 unsigned long flags; 577 unsigned long flags;
598 578
@@ -603,8 +583,9 @@ static void visor_throttle (struct usb_serial_port *port)
603} 583}
604 584
605 585
606static void visor_unthrottle (struct usb_serial_port *port) 586static void visor_unthrottle (struct tty_struct *tty)
607{ 587{
588 struct usb_serial_port *port = tty->driver_data;
608 struct visor_private *priv = usb_get_serial_port_data(port); 589 struct visor_private *priv = usb_get_serial_port_data(port);
609 unsigned long flags; 590 unsigned long flags;
610 int result; 591 int result;
@@ -922,13 +903,6 @@ static void visor_shutdown (struct usb_serial *serial)
922 } 903 }
923} 904}
924 905
925static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
926{
927 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
928
929 return -ENOIOCTLCMD;
930}
931
932static int __init visor_init (void) 906static int __init visor_init (void)
933{ 907{
934 int i, retval; 908 int i, retval;
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 665aa77a917b..b07d6a5cac31 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -142,18 +142,18 @@ static int whiteheat_firmware_attach (struct usb_serial *serial);
142/* function prototypes for the Connect Tech WhiteHEAT serial converter */ 142/* function prototypes for the Connect Tech WhiteHEAT serial converter */
143static int whiteheat_attach (struct usb_serial *serial); 143static int whiteheat_attach (struct usb_serial *serial);
144static void whiteheat_shutdown (struct usb_serial *serial); 144static void whiteheat_shutdown (struct usb_serial *serial);
145static int whiteheat_open (struct usb_serial_port *port, struct file *filp); 145static int whiteheat_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
146static void whiteheat_close (struct usb_serial_port *port, struct file *filp); 146static void whiteheat_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
147static int whiteheat_write (struct usb_serial_port *port, const unsigned char *buf, int count); 147static int whiteheat_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
148static int whiteheat_write_room (struct usb_serial_port *port); 148static int whiteheat_write_room (struct tty_struct *tty);
149static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 149static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
150static void whiteheat_set_termios (struct usb_serial_port *port, struct ktermios * old); 150static void whiteheat_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old);
151static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file); 151static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file);
152static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 152static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
153static void whiteheat_break_ctl (struct usb_serial_port *port, int break_state); 153static void whiteheat_break_ctl (struct tty_struct *tty, int break_state);
154static int whiteheat_chars_in_buffer (struct usb_serial_port *port); 154static int whiteheat_chars_in_buffer (struct tty_struct *tty);
155static void whiteheat_throttle (struct usb_serial_port *port); 155static void whiteheat_throttle (struct tty_struct *tty);
156static void whiteheat_unthrottle (struct usb_serial_port *port); 156static void whiteheat_unthrottle (struct tty_struct *tty);
157static void whiteheat_read_callback (struct urb *urb); 157static void whiteheat_read_callback (struct urb *urb);
158static void whiteheat_write_callback (struct urb *urb); 158static void whiteheat_write_callback (struct urb *urb);
159 159
@@ -246,7 +246,7 @@ static void rx_data_softint(struct work_struct *work);
246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); 246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
247static int firm_open(struct usb_serial_port *port); 247static int firm_open(struct usb_serial_port *port);
248static int firm_close(struct usb_serial_port *port); 248static int firm_close(struct usb_serial_port *port);
249static int firm_setup_port(struct usb_serial_port *port); 249static int firm_setup_port(struct tty_struct *tty);
250static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); 250static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
251static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); 251static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
252static int firm_set_break(struct usb_serial_port *port, __u8 onoff); 252static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
@@ -613,7 +613,8 @@ static void whiteheat_shutdown (struct usb_serial *serial)
613} 613}
614 614
615 615
616static int whiteheat_open (struct usb_serial_port *port, struct file *filp) 616static int whiteheat_open (struct tty_struct *tty,
617 struct usb_serial_port *port, struct file *filp)
617{ 618{
618 int retval = 0; 619 int retval = 0;
619 struct ktermios old_term; 620 struct ktermios old_term;
@@ -624,7 +625,8 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
624 if (retval) 625 if (retval)
625 goto exit; 626 goto exit;
626 627
627 port->tty->low_latency = 1; 628 if (tty)
629 tty->low_latency = 1;
628 630
629 /* send an open port command */ 631 /* send an open port command */
630 retval = firm_open(port); 632 retval = firm_open(port);
@@ -640,9 +642,11 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
640 goto exit; 642 goto exit;
641 } 643 }
642 644
643 old_term.c_cflag = ~port->tty->termios->c_cflag; 645 if (tty) {
644 old_term.c_iflag = ~port->tty->termios->c_iflag; 646 old_term.c_cflag = ~tty->termios->c_cflag;
645 whiteheat_set_termios(port, &old_term); 647 old_term.c_iflag = ~tty->termios->c_iflag;
648 whiteheat_set_termios(tty, port, &old_term);
649 }
646 650
647 /* Work around HCD bugs */ 651 /* Work around HCD bugs */
648 usb_clear_halt(port->serial->dev, port->read_urb->pipe); 652 usb_clear_halt(port->serial->dev, port->read_urb->pipe);
@@ -663,7 +667,8 @@ exit:
663} 667}
664 668
665 669
666static void whiteheat_close(struct usb_serial_port *port, struct file * filp) 670static void whiteheat_close(struct tty_struct *tty,
671 struct usb_serial_port *port, struct file * filp)
667{ 672{
668 struct whiteheat_private *info = usb_get_serial_port_data(port); 673 struct whiteheat_private *info = usb_get_serial_port_data(port);
669 struct whiteheat_urb_wrap *wrap; 674 struct whiteheat_urb_wrap *wrap;
@@ -681,7 +686,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
681 } 686 }
682 mutex_unlock(&port->serial->disc_mutex); 687 mutex_unlock(&port->serial->disc_mutex);
683 688
684 port->tty->closing = 1; 689 tty->closing = 1;
685 690
686/* 691/*
687 * Not currently in use; tty_wait_until_sent() calls 692 * Not currently in use; tty_wait_until_sent() calls
@@ -689,12 +694,12 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
689 * acquisition. This should be fixed at some point. Greg's been 694 * acquisition. This should be fixed at some point. Greg's been
690 * notified. 695 * notified.
691 if ((filp->f_flags & (O_NDELAY | O_NONBLOCK)) == 0) { 696 if ((filp->f_flags & (O_NDELAY | O_NONBLOCK)) == 0) {
692 tty_wait_until_sent(port->tty, CLOSING_DELAY); 697 tty_wait_until_sent(tty, CLOSING_DELAY);
693 } 698 }
694*/ 699*/
695 700
696 tty_driver_flush_buffer(port->tty); 701 tty_driver_flush_buffer(tty);
697 tty_ldisc_flush(port->tty); 702 tty_ldisc_flush(tty);
698 703
699 firm_report_tx_done(port); 704 firm_report_tx_done(port);
700 705
@@ -728,11 +733,12 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
728 733
729 stop_command_port(port->serial); 734 stop_command_port(port->serial);
730 735
731 port->tty->closing = 0; 736 tty->closing = 0;
732} 737}
733 738
734 739
735static int whiteheat_write(struct usb_serial_port *port, const unsigned char *buf, int count) 740static int whiteheat_write(struct tty_struct *tty,
741 struct usb_serial_port *port, const unsigned char *buf, int count)
736{ 742{
737 struct usb_serial *serial = port->serial; 743 struct usb_serial *serial = port->serial;
738 struct whiteheat_private *info = usb_get_serial_port_data(port); 744 struct whiteheat_private *info = usb_get_serial_port_data(port);
@@ -791,8 +797,9 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu
791} 797}
792 798
793 799
794static int whiteheat_write_room(struct usb_serial_port *port) 800static int whiteheat_write_room(struct tty_struct *tty)
795{ 801{
802 struct usb_serial_port *port = tty->driver_data;
796 struct whiteheat_private *info = usb_get_serial_port_data(port); 803 struct whiteheat_private *info = usb_get_serial_port_data(port);
797 struct list_head *tmp; 804 struct list_head *tmp;
798 int room = 0; 805 int room = 0;
@@ -811,8 +818,9 @@ static int whiteheat_write_room(struct usb_serial_port *port)
811} 818}
812 819
813 820
814static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file) 821static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file)
815{ 822{
823 struct usb_serial_port *port = tty->driver_data;
816 struct whiteheat_private *info = usb_get_serial_port_data(port); 824 struct whiteheat_private *info = usb_get_serial_port_data(port);
817 unsigned int modem_signals = 0; 825 unsigned int modem_signals = 0;
818 826
@@ -828,9 +836,10 @@ static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file)
828} 836}
829 837
830 838
831static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file, 839static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file,
832 unsigned int set, unsigned int clear) 840 unsigned int set, unsigned int clear)
833{ 841{
842 struct usb_serial_port *port = tty->driver_data;
834 struct whiteheat_private *info = usb_get_serial_port_data(port); 843 struct whiteheat_private *info = usb_get_serial_port_data(port);
835 844
836 dbg("%s - port %d", __func__, port->number); 845 dbg("%s - port %d", __func__, port->number);
@@ -851,8 +860,9 @@ static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file,
851} 860}
852 861
853 862
854static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) 863static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
855{ 864{
865 struct usb_serial_port *port = tty->driver_data;
856 struct serial_struct serstruct; 866 struct serial_struct serstruct;
857 void __user *user_arg = (void __user *)arg; 867 void __user *user_arg = (void __user *)arg;
858 868
@@ -896,20 +906,21 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un
896} 906}
897 907
898 908
899static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios) 909static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios)
900{ 910{
901 dbg("%s -port %d", __func__, port->number); 911 firm_setup_port(tty);
902 firm_setup_port(port);
903} 912}
904 913
905 914
906static void whiteheat_break_ctl(struct usb_serial_port *port, int break_state) { 915static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) {
916 struct usb_serial_port *port = tty->driver_data;
907 firm_set_break(port, break_state); 917 firm_set_break(port, break_state);
908} 918}
909 919
910 920
911static int whiteheat_chars_in_buffer(struct usb_serial_port *port) 921static int whiteheat_chars_in_buffer(struct tty_struct *tty)
912{ 922{
923 struct usb_serial_port *port = tty->driver_data;
913 struct whiteheat_private *info = usb_get_serial_port_data(port); 924 struct whiteheat_private *info = usb_get_serial_port_data(port);
914 struct list_head *tmp; 925 struct list_head *tmp;
915 struct whiteheat_urb_wrap *wrap; 926 struct whiteheat_urb_wrap *wrap;
@@ -930,8 +941,9 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
930} 941}
931 942
932 943
933static void whiteheat_throttle (struct usb_serial_port *port) 944static void whiteheat_throttle (struct tty_struct *tty)
934{ 945{
946 struct usb_serial_port *port = tty->driver_data;
935 struct whiteheat_private *info = usb_get_serial_port_data(port); 947 struct whiteheat_private *info = usb_get_serial_port_data(port);
936 unsigned long flags; 948 unsigned long flags;
937 949
@@ -945,8 +957,9 @@ static void whiteheat_throttle (struct usb_serial_port *port)
945} 957}
946 958
947 959
948static void whiteheat_unthrottle (struct usb_serial_port *port) 960static void whiteheat_unthrottle (struct tty_struct *tty)
949{ 961{
962 struct usb_serial_port *port = tty->driver_data;
950 struct whiteheat_private *info = usb_get_serial_port_data(port); 963 struct whiteheat_private *info = usb_get_serial_port_data(port);
951 int actually_throttled; 964 int actually_throttled;
952 unsigned long flags; 965 unsigned long flags;
@@ -1184,9 +1197,10 @@ static int firm_close(struct usb_serial_port *port) {
1184} 1197}
1185 1198
1186 1199
1187static int firm_setup_port(struct usb_serial_port *port) { 1200static int firm_setup_port(struct tty_struct *tty) {
1201 struct usb_serial_port *port = tty->driver_data;
1188 struct whiteheat_port_settings port_settings; 1202 struct whiteheat_port_settings port_settings;
1189 unsigned int cflag = port->tty->termios->c_cflag; 1203 unsigned int cflag = tty->termios->c_cflag;
1190 1204
1191 port_settings.port = port->number + 1; 1205 port_settings.port = port->number + 1;
1192 1206
@@ -1235,22 +1249,22 @@ static int firm_setup_port(struct usb_serial_port *port) {
1235 (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : ""); 1249 (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : "");
1236 1250
1237 /* determine software flow control */ 1251 /* determine software flow control */
1238 if (I_IXOFF(port->tty)) 1252 if (I_IXOFF(tty))
1239 port_settings.sflow = WHITEHEAT_SFLOW_RXTX; 1253 port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
1240 else 1254 else
1241 port_settings.sflow = WHITEHEAT_SFLOW_NONE; 1255 port_settings.sflow = WHITEHEAT_SFLOW_NONE;
1242 dbg("%s - software flow control = %c", __func__, port_settings.sflow); 1256 dbg("%s - software flow control = %c", __func__, port_settings.sflow);
1243 1257
1244 port_settings.xon = START_CHAR(port->tty); 1258 port_settings.xon = START_CHAR(tty);
1245 port_settings.xoff = STOP_CHAR(port->tty); 1259 port_settings.xoff = STOP_CHAR(tty);
1246 dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff); 1260 dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff);
1247 1261
1248 /* get the baud rate wanted */ 1262 /* get the baud rate wanted */
1249 port_settings.baud = tty_get_baud_rate(port->tty); 1263 port_settings.baud = tty_get_baud_rate(tty);
1250 dbg("%s - baud rate = %d", __func__, port_settings.baud); 1264 dbg("%s - baud rate = %d", __func__, port_settings.baud);
1251 1265
1252 /* fixme: should set validated settings */ 1266 /* fixme: should set validated settings */
1253 tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud); 1267 tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud);
1254 /* handle any settings that aren't specified in the tty structure */ 1268 /* handle any settings that aren't specified in the tty structure */
1255 port_settings.lloop = 0; 1269 port_settings.lloop = 0;
1256 1270
@@ -1426,7 +1440,7 @@ static void rx_data_softint(struct work_struct *work)
1426 struct whiteheat_private *info = 1440 struct whiteheat_private *info =
1427 container_of(work, struct whiteheat_private, rx_work); 1441 container_of(work, struct whiteheat_private, rx_work);
1428 struct usb_serial_port *port = info->port; 1442 struct usb_serial_port *port = info->port;
1429 struct tty_struct *tty = port->tty; 1443 struct tty_struct *tty = port->port.tty;
1430 struct whiteheat_urb_wrap *wrap; 1444 struct whiteheat_urb_wrap *wrap;
1431 struct urb *urb; 1445 struct urb *urb;
1432 unsigned long flags; 1446 unsigned long flags;