USB: tty: Prune uses of tty_request_room in the USB layer
[safe/jmp/linux-2.6] / drivers / usb / serial / symbolserial.c
index 6157fac..7239888 100644 (file)
@@ -21,7 +21,7 @@
 
 static int debug;
 
-static struct usb_device_id id_table[] = {
+static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x05e0, 0x0600) },
        { },
 };
@@ -51,7 +51,6 @@ static void symbol_int_callback(struct urb *urb)
        int status = urb->status;
        struct tty_struct *tty;
        int result;
-       int available_room = 0;
        int data_length;
 
        dbg("%s - port %d", __func__, port->number);
@@ -89,13 +88,8 @@ static void symbol_int_callback(struct urb *urb)
                 */
                tty = tty_port_tty_get(&port->port);
                if (tty) {
-                       available_room = tty_buffer_request_room(tty,
-                                                       data_length);
-                       if (available_room) {
-                               tty_insert_flip_string(tty, &data[1],
-                                                      available_room);
-                               tty_flip_buffer_push(tty);
-                       }
+                       tty_insert_flip_string(tty, &data[1], data_length);
+                       tty_flip_buffer_push(tty);
                        tty_kref_put(tty);
                }
        } else {
@@ -124,8 +118,7 @@ exit:
        spin_unlock(&priv->lock);
 }
 
-static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port,
-                       struct file *filp)
+static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
        struct symbol_private *priv = usb_get_serial_data(port->serial);
        unsigned long flags;
@@ -166,34 +159,36 @@ static void symbol_throttle(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        struct symbol_private *priv = usb_get_serial_data(port->serial);
-       unsigned long flags;
 
        dbg("%s - port %d", __func__, port->number);
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irq(&priv->lock);
        priv->throttled = true;
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irq(&priv->lock);
 }
 
 static void symbol_unthrottle(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        struct symbol_private *priv = usb_get_serial_data(port->serial);
-       unsigned long flags;
        int result;
+       bool was_throttled;
 
        dbg("%s - port %d", __func__, port->number);
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irq(&priv->lock);
        priv->throttled = false;
+       was_throttled = priv->actually_throttled;
        priv->actually_throttled = false;
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irq(&priv->lock);
 
        priv->int_urb->dev = port->serial->dev;
-       result = usb_submit_urb(priv->int_urb, GFP_ATOMIC);
-       if (result)
-               dev_err(&port->dev,
-                       "%s - failed submitting read urb, error %d\n",
+       if (was_throttled) {
+               result = usb_submit_urb(priv->int_urb, GFP_KERNEL);
+               if (result)
+                       dev_err(&port->dev,
+                               "%s - failed submitting read urb, error %d\n",
                                                        __func__, result);
+       }
 }
 
 static int symbol_startup(struct usb_serial *serial)