quatech2.c (05c7cd39907184328f48d3e7899f9cdd653ad336) quatech2.c (2e124b4a390ca85325fae75764bef92f0547fa25)
1/*
2 * usb-serial driver for Quatech USB 2 devices
3 *
4 * Copyright (C) 2012 Bill Pemberton (wfp5p@virginia.edu)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.

--- 595 unchanged lines hidden (view full) ---

604}
605
606void qt2_process_read_urb(struct urb *urb)
607{
608 struct usb_serial *serial;
609 struct qt2_serial_private *serial_priv;
610 struct usb_serial_port *port;
611 struct qt2_port_private *port_priv;
1/*
2 * usb-serial driver for Quatech USB 2 devices
3 *
4 * Copyright (C) 2012 Bill Pemberton (wfp5p@virginia.edu)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.

--- 595 unchanged lines hidden (view full) ---

604}
605
606void qt2_process_read_urb(struct urb *urb)
607{
608 struct usb_serial *serial;
609 struct qt2_serial_private *serial_priv;
610 struct usb_serial_port *port;
611 struct qt2_port_private *port_priv;
612 struct tty_struct *tty;
613 bool escapeflag;
614 unsigned char *ch;
615 int i;
616 unsigned char newport;
617 int len = urb->actual_length;
618
619 if (!len)
620 return;
621
622 ch = urb->transfer_buffer;
612 bool escapeflag;
613 unsigned char *ch;
614 int i;
615 unsigned char newport;
616 int len = urb->actual_length;
617
618 if (!len)
619 return;
620
621 ch = urb->transfer_buffer;
623 tty = NULL;
624 serial = urb->context;
625 serial_priv = usb_get_serial_data(serial);
626 port = serial->port[serial_priv->current_port];
627 port_priv = usb_get_serial_port_data(port);
628
622 serial = urb->context;
623 serial_priv = usb_get_serial_data(serial);
624 port = serial->port[serial_priv->current_port];
625 port_priv = usb_get_serial_port_data(port);
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++) {
633 ch = (unsigned char *)urb->transfer_buffer + i;
634 if ((i <= (len - 3)) &&
635 (*ch == QT2_CONTROL_BYTE) &&
636 (*(ch + 1) == QT2_CONTROL_BYTE)) {
637 escapeflag = false;
638 switch (*(ch + 2)) {
639 case QT2_LINE_STATUS:

--- 21 unchanged lines hidden (view full) ---

661 break;
662 case QT2_CHANGE_PORT:
663 if (i > (len - 4)) {
664 dev_warn(&port->dev,
665 "%s - change_port message too short\n",
666 __func__);
667 break;
668 }
627 for (i = 0; i < urb->actual_length; i++) {
628 ch = (unsigned char *)urb->transfer_buffer + i;
629 if ((i <= (len - 3)) &&
630 (*ch == QT2_CONTROL_BYTE) &&
631 (*(ch + 1) == QT2_CONTROL_BYTE)) {
632 escapeflag = false;
633 switch (*(ch + 2)) {
634 case QT2_LINE_STATUS:

--- 21 unchanged lines hidden (view full) ---

656 break;
657 case QT2_CHANGE_PORT:
658 if (i > (len - 4)) {
659 dev_warn(&port->dev,
660 "%s - change_port message too short\n",
661 __func__);
662 break;
663 }
669 if (tty) {
670 tty_flip_buffer_push(tty);
671 tty_kref_put(tty);
672 }
664 tty_flip_buffer_push(&port->port);
673
674 newport = *(ch + 3);
675
676 if (newport > serial->num_ports) {
677 dev_err(&port->dev,
678 "%s - port change to invalid port: %i\n",
679 __func__, newport);
680 break;
681 }
682
683 serial_priv->current_port = newport;
684 port = serial->port[serial_priv->current_port];
685 port_priv = usb_get_serial_port_data(port);
665
666 newport = *(ch + 3);
667
668 if (newport > serial->num_ports) {
669 dev_err(&port->dev,
670 "%s - port change to invalid port: %i\n",
671 __func__, newport);
672 break;
673 }
674
675 serial_priv->current_port = newport;
676 port = serial->port[serial_priv->current_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;
691 escapeflag = true;
692 break;
693 case QT2_REC_FLUSH:
694 case QT2_XMIT_FLUSH:
695 qt2_process_flush(port, ch + 2);
696 i += 2;
697 escapeflag = true;

--- 13 unchanged lines hidden (view full) ---

711 if (escapeflag)
712 continue;
713 }
714
715 tty_buffer_request_room(&port->port, 1);
716 tty_insert_flip_string(&port->port, ch, 1);
717 }
718
678 i += 3;
679 escapeflag = true;
680 break;
681 case QT2_REC_FLUSH:
682 case QT2_XMIT_FLUSH:
683 qt2_process_flush(port, ch + 2);
684 i += 2;
685 escapeflag = true;

--- 13 unchanged lines hidden (view full) ---

699 if (escapeflag)
700 continue;
701 }
702
703 tty_buffer_request_room(&port->port, 1);
704 tty_insert_flip_string(&port->port, ch, 1);
705 }
706
719 if (tty) {
720 tty_flip_buffer_push(tty);
721 tty_kref_put(tty);
722 }
707 tty_flip_buffer_push(&port->port);
723}
724
725static void qt2_write_bulk_callback(struct urb *urb)
726{
727 struct usb_serial_port *port;
728 struct qt2_port_private *port_priv;
729
730 port = urb->context;

--- 399 unchanged lines hidden ---
708}
709
710static void qt2_write_bulk_callback(struct urb *urb)
711{
712 struct usb_serial_port *port;
713 struct qt2_port_private *port_priv;
714
715 port = urb->context;

--- 399 unchanged lines hidden ---