From 95da310e66ee8090119596c70ca8432e57f9a97f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 22 Jul 2008 11:09:07 +0100 Subject: usb_serial: API all change USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- drivers/usb/serial/ipw.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers/usb/serial/ipw.c') diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index bc85ca5c1c37..a89ebfe9e915 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -179,7 +179,7 @@ static void ipw_read_bulk_callback(struct urb *urb) usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); - tty = port->tty; + tty = port->port.tty; if (tty && urb->actual_length) { tty_buffer_request_room(tty, urb->actual_length); tty_insert_flip_string(tty, data, urb->actual_length); @@ -199,7 +199,8 @@ static void ipw_read_bulk_callback(struct urb *urb) return; } -static int ipw_open(struct usb_serial_port *port, struct file *filp) +static int ipw_open(struct tty_struct *tty, + struct usb_serial_port *port, struct file *filp) { struct usb_device *dev = port->serial->dev; u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; @@ -212,8 +213,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) if (!buf_flow_init) return -ENOMEM; - if (port->tty) - port->tty->low_latency = 1; + if (tty) + tty->low_latency = 1; /* --1: Tell the modem to initialize (we think) From sniffs this is always the * first thing that gets sent to the modem during opening of the device */ @@ -301,7 +302,8 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp) return 0; } -static void ipw_close(struct usb_serial_port *port, struct file * filp) +static void ipw_close(struct tty_struct *tty, + struct usb_serial_port *port, struct file * filp) { struct usb_device *dev = port->serial->dev; int result; @@ -384,7 +386,8 @@ static void ipw_write_bulk_callback(struct urb *urb) usb_serial_port_softint(port); } -static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count) +static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port, + const unsigned char *buf, int count) { struct usb_device *dev = port->serial->dev; int ret; -- cgit v1.2.1