aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/quatech2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/quatech2.c')
-rw-r--r--drivers/usb/serial/quatech2.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index d152be97d041..6850745808c3 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -609,7 +609,6 @@ void qt2_process_read_urb(struct urb *urb)
609 struct qt2_serial_private *serial_priv; 609 struct qt2_serial_private *serial_priv;
610 struct usb_serial_port *port; 610 struct usb_serial_port *port;
611 struct qt2_port_private *port_priv; 611 struct qt2_port_private *port_priv;
612 struct tty_struct *tty;
613 bool escapeflag; 612 bool escapeflag;
614 unsigned char *ch; 613 unsigned char *ch;
615 int i; 614 int i;
@@ -620,15 +619,11 @@ void qt2_process_read_urb(struct urb *urb)
620 return; 619 return;
621 620
622 ch = urb->transfer_buffer; 621 ch = urb->transfer_buffer;
623 tty = NULL;
624 serial = urb->context; 622 serial = urb->context;
625 serial_priv = usb_get_serial_data(serial); 623 serial_priv = usb_get_serial_data(serial);
626 port = serial->port[serial_priv->current_port]; 624 port = serial->port[serial_priv->current_port];
627 port_priv = usb_get_serial_port_data(port); 625 port_priv = usb_get_serial_port_data(port);
628 626
629 if (port_priv->is_open)
630 tty = tty_port_tty_get(&port->port);
631
632 for (i = 0; i < urb->actual_length; i++) { 627 for (i = 0; i < urb->actual_length; i++) {
633 ch = (unsigned char *)urb->transfer_buffer + i; 628 ch = (unsigned char *)urb->transfer_buffer + i;
634 if ((i <= (len - 3)) && 629 if ((i <= (len - 3)) &&
@@ -666,10 +661,7 @@ void qt2_process_read_urb(struct urb *urb)
666 __func__); 661 __func__);
667 break; 662 break;
668 } 663 }
669 if (tty) { 664 tty_flip_buffer_push(&port->port);
670 tty_flip_buffer_push(tty);
671 tty_kref_put(tty);
672 }
673 665
674 newport = *(ch + 3); 666 newport = *(ch + 3);
675 667
@@ -683,10 +675,6 @@ void qt2_process_read_urb(struct urb *urb)
683 serial_priv->current_port = newport; 675 serial_priv->current_port = newport;
684 port = serial->port[serial_priv->current_port]; 676 port = serial->port[serial_priv->current_port];
685 port_priv = usb_get_serial_port_data(port); 677 port_priv = usb_get_serial_port_data(port);
686 if (port_priv->is_open)
687 tty = tty_port_tty_get(&port->port);
688 else
689 tty = NULL;
690 i += 3; 678 i += 3;
691 escapeflag = true; 679 escapeflag = true;
692 break; 680 break;
@@ -697,8 +685,8 @@ void qt2_process_read_urb(struct urb *urb)
697 escapeflag = true; 685 escapeflag = true;
698 break; 686 break;
699 case QT2_CONTROL_ESCAPE: 687 case QT2_CONTROL_ESCAPE:
700 tty_buffer_request_room(tty, 2); 688 tty_buffer_request_room(&port->port, 2);
701 tty_insert_flip_string(tty, ch, 2); 689 tty_insert_flip_string(&port->port, ch, 2);
702 i += 2; 690 i += 2;
703 escapeflag = true; 691 escapeflag = true;
704 break; 692 break;
@@ -712,16 +700,11 @@ void qt2_process_read_urb(struct urb *urb)
712 continue; 700 continue;
713 } 701 }
714 702
715 if (tty) { 703 tty_buffer_request_room(&port->port, 1);
716 tty_buffer_request_room(tty, 1); 704 tty_insert_flip_string(&port->port, ch, 1);
717 tty_insert_flip_string(tty, ch, 1);
718 }
719 } 705 }
720 706
721 if (tty) { 707 tty_flip_buffer_push(&port->port);
722 tty_flip_buffer_push(tty);
723 tty_kref_put(tty);
724 }
725} 708}
726 709
727static void qt2_write_bulk_callback(struct urb *urb) 710static void qt2_write_bulk_callback(struct urb *urb)