aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/class/cdc-acm.c5
-rw-r--r--drivers/usb/serial/ark3116.c51
-rw-r--r--drivers/usb/serial/belkin_sa.c4
-rw-r--r--drivers/usb/serial/ch341.c5
-rw-r--r--drivers/usb/serial/console.c32
-rw-r--r--drivers/usb/serial/cp210x.c12
-rw-r--r--drivers/usb/serial/cyberjack.c4
-rw-r--r--drivers/usb/serial/cypress_m8.c18
-rw-r--r--drivers/usb/serial/digi_acceleport.c6
-rw-r--r--drivers/usb/serial/empeg.c18
-rw-r--r--drivers/usb/serial/ftdi_sio.c6
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/generic.c3
-rw-r--r--drivers/usb/serial/io_edgeport.c6
-rw-r--r--drivers/usb/serial/io_ti.c3
-rw-r--r--drivers/usb/serial/ipaq.c9
-rw-r--r--drivers/usb/serial/ipw.c3
-rw-r--r--drivers/usb/serial/ir-usb.c6
-rw-r--r--drivers/usb/serial/iuu_phoenix.c34
-rw-r--r--drivers/usb/serial/keyspan.c3
-rw-r--r--drivers/usb/serial/keyspan.h3
-rw-r--r--drivers/usb/serial/keyspan_pda.c2
-rw-r--r--drivers/usb/serial/kl5kusb105.c10
-rw-r--r--drivers/usb/serial/kobil_sct.c28
-rw-r--r--drivers/usb/serial/mct_u232.c15
-rw-r--r--drivers/usb/serial/mos7720.c123
-rw-r--r--drivers/usb/serial/mos7840.c118
-rw-r--r--drivers/usb/serial/navman.c3
-rw-r--r--drivers/usb/serial/omninet.c6
-rw-r--r--drivers/usb/serial/opticon.c3
-rw-r--r--drivers/usb/serial/option.c6
-rw-r--r--drivers/usb/serial/oti6858.c27
-rw-r--r--drivers/usb/serial/pl2303.c5
-rw-r--r--drivers/usb/serial/sierra.c3
-rw-r--r--drivers/usb/serial/spcp8x5.c26
-rw-r--r--drivers/usb/serial/symbolserial.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c6
-rw-r--r--drivers/usb/serial/usb-serial.c385
-rw-r--r--drivers/usb/serial/usb_debug.c5
-rw-r--r--drivers/usb/serial/visor.c6
-rw-r--r--drivers/usb/serial/whiteheat.c11
41 files changed, 405 insertions, 620 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 2bfc41ece0e1..85a1a55815cf 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -858,10 +858,7 @@ static void acm_tty_set_termios(struct tty_struct *tty,
858 if (!ACM_READY(acm)) 858 if (!ACM_READY(acm))
859 return; 859 return;
860 860
861 /* FIXME: Needs to support the tty_baud interface */ 861 newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty));
862 /* FIXME: Broken on sparc */
863 newline.dwDTERate = cpu_to_le32p(acm_tty_speed +
864 (termios->c_cflag & CBAUD & ~CBAUDEX) + (termios->c_cflag & CBAUDEX ? 15 : 0));
865 newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0; 862 newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0;
866 newline.bParityType = termios->c_cflag & PARENB ? 863 newline.bParityType = termios->c_cflag & PARENB ?
867 (termios->c_cflag & PARODD ? 1 : 2) + 864 (termios->c_cflag & PARODD ? 1 : 2) +
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index aec61880f36c..5d25d3e52bf6 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -35,11 +35,6 @@ static struct usb_device_id id_table [] = {
35}; 35};
36MODULE_DEVICE_TABLE(usb, id_table); 36MODULE_DEVICE_TABLE(usb, id_table);
37 37
38struct ark3116_private {
39 spinlock_t lock;
40 u8 termios_initialized;
41};
42
43static inline void ARK3116_SND(struct usb_serial *serial, int seq, 38static inline void ARK3116_SND(struct usb_serial *serial, int seq,
44 __u8 request, __u8 requesttype, 39 __u8 request, __u8 requesttype,
45 __u16 value, __u16 index) 40 __u16 value, __u16 index)
@@ -82,22 +77,11 @@ static inline void ARK3116_RCV_QUIET(struct usb_serial *serial,
82static int ark3116_attach(struct usb_serial *serial) 77static int ark3116_attach(struct usb_serial *serial)
83{ 78{
84 char *buf; 79 char *buf;
85 struct ark3116_private *priv;
86 int i;
87
88 for (i = 0; i < serial->num_ports; ++i) {
89 priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL);
90 if (!priv)
91 goto cleanup;
92 spin_lock_init(&priv->lock);
93
94 usb_set_serial_port_data(serial->port[i], priv);
95 }
96 80
97 buf = kmalloc(1, GFP_KERNEL); 81 buf = kmalloc(1, GFP_KERNEL);
98 if (!buf) { 82 if (!buf) {
99 dbg("error kmalloc -> out of mem?"); 83 dbg("error kmalloc -> out of mem?");
100 goto cleanup; 84 return -ENOMEM;
101 } 85 }
102 86
103 /* 3 */ 87 /* 3 */
@@ -149,13 +133,16 @@ static int ark3116_attach(struct usb_serial *serial)
149 133
150 kfree(buf); 134 kfree(buf);
151 return 0; 135 return 0;
136}
152 137
153cleanup: 138static void ark3116_init_termios(struct tty_struct *tty)
154 for (--i; i >= 0; --i) { 139{
155 kfree(usb_get_serial_port_data(serial->port[i])); 140 struct ktermios *termios = tty->termios;
156 usb_set_serial_port_data(serial->port[i], NULL); 141 *termios = tty_std_termios;
157 } 142 termios->c_cflag = B9600 | CS8
158 return -ENOMEM; 143 | CREAD | HUPCL | CLOCAL;
144 termios->c_ispeed = 9600;
145 termios->c_ospeed = 9600;
159} 146}
160 147
161static void ark3116_set_termios(struct tty_struct *tty, 148static void ark3116_set_termios(struct tty_struct *tty,
@@ -163,10 +150,8 @@ static void ark3116_set_termios(struct tty_struct *tty,
163 struct ktermios *old_termios) 150 struct ktermios *old_termios)
164{ 151{
165 struct usb_serial *serial = port->serial; 152 struct usb_serial *serial = port->serial;
166 struct ark3116_private *priv = usb_get_serial_port_data(port);
167 struct ktermios *termios = tty->termios; 153 struct ktermios *termios = tty->termios;
168 unsigned int cflag = termios->c_cflag; 154 unsigned int cflag = termios->c_cflag;
169 unsigned long flags;
170 int baud; 155 int baud;
171 int ark3116_baud; 156 int ark3116_baud;
172 char *buf; 157 char *buf;
@@ -176,16 +161,6 @@ static void ark3116_set_termios(struct tty_struct *tty,
176 161
177 dbg("%s - port %d", __func__, port->number); 162 dbg("%s - port %d", __func__, port->number);
178 163
179 spin_lock_irqsave(&priv->lock, flags);
180 if (!priv->termios_initialized) {
181 *termios = tty_std_termios;
182 termios->c_cflag = B9600 | CS8
183 | CREAD | HUPCL | CLOCAL;
184 termios->c_ispeed = 9600;
185 termios->c_ospeed = 9600;
186 priv->termios_initialized = 1;
187 }
188 spin_unlock_irqrestore(&priv->lock, flags);
189 164
190 cflag = termios->c_cflag; 165 cflag = termios->c_cflag;
191 termios->c_cflag &= ~(CMSPAR|CRTSCTS); 166 termios->c_cflag &= ~(CMSPAR|CRTSCTS);
@@ -318,8 +293,7 @@ static void ark3116_set_termios(struct tty_struct *tty,
318 return; 293 return;
319} 294}
320 295
321static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port, 296static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
322 struct file *filp)
323{ 297{
324 struct ktermios tmp_termios; 298 struct ktermios tmp_termios;
325 struct usb_serial *serial = port->serial; 299 struct usb_serial *serial = port->serial;
@@ -334,7 +308,7 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port,
334 return -ENOMEM; 308 return -ENOMEM;
335 } 309 }
336 310
337 result = usb_serial_generic_open(tty, port, filp); 311 result = usb_serial_generic_open(tty, port);
338 if (result) 312 if (result)
339 goto err_out; 313 goto err_out;
340 314
@@ -455,6 +429,7 @@ static struct usb_serial_driver ark3116_device = {
455 .num_ports = 1, 429 .num_ports = 1,
456 .attach = ark3116_attach, 430 .attach = ark3116_attach,
457 .set_termios = ark3116_set_termios, 431 .set_termios = ark3116_set_termios,
432 .init_termios = ark3116_init_termios,
458 .ioctl = ark3116_ioctl, 433 .ioctl = ark3116_ioctl,
459 .tiocmget = ark3116_tiocmget, 434 .tiocmget = ark3116_tiocmget,
460 .open = ark3116_open, 435 .open = ark3116_open,
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 7033b031b443..a0467bc61627 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -92,7 +92,7 @@ static int debug;
92static int belkin_sa_startup(struct usb_serial *serial); 92static int belkin_sa_startup(struct usb_serial *serial);
93static void belkin_sa_release(struct usb_serial *serial); 93static void belkin_sa_release(struct usb_serial *serial);
94static int belkin_sa_open(struct tty_struct *tty, 94static int belkin_sa_open(struct tty_struct *tty,
95 struct usb_serial_port *port, struct file *filp); 95 struct usb_serial_port *port);
96static void belkin_sa_close(struct usb_serial_port *port); 96static void belkin_sa_close(struct usb_serial_port *port);
97static void belkin_sa_read_int_callback(struct urb *urb); 97static void belkin_sa_read_int_callback(struct urb *urb);
98static void belkin_sa_set_termios(struct tty_struct *tty, 98static void belkin_sa_set_termios(struct tty_struct *tty,
@@ -213,7 +213,7 @@ static void belkin_sa_release(struct usb_serial *serial)
213 213
214 214
215static int belkin_sa_open(struct tty_struct *tty, 215static int belkin_sa_open(struct tty_struct *tty,
216 struct usb_serial_port *port, struct file *filp) 216 struct usb_serial_port *port)
217{ 217{
218 int retval = 0; 218 int retval = 0;
219 219
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 2830766f5b39..8c894a7d5dcf 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -300,8 +300,7 @@ static void ch341_close(struct usb_serial_port *port)
300 300
301 301
302/* open this device, set default parameters */ 302/* open this device, set default parameters */
303static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port, 303static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
304 struct file *filp)
305{ 304{
306 struct usb_serial *serial = port->serial; 305 struct usb_serial *serial = port->serial;
307 struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); 306 struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]);
@@ -333,7 +332,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
333 return -EPROTO; 332 return -EPROTO;
334 } 333 }
335 334
336 r = usb_serial_generic_open(tty, port, filp); 335 r = usb_serial_generic_open(tty, port);
337 336
338out: return r; 337out: return r;
339} 338}
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 0e4f2e41ace5..b22ac3258523 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/serial.h>
19#include <linux/usb.h> 20#include <linux/usb.h>
20#include <linux/usb/serial.h> 21#include <linux/usb/serial.h>
21 22
@@ -63,7 +64,7 @@ static int usb_console_setup(struct console *co, char *options)
63 char *s; 64 char *s;
64 struct usb_serial *serial; 65 struct usb_serial *serial;
65 struct usb_serial_port *port; 66 struct usb_serial_port *port;
66 int retval = 0; 67 int retval;
67 struct tty_struct *tty = NULL; 68 struct tty_struct *tty = NULL;
68 struct ktermios *termios = NULL, dummy; 69 struct ktermios *termios = NULL, dummy;
69 70
@@ -116,13 +117,17 @@ static int usb_console_setup(struct console *co, char *options)
116 return -ENODEV; 117 return -ENODEV;
117 } 118 }
118 119
119 port = serial->port[0]; 120 retval = usb_autopm_get_interface(serial->interface);
121 if (retval)
122 goto error_get_interface;
123
124 port = serial->port[co->index - serial->minor];
120 tty_port_tty_set(&port->port, NULL); 125 tty_port_tty_set(&port->port, NULL);
121 126
122 info->port = port; 127 info->port = port;
123 128
124 ++port->port.count; 129 ++port->port.count;
125 if (port->port.count == 1) { 130 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
126 if (serial->type->set_termios) { 131 if (serial->type->set_termios) {
127 /* 132 /*
128 * allocate a fake tty so the driver can initialize 133 * allocate a fake tty so the driver can initialize
@@ -150,9 +155,9 @@ static int usb_console_setup(struct console *co, char *options)
150 /* only call the device specific open if this 155 /* only call the device specific open if this
151 * is the first time the port is opened */ 156 * is the first time the port is opened */
152 if (serial->type->open) 157 if (serial->type->open)
153 retval = serial->type->open(NULL, port, NULL); 158 retval = serial->type->open(NULL, port);
154 else 159 else
155 retval = usb_serial_generic_open(NULL, port, NULL); 160 retval = usb_serial_generic_open(NULL, port);
156 161
157 if (retval) { 162 if (retval) {
158 err("could not open USB console port"); 163 err("could not open USB console port");
@@ -168,6 +173,7 @@ static int usb_console_setup(struct console *co, char *options)
168 kfree(termios); 173 kfree(termios);
169 kfree(tty); 174 kfree(tty);
170 } 175 }
176 set_bit(ASYNCB_INITIALIZED, &port->port.flags);
171 } 177 }
172 /* Now that any required fake tty operations are completed restore 178 /* Now that any required fake tty operations are completed restore
173 * the tty port count */ 179 * the tty port count */
@@ -175,18 +181,22 @@ static int usb_console_setup(struct console *co, char *options)
175 /* The console is special in terms of closing the device so 181 /* The console is special in terms of closing the device so
176 * indicate this port is now acting as a system console. */ 182 * indicate this port is now acting as a system console. */
177 port->console = 1; 183 port->console = 1;
178 retval = 0;
179 184
180out: 185 mutex_unlock(&serial->disc_mutex);
181 return retval; 186 return retval;
182free_termios: 187
188 free_termios:
183 kfree(termios); 189 kfree(termios);
184 tty_port_tty_set(&port->port, NULL); 190 tty_port_tty_set(&port->port, NULL);
185free_tty: 191 free_tty:
186 kfree(tty); 192 kfree(tty);
187reset_open_count: 193 reset_open_count:
188 port->port.count = 0; 194 port->port.count = 0;
189 goto out; 195 usb_autopm_put_interface(serial->interface);
196 error_get_interface:
197 usb_serial_put(serial);
198 mutex_unlock(&serial->disc_mutex);
199 return retval;
190} 200}
191 201
192static void usb_console_write(struct console *co, 202static void usb_console_write(struct console *co,
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 985cbcf48bda..4a208fe85bc9 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -33,8 +33,7 @@
33/* 33/*
34 * Function Prototypes 34 * Function Prototypes
35 */ 35 */
36static int cp210x_open(struct tty_struct *, struct usb_serial_port *, 36static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
37 struct file *);
38static void cp210x_cleanup(struct usb_serial_port *); 37static void cp210x_cleanup(struct usb_serial_port *);
39static void cp210x_close(struct usb_serial_port *); 38static void cp210x_close(struct usb_serial_port *);
40static void cp210x_get_termios(struct tty_struct *, 39static void cp210x_get_termios(struct tty_struct *,
@@ -368,8 +367,7 @@ static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
368 return baud; 367 return baud;
369} 368}
370 369
371static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port, 370static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
372 struct file *filp)
373{ 371{
374 struct usb_serial *serial = port->serial; 372 struct usb_serial *serial = port->serial;
375 int result; 373 int result;
@@ -399,12 +397,6 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port,
399 397
400 /* Configure the termios structure */ 398 /* Configure the termios structure */
401 cp210x_get_termios(tty, port); 399 cp210x_get_termios(tty, port);
402
403 /* Set the DTR and RTS pins low */
404 cp210x_tiocmset_port(tty ? (struct usb_serial_port *) tty->driver_data
405 : port,
406 NULL, TIOCM_DTR | TIOCM_RTS, 0);
407
408 return 0; 400 return 0;
409} 401}
410 402
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 336523fd7366..b0f6402a91ca 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -61,7 +61,7 @@ static int cyberjack_startup(struct usb_serial *serial);
61static void cyberjack_disconnect(struct usb_serial *serial); 61static void cyberjack_disconnect(struct usb_serial *serial);
62static void cyberjack_release(struct usb_serial *serial); 62static void cyberjack_release(struct usb_serial *serial);
63static int cyberjack_open(struct tty_struct *tty, 63static int cyberjack_open(struct tty_struct *tty,
64 struct usb_serial_port *port, struct file *filp); 64 struct usb_serial_port *port);
65static void cyberjack_close(struct usb_serial_port *port); 65static void cyberjack_close(struct usb_serial_port *port);
66static int cyberjack_write(struct tty_struct *tty, 66static int cyberjack_write(struct tty_struct *tty,
67 struct usb_serial_port *port, const unsigned char *buf, int count); 67 struct usb_serial_port *port, const unsigned char *buf, int count);
@@ -173,7 +173,7 @@ static void cyberjack_release(struct usb_serial *serial)
173} 173}
174 174
175static int cyberjack_open(struct tty_struct *tty, 175static int cyberjack_open(struct tty_struct *tty,
176 struct usb_serial_port *port, struct file *filp) 176 struct usb_serial_port *port)
177{ 177{
178 struct cyberjack_private *priv; 178 struct cyberjack_private *priv;
179 unsigned long flags; 179 unsigned long flags;
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 59adfe123110..e0a8b715f2f2 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -172,8 +172,7 @@ static int cypress_earthmate_startup(struct usb_serial *serial);
172static int cypress_hidcom_startup(struct usb_serial *serial); 172static int cypress_hidcom_startup(struct usb_serial *serial);
173static int cypress_ca42v2_startup(struct usb_serial *serial); 173static int cypress_ca42v2_startup(struct usb_serial *serial);
174static void cypress_release(struct usb_serial *serial); 174static void cypress_release(struct usb_serial *serial);
175static int cypress_open(struct tty_struct *tty, 175static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port);
176 struct usb_serial_port *port, struct file *filp);
177static void cypress_close(struct usb_serial_port *port); 176static void cypress_close(struct usb_serial_port *port);
178static void cypress_dtr_rts(struct usb_serial_port *port, int on); 177static void cypress_dtr_rts(struct usb_serial_port *port, int on);
179static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, 178static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -633,8 +632,7 @@ static void cypress_release(struct usb_serial *serial)
633} 632}
634 633
635 634
636static int cypress_open(struct tty_struct *tty, 635static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
637 struct usb_serial_port *port, struct file *filp)
638{ 636{
639 struct cypress_private *priv = usb_get_serial_port_data(port); 637 struct cypress_private *priv = usb_get_serial_port_data(port);
640 struct usb_serial *serial = port->serial; 638 struct usb_serial *serial = port->serial;
@@ -659,15 +657,7 @@ static int cypress_open(struct tty_struct *tty,
659 spin_unlock_irqrestore(&priv->lock, flags); 657 spin_unlock_irqrestore(&priv->lock, flags);
660 658
661 /* Set termios */ 659 /* Set termios */
662 result = cypress_write(tty, port, NULL, 0); 660 cypress_send(port);
663
664 if (result) {
665 dev_err(&port->dev,
666 "%s - failed setting the control lines - error %d\n",
667 __func__, result);
668 return result;
669 } else
670 dbg("%s - success setting the control lines", __func__);
671 661
672 if (tty) 662 if (tty)
673 cypress_set_termios(tty, port, &priv->tmp_termios); 663 cypress_set_termios(tty, port, &priv->tmp_termios);
@@ -1005,6 +995,8 @@ static void cypress_set_termios(struct tty_struct *tty,
1005 dbg("%s - port %d", __func__, port->number); 995 dbg("%s - port %d", __func__, port->number);
1006 996
1007 spin_lock_irqsave(&priv->lock, flags); 997 spin_lock_irqsave(&priv->lock, flags);
998 /* We can't clean this one up as we don't know the device type
999 early enough */
1008 if (!priv->termios_initialized) { 1000 if (!priv->termios_initialized) {
1009 if (priv->chiptype == CT_EARTHMATE) { 1001 if (priv->chiptype == CT_EARTHMATE) {
1010 *(tty->termios) = tty_std_termios; 1002 *(tty->termios) = tty_std_termios;
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index f4808091c47c..ab3dd991586b 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -453,8 +453,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
453static void digi_write_bulk_callback(struct urb *urb); 453static void digi_write_bulk_callback(struct urb *urb);
454static int digi_write_room(struct tty_struct *tty); 454static int digi_write_room(struct tty_struct *tty);
455static int digi_chars_in_buffer(struct tty_struct *tty); 455static int digi_chars_in_buffer(struct tty_struct *tty);
456static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, 456static int digi_open(struct tty_struct *tty, struct usb_serial_port *port);
457 struct file *filp);
458static void digi_close(struct usb_serial_port *port); 457static void digi_close(struct usb_serial_port *port);
459static int digi_carrier_raised(struct usb_serial_port *port); 458static int digi_carrier_raised(struct usb_serial_port *port);
460static void digi_dtr_rts(struct usb_serial_port *port, int on); 459static void digi_dtr_rts(struct usb_serial_port *port, int on);
@@ -1347,8 +1346,7 @@ static int digi_carrier_raised(struct usb_serial_port *port)
1347 return 0; 1346 return 0;
1348} 1347}
1349 1348
1350static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, 1349static int digi_open(struct tty_struct *tty, struct usb_serial_port *port)
1351 struct file *filp)
1352{ 1350{
1353 int ret; 1351 int ret;
1354 unsigned char buf[32]; 1352 unsigned char buf[32];
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 80cb3471adbe..33c9e9cf9eb2 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -79,8 +79,7 @@ static int debug;
79#define EMPEG_PRODUCT_ID 0x0001 79#define EMPEG_PRODUCT_ID 0x0001
80 80
81/* function prototypes for an empeg-car player */ 81/* function prototypes for an empeg-car player */
82static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, 82static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port);
83 struct file *filp);
84static void empeg_close(struct usb_serial_port *port); 83static void empeg_close(struct usb_serial_port *port);
85static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port, 84static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port,
86 const unsigned char *buf, 85 const unsigned char *buf,
@@ -90,8 +89,7 @@ static int empeg_chars_in_buffer(struct tty_struct *tty);
90static void empeg_throttle(struct tty_struct *tty); 89static void empeg_throttle(struct tty_struct *tty);
91static void empeg_unthrottle(struct tty_struct *tty); 90static void empeg_unthrottle(struct tty_struct *tty);
92static int empeg_startup(struct usb_serial *serial); 91static int empeg_startup(struct usb_serial *serial);
93static void empeg_set_termios(struct tty_struct *tty, 92static void empeg_init_termios(struct tty_struct *tty);
94 struct usb_serial_port *port, struct ktermios *old_termios);
95static void empeg_write_bulk_callback(struct urb *urb); 93static void empeg_write_bulk_callback(struct urb *urb);
96static void empeg_read_bulk_callback(struct urb *urb); 94static void empeg_read_bulk_callback(struct urb *urb);
97 95
@@ -123,7 +121,7 @@ static struct usb_serial_driver empeg_device = {
123 .throttle = empeg_throttle, 121 .throttle = empeg_throttle,
124 .unthrottle = empeg_unthrottle, 122 .unthrottle = empeg_unthrottle,
125 .attach = empeg_startup, 123 .attach = empeg_startup,
126 .set_termios = empeg_set_termios, 124 .init_termios = empeg_init_termios,
127 .write = empeg_write, 125 .write = empeg_write,
128 .write_room = empeg_write_room, 126 .write_room = empeg_write_room,
129 .chars_in_buffer = empeg_chars_in_buffer, 127 .chars_in_buffer = empeg_chars_in_buffer,
@@ -142,17 +140,13 @@ static int bytes_out;
142/****************************************************************************** 140/******************************************************************************
143 * Empeg specific driver functions 141 * Empeg specific driver functions
144 ******************************************************************************/ 142 ******************************************************************************/
145static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port, 143static int empeg_open(struct tty_struct *tty,struct usb_serial_port *port)
146 struct file *filp)
147{ 144{
148 struct usb_serial *serial = port->serial; 145 struct usb_serial *serial = port->serial;
149 int result = 0; 146 int result = 0;
150 147
151 dbg("%s - port %d", __func__, port->number); 148 dbg("%s - port %d", __func__, port->number);
152 149
153 /* Force default termio settings */
154 empeg_set_termios(tty, port, NULL) ;
155
156 bytes_in = 0; 150 bytes_in = 0;
157 bytes_out = 0; 151 bytes_out = 0;
158 152
@@ -425,11 +419,9 @@ static int empeg_startup(struct usb_serial *serial)
425} 419}
426 420
427 421
428static void empeg_set_termios(struct tty_struct *tty, 422static void empeg_init_termios(struct tty_struct *tty)
429 struct usb_serial_port *port, struct ktermios *old_termios)
430{ 423{
431 struct ktermios *termios = tty->termios; 424 struct ktermios *termios = tty->termios;
432 dbg("%s - port %d", __func__, port->number);
433 425
434 /* 426 /*
435 * The empeg-car player wants these particular tty settings. 427 * The empeg-car player wants these particular tty settings.
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8fec5d4455c9..76a17f915eef 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -747,8 +747,7 @@ static int ftdi_sio_probe(struct usb_serial *serial,
747 const struct usb_device_id *id); 747 const struct usb_device_id *id);
748static int ftdi_sio_port_probe(struct usb_serial_port *port); 748static int ftdi_sio_port_probe(struct usb_serial_port *port);
749static int ftdi_sio_port_remove(struct usb_serial_port *port); 749static int ftdi_sio_port_remove(struct usb_serial_port *port);
750static int ftdi_open(struct tty_struct *tty, 750static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port);
751 struct usb_serial_port *port, struct file *filp);
752static void ftdi_close(struct usb_serial_port *port); 751static void ftdi_close(struct usb_serial_port *port);
753static void ftdi_dtr_rts(struct usb_serial_port *port, int on); 752static void ftdi_dtr_rts(struct usb_serial_port *port, int on);
754static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, 753static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -1680,8 +1679,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1680 return 0; 1679 return 0;
1681} 1680}
1682 1681
1683static int ftdi_open(struct tty_struct *tty, 1682static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
1684 struct usb_serial_port *port, struct file *filp)
1685{ /* ftdi_open */ 1683{ /* ftdi_open */
1686 struct usb_device *dev = port->serial->dev; 1684 struct usb_device *dev = port->serial->dev;
1687 struct ftdi_private *priv = usb_get_serial_port_data(port); 1685 struct ftdi_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 8839f1c70b7f..20432d345529 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -933,8 +933,7 @@ static int garmin_init_session(struct usb_serial_port *port)
933 933
934 934
935 935
936static int garmin_open(struct tty_struct *tty, 936static int garmin_open(struct tty_struct *tty, struct usb_serial_port *port)
937 struct usb_serial_port *port, struct file *filp)
938{ 937{
939 unsigned long flags; 938 unsigned long flags;
940 int status = 0; 939 int status = 0;
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index ce57f6a32bdf..d9398e9f30ce 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -114,8 +114,7 @@ void usb_serial_generic_deregister(void)
114#endif 114#endif
115} 115}
116 116
117int usb_serial_generic_open(struct tty_struct *tty, 117int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)
118 struct usb_serial_port *port, struct file *filp)
119{ 118{
120 struct usb_serial *serial = port->serial; 119 struct usb_serial *serial = port->serial;
121 int result = 0; 120 int result = 0;
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 0191693625d6..dc0f832657e6 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -205,8 +205,7 @@ static void edge_bulk_out_data_callback(struct urb *urb);
205static void edge_bulk_out_cmd_callback(struct urb *urb); 205static void edge_bulk_out_cmd_callback(struct urb *urb);
206 206
207/* function prototypes for the usbserial callbacks */ 207/* function prototypes for the usbserial callbacks */
208static int edge_open(struct tty_struct *tty, struct usb_serial_port *port, 208static int edge_open(struct tty_struct *tty, struct usb_serial_port *port);
209 struct file *filp);
210static void edge_close(struct usb_serial_port *port); 209static void edge_close(struct usb_serial_port *port);
211static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, 210static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
212 const unsigned char *buf, int count); 211 const unsigned char *buf, int count);
@@ -852,8 +851,7 @@ static void edge_bulk_out_cmd_callback(struct urb *urb)
852 * If successful, we return 0 851 * If successful, we return 0
853 * Otherwise we return a negative error number. 852 * Otherwise we return a negative error number.
854 *****************************************************************************/ 853 *****************************************************************************/
855static int edge_open(struct tty_struct *tty, 854static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
856 struct usb_serial_port *port, struct file *filp)
857{ 855{
858 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 856 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
859 struct usb_serial *serial; 857 struct usb_serial *serial;
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index e8bc42f92e79..d4cc0f7af400 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1831,8 +1831,7 @@ static void edge_bulk_out_callback(struct urb *urb)
1831 tty_kref_put(tty); 1831 tty_kref_put(tty);
1832} 1832}
1833 1833
1834static int edge_open(struct tty_struct *tty, 1834static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1835 struct usb_serial_port *port, struct file *filp)
1836{ 1835{
1837 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1836 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1838 struct edgeport_serial *edge_serial; 1837 struct edgeport_serial *edge_serial;
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 2545d45ce16f..24fcc64b837d 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -75,7 +75,7 @@ static int initial_wait;
75 75
76/* Function prototypes for an ipaq */ 76/* Function prototypes for an ipaq */
77static int ipaq_open(struct tty_struct *tty, 77static int ipaq_open(struct tty_struct *tty,
78 struct usb_serial_port *port, struct file *filp); 78 struct usb_serial_port *port);
79static void ipaq_close(struct usb_serial_port *port); 79static void ipaq_close(struct usb_serial_port *port);
80static int ipaq_calc_num_ports(struct usb_serial *serial); 80static int ipaq_calc_num_ports(struct usb_serial *serial);
81static int ipaq_startup(struct usb_serial *serial); 81static int ipaq_startup(struct usb_serial *serial);
@@ -587,7 +587,7 @@ static int bytes_in;
587static int bytes_out; 587static int bytes_out;
588 588
589static int ipaq_open(struct tty_struct *tty, 589static int ipaq_open(struct tty_struct *tty,
590 struct usb_serial_port *port, struct file *filp) 590 struct usb_serial_port *port)
591{ 591{
592 struct usb_serial *serial = port->serial; 592 struct usb_serial *serial = port->serial;
593 struct ipaq_private *priv; 593 struct ipaq_private *priv;
@@ -628,11 +628,6 @@ static int ipaq_open(struct tty_struct *tty,
628 priv->free_len += PACKET_SIZE; 628 priv->free_len += PACKET_SIZE;
629 } 629 }
630 630
631 if (tty) {
632 /* FIXME: These two are bogus */
633 tty->raw = 1;
634 tty->real_raw = 1;
635 }
636 /* 631 /*
637 * Lose the small buffers usbserial provides. Make larger ones. 632 * Lose the small buffers usbserial provides. Make larger ones.
638 */ 633 */
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 29ad038b9c8d..727d323f092a 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -193,8 +193,7 @@ static void ipw_read_bulk_callback(struct urb *urb)
193 return; 193 return;
194} 194}
195 195
196static int ipw_open(struct tty_struct *tty, 196static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
197 struct usb_serial_port *port, struct file *filp)
198{ 197{
199 struct usb_device *dev = port->serial->dev; 198 struct usb_device *dev = port->serial->dev;
200 u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; 199 u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT;
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 66009b6b763a..95d8d26b9a44 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -86,8 +86,7 @@ static int buffer_size;
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 tty_struct *tty, struct usb_serial_port *port, 89static int ir_open(struct tty_struct *tty, struct usb_serial_port *port);
90 struct file *filep);
91static void ir_close(struct usb_serial_port *port); 90static void ir_close(struct usb_serial_port *port);
92static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, 91static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
93 const unsigned char *buf, int count); 92 const unsigned char *buf, int count);
@@ -296,8 +295,7 @@ static int ir_startup(struct usb_serial *serial)
296 return 0; 295 return 0;
297} 296}
298 297
299static int ir_open(struct tty_struct *tty, 298static int ir_open(struct tty_struct *tty, struct usb_serial_port *port)
300 struct usb_serial_port *port, struct file *filp)
301{ 299{
302 char *buffer; 300 char *buffer;
303 int result = 0; 301 int result = 0;
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 96873a7a32b0..6138c1cda35f 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -71,7 +71,6 @@ struct iuu_private {
71 spinlock_t lock; /* store irq state */ 71 spinlock_t lock; /* store irq state */
72 wait_queue_head_t delta_msr_wait; 72 wait_queue_head_t delta_msr_wait;
73 u8 line_status; 73 u8 line_status;
74 u8 termios_initialized;
75 int tiostatus; /* store IUART SIGNAL for tiocmget call */ 74 int tiostatus; /* store IUART SIGNAL for tiocmget call */
76 u8 reset; /* if 1 reset is needed */ 75 u8 reset; /* if 1 reset is needed */
77 int poll; /* number of poll */ 76 int poll; /* number of poll */
@@ -1018,14 +1017,24 @@ static void iuu_close(struct usb_serial_port *port)
1018 } 1017 }
1019} 1018}
1020 1019
1021static int iuu_open(struct tty_struct *tty, 1020static void iuu_init_termios(struct tty_struct *tty)
1022 struct usb_serial_port *port, struct file *filp) 1021{
1022 *(tty->termios) = tty_std_termios;
1023 tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
1024 | TIOCM_CTS | CSTOPB | PARENB;
1025 tty->termios->c_ispeed = 9600;
1026 tty->termios->c_ospeed = 9600;
1027 tty->termios->c_lflag = 0;
1028 tty->termios->c_oflag = 0;
1029 tty->termios->c_iflag = 0;
1030}
1031
1032static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1023{ 1033{
1024 struct usb_serial *serial = port->serial; 1034 struct usb_serial *serial = port->serial;
1025 u8 *buf; 1035 u8 *buf;
1026 int result; 1036 int result;
1027 u32 actual; 1037 u32 actual;
1028 unsigned long flags;
1029 struct iuu_private *priv = usb_get_serial_port_data(port); 1038 struct iuu_private *priv = usb_get_serial_port_data(port);
1030 1039
1031 dbg("%s - port %d", __func__, port->number); 1040 dbg("%s - port %d", __func__, port->number);
@@ -1064,21 +1073,7 @@ static int iuu_open(struct tty_struct *tty,
1064 port->bulk_in_buffer, 512, 1073 port->bulk_in_buffer, 512,
1065 NULL, NULL); 1074 NULL, NULL);
1066 1075
1067 /* set the termios structure */ 1076 priv->poll = 0;
1068 spin_lock_irqsave(&priv->lock, flags);
1069 if (tty && !priv->termios_initialized) {
1070 *(tty->termios) = tty_std_termios;
1071 tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
1072 | TIOCM_CTS | CSTOPB | PARENB;
1073 tty->termios->c_ispeed = 9600;
1074 tty->termios->c_ospeed = 9600;
1075 tty->termios->c_lflag = 0;
1076 tty->termios->c_oflag = 0;
1077 tty->termios->c_iflag = 0;
1078 priv->termios_initialized = 1;
1079 priv->poll = 0;
1080 }
1081 spin_unlock_irqrestore(&priv->lock, flags);
1082 1077
1083 /* initialize writebuf */ 1078 /* initialize writebuf */
1084#define FISH(a, b, c, d) do { \ 1079#define FISH(a, b, c, d) do { \
@@ -1201,6 +1196,7 @@ static struct usb_serial_driver iuu_device = {
1201 .tiocmget = iuu_tiocmget, 1196 .tiocmget = iuu_tiocmget,
1202 .tiocmset = iuu_tiocmset, 1197 .tiocmset = iuu_tiocmset,
1203 .set_termios = iuu_set_termios, 1198 .set_termios = iuu_set_termios,
1199 .init_termios = iuu_init_termios,
1204 .attach = iuu_startup, 1200 .attach = iuu_startup,
1205 .release = iuu_release, 1201 .release = iuu_release,
1206}; 1202};
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 2594b8743d3f..f8c4b07033ff 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1209,8 +1209,7 @@ static int keyspan_write_room(struct tty_struct *tty)
1209} 1209}
1210 1210
1211 1211
1212static int keyspan_open(struct tty_struct *tty, 1212static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
1213 struct usb_serial_port *port, struct file *filp)
1214{ 1213{
1215 struct keyspan_port_private *p_priv; 1214 struct keyspan_port_private *p_priv;
1216 struct keyspan_serial_private *s_priv; 1215 struct keyspan_serial_private *s_priv;
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 3107ed15af64..30771e5b3973 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -36,8 +36,7 @@
36 36
37/* Function prototypes for Keyspan serial converter */ 37/* Function prototypes for Keyspan serial converter */
38static int keyspan_open (struct tty_struct *tty, 38static int keyspan_open (struct tty_struct *tty,
39 struct usb_serial_port *port, 39 struct usb_serial_port *port);
40 struct file *filp);
41static void keyspan_close (struct usb_serial_port *port); 40static void keyspan_close (struct usb_serial_port *port);
42static void keyspan_dtr_rts (struct usb_serial_port *port, int on); 41static void keyspan_dtr_rts (struct usb_serial_port *port, int on);
43static int keyspan_startup (struct usb_serial *serial); 42static int keyspan_startup (struct usb_serial *serial);
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index d0b12e40c2b1..257c16cc6b2a 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -681,7 +681,7 @@ static int keyspan_pda_carrier_raised(struct usb_serial_port *port)
681 681
682 682
683static int keyspan_pda_open(struct tty_struct *tty, 683static int keyspan_pda_open(struct tty_struct *tty,
684 struct usb_serial_port *port, struct file *filp) 684 struct usb_serial_port *port)
685{ 685{
686 struct usb_serial *serial = port->serial; 686 struct usb_serial *serial = port->serial;
687 unsigned char room; 687 unsigned char room;
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 0f44bb8e8d4f..a61673133d7d 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -75,8 +75,7 @@ static int debug;
75static int klsi_105_startup(struct usb_serial *serial); 75static int klsi_105_startup(struct usb_serial *serial);
76static void klsi_105_disconnect(struct usb_serial *serial); 76static void klsi_105_disconnect(struct usb_serial *serial);
77static void klsi_105_release(struct usb_serial *serial); 77static void klsi_105_release(struct usb_serial *serial);
78static int klsi_105_open(struct tty_struct *tty, 78static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port);
79 struct usb_serial_port *port, struct file *filp);
80static void klsi_105_close(struct usb_serial_port *port); 79static void klsi_105_close(struct usb_serial_port *port);
81static int klsi_105_write(struct tty_struct *tty, 80static int klsi_105_write(struct tty_struct *tty,
82 struct usb_serial_port *port, const unsigned char *buf, int count); 81 struct usb_serial_port *port, const unsigned char *buf, int count);
@@ -358,8 +357,7 @@ static void klsi_105_release(struct usb_serial *serial)
358 } 357 }
359} /* klsi_105_release */ 358} /* klsi_105_release */
360 359
361static int klsi_105_open(struct tty_struct *tty, 360static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
362 struct usb_serial_port *port, struct file *filp)
363{ 361{
364 struct klsi_105_private *priv = usb_get_serial_port_data(port); 362 struct klsi_105_private *priv = usb_get_serial_port_data(port);
365 int retval = 0; 363 int retval = 0;
@@ -371,10 +369,6 @@ static int klsi_105_open(struct tty_struct *tty,
371 369
372 dbg("%s port %d", __func__, port->number); 370 dbg("%s port %d", __func__, port->number);
373 371
374 /* force low_latency on so that our tty_push actually forces
375 * the data through
376 * tty->low_latency = 1; */
377
378 /* Do a defined restart: 372 /* Do a defined restart:
379 * Set up sane default baud rate and send the 'READ_ON' 373 * Set up sane default baud rate and send the 'READ_ON'
380 * vendor command. 374 * vendor command.
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 6db0e561f680..45ea694b3ae6 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -70,8 +70,7 @@ 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_release(struct usb_serial *serial); 72static void kobil_release(struct usb_serial *serial);
73static int kobil_open(struct tty_struct *tty, 73static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
74 struct usb_serial_port *port, struct file *filp);
75static void kobil_close(struct usb_serial_port *port); 74static void kobil_close(struct usb_serial_port *port);
76static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, 75static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
77 const unsigned char *buf, int count); 76 const unsigned char *buf, int count);
@@ -85,7 +84,7 @@ static void kobil_read_int_callback(struct urb *urb);
85static void kobil_write_callback(struct urb *purb); 84static void kobil_write_callback(struct urb *purb);
86static void kobil_set_termios(struct tty_struct *tty, 85static void kobil_set_termios(struct tty_struct *tty,
87 struct usb_serial_port *port, struct ktermios *old); 86 struct usb_serial_port *port, struct ktermios *old);
88 87static void kobil_init_termios(struct tty_struct *tty);
89 88
90static struct usb_device_id id_table [] = { 89static struct usb_device_id id_table [] = {
91 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, 90 { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) },
@@ -120,6 +119,7 @@ static struct usb_serial_driver kobil_device = {
120 .release = kobil_release, 119 .release = kobil_release,
121 .ioctl = kobil_ioctl, 120 .ioctl = kobil_ioctl,
122 .set_termios = kobil_set_termios, 121 .set_termios = kobil_set_termios,
122 .init_termios = kobil_init_termios,
123 .tiocmget = kobil_tiocmget, 123 .tiocmget = kobil_tiocmget,
124 .tiocmset = kobil_tiocmset, 124 .tiocmset = kobil_tiocmset,
125 .open = kobil_open, 125 .open = kobil_open,
@@ -210,9 +210,17 @@ static void kobil_release(struct usb_serial *serial)
210 kfree(usb_get_serial_port_data(serial->port[i])); 210 kfree(usb_get_serial_port_data(serial->port[i]));
211} 211}
212 212
213static void kobil_init_termios(struct tty_struct *tty)
214{
215 /* Default to echo off and other sane device settings */
216 tty->termios->c_lflag = 0;
217 tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
218 tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
219 /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
220 tty->termios->c_oflag &= ~ONLCR;
221}
213 222
214static int kobil_open(struct tty_struct *tty, 223static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
215 struct usb_serial_port *port, struct file *filp)
216{ 224{
217 int result = 0; 225 int result = 0;
218 struct kobil_private *priv; 226 struct kobil_private *priv;
@@ -226,16 +234,6 @@ static int kobil_open(struct tty_struct *tty,
226 /* someone sets the dev to 0 if the close method has been called */ 234 /* someone sets the dev to 0 if the close method has been called */
227 port->interrupt_in_urb->dev = port->serial->dev; 235 port->interrupt_in_urb->dev = port->serial->dev;
228 236
229 if (tty) {
230
231 /* Default to echo off and other sane device settings */
232 tty->termios->c_lflag = 0;
233 tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN |
234 XCASE);
235 tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
236 /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
237 tty->termios->c_oflag &= ~ONLCR;
238 }
239 /* allocate memory for transfer buffer */ 237 /* allocate memory for transfer buffer */
240 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); 238 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
241 if (!transfer_buffer) 239 if (!transfer_buffer)
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index d8825e159aa5..ad4998bbf16f 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -93,8 +93,7 @@ static int debug;
93 */ 93 */
94static int mct_u232_startup(struct usb_serial *serial); 94static int mct_u232_startup(struct usb_serial *serial);
95static void mct_u232_release(struct usb_serial *serial); 95static void mct_u232_release(struct usb_serial *serial);
96static int mct_u232_open(struct tty_struct *tty, 96static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port);
97 struct usb_serial_port *port, struct file *filp);
98static void mct_u232_close(struct usb_serial_port *port); 97static void mct_u232_close(struct usb_serial_port *port);
99static void mct_u232_dtr_rts(struct usb_serial_port *port, int on); 98static void mct_u232_dtr_rts(struct usb_serial_port *port, int on);
100static void mct_u232_read_int_callback(struct urb *urb); 99static void mct_u232_read_int_callback(struct urb *urb);
@@ -421,8 +420,7 @@ static void mct_u232_release(struct usb_serial *serial)
421 } 420 }
422} /* mct_u232_release */ 421} /* mct_u232_release */
423 422
424static int mct_u232_open(struct tty_struct *tty, 423static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port)
425 struct usb_serial_port *port, struct file *filp)
426{ 424{
427 struct usb_serial *serial = port->serial; 425 struct usb_serial *serial = port->serial;
428 struct mct_u232_private *priv = usb_get_serial_port_data(port); 426 struct mct_u232_private *priv = usb_get_serial_port_data(port);
@@ -568,10 +566,13 @@ static void mct_u232_read_int_callback(struct urb *urb)
568 * Work-a-round: handle the 'usual' bulk-in pipe here 566 * Work-a-round: handle the 'usual' bulk-in pipe here
569 */ 567 */
570 if (urb->transfer_buffer_length > 2) { 568 if (urb->transfer_buffer_length > 2) {
571 tty = tty_port_tty_get(&port->port);
572 if (urb->actual_length) { 569 if (urb->actual_length) {
573 tty_insert_flip_string(tty, data, urb->actual_length); 570 tty = tty_port_tty_get(&port->port);
574 tty_flip_buffer_push(tty); 571 if (tty) {
572 tty_insert_flip_string(tty, data,
573 urb->actual_length);
574 tty_flip_buffer_push(tty);
575 }
575 tty_kref_put(tty); 576 tty_kref_put(tty);
576 } 577 }
577 goto exit; 578 goto exit;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index ccd4dd340d2c..763e32a44be0 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -85,7 +85,7 @@ static int debug;
85#define MOSCHIP_DEVICE_ID_7720 0x7720 85#define MOSCHIP_DEVICE_ID_7720 0x7720
86#define MOSCHIP_DEVICE_ID_7715 0x7715 86#define MOSCHIP_DEVICE_ID_7715 0x7715
87 87
88static struct usb_device_id moschip_port_id_table [] = { 88static struct usb_device_id moschip_port_id_table[] = {
89 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, 89 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) },
90 { } /* terminating entry */ 90 { } /* terminating entry */
91}; 91};
@@ -319,8 +319,7 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
319 return status; 319 return status;
320} 320}
321 321
322static int mos7720_open(struct tty_struct *tty, 322static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port)
323 struct usb_serial_port *port, struct file *filp)
324{ 323{
325 struct usb_serial *serial; 324 struct usb_serial *serial;
326 struct usb_serial_port *port0; 325 struct usb_serial_port *port0;
@@ -378,10 +377,14 @@ static int mos7720_open(struct tty_struct *tty,
378 /* Initialize MCS7720 -- Write Init values to corresponding Registers 377 /* Initialize MCS7720 -- Write Init values to corresponding Registers
379 * 378 *
380 * Register Index 379 * Register Index
380 * 0 : THR/RHR
381 * 1 : IER 381 * 1 : IER
382 * 2 : FCR 382 * 2 : FCR
383 * 3 : LCR 383 * 3 : LCR
384 * 4 : MCR 384 * 4 : MCR
385 * 5 : LSR
386 * 6 : MSR
387 * 7 : SPR
385 * 388 *
386 * 0x08 : SP1/2 Control Reg 389 * 0x08 : SP1/2 Control Reg
387 */ 390 */
@@ -1250,20 +1253,88 @@ static void mos7720_set_termios(struct tty_struct *tty,
1250static int get_lsr_info(struct tty_struct *tty, 1253static int get_lsr_info(struct tty_struct *tty,
1251 struct moschip_port *mos7720_port, unsigned int __user *value) 1254 struct moschip_port *mos7720_port, unsigned int __user *value)
1252{ 1255{
1253 int count; 1256 struct usb_serial_port *port = tty->driver_data;
1254 unsigned int result = 0; 1257 unsigned int result = 0;
1258 unsigned char data = 0;
1259 int port_number = port->number - port->serial->minor;
1260 int count;
1255 1261
1256 count = mos7720_chars_in_buffer(tty); 1262 count = mos7720_chars_in_buffer(tty);
1257 if (count == 0) { 1263 if (count == 0) {
1258 dbg("%s -- Empty", __func__); 1264 send_mos_cmd(port->serial, MOS_READ, port_number,
1259 result = TIOCSER_TEMT; 1265 UART_LSR, &data);
1266 if ((data & (UART_LSR_TEMT | UART_LSR_THRE))
1267 == (UART_LSR_TEMT | UART_LSR_THRE)) {
1268 dbg("%s -- Empty", __func__);
1269 result = TIOCSER_TEMT;
1270 }
1260 } 1271 }
1261
1262 if (copy_to_user(value, &result, sizeof(int))) 1272 if (copy_to_user(value, &result, sizeof(int)))
1263 return -EFAULT; 1273 return -EFAULT;
1264 return 0; 1274 return 0;
1265} 1275}
1266 1276
1277static int mos7720_tiocmget(struct tty_struct *tty, struct file *file)
1278{
1279 struct usb_serial_port *port = tty->driver_data;
1280 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
1281 unsigned int result = 0;
1282 unsigned int mcr ;
1283 unsigned int msr ;
1284
1285 dbg("%s - port %d", __func__, port->number);
1286
1287 mcr = mos7720_port->shadowMCR;
1288 msr = mos7720_port->shadowMSR;
1289
1290 result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
1291 | ((mcr & UART_MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
1292 | ((msr & UART_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */
1293 | ((msr & UART_MSR_DCD) ? TIOCM_CAR : 0) /* 0x040 */
1294 | ((msr & UART_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */
1295 | ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */
1296
1297 dbg("%s -- %x", __func__, result);
1298
1299 return result;
1300}
1301
1302static int mos7720_tiocmset(struct tty_struct *tty, struct file *file,
1303 unsigned int set, unsigned int clear)
1304{
1305 struct usb_serial_port *port = tty->driver_data;
1306 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
1307 unsigned int mcr ;
1308 unsigned char lmcr;
1309
1310 dbg("%s - port %d", __func__, port->number);
1311 dbg("he was at tiocmget");
1312
1313 mcr = mos7720_port->shadowMCR;
1314
1315 if (set & TIOCM_RTS)
1316 mcr |= UART_MCR_RTS;
1317 if (set & TIOCM_DTR)
1318 mcr |= UART_MCR_DTR;
1319 if (set & TIOCM_LOOP)
1320 mcr |= UART_MCR_LOOP;
1321
1322 if (clear & TIOCM_RTS)
1323 mcr &= ~UART_MCR_RTS;
1324 if (clear & TIOCM_DTR)
1325 mcr &= ~UART_MCR_DTR;
1326 if (clear & TIOCM_LOOP)
1327 mcr &= ~UART_MCR_LOOP;
1328
1329 mos7720_port->shadowMCR = mcr;
1330 lmcr = mos7720_port->shadowMCR;
1331
1332 send_mos_cmd(port->serial, MOS_WRITE,
1333 port->number - port->serial->minor, UART_MCR, &lmcr);
1334
1335 return 0;
1336}
1337
1267static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, 1338static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1268 unsigned int __user *value) 1339 unsigned int __user *value)
1269{ 1340{
@@ -1301,14 +1372,6 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1301 mcr &= ~UART_MCR_LOOP; 1372 mcr &= ~UART_MCR_LOOP;
1302 break; 1373 break;
1303 1374
1304 case TIOCMSET:
1305 /* turn off the RTS and DTR and LOOPBACK
1306 * and then only turn on what was asked to */
1307 mcr &= ~(UART_MCR_RTS | UART_MCR_DTR | UART_MCR_LOOP);
1308 mcr |= ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0);
1309 mcr |= ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0);
1310 mcr |= ((arg & TIOCM_LOOP) ? UART_MCR_LOOP : 0);
1311 break;
1312 } 1375 }
1313 1376
1314 mos7720_port->shadowMCR = mcr; 1377 mos7720_port->shadowMCR = mcr;
@@ -1320,28 +1383,6 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1320 return 0; 1383 return 0;
1321} 1384}
1322 1385
1323static int get_modem_info(struct moschip_port *mos7720_port,
1324 unsigned int __user *value)
1325{
1326 unsigned int result = 0;
1327 unsigned int msr = mos7720_port->shadowMSR;
1328 unsigned int mcr = mos7720_port->shadowMCR;
1329
1330 result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
1331 | ((mcr & UART_MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */
1332 | ((msr & UART_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */
1333 | ((msr & UART_MSR_DCD) ? TIOCM_CAR: 0) /* 0x040 */
1334 | ((msr & UART_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */
1335 | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1336
1337
1338 dbg("%s -- %x", __func__, result);
1339
1340 if (copy_to_user(value, &result, sizeof(int)))
1341 return -EFAULT;
1342 return 0;
1343}
1344
1345static int get_serial_info(struct moschip_port *mos7720_port, 1386static int get_serial_info(struct moschip_port *mos7720_port,
1346 struct serial_struct __user *retinfo) 1387 struct serial_struct __user *retinfo)
1347{ 1388{
@@ -1392,17 +1433,11 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
1392 /* FIXME: These should be using the mode methods */ 1433 /* FIXME: These should be using the mode methods */
1393 case TIOCMBIS: 1434 case TIOCMBIS:
1394 case TIOCMBIC: 1435 case TIOCMBIC:
1395 case TIOCMSET:
1396 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", 1436 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET",
1397 __func__, port->number); 1437 __func__, port->number);
1398 return set_modem_info(mos7720_port, cmd, 1438 return set_modem_info(mos7720_port, cmd,
1399 (unsigned int __user *)arg); 1439 (unsigned int __user *)arg);
1400 1440
1401 case TIOCMGET:
1402 dbg("%s (%d) TIOCMGET", __func__, port->number);
1403 return get_modem_info(mos7720_port,
1404 (unsigned int __user *)arg);
1405
1406 case TIOCGSERIAL: 1441 case TIOCGSERIAL:
1407 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 1442 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
1408 return get_serial_info(mos7720_port, 1443 return get_serial_info(mos7720_port,
@@ -1557,6 +1592,8 @@ static struct usb_serial_driver moschip7720_2port_driver = {
1557 .attach = mos7720_startup, 1592 .attach = mos7720_startup,
1558 .release = mos7720_release, 1593 .release = mos7720_release,
1559 .ioctl = mos7720_ioctl, 1594 .ioctl = mos7720_ioctl,
1595 .tiocmget = mos7720_tiocmget,
1596 .tiocmset = mos7720_tiocmset,
1560 .set_termios = mos7720_set_termios, 1597 .set_termios = mos7720_set_termios,
1561 .write = mos7720_write, 1598 .write = mos7720_write,
1562 .write_room = mos7720_write_room, 1599 .write_room = mos7720_write_room,
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 270009afdf77..f11abf52be7d 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -824,8 +824,7 @@ static int mos7840_serial_probe(struct usb_serial *serial,
824 * Otherwise we return a negative error number. 824 * Otherwise we return a negative error number.
825 *****************************************************************************/ 825 *****************************************************************************/
826 826
827static int mos7840_open(struct tty_struct *tty, 827static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
828 struct usb_serial_port *port, struct file *filp)
829{ 828{
830 int response; 829 int response;
831 int j; 830 int j;
@@ -2134,106 +2133,6 @@ static int mos7840_get_lsr_info(struct tty_struct *tty,
2134} 2133}
2135 2134
2136/***************************************************************************** 2135/*****************************************************************************
2137 * mos7840_set_modem_info
2138 * function to set modem info
2139 *****************************************************************************/
2140
2141/* FIXME: Should be using the model control hooks */
2142
2143static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2144 unsigned int cmd, unsigned int __user *value)
2145{
2146 unsigned int mcr;
2147 unsigned int arg;
2148 __u16 Data;
2149 int status;
2150 struct usb_serial_port *port;
2151
2152 if (mos7840_port == NULL)
2153 return -1;
2154
2155 port = (struct usb_serial_port *)mos7840_port->port;
2156 if (mos7840_port_paranoia_check(port, __func__)) {
2157 dbg("%s", "Invalid port");
2158 return -1;
2159 }
2160
2161 mcr = mos7840_port->shadowMCR;
2162
2163 if (copy_from_user(&arg, value, sizeof(int)))
2164 return -EFAULT;
2165
2166 switch (cmd) {
2167 case TIOCMBIS:
2168 if (arg & TIOCM_RTS)
2169 mcr |= MCR_RTS;
2170 if (arg & TIOCM_DTR)
2171 mcr |= MCR_RTS;
2172 if (arg & TIOCM_LOOP)
2173 mcr |= MCR_LOOPBACK;
2174 break;
2175
2176 case TIOCMBIC:
2177 if (arg & TIOCM_RTS)
2178 mcr &= ~MCR_RTS;
2179 if (arg & TIOCM_DTR)
2180 mcr &= ~MCR_RTS;
2181 if (arg & TIOCM_LOOP)
2182 mcr &= ~MCR_LOOPBACK;
2183 break;
2184
2185 case TIOCMSET:
2186 /* turn off the RTS and DTR and LOOPBACK
2187 * and then only turn on what was asked to */
2188 mcr &= ~(MCR_RTS | MCR_DTR | MCR_LOOPBACK);
2189 mcr |= ((arg & TIOCM_RTS) ? MCR_RTS : 0);
2190 mcr |= ((arg & TIOCM_DTR) ? MCR_DTR : 0);
2191 mcr |= ((arg & TIOCM_LOOP) ? MCR_LOOPBACK : 0);
2192 break;
2193 }
2194
2195 lock_kernel();
2196 mos7840_port->shadowMCR = mcr;
2197
2198 Data = mos7840_port->shadowMCR;
2199 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
2200 unlock_kernel();
2201 if (status < 0) {
2202 dbg("setting MODEM_CONTROL_REGISTER Failed");
2203 return -1;
2204 }
2205
2206 return 0;
2207}
2208
2209/*****************************************************************************
2210 * mos7840_get_modem_info
2211 * function to get modem info
2212 *****************************************************************************/
2213
2214static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2215 unsigned int __user *value)
2216{
2217 unsigned int result = 0;
2218 __u16 msr;
2219 unsigned int mcr = mos7840_port->shadowMCR;
2220 mos7840_get_uart_reg(mos7840_port->port,
2221 MODEM_STATUS_REGISTER, &msr);
2222 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
2223 |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
2224 |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */
2225 |((msr & MOS7840_MSR_CD) ? TIOCM_CAR : 0) /* 0x040 */
2226 |((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */
2227 |((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */
2228
2229 dbg("%s -- %x", __func__, result);
2230
2231 if (copy_to_user(value, &result, sizeof(int)))
2232 return -EFAULT;
2233 return 0;
2234}
2235
2236/*****************************************************************************
2237 * mos7840_get_serial_info 2136 * mos7840_get_serial_info
2238 * function to get information about serial port 2137 * function to get information about serial port
2239 *****************************************************************************/ 2138 *****************************************************************************/
@@ -2281,7 +2180,6 @@ static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
2281 struct async_icount cnow; 2180 struct async_icount cnow;
2282 struct async_icount cprev; 2181 struct async_icount cprev;
2283 struct serial_icounter_struct icount; 2182 struct serial_icounter_struct icount;
2284 int mosret = 0;
2285 2183
2286 if (mos7840_port_paranoia_check(port, __func__)) { 2184 if (mos7840_port_paranoia_check(port, __func__)) {
2287 dbg("%s", "Invalid port"); 2185 dbg("%s", "Invalid port");
@@ -2303,20 +2201,6 @@ static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
2303 return mos7840_get_lsr_info(tty, argp); 2201 return mos7840_get_lsr_info(tty, argp);
2304 return 0; 2202 return 0;
2305 2203
2306 /* FIXME: use the modem hooks and remove this */
2307 case TIOCMBIS:
2308 case TIOCMBIC:
2309 case TIOCMSET:
2310 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__,
2311 port->number);
2312 mosret =
2313 mos7840_set_modem_info(mos7840_port, cmd, argp);
2314 return mosret;
2315
2316 case TIOCMGET:
2317 dbg("%s (%d) TIOCMGET", __func__, port->number);
2318 return mos7840_get_modem_info(mos7840_port, argp);
2319
2320 case TIOCGSERIAL: 2204 case TIOCGSERIAL:
2321 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 2205 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
2322 return mos7840_get_serial_info(mos7840_port, argp); 2206 return mos7840_get_serial_info(mos7840_port, argp);
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index f5f3751a888c..5ceaa4c6be09 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -80,8 +80,7 @@ exit:
80 __func__, result); 80 __func__, result);
81} 81}
82 82
83static int navman_open(struct tty_struct *tty, 83static int navman_open(struct tty_struct *tty, struct usb_serial_port *port)
84 struct usb_serial_port *port, struct file *filp)
85{ 84{
86 int result = 0; 85 int result = 0;
87 86
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 56857ddbd70b..062265038bf0 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -64,8 +64,7 @@ static int debug;
64#define BT_IGNITIONPRO_ID 0x2000 64#define BT_IGNITIONPRO_ID 0x2000
65 65
66/* function prototypes */ 66/* function prototypes */
67static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port, 67static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port);
68 struct file *filp);
69static void omninet_close(struct usb_serial_port *port); 68static void omninet_close(struct usb_serial_port *port);
70static void omninet_read_bulk_callback(struct urb *urb); 69static void omninet_read_bulk_callback(struct urb *urb);
71static void omninet_write_bulk_callback(struct urb *urb); 70static void omninet_write_bulk_callback(struct urb *urb);
@@ -163,8 +162,7 @@ static int omninet_attach(struct usb_serial *serial)
163 return 0; 162 return 0;
164} 163}
165 164
166static int omninet_open(struct tty_struct *tty, 165static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port)
167 struct usb_serial_port *port, struct file *filp)
168{ 166{
169 struct usb_serial *serial = port->serial; 167 struct usb_serial *serial = port->serial;
170 struct usb_serial_port *wport; 168 struct usb_serial_port *wport;
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 336bba79ad32..1085a577c5c1 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -144,8 +144,7 @@ exit:
144 spin_unlock(&priv->lock); 144 spin_unlock(&priv->lock);
145} 145}
146 146
147static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port, 147static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port)
148 struct file *filp)
149{ 148{
150 struct opticon_private *priv = usb_get_serial_data(port->serial); 149 struct opticon_private *priv = usb_get_serial_data(port->serial);
151 unsigned long flags; 150 unsigned long flags;
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index c784ddbe7b61..fe47051dbef2 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -45,8 +45,7 @@
45/* Function prototypes */ 45/* Function prototypes */
46static int option_probe(struct usb_serial *serial, 46static int option_probe(struct usb_serial *serial,
47 const struct usb_device_id *id); 47 const struct usb_device_id *id);
48static int option_open(struct tty_struct *tty, struct usb_serial_port *port, 48static int option_open(struct tty_struct *tty, struct usb_serial_port *port);
49 struct file *filp);
50static void option_close(struct usb_serial_port *port); 49static void option_close(struct usb_serial_port *port);
51static void option_dtr_rts(struct usb_serial_port *port, int on); 50static void option_dtr_rts(struct usb_serial_port *port, int on);
52 51
@@ -961,8 +960,7 @@ static int option_chars_in_buffer(struct tty_struct *tty)
961 return data_len; 960 return data_len;
962} 961}
963 962
964static int option_open(struct tty_struct *tty, 963static int option_open(struct tty_struct *tty, struct usb_serial_port *port)
965 struct usb_serial_port *port, struct file *filp)
966{ 964{
967 struct option_port_private *portdata; 965 struct option_port_private *portdata;
968 int i, err; 966 int i, err;
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 3cece27325e7..0f4a70ce3823 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -141,11 +141,11 @@ struct oti6858_control_pkt {
141 && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt)) 141 && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt))
142 142
143/* function prototypes */ 143/* function prototypes */
144static int oti6858_open(struct tty_struct *tty, 144static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port);
145 struct usb_serial_port *port, struct file *filp);
146static void oti6858_close(struct usb_serial_port *port); 145static void oti6858_close(struct usb_serial_port *port);
147static void oti6858_set_termios(struct tty_struct *tty, 146static void oti6858_set_termios(struct tty_struct *tty,
148 struct usb_serial_port *port, struct ktermios *old); 147 struct usb_serial_port *port, struct ktermios *old);
148static void oti6858_init_termios(struct tty_struct *tty);
149static int oti6858_ioctl(struct tty_struct *tty, struct file *file, 149static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
150 unsigned int cmd, unsigned long arg); 150 unsigned int cmd, unsigned long arg);
151static void oti6858_read_int_callback(struct urb *urb); 151static void oti6858_read_int_callback(struct urb *urb);
@@ -186,6 +186,7 @@ static struct usb_serial_driver oti6858_device = {
186 .write = oti6858_write, 186 .write = oti6858_write,
187 .ioctl = oti6858_ioctl, 187 .ioctl = oti6858_ioctl,
188 .set_termios = oti6858_set_termios, 188 .set_termios = oti6858_set_termios,
189 .init_termios = oti6858_init_termios,
189 .tiocmget = oti6858_tiocmget, 190 .tiocmget = oti6858_tiocmget,
190 .tiocmset = oti6858_tiocmset, 191 .tiocmset = oti6858_tiocmset,
191 .read_bulk_callback = oti6858_read_bulk_callback, 192 .read_bulk_callback = oti6858_read_bulk_callback,
@@ -206,7 +207,6 @@ struct oti6858_private {
206 struct { 207 struct {
207 u8 read_urb_in_use; 208 u8 read_urb_in_use;
208 u8 write_urb_in_use; 209 u8 write_urb_in_use;
209 u8 termios_initialized;
210 } flags; 210 } flags;
211 struct delayed_work delayed_write_work; 211 struct delayed_work delayed_write_work;
212 212
@@ -447,6 +447,14 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty)
447 return chars; 447 return chars;
448} 448}
449 449
450static void oti6858_init_termios(struct tty_struct *tty)
451{
452 *(tty->termios) = tty_std_termios;
453 tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
454 tty->termios->c_ispeed = 38400;
455 tty->termios->c_ospeed = 38400;
456}
457
450static void oti6858_set_termios(struct tty_struct *tty, 458static void oti6858_set_termios(struct tty_struct *tty,
451 struct usb_serial_port *port, struct ktermios *old_termios) 459 struct usb_serial_port *port, struct ktermios *old_termios)
452{ 460{
@@ -464,16 +472,6 @@ static void oti6858_set_termios(struct tty_struct *tty,
464 return; 472 return;
465 } 473 }
466 474
467 spin_lock_irqsave(&priv->lock, flags);
468 if (!priv->flags.termios_initialized) {
469 *(tty->termios) = tty_std_termios;
470 tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
471 tty->termios->c_ispeed = 38400;
472 tty->termios->c_ospeed = 38400;
473 priv->flags.termios_initialized = 1;
474 }
475 spin_unlock_irqrestore(&priv->lock, flags);
476
477 cflag = tty->termios->c_cflag; 475 cflag = tty->termios->c_cflag;
478 476
479 spin_lock_irqsave(&priv->lock, flags); 477 spin_lock_irqsave(&priv->lock, flags);
@@ -566,8 +564,7 @@ static void oti6858_set_termios(struct tty_struct *tty,
566 spin_unlock_irqrestore(&priv->lock, flags); 564 spin_unlock_irqrestore(&priv->lock, flags);
567} 565}
568 566
569static int oti6858_open(struct tty_struct *tty, 567static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port)
570 struct usb_serial_port *port, struct file *filp)
571{ 568{
572 struct oti6858_private *priv = usb_get_serial_port_data(port); 569 struct oti6858_private *priv = usb_get_serial_port_data(port);
573 struct ktermios tmp_termios; 570 struct ktermios tmp_termios;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 3e86815b2705..a63ea99936f7 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -691,8 +691,7 @@ static void pl2303_close(struct usb_serial_port *port)
691 691
692} 692}
693 693
694static int pl2303_open(struct tty_struct *tty, 694static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
695 struct usb_serial_port *port, struct file *filp)
696{ 695{
697 struct ktermios tmp_termios; 696 struct ktermios tmp_termios;
698 struct usb_serial *serial = port->serial; 697 struct usb_serial *serial = port->serial;
@@ -714,8 +713,6 @@ static int pl2303_open(struct tty_struct *tty,
714 if (tty) 713 if (tty)
715 pl2303_set_termios(tty, port, &tmp_termios); 714 pl2303_set_termios(tty, port, &tmp_termios);
716 715
717 /* FIXME: need to assert RTS and DTR if CRTSCTS off */
718
719 dbg("%s - submitting read urb", __func__); 716 dbg("%s - submitting read urb", __func__);
720 port->read_urb->dev = serial->dev; 717 port->read_urb->dev = serial->dev;
721 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 718 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index f48d05e0acc1..55391bbe1230 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -734,8 +734,7 @@ static void sierra_close(struct usb_serial_port *port)
734 } 734 }
735} 735}
736 736
737static int sierra_open(struct tty_struct *tty, 737static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)
738 struct usb_serial_port *port, struct file *filp)
739{ 738{
740 struct sierra_port_private *portdata; 739 struct sierra_port_private *portdata;
741 struct usb_serial *serial = port->serial; 740 struct usb_serial *serial = port->serial;
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 3c249d8e8b8e..61e7c40b94fb 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -299,7 +299,6 @@ struct spcp8x5_private {
299 wait_queue_head_t delta_msr_wait; 299 wait_queue_head_t delta_msr_wait;
300 u8 line_control; 300 u8 line_control;
301 u8 line_status; 301 u8 line_status;
302 u8 termios_initialized;
303}; 302};
304 303
305/* desc : when device plug in,this function would be called. 304/* desc : when device plug in,this function would be called.
@@ -498,6 +497,15 @@ static void spcp8x5_close(struct usb_serial_port *port)
498 dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result); 497 dev_dbg(&port->dev, "usb_unlink_urb(read_urb) = %d\n", result);
499} 498}
500 499
500static void spcp8x5_init_termios(struct tty_struct *tty)
501{
502 /* for the 1st time call this function */
503 *(tty->termios) = tty_std_termios;
504 tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
505 tty->termios->c_ispeed = 115200;
506 tty->termios->c_ospeed = 115200;
507}
508
501/* set the serial param for transfer. we should check if we really need to 509/* set the serial param for transfer. we should check if we really need to
502 * transfer. if we set flow control we should do this too. */ 510 * transfer. if we set flow control we should do this too. */
503static void spcp8x5_set_termios(struct tty_struct *tty, 511static void spcp8x5_set_termios(struct tty_struct *tty,
@@ -514,16 +522,6 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
514 int i; 522 int i;
515 u8 control; 523 u8 control;
516 524
517 /* for the 1st time call this function */
518 spin_lock_irqsave(&priv->lock, flags);
519 if (!priv->termios_initialized) {
520 *(tty->termios) = tty_std_termios;
521 tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
522 tty->termios->c_ispeed = 115200;
523 tty->termios->c_ospeed = 115200;
524 priv->termios_initialized = 1;
525 }
526 spin_unlock_irqrestore(&priv->lock, flags);
527 525
528 /* check that they really want us to change something */ 526 /* check that they really want us to change something */
529 if (!tty_termios_hw_change(tty->termios, old_termios)) 527 if (!tty_termios_hw_change(tty->termios, old_termios))
@@ -623,8 +621,7 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
623 621
624/* open the serial port. do some usb system call. set termios and get the line 622/* open the serial port. do some usb system call. set termios and get the line
625 * status of the device. then submit the read urb */ 623 * status of the device. then submit the read urb */
626static int spcp8x5_open(struct tty_struct *tty, 624static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port)
627 struct usb_serial_port *port, struct file *filp)
628{ 625{
629 struct ktermios tmp_termios; 626 struct ktermios tmp_termios;
630 struct usb_serial *serial = port->serial; 627 struct usb_serial *serial = port->serial;
@@ -658,8 +655,6 @@ static int spcp8x5_open(struct tty_struct *tty,
658 priv->line_status = status & 0xf0 ; 655 priv->line_status = status & 0xf0 ;
659 spin_unlock_irqrestore(&priv->lock, flags); 656 spin_unlock_irqrestore(&priv->lock, flags);
660 657
661 /* FIXME: need to assert RTS and DTR if CRTSCTS off */
662
663 dbg("%s - submitting read urb", __func__); 658 dbg("%s - submitting read urb", __func__);
664 port->read_urb->dev = serial->dev; 659 port->read_urb->dev = serial->dev;
665 ret = usb_submit_urb(port->read_urb, GFP_KERNEL); 660 ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
@@ -1011,6 +1006,7 @@ static struct usb_serial_driver spcp8x5_device = {
1011 .carrier_raised = spcp8x5_carrier_raised, 1006 .carrier_raised = spcp8x5_carrier_raised,
1012 .write = spcp8x5_write, 1007 .write = spcp8x5_write,
1013 .set_termios = spcp8x5_set_termios, 1008 .set_termios = spcp8x5_set_termios,
1009 .init_termios = spcp8x5_init_termios,
1014 .ioctl = spcp8x5_ioctl, 1010 .ioctl = spcp8x5_ioctl,
1015 .tiocmget = spcp8x5_tiocmget, 1011 .tiocmget = spcp8x5_tiocmget,
1016 .tiocmset = spcp8x5_tiocmset, 1012 .tiocmset = spcp8x5_tiocmset,
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index 6157fac9366b..cb7e95f9fcbf 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -124,8 +124,7 @@ exit:
124 spin_unlock(&priv->lock); 124 spin_unlock(&priv->lock);
125} 125}
126 126
127static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port, 127static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port)
128 struct file *filp)
129{ 128{
130 struct symbol_private *priv = usb_get_serial_data(port->serial); 129 struct symbol_private *priv = usb_get_serial_data(port->serial);
131 unsigned long flags; 130 unsigned long flags;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 3bc609fe2242..1e9dc8821698 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -98,8 +98,7 @@ struct ti_device {
98 98
99static int ti_startup(struct usb_serial *serial); 99static int ti_startup(struct usb_serial *serial);
100static void ti_release(struct usb_serial *serial); 100static void ti_release(struct usb_serial *serial);
101static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, 101static int ti_open(struct tty_struct *tty, struct usb_serial_port *port);
102 struct file *file);
103static void ti_close(struct usb_serial_port *port); 102static void ti_close(struct usb_serial_port *port);
104static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, 103static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
105 const unsigned char *data, int count); 104 const unsigned char *data, int count);
@@ -492,8 +491,7 @@ static void ti_release(struct usb_serial *serial)
492} 491}
493 492
494 493
495static int ti_open(struct tty_struct *tty, 494static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
496 struct usb_serial_port *port, struct file *file)
497{ 495{
498 struct ti_port *tport = usb_get_serial_port_data(port); 496 struct ti_port *tport = usb_get_serial_port_data(port);
499 struct ti_device *tdev; 497 struct ti_device *tdev;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 99188c92068b..9d7ca4868d37 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -43,8 +43,6 @@
43#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" 43#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/"
44#define DRIVER_DESC "USB Serial Driver core" 44#define DRIVER_DESC "USB Serial Driver core"
45 45
46static void port_free(struct usb_serial_port *port);
47
48/* Driver structure we register with the USB core */ 46/* Driver structure we register with the USB core */
49static struct usb_driver usb_serial_driver = { 47static struct usb_driver usb_serial_driver = {
50 .name = "usbserial", 48 .name = "usbserial",
@@ -68,6 +66,11 @@ static struct usb_serial *serial_table[SERIAL_TTY_MINORS];
68static DEFINE_MUTEX(table_lock); 66static DEFINE_MUTEX(table_lock);
69static LIST_HEAD(usb_serial_driver_list); 67static LIST_HEAD(usb_serial_driver_list);
70 68
69/*
70 * Look up the serial structure. If it is found and it hasn't been
71 * disconnected, return with its disc_mutex held and its refcount
72 * incremented. Otherwise return NULL.
73 */
71struct usb_serial *usb_serial_get_by_index(unsigned index) 74struct usb_serial *usb_serial_get_by_index(unsigned index)
72{ 75{
73 struct usb_serial *serial; 76 struct usb_serial *serial;
@@ -75,8 +78,15 @@ struct usb_serial *usb_serial_get_by_index(unsigned index)
75 mutex_lock(&table_lock); 78 mutex_lock(&table_lock);
76 serial = serial_table[index]; 79 serial = serial_table[index];
77 80
78 if (serial) 81 if (serial) {
79 kref_get(&serial->kref); 82 mutex_lock(&serial->disc_mutex);
83 if (serial->disconnected) {
84 mutex_unlock(&serial->disc_mutex);
85 serial = NULL;
86 } else {
87 kref_get(&serial->kref);
88 }
89 }
80 mutex_unlock(&table_lock); 90 mutex_unlock(&table_lock);
81 return serial; 91 return serial;
82} 92}
@@ -125,8 +135,10 @@ static void return_serial(struct usb_serial *serial)
125 135
126 dbg("%s", __func__); 136 dbg("%s", __func__);
127 137
138 mutex_lock(&table_lock);
128 for (i = 0; i < serial->num_ports; ++i) 139 for (i = 0; i < serial->num_ports; ++i)
129 serial_table[serial->minor + i] = NULL; 140 serial_table[serial->minor + i] = NULL;
141 mutex_unlock(&table_lock);
130} 142}
131 143
132static void destroy_serial(struct kref *kref) 144static void destroy_serial(struct kref *kref)
@@ -145,161 +157,157 @@ static void destroy_serial(struct kref *kref)
145 157
146 serial->type->release(serial); 158 serial->type->release(serial);
147 159
148 for (i = 0; i < serial->num_ports; ++i) { 160 /* Now that nothing is using the ports, they can be freed */
161 for (i = 0; i < serial->num_port_pointers; ++i) {
149 port = serial->port[i]; 162 port = serial->port[i];
150 if (port) 163 if (port) {
164 port->serial = NULL;
151 put_device(&port->dev); 165 put_device(&port->dev);
152 }
153
154 /* If this is a "fake" port, we have to clean it up here, as it will
155 * not get cleaned up in port_release() as it was never registered with
156 * the driver core */
157 if (serial->num_ports < serial->num_port_pointers) {
158 for (i = serial->num_ports;
159 i < serial->num_port_pointers; ++i) {
160 port = serial->port[i];
161 if (port)
162 port_free(port);
163 } 166 }
164 } 167 }
165 168
166 usb_put_dev(serial->dev); 169 usb_put_dev(serial->dev);
167
168 /* free up any memory that we allocated */
169 kfree(serial); 170 kfree(serial);
170} 171}
171 172
172void usb_serial_put(struct usb_serial *serial) 173void usb_serial_put(struct usb_serial *serial)
173{ 174{
174 mutex_lock(&table_lock);
175 kref_put(&serial->kref, destroy_serial); 175 kref_put(&serial->kref, destroy_serial);
176 mutex_unlock(&table_lock);
177} 176}
178 177
179/***************************************************************************** 178/*****************************************************************************
180 * Driver tty interface functions 179 * Driver tty interface functions
181 *****************************************************************************/ 180 *****************************************************************************/
182static int serial_open (struct tty_struct *tty, struct file *filp) 181
182/**
183 * serial_install - install tty
184 * @driver: the driver (USB in our case)
185 * @tty: the tty being created
186 *
187 * Create the termios objects for this tty. We use the default
188 * USB serial settings but permit them to be overridden by
189 * serial->type->init_termios.
190 *
191 * This is the first place a new tty gets used. Hence this is where we
192 * acquire references to the usb_serial structure and the driver module,
193 * where we store a pointer to the port, and where we do an autoresume.
194 * All these actions are reversed in serial_release().
195 */
196static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
183{ 197{
198 int idx = tty->index;
184 struct usb_serial *serial; 199 struct usb_serial *serial;
185 struct usb_serial_port *port; 200 struct usb_serial_port *port;
186 unsigned int portNumber; 201 int retval = -ENODEV;
187 int retval = 0;
188 int first = 0;
189 202
190 dbg("%s", __func__); 203 dbg("%s", __func__);
191 204
192 /* get the serial object associated with this tty pointer */ 205 serial = usb_serial_get_by_index(idx);
193 serial = usb_serial_get_by_index(tty->index); 206 if (!serial)
194 if (!serial) { 207 return retval;
195 tty->driver_data = NULL;
196 return -ENODEV;
197 }
198 208
199 mutex_lock(&serial->disc_mutex); 209 port = serial->port[idx - serial->minor];
200 portNumber = tty->index - serial->minor; 210 if (!port)
201 port = serial->port[portNumber]; 211 goto error_no_port;
202 if (!port || serial->disconnected) 212 if (!try_module_get(serial->type->driver.owner))
203 retval = -ENODEV; 213 goto error_module_get;
204 else 214
205 get_device(&port->dev); 215 /* perform the standard setup */
206 /* 216 retval = tty_init_termios(tty);
207 * Note: Our locking order requirement does not allow port->mutex
208 * to be acquired while serial->disc_mutex is held.
209 */
210 mutex_unlock(&serial->disc_mutex);
211 if (retval) 217 if (retval)
212 goto bailout_serial_put; 218 goto error_init_termios;
213 219
214 if (mutex_lock_interruptible(&port->mutex)) { 220 retval = usb_autopm_get_interface(serial->interface);
215 retval = -ERESTARTSYS; 221 if (retval)
216 goto bailout_port_put; 222 goto error_get_interface;
217 } 223
224 mutex_unlock(&serial->disc_mutex);
218 225
219 ++port->port.count; 226 /* allow the driver to update the settings */
227 if (serial->type->init_termios)
228 serial->type->init_termios(tty);
220 229
221 /* set up our port structure making the tty driver
222 * remember our port object, and us it */
223 tty->driver_data = port; 230 tty->driver_data = port;
224 tty_port_tty_set(&port->port, tty);
225 231
226 /* If the console is attached, the device is already open */ 232 /* Final install (we use the default method) */
227 if (port->port.count == 1 && !port->console) { 233 tty_driver_kref_get(driver);
228 first = 1; 234 tty->count++;
229 /* lock this module before we call it 235 driver->ttys[idx] = tty;
230 * this may fail, which means we must bail out, 236 return retval;
231 * safe because we are called with BKL held */
232 if (!try_module_get(serial->type->driver.owner)) {
233 retval = -ENODEV;
234 goto bailout_mutex_unlock;
235 }
236 237
238 error_get_interface:
239 error_init_termios:
240 module_put(serial->type->driver.owner);
241 error_module_get:
242 error_no_port:
243 usb_serial_put(serial);
244 mutex_unlock(&serial->disc_mutex);
245 return retval;
246}
247
248static int serial_open(struct tty_struct *tty, struct file *filp)
249{
250 struct usb_serial_port *port = tty->driver_data;
251 struct usb_serial *serial = port->serial;
252 int retval;
253
254 dbg("%s - port %d", __func__, port->number);
255
256 spin_lock_irq(&port->port.lock);
257 if (!tty_hung_up_p(filp))
258 ++port->port.count;
259 spin_unlock_irq(&port->port.lock);
260 tty_port_tty_set(&port->port, tty);
261
262 /* Do the device-specific open only if the hardware isn't
263 * already initialized.
264 */
265 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
266 if (mutex_lock_interruptible(&port->mutex))
267 return -ERESTARTSYS;
237 mutex_lock(&serial->disc_mutex); 268 mutex_lock(&serial->disc_mutex);
238 if (serial->disconnected) 269 if (serial->disconnected)
239 retval = -ENODEV; 270 retval = -ENODEV;
240 else 271 else
241 retval = usb_autopm_get_interface(serial->interface); 272 retval = port->serial->type->open(tty, port);
242 if (retval)
243 goto bailout_module_put;
244
245 /* only call the device specific open if this
246 * is the first time the port is opened */
247 retval = serial->type->open(tty, port, filp);
248 if (retval)
249 goto bailout_interface_put;
250 mutex_unlock(&serial->disc_mutex); 273 mutex_unlock(&serial->disc_mutex);
274 mutex_unlock(&port->mutex);
275 if (retval)
276 return retval;
251 set_bit(ASYNCB_INITIALIZED, &port->port.flags); 277 set_bit(ASYNCB_INITIALIZED, &port->port.flags);
252 } 278 }
253 mutex_unlock(&port->mutex); 279
254 /* Now do the correct tty layer semantics */ 280 /* Now do the correct tty layer semantics */
255 retval = tty_port_block_til_ready(&port->port, tty, filp); 281 retval = tty_port_block_til_ready(&port->port, tty, filp);
256 if (retval == 0) {
257 if (!first)
258 usb_serial_put(serial);
259 return 0;
260 }
261 mutex_lock(&port->mutex);
262 if (first == 0)
263 goto bailout_mutex_unlock;
264 /* Undo the initial port actions */
265 mutex_lock(&serial->disc_mutex);
266bailout_interface_put:
267 usb_autopm_put_interface(serial->interface);
268bailout_module_put:
269 mutex_unlock(&serial->disc_mutex);
270 module_put(serial->type->driver.owner);
271bailout_mutex_unlock:
272 port->port.count = 0;
273 tty->driver_data = NULL;
274 tty_port_tty_set(&port->port, NULL);
275 mutex_unlock(&port->mutex);
276bailout_port_put:
277 put_device(&port->dev);
278bailout_serial_put:
279 usb_serial_put(serial);
280 return retval; 282 return retval;
281} 283}
282 284
283/** 285/**
284 * serial_do_down - shut down hardware 286 * serial_down - shut down hardware
285 * @port: port to shut down 287 * @port: port to shut down
286 *
287 * Shut down a USB port unless it is the console. We never shut down the
288 * console hardware as it will always be in use.
289 * 288 *
290 * Don't free any resources at this point 289 * Shut down a USB serial port unless it is the console. We never
290 * shut down the console hardware as it will always be in use.
291 */ 291 */
292static void serial_do_down(struct usb_serial_port *port) 292static void serial_down(struct usb_serial_port *port)
293{ 293{
294 struct usb_serial_driver *drv = port->serial->type; 294 struct usb_serial_driver *drv = port->serial->type;
295 struct usb_serial *serial; 295 struct usb_serial *serial;
296 struct module *owner; 296 struct module *owner;
297 297
298 /* The console is magical, do not hang up the console hardware 298 /*
299 or there will be tears */ 299 * The console is magical. Do not hang up the console hardware
300 * or there will be tears.
301 */
300 if (port->console) 302 if (port->console)
301 return; 303 return;
302 304
305 /* Don't call the close method if the hardware hasn't been
306 * initialized.
307 */
308 if (!test_and_clear_bit(ASYNCB_INITIALIZED, &port->port.flags))
309 return;
310
303 mutex_lock(&port->mutex); 311 mutex_lock(&port->mutex);
304 serial = port->serial; 312 serial = port->serial;
305 owner = serial->type->driver.owner; 313 owner = serial->type->driver.owner;
@@ -310,79 +318,69 @@ static void serial_do_down(struct usb_serial_port *port)
310 mutex_unlock(&port->mutex); 318 mutex_unlock(&port->mutex);
311} 319}
312 320
313/** 321static void serial_hangup(struct tty_struct *tty)
314 * serial_do_free - free resources post close/hangup
315 * @port: port to free up
316 *
317 * Do the resource freeing and refcount dropping for the port. We must
318 * be careful about ordering and we must avoid freeing up the console.
319 */
320
321static void serial_do_free(struct usb_serial_port *port)
322{ 322{
323 struct usb_serial *serial; 323 struct usb_serial_port *port = tty->driver_data;
324 struct module *owner;
325 324
326 /* The console is magical, do not hang up the console hardware 325 dbg("%s - port %d", __func__, port->number);
327 or there will be tears */
328 if (port->console)
329 return;
330 326
331 serial = port->serial; 327 serial_down(port);
332 owner = serial->type->driver.owner; 328 tty_port_hangup(&port->port);
333 put_device(&port->dev);
334 /* Mustn't dereference port any more */
335 mutex_lock(&serial->disc_mutex);
336 if (!serial->disconnected)
337 usb_autopm_put_interface(serial->interface);
338 mutex_unlock(&serial->disc_mutex);
339 usb_serial_put(serial);
340 /* Mustn't dereference serial any more */
341 module_put(owner);
342} 329}
343 330
344static void serial_close(struct tty_struct *tty, struct file *filp) 331static void serial_close(struct tty_struct *tty, struct file *filp)
345{ 332{
346 struct usb_serial_port *port = tty->driver_data; 333 struct usb_serial_port *port = tty->driver_data;
347 334
348 if (!port)
349 return;
350
351 dbg("%s - port %d", __func__, port->number); 335 dbg("%s - port %d", __func__, port->number);
352 336
353 /* FIXME: 337 if (tty_hung_up_p(filp))
354 This leaves a very narrow race. Really we should do the
355 serial_do_free() on tty->shutdown(), but tty->shutdown can
356 be called from IRQ context and serial_do_free can sleep.
357
358 The right fix is probably to make the tty free (which is rare)
359 and thus tty->shutdown() occur via a work queue and simplify all
360 the drivers that use it.
361 */
362 if (tty_hung_up_p(filp)) {
363 /* serial_hangup already called serial_down at this point.
364 Another user may have already reopened the port but
365 serial_do_free is refcounted */
366 serial_do_free(port);
367 return; 338 return;
368 }
369
370 if (tty_port_close_start(&port->port, tty, filp) == 0) 339 if (tty_port_close_start(&port->port, tty, filp) == 0)
371 return; 340 return;
372 341 serial_down(port);
373 serial_do_down(port);
374 tty_port_close_end(&port->port, tty); 342 tty_port_close_end(&port->port, tty);
375 tty_port_tty_set(&port->port, NULL); 343 tty_port_tty_set(&port->port, NULL);
376 serial_do_free(port);
377} 344}
378 345
379static void serial_hangup(struct tty_struct *tty) 346/**
347 * serial_release - free resources post close/hangup
348 * @port: port to free up
349 *
350 * Do the resource freeing and refcount dropping for the port.
351 * Avoid freeing the console.
352 *
353 * Called when the last tty kref is dropped.
354 */
355static void serial_release(struct tty_struct *tty)
380{ 356{
381 struct usb_serial_port *port = tty->driver_data; 357 struct usb_serial_port *port = tty->driver_data;
382 serial_do_down(port); 358 struct usb_serial *serial;
383 tty_port_hangup(&port->port); 359 struct module *owner;
384 /* We must not free port yet - the USB serial layer depends on it's 360
385 continued existence */ 361 /* The console is magical. Do not hang up the console hardware
362 * or there will be tears.
363 */
364 if (port->console)
365 return;
366
367 dbg("%s - port %d", __func__, port->number);
368
369 /* Standard shutdown processing */
370 tty_shutdown(tty);
371
372 tty->driver_data = NULL;
373
374 serial = port->serial;
375 owner = serial->type->driver.owner;
376
377 mutex_lock(&serial->disc_mutex);
378 if (!serial->disconnected)
379 usb_autopm_put_interface(serial->interface);
380 mutex_unlock(&serial->disc_mutex);
381
382 usb_serial_put(serial);
383 module_put(owner);
386} 384}
387 385
388static int serial_write(struct tty_struct *tty, const unsigned char *buf, 386static int serial_write(struct tty_struct *tty, const unsigned char *buf,
@@ -527,6 +525,7 @@ static int serial_proc_show(struct seq_file *m, void *v)
527 525
528 seq_putc(m, '\n'); 526 seq_putc(m, '\n');
529 usb_serial_put(serial); 527 usb_serial_put(serial);
528 mutex_unlock(&serial->disc_mutex);
530 } 529 }
531 return 0; 530 return 0;
532} 531}
@@ -596,14 +595,6 @@ static void usb_serial_port_work(struct work_struct *work)
596 tty_kref_put(tty); 595 tty_kref_put(tty);
597} 596}
598 597
599static void port_release(struct device *dev)
600{
601 struct usb_serial_port *port = to_usb_serial_port(dev);
602
603 dbg ("%s - %s", __func__, dev_name(dev));
604 port_free(port);
605}
606
607static void kill_traffic(struct usb_serial_port *port) 598static void kill_traffic(struct usb_serial_port *port)
608{ 599{
609 usb_kill_urb(port->read_urb); 600 usb_kill_urb(port->read_urb);
@@ -623,8 +614,12 @@ static void kill_traffic(struct usb_serial_port *port)
623 usb_kill_urb(port->interrupt_out_urb); 614 usb_kill_urb(port->interrupt_out_urb);
624} 615}
625 616
626static void port_free(struct usb_serial_port *port) 617static void port_release(struct device *dev)
627{ 618{
619 struct usb_serial_port *port = to_usb_serial_port(dev);
620
621 dbg ("%s - %s", __func__, dev_name(dev));
622
628 /* 623 /*
629 * Stop all the traffic before cancelling the work, so that 624 * Stop all the traffic before cancelling the work, so that
630 * nobody will restart it by calling usb_serial_port_softint. 625 * nobody will restart it by calling usb_serial_port_softint.
@@ -935,6 +930,11 @@ int usb_serial_probe(struct usb_interface *interface,
935 mutex_init(&port->mutex); 930 mutex_init(&port->mutex);
936 INIT_WORK(&port->work, usb_serial_port_work); 931 INIT_WORK(&port->work, usb_serial_port_work);
937 serial->port[i] = port; 932 serial->port[i] = port;
933 port->dev.parent = &interface->dev;
934 port->dev.driver = NULL;
935 port->dev.bus = &usb_serial_bus_type;
936 port->dev.release = &port_release;
937 device_initialize(&port->dev);
938 } 938 }
939 939
940 /* set up the endpoint information */ 940 /* set up the endpoint information */
@@ -1077,15 +1077,10 @@ int usb_serial_probe(struct usb_interface *interface,
1077 /* register all of the individual ports with the driver core */ 1077 /* register all of the individual ports with the driver core */
1078 for (i = 0; i < num_ports; ++i) { 1078 for (i = 0; i < num_ports; ++i) {
1079 port = serial->port[i]; 1079 port = serial->port[i];
1080 port->dev.parent = &interface->dev;
1081 port->dev.driver = NULL;
1082 port->dev.bus = &usb_serial_bus_type;
1083 port->dev.release = &port_release;
1084
1085 dev_set_name(&port->dev, "ttyUSB%d", port->number); 1080 dev_set_name(&port->dev, "ttyUSB%d", port->number);
1086 dbg ("%s - registering %s", __func__, dev_name(&port->dev)); 1081 dbg ("%s - registering %s", __func__, dev_name(&port->dev));
1087 port->dev_state = PORT_REGISTERING; 1082 port->dev_state = PORT_REGISTERING;
1088 retval = device_register(&port->dev); 1083 retval = device_add(&port->dev);
1089 if (retval) { 1084 if (retval) {
1090 dev_err(&port->dev, "Error registering port device, " 1085 dev_err(&port->dev, "Error registering port device, "
1091 "continuing\n"); 1086 "continuing\n");
@@ -1103,39 +1098,7 @@ exit:
1103 return 0; 1098 return 0;
1104 1099
1105probe_error: 1100probe_error:
1106 for (i = 0; i < num_bulk_in; ++i) { 1101 usb_serial_put(serial);
1107 port = serial->port[i];
1108 if (!port)
1109 continue;
1110 usb_free_urb(port->read_urb);
1111 kfree(port->bulk_in_buffer);
1112 }
1113 for (i = 0; i < num_bulk_out; ++i) {
1114 port = serial->port[i];
1115 if (!port)
1116 continue;
1117 usb_free_urb(port->write_urb);
1118 kfree(port->bulk_out_buffer);
1119 }
1120 for (i = 0; i < num_interrupt_in; ++i) {
1121 port = serial->port[i];
1122 if (!port)
1123 continue;
1124 usb_free_urb(port->interrupt_in_urb);
1125 kfree(port->interrupt_in_buffer);
1126 }
1127 for (i = 0; i < num_interrupt_out; ++i) {
1128 port = serial->port[i];
1129 if (!port)
1130 continue;
1131 usb_free_urb(port->interrupt_out_urb);
1132 kfree(port->interrupt_out_buffer);
1133 }
1134
1135 /* free up any memory that we allocated */
1136 for (i = 0; i < serial->num_port_pointers; ++i)
1137 kfree(serial->port[i]);
1138 kfree(serial);
1139 return -EIO; 1102 return -EIO;
1140} 1103}
1141EXPORT_SYMBOL_GPL(usb_serial_probe); 1104EXPORT_SYMBOL_GPL(usb_serial_probe);
@@ -1161,10 +1124,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
1161 if (port) { 1124 if (port) {
1162 struct tty_struct *tty = tty_port_tty_get(&port->port); 1125 struct tty_struct *tty = tty_port_tty_get(&port->port);
1163 if (tty) { 1126 if (tty) {
1164 /* The hangup will occur asynchronously but 1127 tty_vhangup(tty);
1165 the object refcounts will sort out all the
1166 cleanup */
1167 tty_hangup(tty);
1168 tty_kref_put(tty); 1128 tty_kref_put(tty);
1169 } 1129 }
1170 kill_traffic(port); 1130 kill_traffic(port);
@@ -1189,8 +1149,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
1189 } 1149 }
1190 serial->type->disconnect(serial); 1150 serial->type->disconnect(serial);
1191 1151
1192 /* let the last holder of this object 1152 /* let the last holder of this object cause it to be cleaned up */
1193 * cause it to be cleaned up */
1194 usb_serial_put(serial); 1153 usb_serial_put(serial);
1195 dev_info(dev, "device disconnected\n"); 1154 dev_info(dev, "device disconnected\n");
1196} 1155}
@@ -1246,6 +1205,8 @@ static const struct tty_operations serial_ops = {
1246 .chars_in_buffer = serial_chars_in_buffer, 1205 .chars_in_buffer = serial_chars_in_buffer,
1247 .tiocmget = serial_tiocmget, 1206 .tiocmget = serial_tiocmget,
1248 .tiocmset = serial_tiocmset, 1207 .tiocmset = serial_tiocmset,
1208 .shutdown = serial_release,
1209 .install = serial_install,
1249 .proc_fops = &serial_proc_fops, 1210 .proc_fops = &serial_proc_fops,
1250}; 1211};
1251 1212
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 614800972dc3..7b5bfc4edd3d 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -43,11 +43,10 @@ static struct usb_driver debug_driver = {
43 .no_dynamic_id = 1, 43 .no_dynamic_id = 1,
44}; 44};
45 45
46static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port, 46static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port)
47 struct file *filp)
48{ 47{
49 port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; 48 port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
50 return usb_serial_generic_open(tty, port, filp); 49 return usb_serial_generic_open(tty, port);
51} 50}
52 51
53/* This HW really does not support a serial break, so one will be 52/* This HW really does not support a serial break, so one will be
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index f5d0f64dcc52..1aa5d20a5d99 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -36,8 +36,7 @@
36#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" 36#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
37 37
38/* function prototypes for a handspring visor */ 38/* function prototypes for a handspring visor */
39static int visor_open(struct tty_struct *tty, struct usb_serial_port *port, 39static int visor_open(struct tty_struct *tty, struct usb_serial_port *port);
40 struct file *filp);
41static void visor_close(struct usb_serial_port *port); 40static void visor_close(struct usb_serial_port *port);
42static int visor_write(struct tty_struct *tty, struct usb_serial_port *port, 41static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
43 const unsigned char *buf, int count); 42 const unsigned char *buf, int count);
@@ -273,8 +272,7 @@ static int stats;
273/****************************************************************************** 272/******************************************************************************
274 * Handspring Visor specific driver functions 273 * Handspring Visor specific driver functions
275 ******************************************************************************/ 274 ******************************************************************************/
276static int visor_open(struct tty_struct *tty, struct usb_serial_port *port, 275static int visor_open(struct tty_struct *tty, struct usb_serial_port *port)
277 struct file *filp)
278{ 276{
279 struct usb_serial *serial = port->serial; 277 struct usb_serial *serial = port->serial;
280 struct visor_private *priv = usb_get_serial_port_data(port); 278 struct visor_private *priv = usb_get_serial_port_data(port);
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 8d126dd7a02e..62424eec33ec 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -146,7 +146,7 @@ static int whiteheat_firmware_attach(struct usb_serial *serial);
146static int whiteheat_attach(struct usb_serial *serial); 146static int whiteheat_attach(struct usb_serial *serial);
147static void whiteheat_release(struct usb_serial *serial); 147static void whiteheat_release(struct usb_serial *serial);
148static int whiteheat_open(struct tty_struct *tty, 148static int whiteheat_open(struct tty_struct *tty,
149 struct usb_serial_port *port, struct file *filp); 149 struct usb_serial_port *port);
150static void whiteheat_close(struct usb_serial_port *port); 150static void whiteheat_close(struct usb_serial_port *port);
151static int whiteheat_write(struct tty_struct *tty, 151static int whiteheat_write(struct tty_struct *tty,
152 struct usb_serial_port *port, 152 struct usb_serial_port *port,
@@ -259,7 +259,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
259 __u8 *data, __u8 datasize); 259 __u8 *data, __u8 datasize);
260static int firm_open(struct usb_serial_port *port); 260static int firm_open(struct usb_serial_port *port);
261static int firm_close(struct usb_serial_port *port); 261static int firm_close(struct usb_serial_port *port);
262static int firm_setup_port(struct tty_struct *tty); 262static void firm_setup_port(struct tty_struct *tty);
263static int firm_set_rts(struct usb_serial_port *port, __u8 onoff); 263static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
264static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff); 264static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
265static int firm_set_break(struct usb_serial_port *port, __u8 onoff); 265static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
@@ -659,8 +659,7 @@ static void whiteheat_release(struct usb_serial *serial)
659 return; 659 return;
660} 660}
661 661
662static int whiteheat_open(struct tty_struct *tty, 662static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port)
663 struct usb_serial_port *port, struct file *filp)
664{ 663{
665 int retval = 0; 664 int retval = 0;
666 665
@@ -1211,7 +1210,7 @@ static int firm_close(struct usb_serial_port *port)
1211} 1210}
1212 1211
1213 1212
1214static int firm_setup_port(struct tty_struct *tty) 1213static void firm_setup_port(struct tty_struct *tty)
1215{ 1214{
1216 struct usb_serial_port *port = tty->driver_data; 1215 struct usb_serial_port *port = tty->driver_data;
1217 struct whiteheat_port_settings port_settings; 1216 struct whiteheat_port_settings port_settings;
@@ -1286,7 +1285,7 @@ static int firm_setup_port(struct tty_struct *tty)
1286 port_settings.lloop = 0; 1285 port_settings.lloop = 0;
1287 1286
1288 /* now send the message to the device */ 1287 /* now send the message to the device */
1289 return firm_send_command(port, WHITEHEAT_SETUP_PORT, 1288 firm_send_command(port, WHITEHEAT_SETUP_PORT,
1290 (__u8 *)&port_settings, sizeof(port_settings)); 1289 (__u8 *)&port_settings, sizeof(port_settings));
1291} 1290}
1292 1291