diff options
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 99 |
1 files changed, 7 insertions, 92 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index ab4ad18d6ef3..01efe6dda05c 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -789,8 +789,7 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
789 | static int ftdi_write_room(struct tty_struct *tty); | 789 | static int ftdi_write_room(struct tty_struct *tty); |
790 | static int ftdi_chars_in_buffer(struct tty_struct *tty); | 790 | static int ftdi_chars_in_buffer(struct tty_struct *tty); |
791 | static void ftdi_write_bulk_callback(struct urb *urb); | 791 | static void ftdi_write_bulk_callback(struct urb *urb); |
792 | static void ftdi_read_bulk_callback(struct urb *urb); | 792 | static void ftdi_process_read_urb(struct urb *urb); |
793 | static void ftdi_process_read(struct usb_serial_port *port); | ||
794 | static void ftdi_set_termios(struct tty_struct *tty, | 793 | static void ftdi_set_termios(struct tty_struct *tty, |
795 | struct usb_serial_port *port, struct ktermios *old); | 794 | struct usb_serial_port *port, struct ktermios *old); |
796 | static int ftdi_tiocmget(struct tty_struct *tty, struct file *file); | 795 | static int ftdi_tiocmget(struct tty_struct *tty, struct file *file); |
@@ -799,8 +798,6 @@ static int ftdi_tiocmset(struct tty_struct *tty, struct file *file, | |||
799 | static int ftdi_ioctl(struct tty_struct *tty, struct file *file, | 798 | static int ftdi_ioctl(struct tty_struct *tty, struct file *file, |
800 | unsigned int cmd, unsigned long arg); | 799 | unsigned int cmd, unsigned long arg); |
801 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state); | 800 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state); |
802 | static void ftdi_throttle(struct tty_struct *tty); | ||
803 | static void ftdi_unthrottle(struct tty_struct *tty); | ||
804 | 801 | ||
805 | static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); | 802 | static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); |
806 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); | 803 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); |
@@ -825,12 +822,12 @@ static struct usb_serial_driver ftdi_sio_device = { | |||
825 | .open = ftdi_open, | 822 | .open = ftdi_open, |
826 | .close = ftdi_close, | 823 | .close = ftdi_close, |
827 | .dtr_rts = ftdi_dtr_rts, | 824 | .dtr_rts = ftdi_dtr_rts, |
828 | .throttle = ftdi_throttle, | 825 | .throttle = usb_serial_generic_throttle, |
829 | .unthrottle = ftdi_unthrottle, | 826 | .unthrottle = usb_serial_generic_unthrottle, |
830 | .write = ftdi_write, | 827 | .write = ftdi_write, |
831 | .write_room = ftdi_write_room, | 828 | .write_room = ftdi_write_room, |
832 | .chars_in_buffer = ftdi_chars_in_buffer, | 829 | .chars_in_buffer = ftdi_chars_in_buffer, |
833 | .read_bulk_callback = ftdi_read_bulk_callback, | 830 | .process_read_urb = ftdi_process_read_urb, |
834 | .write_bulk_callback = ftdi_write_bulk_callback, | 831 | .write_bulk_callback = ftdi_write_bulk_callback, |
835 | .tiocmget = ftdi_tiocmget, | 832 | .tiocmget = ftdi_tiocmget, |
836 | .tiocmset = ftdi_tiocmset, | 833 | .tiocmset = ftdi_tiocmset, |
@@ -1686,31 +1683,10 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) | |||
1686 | return 0; | 1683 | return 0; |
1687 | } | 1684 | } |
1688 | 1685 | ||
1689 | static int ftdi_submit_read_urb(struct usb_serial_port *port, gfp_t mem_flags) | ||
1690 | { | ||
1691 | struct urb *urb = port->read_urb; | ||
1692 | struct usb_serial *serial = port->serial; | ||
1693 | int result; | ||
1694 | |||
1695 | usb_fill_bulk_urb(urb, serial->dev, | ||
1696 | usb_rcvbulkpipe(serial->dev, | ||
1697 | port->bulk_in_endpointAddress), | ||
1698 | urb->transfer_buffer, | ||
1699 | urb->transfer_buffer_length, | ||
1700 | ftdi_read_bulk_callback, port); | ||
1701 | result = usb_submit_urb(urb, mem_flags); | ||
1702 | if (result && result != -EPERM) | ||
1703 | dev_err(&port->dev, | ||
1704 | "%s - failed submitting read urb, error %d\n", | ||
1705 | __func__, result); | ||
1706 | return result; | ||
1707 | } | ||
1708 | |||
1709 | static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) | 1686 | static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) |
1710 | { /* ftdi_open */ | 1687 | { /* ftdi_open */ |
1711 | struct usb_device *dev = port->serial->dev; | 1688 | struct usb_device *dev = port->serial->dev; |
1712 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1689 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1713 | unsigned long flags; | ||
1714 | int result; | 1690 | int result; |
1715 | 1691 | ||
1716 | dbg("%s", __func__); | 1692 | dbg("%s", __func__); |
@@ -1732,14 +1708,8 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1732 | if (tty) | 1708 | if (tty) |
1733 | ftdi_set_termios(tty, port, tty->termios); | 1709 | ftdi_set_termios(tty, port, tty->termios); |
1734 | 1710 | ||
1735 | /* Not throttled */ | ||
1736 | spin_lock_irqsave(&port->lock, flags); | ||
1737 | port->throttled = 0; | ||
1738 | port->throttle_req = 0; | ||
1739 | spin_unlock_irqrestore(&port->lock, flags); | ||
1740 | |||
1741 | /* Start reading from the device */ | 1711 | /* Start reading from the device */ |
1742 | result = ftdi_submit_read_urb(port, GFP_KERNEL); | 1712 | result = usb_serial_generic_open(tty, port); |
1743 | if (!result) | 1713 | if (!result) |
1744 | kref_get(&priv->kref); | 1714 | kref_get(&priv->kref); |
1745 | 1715 | ||
@@ -2071,9 +2041,9 @@ static int ftdi_process_packet(struct tty_struct *tty, | |||
2071 | return len; | 2041 | return len; |
2072 | } | 2042 | } |
2073 | 2043 | ||
2074 | static void ftdi_process_read(struct usb_serial_port *port) | 2044 | static void ftdi_process_read_urb(struct urb *urb) |
2075 | { | 2045 | { |
2076 | struct urb *urb = port->read_urb; | 2046 | struct usb_serial_port *port = urb->context; |
2077 | struct tty_struct *tty; | 2047 | struct tty_struct *tty; |
2078 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2048 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2079 | char *data = (char *)urb->transfer_buffer; | 2049 | char *data = (char *)urb->transfer_buffer; |
@@ -2095,32 +2065,6 @@ static void ftdi_process_read(struct usb_serial_port *port) | |||
2095 | tty_kref_put(tty); | 2065 | tty_kref_put(tty); |
2096 | } | 2066 | } |
2097 | 2067 | ||
2098 | static void ftdi_read_bulk_callback(struct urb *urb) | ||
2099 | { | ||
2100 | struct usb_serial_port *port = urb->context; | ||
2101 | unsigned long flags; | ||
2102 | |||
2103 | dbg("%s - port %d", __func__, port->number); | ||
2104 | |||
2105 | if (urb->status) { | ||
2106 | dbg("%s - nonzero read bulk status received: %d", | ||
2107 | __func__, urb->status); | ||
2108 | return; | ||
2109 | } | ||
2110 | |||
2111 | usb_serial_debug_data(debug, &port->dev, __func__, | ||
2112 | urb->actual_length, urb->transfer_buffer); | ||
2113 | ftdi_process_read(port); | ||
2114 | |||
2115 | spin_lock_irqsave(&port->lock, flags); | ||
2116 | port->throttled = port->throttle_req; | ||
2117 | if (!port->throttled) { | ||
2118 | spin_unlock_irqrestore(&port->lock, flags); | ||
2119 | ftdi_submit_read_urb(port, GFP_ATOMIC); | ||
2120 | } else | ||
2121 | spin_unlock_irqrestore(&port->lock, flags); | ||
2122 | } | ||
2123 | |||
2124 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | 2068 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state) |
2125 | { | 2069 | { |
2126 | struct usb_serial_port *port = tty->driver_data; | 2070 | struct usb_serial_port *port = tty->driver_data; |
@@ -2456,35 +2400,6 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file *file, | |||
2456 | return -ENOIOCTLCMD; | 2400 | return -ENOIOCTLCMD; |
2457 | } | 2401 | } |
2458 | 2402 | ||
2459 | static void ftdi_throttle(struct tty_struct *tty) | ||
2460 | { | ||
2461 | struct usb_serial_port *port = tty->driver_data; | ||
2462 | unsigned long flags; | ||
2463 | |||
2464 | dbg("%s - port %d", __func__, port->number); | ||
2465 | |||
2466 | spin_lock_irqsave(&port->lock, flags); | ||
2467 | port->throttle_req = 1; | ||
2468 | spin_unlock_irqrestore(&port->lock, flags); | ||
2469 | } | ||
2470 | |||
2471 | void ftdi_unthrottle(struct tty_struct *tty) | ||
2472 | { | ||
2473 | struct usb_serial_port *port = tty->driver_data; | ||
2474 | int was_throttled; | ||
2475 | unsigned long flags; | ||
2476 | |||
2477 | dbg("%s - port %d", __func__, port->number); | ||
2478 | |||
2479 | spin_lock_irqsave(&port->lock, flags); | ||
2480 | was_throttled = port->throttled; | ||
2481 | port->throttled = port->throttle_req = 0; | ||
2482 | spin_unlock_irqrestore(&port->lock, flags); | ||
2483 | |||
2484 | if (was_throttled) | ||
2485 | ftdi_submit_read_urb(port, GFP_KERNEL); | ||
2486 | } | ||
2487 | |||
2488 | static int __init ftdi_init(void) | 2403 | static int __init ftdi_init(void) |
2489 | { | 2404 | { |
2490 | int retval; | 2405 | int retval; |