mirror of
https://github.com/torvalds/linux.git
synced 2024-12-20 01:52:13 +00:00
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>
This commit is contained in:
parent
74556123e0
commit
ff8324df11
@ -200,6 +200,8 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
|
|||||||
struct usb_serial_port *port;
|
struct usb_serial_port *port;
|
||||||
int retval = -ENODEV;
|
int retval = -ENODEV;
|
||||||
|
|
||||||
|
dbg("%s", __func__);
|
||||||
|
|
||||||
serial = usb_serial_get_by_index(idx);
|
serial = usb_serial_get_by_index(idx);
|
||||||
if (!serial)
|
if (!serial)
|
||||||
return retval;
|
return retval;
|
||||||
@ -250,11 +252,11 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
|
|||||||
int retval = 0;
|
int retval = 0;
|
||||||
int first = 0;
|
int first = 0;
|
||||||
|
|
||||||
dbg("%s", __func__);
|
|
||||||
|
|
||||||
port = tty->driver_data;
|
port = tty->driver_data;
|
||||||
serial = port->serial;
|
serial = port->serial;
|
||||||
|
|
||||||
|
dbg("%s - port %d", __func__, port->number);
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&port->mutex))
|
if (mutex_lock_interruptible(&port->mutex))
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
|
|
||||||
@ -315,6 +317,12 @@ static void serial_down(struct usb_serial_port *port)
|
|||||||
if (port->console)
|
if (port->console)
|
||||||
return;
|
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);
|
mutex_lock(&port->mutex);
|
||||||
serial = port->serial;
|
serial = port->serial;
|
||||||
owner = serial->type->driver.owner;
|
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)
|
static void serial_hangup(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct usb_serial_port *port = tty->driver_data;
|
struct usb_serial_port *port = tty->driver_data;
|
||||||
|
|
||||||
|
dbg("%s - port %d", __func__, port->number);
|
||||||
|
|
||||||
serial_down(port);
|
serial_down(port);
|
||||||
tty_port_hangup(&port->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)
|
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);
|
dbg("%s - port %d", __func__, port->number);
|
||||||
|
|
||||||
|
if (tty_hung_up_p(filp))
|
||||||
|
return;
|
||||||
if (tty_port_close_start(&port->port, tty, filp) == 0)
|
if (tty_port_close_start(&port->port, tty, filp) == 0)
|
||||||
return;
|
return;
|
||||||
serial_down(port);
|
serial_down(port);
|
||||||
@ -368,6 +379,8 @@ static void serial_release(struct tty_struct *tty)
|
|||||||
if (port->console)
|
if (port->console)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
dbg("%s - port %d", __func__, port->number);
|
||||||
|
|
||||||
/* Standard shutdown processing */
|
/* Standard shutdown processing */
|
||||||
tty_shutdown(tty);
|
tty_shutdown(tty);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user