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 <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox
2008-07-22 11:09:07 +01:00
committed by Linus Torvalds
parent 1aa3692da5
commit 95da310e66
42 changed files with 1819 additions and 1719 deletions

View File

@@ -229,8 +229,8 @@ static void safe_read_bulk_callback (struct urb *urb)
int actual_length = data[length - 2] >> 2;
if (actual_length <= (length - 2)) {
info ("%s - actual: %d", __func__, actual_length);
tty_insert_flip_string(port->tty, data, actual_length);
tty_flip_buffer_push (port->tty);
tty_insert_flip_string(port->port.tty, data, actual_length);
tty_flip_buffer_push (port->port.tty);
} else {
err ("%s - inconsistent lengths %d:%d", __func__,
actual_length, length);
@@ -239,8 +239,8 @@ static void safe_read_bulk_callback (struct urb *urb)
err ("%s - bad CRC %x", __func__, fcs);
}
} else {
tty_insert_flip_string(port->tty, data, length);
tty_flip_buffer_push (port->tty);
tty_insert_flip_string(port->port.tty, data, length);
tty_flip_buffer_push (port->port.tty);
}
/* Continue trying to always read */
@@ -255,7 +255,8 @@ static void safe_read_bulk_callback (struct urb *urb)
}
}
static int safe_write (struct usb_serial_port *port, const unsigned char *buf, int count)
static int safe_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count)
{
unsigned char *data;
int result;
@@ -349,8 +350,9 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i
return (count);
}
static int safe_write_room (struct usb_serial_port *port)
static int safe_write_room(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
int room = 0; /* Default: no room */
unsigned long flags;