USB: ftdi_sio: clean up line-status handling
[pandora-kernel.git] / drivers / usb / serial / ftdi_sio.c
index 1d7c4fa..00b938a 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * USB FTDI SIO driver
  *
+ *     Copyright (C) 2009 - 2010
+ *         Johan Hovold (jhovold@gmail.com)
  *     Copyright (C) 1999 - 2001
  *         Greg Kroah-Hartman (greg@kroah.com)
  *          Bill Ryder (bryder@sgi.com)
@@ -49,8 +51,8 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v1.5.0"
-#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr"
+#define DRIVER_VERSION "v1.6.0"
+#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>"
 #define DRIVER_DESC "USB FTDI Serial Converters Driver"
 
 static int debug;
@@ -69,10 +71,6 @@ struct ftdi_private {
                                /* the last data state set - needed for doing
                                 * a break
                                 */
-       int write_offset;       /* This is the offset in the usb data block to
-                                * write the serial data - it varies between
-                                * devices
-                                */
        int flags;              /* some ASYNC_xxxx flags are supported */
        unsigned long last_dtr_rts;     /* saved modem control outputs */
        wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
@@ -87,9 +85,6 @@ struct ftdi_private {
                                   be enabled */
 
        unsigned int latency;           /* latency setting in use */
-       spinlock_t tx_lock;     /* spinlock for transmit state */
-       unsigned long tx_outstanding_bytes;
-       unsigned long tx_outstanding_urbs;
        unsigned short max_packet_size;
        struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */
 };
@@ -768,9 +763,6 @@ static const char *ftdi_chip_name[] = {
 };
 
 
-/* Constants for read urb and write urb */
-#define BUFSZ 512
-
 /* Used for TIOCMIWAIT */
 #define FTDI_STATUS_B0_MASK    (FTDI_RS0_CTS | FTDI_RS0_DSR | FTDI_RS0_RI | FTDI_RS0_RLSD)
 #define FTDI_STATUS_B1_MASK    (FTDI_RS_BI)
@@ -787,13 +779,9 @@ static int  ftdi_sio_port_remove(struct usb_serial_port *port);
 static int  ftdi_open(struct tty_struct *tty, struct usb_serial_port *port);
 static void ftdi_close(struct usb_serial_port *port);
 static void ftdi_dtr_rts(struct usb_serial_port *port, int on);
-static int  ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
-                       const unsigned char *buf, int count);
-static int  ftdi_write_room(struct tty_struct *tty);
-static int  ftdi_chars_in_buffer(struct tty_struct *tty);
-static void ftdi_write_bulk_callback(struct urb *urb);
-static void ftdi_read_bulk_callback(struct urb *urb);
-static void ftdi_process_read(struct usb_serial_port *port);
+static void ftdi_process_read_urb(struct urb *urb);
+static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
+                                               void *dest, size_t size);
 static void ftdi_set_termios(struct tty_struct *tty,
                        struct usb_serial_port *port, struct ktermios *old);
 static int  ftdi_tiocmget(struct tty_struct *tty, struct file *file);
