tty: usb-serial krefs

Use kref in the USB serial drivers so that we don't free tty structures
from under the URB receive handlers as has historically been the case if
you were unlucky. This also gives us a framework for general tty drivers to
use tty_port objects and refcount.

Contains two err->dev_err changes merged together to fix clashes in the
-next tree.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox
2008-10-13 10:39:46 +01:00
committed by Linus Torvalds
parent 95f9bfc6b7
commit 4a90f09b20
37 changed files with 313 additions and 208 deletions

View File

@@ -217,6 +217,7 @@ static void safe_read_bulk_callback(struct urb *urb)
struct usb_serial_port *port = urb->context;
unsigned char *data = urb->transfer_buffer;
unsigned char length = urb->actual_length;
struct tty_struct *tty;
int result;
int status = urb->status;
@@ -242,6 +243,7 @@ static void safe_read_bulk_callback(struct urb *urb)
printk("\n");
}
#endif
tty = tty_port_tty_get(&port->port);
if (safe) {
__u16 fcs;
fcs = fcs_compute10(data, length, CRC10_INITFCS);
@@ -250,9 +252,9 @@ static void safe_read_bulk_callback(struct urb *urb)
if (actual_length <= (length - 2)) {
info("%s - actual: %d", __func__,
actual_length);
tty_insert_flip_string(port->port.tty,
tty_insert_flip_string(tty,
data, actual_length);
tty_flip_buffer_push(port->port.tty);
tty_flip_buffer_push(tty);
} else {
err("%s - inconsistent lengths %d:%d",
__func__, actual_length, length);
@@ -261,9 +263,10 @@ static void safe_read_bulk_callback(struct urb *urb)
err("%s - bad CRC %x", __func__, fcs);
}
} else {
tty_insert_flip_string(port->port.tty, data, length);
tty_flip_buffer_push(port->port.tty);
tty_insert_flip_string(tty, data, length);
tty_flip_buffer_push(tty);
}
tty_kref_put(tty);
/* Continue trying to always read */
usb_fill_bulk_urb(urb, port->serial->dev,