aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/usb-serial.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 28125de7d902..9a3258046c8c 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -200,6 +200,8 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
200 struct usb_serial_port *port; 200 struct usb_serial_port *port;
201 int retval = -ENODEV; 201 int retval = -ENODEV;
202 202
203 dbg("%s", __func__);
204
203 serial = usb_serial_get_by_index(idx); 205 serial = usb_serial_get_by_index(idx);
204 if (!serial) 206 if (!serial)
205 return retval; 207 return retval;
@@ -250,11 +252,11 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
250 int retval = 0; 252 int retval = 0;
251 int first = 0; 253 int first = 0;
252 254
253 dbg("%s", __func__);
254
255 port = tty->driver_data; 255 port = tty->driver_data;
256 serial = port->serial; 256 serial = port->serial;
257 257
258 dbg("%s - port %d", __func__, port->number);
259
258 if (mutex_lock_interruptible(&port->mutex)) 260 if (mutex_lock_interruptible(&port->mutex))
259 return -ERESTARTSYS; 261 return -ERESTARTSYS;
260 262
@@ -315,6 +317,12 @@ static void serial_down(struct usb_serial_port *port)
315 if (port->console) 317 if (port->console)
316 return; 318 return;
317 319
320 /* Don't call the close method if the hardware hasn't been
321 * initialized.
322 */
323 if (!test_and_clear_bit(ASYNCB_INITIALIZED, &port->port.flags))
324 return;
325
318 mutex_lock(&port->mutex); 326 mutex_lock(&port->mutex);
319 serial = port->serial; 327 serial = port->serial;
320 owner = serial->type->driver.owner; 328 owner = serial->type->driver.owner;
@@ -328,10 +336,11 @@ static void serial_down(struct usb_serial_port *port)
328static void serial_hangup(struct tty_struct *tty) 336static void serial_hangup(struct tty_struct *tty)
329{ 337{
330 struct usb_serial_port *port = tty->driver_data; 338 struct usb_serial_port *port = tty->driver_data;
339
340 dbg("%s - port %d", __func__, port->number);
341
331 serial_down(port); 342 serial_down(port);
332 tty_port_hangup(&port->port); 343 tty_port_hangup(&port->port);
333 /* We must not free port yet - the USB serial layer depends on it's
334 continued existence */
335} 344}
336 345
337static void serial_close(struct tty_struct *tty, struct file *filp) 346static void serial_close(struct tty_struct *tty, struct file *filp)
@@ -340,6 +349,8 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
340 349
341 dbg("%s - port %d", __func__, port->number); 350 dbg("%s - port %d", __func__, port->number);
342 351
352 if (tty_hung_up_p(filp))
353 return;
343 if (tty_port_close_start(&port->port, tty, filp) == 0) 354 if (tty_port_close_start(&port->port, tty, filp) == 0)
344 return; 355 return;
345 serial_down(port); 356 serial_down(port);
@@ -368,6 +379,8 @@ static void serial_release(struct tty_struct *tty)
368 if (port->console) 379 if (port->console)
369 return; 380 return;
370 381
382 dbg("%s - port %d", __func__, port->number);
383
371 /* Standard shutdown processing */ 384 /* Standard shutdown processing */
372 tty_shutdown(tty); 385 tty_shutdown(tty);
373 386