@@ -802,8 +790,6 @@ static int  ftdi_tiocmset(struct tty_struct *tty, struct file *file,
 static int  ftdi_ioctl(struct tty_struct *tty, struct file *file,
                        unsigned int cmd, unsigned long arg);
 static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
-static void ftdi_throttle(struct tty_struct *tty);
-static void ftdi_unthrottle(struct tty_struct *tty);
 
 static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
 static unsigned short int ftdi_232am_baud_to_divisor(int baud);
@@ -821,19 +807,18 @@ static struct usb_serial_driver ftdi_sio_device = {
        .usb_driver =           &ftdi_driver,
        .id_table =             id_table_combined,
        .num_ports =            1,
+       .bulk_in_size =         512,
+       .bulk_out_size =        256,
        .probe =                ftdi_sio_probe,
        .port_probe =           ftdi_sio_port_probe,
        .port_remove =          ftdi_sio_port_remove,
        .open =                 ftdi_open,
        .close =                ftdi_close,
        .dtr_rts =              ftdi_dtr_rts,
-       .throttle =             ftdi_throttle,
-       .unthrottle =           ftdi_unthrottle,
-       .write =                ftdi_write,
-       .write_room =           ftdi_write_room,
-       .chars_in_buffer =      ftdi_chars_in_buffer,
-       .read_bulk_callback =   ftdi_read_bulk_callback,
-       .write_bulk_callback =  ftdi_write_bulk_callback,
+       .throttle =             usb_serial_generic_throttle,
+       .unthrottle =           usb_serial_generic_unthrottle,
+       .process_read_urb =     ftdi_process_read_urb,
+       .prepare_write_buffer = ftdi_prepare_write_buffer,
        .tiocmget =             ftdi_tiocmget,
        .tiocmset =             ftdi_tiocmset,
        .ioctl =                ftdi_ioctl,
@@ -849,9 +834,6 @@ static struct usb_serial_driver ftdi_sio_device = {
 #define HIGH 1
 #define LOW 0
 
-/* number of outstanding urbs to prevent userspace DoS from happening */
-#define URB_UPPER_LIMIT        42
-
 /*
  * ***************************************************************************
  * Utility functions
@@ -987,7 +969,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
 
 static __u32 get_ftdi_divisor(struct tty_struct *tty,
                                                struct usb_serial_port *port)
-{ /* get_ftdi_divisor */
+{
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        __u32 div_value = 0;
        int div_okay = 1;
@@ -1211,12 +1193,11 @@ static int get_serial_info(struct usb_serial_port *port,
        if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
                return -EFAULT;
        return 0;
-} /* get_serial_info */
-
+}
 
 static int set_serial_info(struct tty_struct *tty,
        struct usb_serial_port *port, struct serial_struct __user *newinfo)
-{ /* set_serial_info */
+{
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        struct serial_struct new_serial;
        struct ftdi_private old_priv;
@@ -1279,8 +1260,7 @@ check_and_exit:
        else
                mutex_unlock(&priv->cfg_lock);
        return 0;
-
-} /* set_serial_info */
+}
 
 
 /* Determine type of FTDI chip based on USB config and descriptor. */
@@ -1294,7 +1274,6 @@ static void ftdi_determine_type(struct usb_serial_port *port)
 
        /* Assume it is not the original SIO device for now. */
        priv->baud_base = 48000000 / 2;
-       priv->write_offset = 0;
 
        version = le16_to_cpu(udev->descriptor.bcdDevice);
        interfaces = udev->actconfig->desc.bNumInterfaces;
@@ -1336,7 +1315,6 @@ static void ftdi_determine_type(struct usb_serial_port *port)
                /* Old device.  Assume it's the original SIO. */
                priv->chip_type = SIO;
                priv->baud_base = 12000000 / 16;
-               priv->write_offset = 1;
        } else if (version < 0x400) {
                /* Assume it's an FT8U232AM (or FT8U245AM) */
                /* (It might be a BM because of the iSerialNumber bug,
@@ -1543,7 +1521,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
        }
 
        kref_init(&priv->kref);
-       spin_lock_init(&priv->tx_lock);
        mutex_init(&priv->cfg_lock);
        init_waitqueue_head(&priv->delta_msr_wait);
 
@@ -1552,28 +1529,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
        if (quirk && quirk->port_probe)
                quirk->port_probe(priv);
 
-       /* Increase the size of read buffers */
-       kfree(port->bulk_in_buffer);
-       port->bulk_in_buffer = kmalloc(BUFSZ, GFP_KERNEL);
-       if (!port->bulk_in_buffer) {
-               kfree(priv);
-               return -ENOMEM;
-       }
-       if (port->read_urb) {
-               port->read_urb->transfer_buffer = port->bulk_in_buffer;
-               port->read_urb->transfer_buffer_length = BUFSZ;
-       }
-
        priv->port = port;
-
-       /* Free port's existing write urb and transfer buffer. */
-       if (port->write_urb) {
-               usb_free_urb(port->write_urb);
-               port->write_urb = NULL;
-       }
-       kfree(port->bulk_out_buffer);
-       port->bulk_out_buffer = NULL;
-
        usb_set_serial_port_data(port, priv);
 
        ftdi_determine_type(port);
@@ -1594,7 +1550,7 @@ static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
        priv->flags |= ASYNC_SPD_CUST;
        priv->custom_divisor = 77;
        priv->force_baud = 38400;
-} /* ftdi_USB_UIRT_setup */
+}
 
 /* Setup for the HE-TIRA1 device, which requires hardwired
  * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled.  */
@@ -1607,7 +1563,7 @@ static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
        priv->custom_divisor = 240;
        priv->force_baud = 38400;
        priv->force_rtscts = 1;
-} /* ftdi_HE_TIRA1_setup */
+}
 
 /*
  * Module parameter to control latency timer for NDI FTDI-based USB devices.
@@ -1700,31 +1656,10 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
        return 0;
 }
 
-static int ftdi_submit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
-{
-       struct urb *urb = port->read_urb;
-       struct usb_serial *serial = port->serial;
-       int result;
-
-       usb_fill_bulk_urb(urb, serial->dev,
-                          usb_rcvbulkpipe(serial->dev,
-                                       port->bulk_in_endpointAddress),
-                          urb->transfer_buffer,
-                          urb->transfer_buffer_length,
-                          ftdi_read_bulk_callback, port);
-       result = usb_submit_urb(urb, mem_flags);
-       if (result && result != -EPERM)
-               dev_err(&port->dev,
-                       "%s - failed submitting read urb, error %d\n",
-                                                       __func__, result);
-       return result;
-}
-
 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
-{ /* ftdi_open */
+{
        struct usb_device *dev = port->serial->dev;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
-       unsigned long flags;
        int result;
 
        dbg("%s", __func__);
@@ -1746,20 +1681,13 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
        if (tty)
                ftdi_set_termios(tty, port, tty->termios);
 
-       /* Not throttled */
-       spin_lock_irqsave(&port->lock, flags);
-       port->throttled = 0;
-       port->throttle_req = 0;
-       spin_unlock_irqrestore(&port->lock, flags);
-
        /* Start reading from the device */
-       result = ftdi_submit_read_urb(port, GFP_KERNEL);
+       result = usb_serial_generic_open(tty, port);
        if (!result)
                kref_get(&priv->kref);
 
        return result;
-} /* ftdi_open */
-
+}
 
 static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
 {
@@ -1789,22 +1717,16 @@ static void ftdi_dtr_rts(struct usb_serial_port *port, int on)
  * usbserial:__serial_close  only calls ftdi_close if the point is open
  *
  *   This only gets called when it is the last close
- *
- *
  */
-
 static void ftdi_close(struct usb_serial_port *port)
-{ /* ftdi_close */
+{
        struct ftdi_private *priv = usb_get_serial_port_data(port);
 
        dbg("%s", __func__);
 
-       /* shutdown our bulk read */
-       usb_kill_urb(port->read_urb);
+       usb_serial_generic_close(port);
        kref_put(&priv->kref, ftdi_sio_priv_release);
-} /* ftdi_close */
-
-
+}
 
 /* The SIO requires the first byte to have:
  *  B0 1
@@ -1813,211 +1735,39 @@ static void ftdi_close(struct usb_serial_port *port)
  *
  * The new devices do not require this byte
  */
-static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
-                          const unsigned char *buf, int count)
-{ /* ftdi_write */
-       struct ftdi_private *priv = usb_get_serial_port_data(port);
-       struct urb *urb;
-       unsigned char *buffer;
-       int data_offset ;       /* will be 1 for the SIO and 0 otherwise */
-       int status;
-       int transfer_size;
+static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
+                                               void *dest, size_t size)
+{
+       struct ftdi_private *priv;
+       int count;
        unsigned long flags;
 
-       dbg("%s port %d, %d bytes", __func__, port->number, count);
-
-       if (count == 0) {
-               dbg("write request of 0 bytes");
-               return 0;
-       }
-       spin_lock_irqsave(&priv->tx_lock, flags);
-       if (priv->tx_outstanding_urbs > URB_UPPER_LIMIT) {
-               spin_unlock_irqrestore(&priv->tx_lock, flags);
-               dbg("%s - write limit hit", __func__);
-               return 0;
-       }
-       priv->tx_outstanding_urbs++;
-       spin_unlock_irqrestore(&priv->tx_lock, flags);
-
-       data_offset = priv->write_offset;
-       dbg("data_offset set to %d", data_offset);
-
-       /* Determine total transfer size */
-       transfer_size = count;
-       if (data_offset > 0) {
-               /* Original sio needs control bytes too... */
-               transfer_size += (data_offset *
-                               ((count + (priv->max_packet_size - 1 - data_offset)) /
-                                (priv->max_packet_size - data_offset)));
-       }
-
-       buffer = kmalloc(transfer_size, GFP_ATOMIC);
-       if (!buffer) {
-               dev_err(&port->dev,
-                       "%s ran out of kernel memory for urb ...\n", __func__);
-               count = -ENOMEM;
-               goto error_no_buffer;
-       }
-
-       urb = usb_alloc_urb(0, GFP_ATOMIC);
-       if (!urb) {
-               dev_err(&port->dev, "%s - no more free urbs\n", __func__);
-               count = -ENOMEM;
-               goto error_no_urb;
-       }
+       priv = usb_get_serial_port_data(port);
 
-       /* Copy data */
-       if (data_offset > 0) {
-               /* Original sio requires control byte at start of
-                  each packet. */
-               int user_pktsz = priv->max_packet_size - data_offset;
-               int todo = count;
-               unsigned char *first_byte = buffer;
-               const unsigned char *current_position = buf;
-
-               while (todo > 0) {
-                       if (user_pktsz > todo)
-                               user_pktsz = todo;
-                       /* Write the control byte at the front of the packet*/
-                       *first_byte = 1 | ((user_pktsz) << 2);
-                       /* Copy data for packet */
-                       memcpy(first_byte + data_offset,
-                               current_position, user_pktsz);
-                       first_byte += user_pktsz + data_offset;
-                       current_position += user_pktsz;
-                       todo -= user_pktsz;
+       if (priv->chip_type == SIO) {
+               unsigned char *buffer = dest;
+               int i, len, c;
+
+               count = 0;
+               spin_lock_irqsave(&port->lock, flags);
+               for (i = 0; i < size - 1; i += priv->max_packet_size) {
+                       len = min_t(int, size - i, priv->max_packet_size) - 1;
+                       buffer[i] = (len << 2) + 1;
+                       c = kfifo_out(&port->write_fifo, &buffer[i + 1], len);
+                       if (!c)
+                               break;
+                       count += c + 1;
                }
+               spin_unlock_irqrestore(&port->lock, flags);
        } else {
-               /* No control byte required. */
-               /* Copy in the data to send */
-               memcpy(buffer, buf, count);
-       }
-
-       usb_serial_debug_data(debug, &port->dev, __func__,
-                                               transfer_size, buffer);
-
-       /* fill the buffer and send it */
-       usb_fill_bulk_urb(urb, port->serial->dev,
-                       usb_sndbulkpipe(port->serial->dev,
-                                       port->bulk_out_endpointAddress),
-                       buffer, transfer_size,
-                       ftdi_write_bulk_callback, port);
-
-       status = usb_submit_urb(urb, GFP_ATOMIC);
-       if (status) {
-               dev_err(&port->dev,
-                       "%s - failed submitting write urb, error %d\n",
-                       __func__, status);
-               count = status;
-               goto error;
-       } else {
-               spin_lock_irqsave(&priv->tx_lock, flags);
-               priv->tx_outstanding_bytes += count;
-               spin_unlock_irqrestore(&priv->tx_lock, flags);
+               count = kfifo_out_locked(&port->write_fifo, dest, size,
+                                                               &port->lock);
        }
 
-       /* we are done with this urb, so let the host driver
-        * really free it when it is finished with it */
-       usb_free_urb(urb);
-
-       dbg("%s write returning: %d", __func__, count);
-       return count;
-error:
-       usb_free_urb(urb);
-error_no_urb:
-       kfree(buffer);
-error_no_buffer:
-       spin_lock_irqsave(&priv->tx_lock, flags);
-       priv->tx_outstanding_urbs--;
-       spin_unlock_irqrestore(&priv->tx_lock, flags);
        return count;
-} /* ftdi_write */
-
-
-/* This function may get called when the device is closed */
-
-static void ftdi_write_bulk_callback(struct urb *urb)
-{
-       unsigned long flags;
-       struct usb_serial_port *port = urb->context;
-       struct ftdi_private *priv;
-       int data_offset;       /* will be 1 for the SIO and 0 otherwise */
-       unsigned long countback;
-       int status = urb->status;
-
-       /* free up the transfer buffer, as usb_free_urb() does not do this */
-       kfree(urb->transfer_buffer);
-
-       dbg("%s - port %d", __func__, port->number);
-
-       priv = usb_get_serial_port_data(port);
-       if (!priv) {
-               dbg("%s - bad port private data pointer - exiting", __func__);
-               return;
-       }
-       /* account for transferred data */
-       countback = urb->transfer_buffer_length;
-       data_offset = priv->write_offset;
-       if (data_offset > 0) {
-               /* Subtract the control bytes */
-               countback -= (data_offset * DIV_ROUND_UP(countback, priv->max_packet_size));
-       }
-       spin_lock_irqsave(&priv->tx_lock, flags);
-       --priv->tx_outstanding_urbs;
-       priv->tx_outstanding_bytes -= countback;
-       spin_unlock_irqrestore(&priv->tx_lock, flags);
-
-       if (status) {
-               dbg("nonzero write bulk status received: %d", status);
-       }
-
-       usb_serial_port_softint(port);
-} /* ftdi_write_bulk_callback */
-
-
-static int ftdi_write_room(struct tty_struct *tty)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       struct ftdi_private *priv = usb_get_serial_port_data(port);
-       int room;
-       unsigned long flags;
-
-       dbg("%s - port %d", __func__, port->number);
-
-       spin_lock_irqsave(&priv->tx_lock, flags);
-       if (priv->tx_outstanding_urbs < URB_UPPER_LIMIT) {
-               /*
-                * We really can take anything the user throws at us
-                * but let's pick a nice big number to tell the tty
-                * layer that we have lots of free space
-                */
-               room = 2048;
-       } else {
-               room = 0;
-       }
-       spin_unlock_irqrestore(&priv->tx_lock, flags);
-       return room;
 }
 
-static int ftdi_chars_in_buffer(struct tty_struct *tty)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       struct ftdi_private *priv = usb_get_serial_port_data(port);
-       int buffered;
-       unsigned long flags;
-
-       dbg("%s - port %d", __func__, port->number);
-
-       spin_lock_irqsave(&priv->tx_lock, flags);
-       buffered = (int)priv->tx_outstanding_bytes;
-       spin_unlock_irqrestore(&priv->tx_lock, flags);
-       if (buffered < 0) {
-               dev_err(&port->dev, "%s outstanding tx bytes is negative!\n",
-                       __func__);
-               buffered = 0;
-       }
-       return buffered;
-}
+#define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE)
 
 static int ftdi_process_packet(struct tty_struct *tty,
                struct usb_serial_port *port, struct ftdi_private *priv,
@@ -2045,28 +1795,21 @@ static int ftdi_process_packet(struct tty_struct *tty,
                priv->prev_status = status;
        }
 
-       /*
-        * Although the device uses a bitmask and hence can have multiple
-        * errors on a packet - the order here sets the priority the error is
-        * returned to the tty layer.
-        */
        flag = TTY_NORMAL;
-       if (packet[1] & FTDI_RS_OE) {
-               flag = TTY_OVERRUN;
-               dbg("OVERRRUN error");
-       }
-       if (packet[1] & FTDI_RS_BI) {
-               flag = TTY_BREAK;
-               dbg("BREAK received");
-               usb_serial_handle_break(port);
-       }
-       if (packet[1] & FTDI_RS_PE) {
-               flag = TTY_PARITY;
-               dbg("PARITY error");
-       }
-       if (packet[1] & FTDI_RS_FE) {
-               flag = TTY_FRAME;
-               dbg("FRAMING error");
+       if (packet[1] & FTDI_RS_ERR_MASK) {
+               /* Break takes precedence over parity, which takes precedence
+                * over framing errors */
+               if (packet[1] & FTDI_RS_BI) {
+                       flag = TTY_BREAK;
+                       usb_serial_handle_break(port);
+               } else if (packet[1] & FTDI_RS_PE) {
+                       flag = TTY_PARITY;
+               } else if (packet[1] & FTDI_RS_FE) {
+                       flag = TTY_FRAME;
+               }
+               /* Overrun is special, not associated with a char */
+               if (packet[1] & FTDI_RS_OE)
+                       tty_insert_flip_char(tty, 0, TTY_OVERRUN);
        }
 
        len -= 2;
@@ -2074,20 +1817,21 @@ static int ftdi_process_packet(struct tty_struct *tty,
                return 0;       /* status only */
        ch = packet + 2;
 
-       if (!(port->console && port->sysrq) && flag == TTY_NORMAL)
-               tty_insert_flip_string(tty, ch, len);
-       else {
+       if (port->port.console && port->sysrq) {
                for (i = 0; i < len; i++, ch++) {
                        if (!usb_serial_handle_sysrq_char(tty, port, *ch))
                                tty_insert_flip_char(tty, *ch, flag);
                }
+       } else {
+               tty_insert_flip_string_fixed_flag(tty, ch, flag, len);
        }
+
        return len;
 }
 
-static void ftdi_process_read(struct usb_serial_port *port)
+static void ftdi_process_read_urb(struct urb *urb)
 {
-       struct urb *urb = port->read_urb;
+       struct usb_serial_port *port = urb->context;
        struct tty_struct *tty;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        char *data = (char *)urb->transfer_buffer;
@@ -2109,32 +1853,6 @@ static void ftdi_process_read(struct usb_serial_port *port)
        tty_kref_put(tty);
 }
 
-static void ftdi_read_bulk_callback(struct urb *urb)
-{
-       struct usb_serial_port *port = urb->context;
-       unsigned long flags;
-
-       dbg("%s - port %d", __func__, port->number);
-
-       if (urb->status) {
-               dbg("%s - nonzero read bulk status received: %d",
-                                               __func__, urb->status);
-               return;
-       }
-
-       usb_serial_debug_data(debug, &port->dev, __func__,
-                               urb->actual_length, urb->transfer_buffer);
-       ftdi_process_read(port);
-
-       spin_lock_irqsave(&port->lock, flags);
-       port->throttled = port->throttle_req;
-       if (!port->throttled) {
-               spin_unlock_irqrestore(&port->lock, flags);
-               ftdi_submit_read_urb(port, GFP_ATOMIC);
-       } else
-               spin_unlock_irqrestore(&port->lock, flags);
-}
-
 static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
 {
        struct usb_serial_port *port = tty->driver_data;
@@ -2165,15 +1883,13 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
 
 }
 
-
 /* old_termios contains the original termios settings and tty->termios contains
  * the new setting to be used
  * WARNING: set_termios calls this with old_termios in kernel space
  */
-
 static void ftdi_set_termios(struct tty_struct *tty,
                struct usb_serial_port *port, struct ktermios *old_termios)
-{ /* ftdi_termios */
+{
        struct usb_device *dev = port->serial->dev;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        struct ktermios *termios = tty->termios;
@@ -2401,7 +2117,6 @@ static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
        return update_mctrl(port, set, clear);
 }
 
-
 static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
                                        unsigned int cmd, unsigned long arg)
 {
@@ -2470,35 +2185,6 @@ static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
        return -ENOIOCTLCMD;
 }
 
-static void ftdi_throttle(struct tty_struct *tty)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       unsigned long flags;
-
-       dbg("%s - port %d", __func__, port->number);
-
-       spin_lock_irqsave(&port->lock, flags);
-       port->throttle_req = 1;
-       spin_unlock_irqrestore(&port->lock, flags);
-}
-
-void ftdi_unthrottle(struct tty_struct *tty)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       int was_throttled;
-       unsigned long flags;
-
-       dbg("%s - port %d", __func__, port->number);
-
-       spin_lock_irqsave(&port->lock, flags);
-       was_throttled = port->throttled;
-       port->throttled = port->throttle_req = 0;
-       spin_unlock_irqrestore(&port->lock, flags);
-
-       if (was_throttled)
-               ftdi_submit_read_urb(port, GFP_KERNEL);
-}
-
 static int __init ftdi_init(void)
 {
        int retval;
@@ -2529,15 +2215,12 @@ failed_sio_register:
        return retval;
 }
 
-
 static void __exit ftdi_exit(void)
 {
-
        dbg("%s", __func__);
 
        usb_deregister(&ftdi_driver);
        usb_serial_deregister(&ftdi_sio_device);
-
 }