summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2009-09-01 11:39:51 -0400
committerLive-CD User <linux@linux.site>2009-09-19 13:13:41 -0700
commitff8324df1187b7280e507c976777df76c73a1ef1 (patch)
treea4b16a4a422f3fca19eb38eb1b46056a1c50392d /drivers/usb/serial/usb-serial.c
parent74556123e034c8337b69a3ebac2f3a5fc0a97032 (diff)
downloadblackbird-op-linux-ff8324df1187b7280e507c976777df76c73a1ef1.tar.gz
blackbird-op-linux-ff8324df1187b7280e507c976777df76c73a1ef1.zip
usb-serial: add missing tests and debug lines
This patch (as1290) adds some missing tests. serial_down() isn't supposed to do anything if the hardware hasn't been initialized, and serial_close() isn't supposed to do anything if the tty has gotten a hangup (because serial_hangup() takes care of shutting down the hardware). The patch also updates and adds a few debugging lines. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-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)
struct usb_serial_port *port;
int retval = -ENODEV;
+ dbg("%s", __func__);
+
serial = usb_serial_get_by_index(idx);
if (!serial)
return retval;
@@ -250,11 +252,11 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
int retval = 0;
int first = 0;
- dbg("%s", __func__);
-
port = tty->driver_data;
serial = port->serial;
+ dbg("%s - port %d", __func__, port->number);
+
if (mutex_lock_interruptible(&port->mutex))
return -ERESTARTSYS;
@@ -315,6 +317,12 @@ static void serial_down(struct usb_serial_port *port)
if (port->console)
return;
+ /* Don't call the close method if the hardware hasn't been
+ * initialized.
+ */
+ if (!test_and_clear_bit(ASYNCB_INITIALIZED, &port->port.flags))
+ return;
+
mutex_lock(&port->mutex);
serial = port->serial;
owner = serial->type->driver.owner;
@@ -328,10 +336,11 @@ static void serial_down(struct usb_serial_port *port)
static void serial_hangup(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
+
+ dbg("%s - port %d", __func__, port->number);
+
serial_down(port);
tty_port_hangup(&port->port);
- /* We must not free port yet - the USB serial layer depends on it's
- continued existence */
}
static 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)
dbg("%s - port %d", __func__, port->number);
+ if (tty_hung_up_p(filp))
+ return;
if (tty_port_close_start(&port->port, tty, filp) == 0)
return;
serial_down(port);
@@ -368,6 +379,8 @@ static void serial_release(struct tty_struct *tty)
if (port->console)
return;
+ dbg("%s - port %d", __func__, port->number);
+
/* Standard shutdown processing */
tty_shutdown(tty);
OpenPOWER on IntegriCloud