diff options
author | Oliver Neukum <oneukum@suse.de> | 2007-05-07 04:37:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:29:51 -0400 |
commit | b308e74d9c708ee2a9af14fbe235e0a41216f4ed (patch) | |
tree | 07129191b1cd553f35c4628cc710e9d871d061f5 /drivers/usb/serial/visor.c | |
parent | a5262dcfda9163ca1f8a64349a6f7ba640ac1dc2 (diff) |
USB: visor driver adapted to new tty buffering
the new tty buffering code allows usb drivers to stop private buffering.
In fact we must do so to allow flushing to work correctly. This does so
for the visor driver.
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/visor.c')
-rw-r--r-- | drivers/usb/serial/visor.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index ffbe601cde2a..ca826b92f6e6 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -273,7 +273,8 @@ struct visor_private { | |||
273 | int bytes_in; | 273 | int bytes_in; |
274 | int bytes_out; | 274 | int bytes_out; |
275 | int outstanding_urbs; | 275 | int outstanding_urbs; |
276 | int throttled; | 276 | unsigned char throttled; |
277 | unsigned char actually_throttled; | ||
277 | }; | 278 | }; |
278 | 279 | ||
279 | /* number of outstanding urbs to prevent userspace DoS from happening */ | 280 | /* number of outstanding urbs to prevent userspace DoS from happening */ |
@@ -509,9 +510,8 @@ static void visor_read_bulk_callback (struct urb *urb) | |||
509 | struct visor_private *priv = usb_get_serial_port_data(port); | 510 | struct visor_private *priv = usb_get_serial_port_data(port); |
510 | unsigned char *data = urb->transfer_buffer; | 511 | unsigned char *data = urb->transfer_buffer; |
511 | struct tty_struct *tty; | 512 | struct tty_struct *tty; |
512 | unsigned long flags; | ||
513 | int throttled; | ||
514 | int result; | 513 | int result; |
514 | int available_room; | ||
515 | 515 | ||
516 | dbg("%s - port %d", __FUNCTION__, port->number); | 516 | dbg("%s - port %d", __FUNCTION__, port->number); |
517 | 517 | ||
@@ -524,17 +524,20 @@ static void visor_read_bulk_callback (struct urb *urb) | |||
524 | 524 | ||
525 | tty = port->tty; | 525 | tty = port->tty; |
526 | if (tty && urb->actual_length) { | 526 | if (tty && urb->actual_length) { |
527 | tty_buffer_request_room(tty, urb->actual_length); | 527 | available_room = tty_buffer_request_room(tty, urb->actual_length); |
528 | tty_insert_flip_string(tty, data, urb->actual_length); | 528 | if (available_room) { |
529 | tty_flip_buffer_push(tty); | 529 | tty_insert_flip_string(tty, data, available_room); |
530 | tty_flip_buffer_push(tty); | ||
531 | } | ||
532 | spin_lock(&priv->lock); | ||
533 | priv->bytes_in += available_room; | ||
534 | |||
535 | } else { | ||
536 | spin_lock(&priv->lock); | ||
530 | } | 537 | } |
531 | spin_lock_irqsave(&priv->lock, flags); | ||
532 | priv->bytes_in += urb->actual_length; | ||
533 | throttled = priv->throttled; | ||
534 | spin_unlock_irqrestore(&priv->lock, flags); | ||
535 | 538 | ||
536 | /* Continue trying to always read if we should */ | 539 | /* Continue trying to always read if we should */ |
537 | if (!throttled) { | 540 | if (!priv->throttled) { |
538 | usb_fill_bulk_urb (port->read_urb, port->serial->dev, | 541 | usb_fill_bulk_urb (port->read_urb, port->serial->dev, |
539 | usb_rcvbulkpipe(port->serial->dev, | 542 | usb_rcvbulkpipe(port->serial->dev, |
540 | port->bulk_in_endpointAddress), | 543 | port->bulk_in_endpointAddress), |
@@ -544,8 +547,10 @@ static void visor_read_bulk_callback (struct urb *urb) | |||
544 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 547 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
545 | if (result) | 548 | if (result) |
546 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); | 549 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); |
550 | } else { | ||
551 | priv->actually_throttled = 1; | ||
547 | } | 552 | } |
548 | return; | 553 | spin_unlock(&priv->lock); |
549 | } | 554 | } |
550 | 555 | ||
551 | static void visor_read_int_callback (struct urb *urb) | 556 | static void visor_read_int_callback (struct urb *urb) |
@@ -608,6 +613,7 @@ static void visor_unthrottle (struct usb_serial_port *port) | |||
608 | dbg("%s - port %d", __FUNCTION__, port->number); | 613 | dbg("%s - port %d", __FUNCTION__, port->number); |
609 | spin_lock_irqsave(&priv->lock, flags); | 614 | spin_lock_irqsave(&priv->lock, flags); |
610 | priv->throttled = 0; | 615 | priv->throttled = 0; |
616 | priv->actually_throttled = 0; | ||
611 | spin_unlock_irqrestore(&priv->lock, flags); | 617 | spin_unlock_irqrestore(&priv->lock, flags); |
612 | 618 | ||
613 | port->read_urb->dev = port->serial->dev; | 619 | port->read_urb->dev = port->serial->dev; |