aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2010-05-07 14:45:34 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:43 -0400
commit82b71cfdf36d568c7a2e44efd705471c3c2caaa2 (patch)
tree1a71a5901db475393666af99da410e6429127e15 /drivers
parent70ced221cc9f041481f129e63cc5b1dedb0ff959 (diff)
USB: ark3116: reimplement read processing
Use process_read_urb to implement read processing. Compile-only tested. Signed-off-by: Johan Hovold <jhovold@gmail.com> Acked-by: Bart Hartgers <bart.hartgers@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/serial/ark3116.c104
1 files changed, 31 insertions, 73 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 0ae610efa23d..4e41a2a39422 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -42,7 +42,7 @@ static int debug;
42 * Version information 42 * Version information
43 */ 43 */
44 44
45#define DRIVER_VERSION "v0.5" 45#define DRIVER_VERSION "v0.6"
46#define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" 46#define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>"
47#define DRIVER_DESC "USB ARK3116 serial/IrDA driver" 47#define DRIVER_DESC "USB ARK3116 serial/IrDA driver"
48#define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" 48#define DRIVER_DEV_DESC "ARK3116 RS232/IrDA"
@@ -672,87 +672,45 @@ static void ark3116_read_int_callback(struct urb *urb)
672 * error for the next block of data as well... 672 * error for the next block of data as well...
673 * For now, let's pretend this can't happen. 673 * For now, let's pretend this can't happen.
674 */ 674 */
675 675static void ark3116_process_read_urb(struct urb *urb)
676static void send_to_tty(struct tty_struct *tty,
677 const unsigned char *chars,
678 size_t size, char flag)
679{ 676{
680 if (size == 0) 677 struct usb_serial_port *port = urb->context;
681 return;
682 if (flag == TTY_NORMAL) {
683 tty_insert_flip_string(tty, chars, size);
684 } else {
685 int i;
686 for (i = 0; i < size; ++i)
687 tty_insert_flip_char(tty, chars[i], flag);
688 }
689}
690
691static void ark3116_read_bulk_callback(struct urb *urb)
692{
693 struct usb_serial_port *port = urb->context;
694 struct ark3116_private *priv = usb_get_serial_port_data(port); 678 struct ark3116_private *priv = usb_get_serial_port_data(port);
695 const __u8 *data = urb->transfer_buffer;
696 int status = urb->status;
697 struct tty_struct *tty; 679 struct tty_struct *tty;
680 unsigned char *data = urb->transfer_buffer;
681 char tty_flag = TTY_NORMAL;
698 unsigned long flags; 682 unsigned long flags;
699 int result;
700 char flag;
701 __u32 lsr; 683 __u32 lsr;
702 684
703 switch (status) { 685 /* update line status */
704 case -ECONNRESET: 686 spin_lock_irqsave(&priv->status_lock, flags);
705 case -ENOENT: 687 lsr = priv->lsr;
706 case -ESHUTDOWN: 688 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS;
707 /* this urb is terminated, clean up */ 689 spin_unlock_irqrestore(&priv->status_lock, flags);
708 dbg("%s - urb shutting down with status: %d", 690
709 __func__, status); 691 if (!urb->actual_length)
710 return; 692 return;
711 default:
712 dbg("%s - nonzero urb status received: %d",
713 __func__, status);
714 break;
715 case 0: /* success */
716 693
717 spin_lock_irqsave(&priv->status_lock, flags); 694 tty = tty_port_tty_get(&port->port);
718 lsr = priv->lsr; 695 if (!tty)
719 /* clear error bits */ 696 return;
720 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS; 697
721 spin_unlock_irqrestore(&priv->status_lock, flags); 698 if (lsr & UART_LSR_BRK_ERROR_BITS) {
722 699 if (lsr & UART_LSR_BI)
723 if (unlikely(lsr & UART_LSR_BI)) 700 tty_flag = TTY_BREAK;
724 flag = TTY_BREAK; 701 else if (lsr & UART_LSR_PE)
725 else if (unlikely(lsr & UART_LSR_PE)) 702 tty_flag = TTY_PARITY;
726 flag = TTY_PARITY; 703 else if (lsr & UART_LSR_FE)
727 else if (unlikely(lsr & UART_LSR_FE)) 704 tty_flag = TTY_FRAME;
728 flag = TTY_FRAME;
729 else
730 flag = TTY_NORMAL;
731
732 tty = tty_port_tty_get(&port->port);
733 if (tty) {
734 /* overrun is special, not associated with a char */
735 if (unlikely(lsr & UART_LSR_OE))
736 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
737 send_to_tty(tty, data, urb->actual_length, flag);
738 tty_flip_buffer_push(tty);
739 tty_kref_put(tty);
740 }
741 705
742 /* Throttle the device if requested by tty */ 706 /* overrun is special, not associated with a char */
743 spin_lock_irqsave(&port->lock, flags); 707 if (lsr & UART_LSR_OE)
744 port->throttled = port->throttle_req; 708 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
745 if (port->throttled) {
746 spin_unlock_irqrestore(&port->lock, flags);
747 return;
748 } else
749 spin_unlock_irqrestore(&port->lock, flags);
750 } 709 }
751 /* Continue reading from device */ 710 tty_insert_flip_string_fixed_flag(tty, data, tty_flag,
752 result = usb_submit_urb(urb, GFP_ATOMIC); 711 urb->actual_length);
753 if (result) 712 tty_flip_buffer_push(tty);
754 dev_err(&urb->dev->dev, "%s - failed resubmitting" 713 tty_kref_put(tty);
755 " read urb, error %d\n", __func__, result);
756} 714}
757 715
758static struct usb_driver ark3116_driver = { 716static struct usb_driver ark3116_driver = {
@@ -782,7 +740,7 @@ static struct usb_serial_driver ark3116_device = {
782 .close = ark3116_close, 740 .close = ark3116_close,
783 .break_ctl = ark3116_break_ctl, 741 .break_ctl = ark3116_break_ctl,
784 .read_int_callback = ark3116_read_int_callback, 742 .read_int_callback = ark3116_read_int_callback,
785 .read_bulk_callback = ark3116_read_bulk_callback, 743 .process_read_urb = ark3116_process_read_urb,
786}; 744};
787 745
788static int __init ark3116_init(void) 746static int __init ark3116_init(void)