diff options
author | Alan Cox <alan@linux.intel.com> | 2010-02-18 16:44:01 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 14:55:12 -0800 |
commit | a108bfcb372d8c4452701039308fb95747911c59 (patch) | |
tree | 3528621937692e28081f71131cddc3130e2641ad | |
parent | 2832fc11f1360668482beec06dbcd631ae5f0cf1 (diff) |
USB: tty: Prune uses of tty_request_room in the USB layer
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>
-rw-r--r-- | drivers/usb/serial/ark3116.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/cyberjack.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/cypress_m8.c | 10 | ||||
-rw-r--r-- | drivers/usb/serial/digi_acceleport.c | 13 | ||||
-rw-r--r-- | drivers/usb/serial/empeg.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/garmin_gps.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/io_edgeport.c | 19 | ||||
-rw-r--r-- | drivers/usb/serial/io_ti.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/ipaq.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/ipw.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/ir-usb.c | 6 | ||||
-rw-r--r-- | drivers/usb/serial/kl5kusb105.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/kobil_sct.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/mos7720.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/mos7840.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/navman.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/opticon.c | 11 | ||||
-rw-r--r-- | drivers/usb/serial/option.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/pl2303.c | 1 | ||||
-rw-r--r-- | drivers/usb/serial/sierra.c | 2 | ||||
-rw-r--r-- | drivers/usb/serial/spcp8x5.c | 6 | ||||
-rw-r--r-- | drivers/usb/serial/symbolserial.c | 10 | ||||
-rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 3 | ||||
-rw-r--r-- | drivers/usb/serial/visor.c | 10 |
24 files changed, 25 insertions, 79 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 1f75fac8123..547c9448c28 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -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); diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 036f9996fe5..f744ab7a3b1 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -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); } diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index c349f790f85..3a5d57f89de 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -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); } diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index 3b6348414c4..38172285842 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -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); } } diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index d02e604e9cc..5f740a1eaca 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -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; diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 6bbedfbb0fb..a42b29a695b 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -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); } diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 66fb58f427c..3ef8df0ef88 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -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); } diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 98e50456ad7..aa876f71f22 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -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", diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index d6231c38813..3fea9298eb1 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -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; diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index c0afa7a219d..e1d07840cee 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -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); } diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index fc2ab81a48d..c3e5d506aea 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -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); /* diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 2dbe22ae50f..8eef91ba4b1 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -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); diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index fc7855388e2..c113a2a0e10 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -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); } diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 546b29f73c2..0d47f2c4d59 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c @@ -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); } diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index c89a89c6394..2fda1c0182b 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c @@ -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); diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index efa61bcd329..04a6cbbed2c 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c @@ -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); } diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index 773286672ec..f37476e2268 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -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 { diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index f6646b30f95..68c7457a98a 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -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 diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 767000c7014..a3e5a56dc06 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -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); diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index fcec4660355..c012e51665b 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -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); diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 067e95ad298..cf508e26f1c 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c @@ -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); diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 1a76bc5261e..72398888858 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c @@ -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 { diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 1e9dc882169..0afe5c71c17 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -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; diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 4f7945e672c..094942707c7 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -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); |