aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 4f7f9e3ae0a4..e7d4246027b2 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -214,7 +214,7 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
214 /* set up our port structure making the tty driver 214 /* set up our port structure making the tty driver
215 * remember our port object, and us it */ 215 * remember our port object, and us it */
216 tty->driver_data = port; 216 tty->driver_data = port;
217 port->port.tty = tty; 217 tty_port_tty_set(&port->port, tty);
218 218
219 if (port->port.count == 1) { 219 if (port->port.count == 1) {
220 220
@@ -246,7 +246,7 @@ bailout_module_put:
246bailout_mutex_unlock: 246bailout_mutex_unlock:
247 port->port.count = 0; 247 port->port.count = 0;
248 tty->driver_data = NULL; 248 tty->driver_data = NULL;
249 port->port.tty = NULL; 249 tty_port_tty_set(&port->port, NULL);
250 mutex_unlock(&port->mutex); 250 mutex_unlock(&port->mutex);
251bailout_kref_put: 251bailout_kref_put:
252 usb_serial_put(serial); 252 usb_serial_put(serial);
@@ -276,10 +276,11 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
276 port->serial->type->close(tty, port, filp); 276 port->serial->type->close(tty, port, filp);
277 277
278 if (port->port.count == (port->console? 1 : 0)) { 278 if (port->port.count == (port->console? 1 : 0)) {
279 if (port->port.tty) { 279 struct tty_struct *tty = tty_port_tty_get(&port->port);
280 if (port->port.tty->driver_data) 280 if (tty) {
281 port->port.tty->driver_data = NULL; 281 if (tty->driver_data)
282 port->port.tty = NULL; 282 tty->driver_data = NULL;
283 tty_port_tty_set(&port->port, NULL);
283 } 284 }
284 } 285 }
285 286
@@ -508,11 +509,12 @@ static void usb_serial_port_work(struct work_struct *work)
508 if (!port) 509 if (!port)
509 return; 510 return;
510 511
511 tty = port->port.tty; 512 tty = tty_port_tty_get(&port->port);
512 if (!tty) 513 if (!tty)
513 return; 514 return;
514 515
515 tty_wakeup(tty); 516 tty_wakeup(tty);
517 tty_kref_put(tty);
516} 518}
517 519
518static void port_release(struct device *dev) 520static void port_release(struct device *dev)
@@ -819,6 +821,7 @@ int usb_serial_probe(struct usb_interface *interface,
819 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); 821 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
820 if (!port) 822 if (!port)
821 goto probe_error; 823 goto probe_error;
824 tty_port_init(&port->port);
822 port->serial = serial; 825 port->serial = serial;
823 spin_lock_init(&port->lock); 826 spin_lock_init(&port->lock);
824 mutex_init(&port->mutex); 827 mutex_init(&port->mutex);
@@ -1040,8 +1043,11 @@ void usb_serial_disconnect(struct usb_interface *interface)
1040 for (i = 0; i < serial->num_ports; ++i) { 1043 for (i = 0; i < serial->num_ports; ++i) {
1041 port = serial->port[i]; 1044 port = serial->port[i];
1042 if (port) { 1045 if (port) {
1043 if (port->port.tty) 1046 struct tty_struct *tty = tty_port_tty_get(&port->port);
1044 tty_hangup(port->port.tty); 1047 if (tty) {
1048 tty_hangup(tty);
1049 tty_kref_put(tty);
1050 }
1045 kill_traffic(port); 1051 kill_traffic(port);
1046 } 1052 }
1047 } 1053 }