summaryrefslogtreecommitdiff
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.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a84216464ca0..c6f69c0f0eb4 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -21,6 +21,7 @@
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
+#include <linux/smp_lock.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
@@ -213,14 +214,13 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
goto bailout_port_put;
}
- ++port->port.count;
-
/* set up our port structure making the tty driver
* remember our port object, and us it */
tty->driver_data = port;
tty_port_tty_set(&port->port, tty);
- if (port->port.count == 1) {
+ /* If the console is attached, the device is already open */
+ if (!port->port.count && !port->console) {
/* lock this module before we call it
* this may fail, which means we must bail out,
@@ -238,12 +238,16 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
if (retval)
goto bailout_module_put;
+ ++port->port.count;
+
/* only call the device specific open if this
* is the first time the port is opened */
retval = serial->type->open(tty, port, filp);
if (retval)
goto bailout_interface_put;
mutex_unlock(&serial->disc_mutex);
+ } else {
+ ++port->port.count;
}
mutex_unlock(&port->mutex);
/* Now do the correct tty layer semantics */