aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/visor.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:39:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:41 -0400
commit4a90f09b20f4622dcbff1f0e1e6bae1704f8ad8c (patch)
tree9b275f88f2705cb10121d5982741aef3a088a7c8 /drivers/usb/serial/visor.c
parent95f9bfc6b76e862265a2d70ae061eec18fe14140 (diff)
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>
Diffstat (limited to 'drivers/usb/serial/visor.c')
-rw-r--r--drivers/usb/serial/visor.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index cf8924f9a2cc..a6d1c75a1c89 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -499,7 +499,7 @@ static void visor_read_bulk_callback(struct urb *urb)
499 int status = urb->status; 499 int status = urb->status;
500 struct tty_struct *tty; 500 struct tty_struct *tty;
501 int result; 501 int result;
502 int available_room; 502 int available_room = 0;
503 503
504 dbg("%s - port %d", __func__, port->number); 504 dbg("%s - port %d", __func__, port->number);
505 505
@@ -512,13 +512,17 @@ static void visor_read_bulk_callback(struct urb *urb)
512 usb_serial_debug_data(debug, &port->dev, __func__, 512 usb_serial_debug_data(debug, &port->dev, __func__,
513 urb->actual_length, data); 513 urb->actual_length, data);
514 514
515 tty = port->port.tty; 515 if (urb->actual_length) {
516 if (tty && urb->actual_length) { 516 tty = tty_port_tty_get(&port->port);
517 available_room = tty_buffer_request_room(tty, 517 if (tty) {
518 available_room = tty_buffer_request_room(tty,
518 urb->actual_length); 519 urb->actual_length);
519 if (available_room) { 520 if (available_room) {
520 tty_insert_flip_string(tty, data, available_room); 521 tty_insert_flip_string(tty, data,
521 tty_flip_buffer_push(tty); 522 available_room);
523 tty_flip_buffer_push(tty);
524 }
525 tty_kref_put(tty);
522 } 526 }
523 spin_lock(&priv->lock); 527 spin_lock(&priv->lock);
524 priv->bytes_in += available_room; 528 priv->bytes_in += available_room;