diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:09:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:22 -0400 |
commit | 95da310e66ee8090119596c70ca8432e57f9a97f (patch) | |
tree | 7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /drivers/usb/serial/safe_serial.c | |
parent | 1aa3692da57c773e5c76de55c5c4a953962d360e (diff) |
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>
Diffstat (limited to 'drivers/usb/serial/safe_serial.c')
-rw-r--r-- | drivers/usb/serial/safe_serial.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 94bddf06ea4f..f823e4dcea1e 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -229,8 +229,8 @@ static void safe_read_bulk_callback (struct urb *urb) | |||
229 | int actual_length = data[length - 2] >> 2; | 229 | int actual_length = data[length - 2] >> 2; |
230 | if (actual_length <= (length - 2)) { | 230 | if (actual_length <= (length - 2)) { |
231 | info ("%s - actual: %d", __func__, actual_length); | 231 | info ("%s - actual: %d", __func__, actual_length); |
232 | tty_insert_flip_string(port->tty, data, actual_length); | 232 | tty_insert_flip_string(port->port.tty, data, actual_length); |
233 | tty_flip_buffer_push (port->tty); | 233 | tty_flip_buffer_push (port->port.tty); |
234 | } else { | 234 | } else { |
235 | err ("%s - inconsistent lengths %d:%d", __func__, | 235 | err ("%s - inconsistent lengths %d:%d", __func__, |
236 | actual_length, length); | 236 | actual_length, length); |
@@ -239,8 +239,8 @@ static void safe_read_bulk_callback (struct urb *urb) | |||
239 | err ("%s - bad CRC %x", __func__, fcs); | 239 | err ("%s - bad CRC %x", __func__, fcs); |
240 | } | 240 | } |
241 | } else { | 241 | } else { |
242 | tty_insert_flip_string(port->tty, data, length); | 242 | tty_insert_flip_string(port->port.tty, data, length); |
243 | tty_flip_buffer_push (port->tty); | 243 | tty_flip_buffer_push (port->port.tty); |
244 | } | 244 | } |
245 | 245 | ||
246 | /* Continue trying to always read */ | 246 | /* Continue trying to always read */ |
@@ -255,7 +255,8 @@ static void safe_read_bulk_callback (struct urb *urb) | |||
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | static int safe_write (struct usb_serial_port *port, const unsigned char *buf, int count) | 258 | static int safe_write(struct tty_struct *tty, struct usb_serial_port *port, |
259 | const unsigned char *buf, int count) | ||
259 | { | 260 | { |
260 | unsigned char *data; | 261 | unsigned char *data; |
261 | int result; | 262 | int result; |
@@ -349,8 +350,9 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i | |||
349 | return (count); | 350 | return (count); |
350 | } | 351 | } |
351 | 352 | ||
352 | static int safe_write_room (struct usb_serial_port *port) | 353 | static int safe_write_room(struct tty_struct *tty) |
353 | { | 354 | { |
355 | struct usb_serial_port *port = tty->driver_data; | ||
354 | int room = 0; /* Default: no room */ | 356 | int room = 0; /* Default: no room */ |
355 | unsigned long flags; | 357 | unsigned long flags; |
356 | 358 | ||