USB: tty: Prune uses of tty_request_room in the USB layer
authorAlan Cox <alan@linux.intel.com>
Thu, 18 Feb 2010 16:44:01 +0000 (16:44 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 2 Mar 2010 22:55:12 +0000 (14:55 -0800)
We have lots of callers that do not need to do this in the first place.
Remove the calls as they both cost CPU and for big buffers can mess up the
multi-page allocation avoidance.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
24 files changed:
drivers/usb/serial/ark3116.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/empeg.c
drivers/usb/serial/garmin_gps.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_ti.c
drivers/usb/serial/ipaq.c
drivers/usb/serial/ipw.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/kobil_sct.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/navman.c
drivers/usb/serial/opticon.c
drivers/usb/serial/option.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/sierra.c
drivers/usb/serial/spcp8x5.c
drivers/usb/serial/symbolserial.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/visor.c

index 1f75fac812326dc4fe082e355c7c56297da8d218..547c9448c28c345fd2f90966e3410b8e7949f2d3 100644 (file)
@@ -733,7 +733,6 @@ static void ark3116_read_bulk_callback(struct urb *urb)
 
                tty = tty_port_tty_get(&port->port);
                if (tty) {
-                       tty_buffer_request_room(tty, urb->actual_length + 1);
                        /* overrun is special, not associated with a char */
                        if (unlikely(lsr & UART_LSR_OE))
                                tty_insert_flip_char(tty, 0, TTY_OVERRUN);
index 036f9996fe52db05cd433e9188fa72f932a5971a..f744ab7a3b19fb098d185a02545d8fa6987260a1 100644 (file)
@@ -395,7 +395,6 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
                return;
        }
        if (urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
index c349f790f856082efa426b889e3474d317af162b..3a5d57f89deefe7d8765eaeb2d53409c8c7a0c86 100644 (file)
@@ -1307,13 +1307,9 @@ static void cypress_read_int_callback(struct urb *urb)
                spin_unlock_irqrestore(&priv->lock, flags);
 
        /* process read if there is data other than line status */
-       if (tty && (bytes > i)) {
-               bytes = tty_buffer_request_room(tty, bytes);
-               for (; i < bytes ; ++i) {
-                       dbg("pushing byte number %d - %d - %c", i, data[i],
-                                       data[i]);
-                       tty_insert_flip_char(tty, data[i], tty_flag);
-               }
+       if (tty && bytes > i) {
+               tty_insert_flip_string_fixed_flag(tty, data + i,
+                               bytes - i, tty_flag);
                tty_flip_buffer_push(tty);
        }
 
index 3b6348414c47409bb93603845d489ae92f6ec527..381722858424156a417c873e94cd3bec65e8b3d4 100644 (file)
@@ -1658,7 +1658,6 @@ static int digi_read_inb_callback(struct urb *urb)
        int port_status = ((unsigned char *)urb->transfer_buffer)[2];
        unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3;
        int flag, throttled;
-       int i;
        int status = urb->status;
 
        /* do not process callbacks on closed ports */
@@ -1705,17 +1704,9 @@ static int digi_read_inb_callback(struct urb *urb)
 
                /* data length is len-1 (one byte of len is port_status) */
                --len;
-
-               len = tty_buffer_request_room(tty, len);
                if (len > 0) {
-                       /* Hot path */
-                       if (flag == TTY_NORMAL)
-                               tty_insert_flip_string(tty, data, len);
-                       else {
-                               for (i = 0; i < len; i++)
-                                       tty_insert_flip_char(tty,
-                                                               data[i], flag);
-                       }
+                       tty_insert_flip_string_fixed_flag(tty, data, len,
+                                                                       flag);
                        tty_flip_buffer_push(tty);
                }
        }
index d02e604e9cc4b925b69af6c8ddfd9eba4c98510d..5f740a1eacab7958e3964c7a76d9369e08535d57 100644 (file)
@@ -346,7 +346,6 @@ static void empeg_read_bulk_callback(struct urb *urb)
        tty = tty_port_tty_get(&port->port);
 
        if (urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
                bytes_in += urb->actual_length;
index 6bbedfbb0fbccb282813ed395001de271c968454..a42b29a695b2a6995a4e331197bc1a2c35a0fa36 100644 (file)
@@ -271,7 +271,6 @@ static void send_to_tty(struct usb_serial_port *port,
                usb_serial_debug_data(debug, &port->dev,
                                        __func__, actual_length, data);
 
-               tty_buffer_request_room(tty, actual_length);
                tty_insert_flip_string(tty, data, actual_length);
                tty_flip_buffer_push(tty);
        }
index 66fb58f427cd39b476288a4144f911cf0e697c8f..3ef8df0ef888e9d99849953d275dfe81a6f6b47b 100644 (file)
@@ -2055,18 +2055,13 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
 {
        int cnt;
 
-       do {
-               cnt = tty_buffer_request_room(tty, length);
-               if (cnt < length) {
-                       dev_err(dev, "%s - dropping data, %d bytes lost\n",
-                                       __func__, length - cnt);
-                       if (cnt == 0)
-                               break;
-               }
-               tty_insert_flip_string(tty, data, cnt);
-               data += cnt;
-               length -= cnt;
-       } while (length > 0);
+       cnt = tty_insert_flip_string(tty, data, length);
+       if (cnt < length) {
+               dev_err(dev, "%s - dropping data, %d bytes lost\n",
+                               __func__, length - cnt);
+       }
+       data += cnt;
+       length -= cnt;
 
        tty_flip_buffer_push(tty);
 }
index 98e50456ad79d0a0a9d1943bef67870924820298..aa876f71f228e4f8bf053e66fc331aca593f7b54 100644 (file)
@@ -1820,7 +1820,6 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
 {
        int queued;
 
-       tty_buffer_request_room(tty, length);
        queued = tty_insert_flip_string(tty, data, length);
        if (queued < length)
                dev_err(dev, "%s - dropping data, %d bytes lost\n",
index d6231c38813e41d7b3072312907fcb33067de2d4..3fea9298eb15bef43fbc95010d73948ddb0c7490 100644 (file)
@@ -747,7 +747,6 @@ static void ipaq_read_bulk_callback(struct urb *urb)
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
                bytes_in += urb->actual_length;
index c0afa7a219d7513f3df829d21244f223677b5f6b..e1d07840cee66c65c2cb62feb5497bf27491cf82 100644 (file)
@@ -172,7 +172,6 @@ static void ipw_read_bulk_callback(struct urb *urb)
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
index fc2ab81a48d1725e17802d1dc8141fe5510b9f0b..c3e5d506aead3368776115319983a8ada014735b 100644 (file)
@@ -462,10 +462,8 @@ static void ir_read_bulk_callback(struct urb *urb)
                usb_serial_debug_data(debug, &port->dev, __func__,
                                                urb->actual_length, data);
                tty = tty_port_tty_get(&port->port);
-               if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
-                       tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
-                       tty_flip_buffer_push(tty);
-               }
+               tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
+               tty_flip_buffer_push(tty);
                tty_kref_put(tty);
 
                /*
index 2dbe22ae50fc155f86ba32fa1013edaf76d236ed..8eef91ba4b1c5021c2ecad2725e028ad4ce7dd73 100644 (file)
@@ -699,7 +699,6 @@ static void klsi_105_read_bulk_callback(struct urb *urb)
                        bytes_sent = urb->actual_length - 2;
                }
 
-               tty_buffer_request_room(tty, bytes_sent);
                tty_insert_flip_string(tty, data + 2, bytes_sent);
                tty_flip_buffer_push(tty);
                tty_kref_put(tty);
index fc7855388e279535fb303f6bc9e61ea0e6cfa2fb..c113a2a0e10c529e198dcd9e6b7de868e27cddba 100644 (file)
@@ -388,7 +388,6 @@ static void kobil_read_int_callback(struct urb *urb)
                */
                /* END DEBUG */
 
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
index 546b29f73c2cfbed9ec536b1b9c13b2e27fd2d0b..0d47f2c4d59f21b80b0f9f1540af9fac422009cf 100644 (file)
@@ -290,7 +290,6 @@ static void mos7720_bulk_in_callback(struct urb *urb)
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
index c89a89c6394efc21d33fa3cbc8e8c9c044df3502..2fda1c0182b74848259f563a3ccfa38731c209f9 100644 (file)
@@ -764,7 +764,6 @@ static void mos7840_bulk_in_callback(struct urb *urb)
        if (urb->actual_length) {
                tty = tty_port_tty_get(&mos7840_port->port->port);
                if (tty) {
-                       tty_buffer_request_room(tty, urb->actual_length);
                        tty_insert_flip_string(tty, data, urb->actual_length);
                        dbg(" %s ", data);
                        tty_flip_buffer_push(tty);
index efa61bcd3297dad6325a319b7ad35cd8e7d3b83d..04a6cbbed2c0f1de6837d9b3d611a3f543e18e97 100644 (file)
@@ -66,7 +66,6 @@ static void navman_read_int_callback(struct urb *urb)
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
index 773286672ec9c84c25d43b12d31dd19b255bedb0..f37476e22684af0663b46e41d4431692834d741b 100644 (file)
@@ -55,7 +55,6 @@ static void opticon_bulk_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);
@@ -96,13 +95,9 @@ static void opticon_bulk_callback(struct urb *urb)
                        /* real data, send it to the tty layer */
                        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,
-                                                              available_room);
-                                       tty_flip_buffer_push(tty);
-                               }
+                               tty_insert_flip_string(tty, data,
+                                                              data_length);
+                               tty_flip_buffer_push(tty);
                                tty_kref_put(tty);
                        }
                } else {
index f6646b30f9540b15107ced413b15244bca4f9b4a..68c7457a98aedf4f4b1eebd778e61e7612cd8dce 100644 (file)
@@ -964,7 +964,6 @@ static void option_indat_callback(struct urb *urb)
        } else {
                tty = tty_port_tty_get(&port->port);
                if (urb->actual_length) {
-                       tty_buffer_request_room(tty, urb->actual_length);
                        tty_insert_flip_string(tty, data, urb->actual_length);
                        tty_flip_buffer_push(tty);
                } else 
index 767000c701492e264e8a64b7c577575fac0c2429..a3e5a56dc0666ecb450a9a56c4dc3072fd852bc9 100644 (file)
@@ -1042,7 +1042,6 @@ static void pl2303_push_data(struct tty_struct *tty,
                tty_flag = TTY_FRAME;
        dbg("%s - tty_flag = %d", __func__, tty_flag);
 
-       tty_buffer_request_room(tty, urb->actual_length + 1);
        /* overrun is special, not associated with a char */
        if (line_status & UART_OVERRUN_ERROR)
                tty_insert_flip_char(tty, 0, TTY_OVERRUN);
index fcec4660355863bdbf61a4ce94d445c03db8093d..c012e51665bd70c5e4c2901d587a91b9d8e6a0df 100644 (file)
@@ -595,8 +595,6 @@ static void sierra_indat_callback(struct urb *urb)
                if (urb->actual_length) {
                        tty = tty_port_tty_get(&port->port);
                        if (tty) {
-                               tty_buffer_request_room(tty,
-                                       urb->actual_length);
                                tty_insert_flip_string(tty, data,
                                        urb->actual_length);
                                tty_flip_buffer_push(tty);
index 067e95ad2987270f678030127db359d9ae784af5..cf508e26f1c6cad14f71f4eff30c58902d482ee3 100644 (file)
@@ -677,7 +677,6 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
        struct tty_struct *tty;
        unsigned char *data = urb->transfer_buffer;
        unsigned long flags;
-       int i;
        int result = urb->status;
        u8 status;
        char tty_flag;
@@ -726,12 +725,11 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_buffer_request_room(tty, urb->actual_length + 1);
                /* overrun is special, not associated with a char */
                if (status & UART_OVERRUN_ERROR)
                        tty_insert_flip_char(tty, 0, TTY_OVERRUN);
-               for (i = 0; i < urb->actual_length; ++i)
-                       tty_insert_flip_char(tty, data[i], tty_flag);
+               tty_insert_flip_string_fixed_flag(tty, data,
+                                               urb->actual_length, tty_flag);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
index 1a76bc5261e9425308b739aa00d3ffe9ea3ea2c9..72398888858ffb95ed24943033d41b5f2ebe4ca0 100644 (file)
@@ -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 {
index 1e9dc882169826ff742e5c199b4a11098f97411c..0afe5c71c17e6e4c687c3b2f5ac816857146087f 100644 (file)
@@ -1271,14 +1271,13 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
        int cnt;
 
        do {
-               cnt = tty_buffer_request_room(tty, length);
+               cnt = tty_insert_flip_string(tty, data, length);
                if (cnt < length) {
                        dev_err(dev, "%s - dropping data, %d bytes lost\n",
                                                __func__, length - cnt);
                        if (cnt == 0)
                                break;
                }
-               tty_insert_flip_string(tty, data, cnt);
                tty_flip_buffer_push(tty);
                data += cnt;
                length -= cnt;
index 4f7945e672cc4ca4498d6fceca474968d8df62df..094942707c7d6591afab24d006cc8d0d1d1de097 100644 (file)
@@ -503,13 +503,9 @@ static void visor_read_bulk_callback(struct urb *urb)
        if (urb->actual_length) {
                tty = tty_port_tty_get(&port->port);
                if (tty) {
-                       available_room = tty_buffer_request_room(tty,
-                                                       urb->actual_length);
-                       if (available_room) {
-                               tty_insert_flip_string(tty, data,
-                                                       available_room);
-                               tty_flip_buffer_push(tty);
-                       }
+                       tty_insert_flip_string(tty, data,
+                                               urb->actual_length);
+                       tty_flip_buffer_push(tty);
                        tty_kref_put(tty);
                }
                spin_lock(&priv->lock);