Commit a108bfcb372d8c4452701039308fb95747911c59
Committed by
Greg Kroah-Hartman
1 parent
2832fc11f1
Exists in
master
and in
7 other branches
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>
Showing 24 changed files with 25 additions and 79 deletions Side-by-side Diff
- 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
drivers/usb/serial/ark3116.c
... | ... | @@ -733,7 +733,6 @@ |
733 | 733 | |
734 | 734 | tty = tty_port_tty_get(&port->port); |
735 | 735 | if (tty) { |
736 | - tty_buffer_request_room(tty, urb->actual_length + 1); | |
737 | 736 | /* overrun is special, not associated with a char */ |
738 | 737 | if (unlikely(lsr & UART_LSR_OE)) |
739 | 738 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
drivers/usb/serial/cyberjack.c
drivers/usb/serial/cypress_m8.c
... | ... | @@ -1307,13 +1307,9 @@ |
1307 | 1307 | spin_unlock_irqrestore(&priv->lock, flags); |
1308 | 1308 | |
1309 | 1309 | /* process read if there is data other than line status */ |
1310 | - if (tty && (bytes > i)) { | |
1311 | - bytes = tty_buffer_request_room(tty, bytes); | |
1312 | - for (; i < bytes ; ++i) { | |
1313 | - dbg("pushing byte number %d - %d - %c", i, data[i], | |
1314 | - data[i]); | |
1315 | - tty_insert_flip_char(tty, data[i], tty_flag); | |
1316 | - } | |
1310 | + if (tty && bytes > i) { | |
1311 | + tty_insert_flip_string_fixed_flag(tty, data + i, | |
1312 | + bytes - i, tty_flag); | |
1317 | 1313 | tty_flip_buffer_push(tty); |
1318 | 1314 | } |
1319 | 1315 |
drivers/usb/serial/digi_acceleport.c
... | ... | @@ -1658,7 +1658,6 @@ |
1658 | 1658 | int port_status = ((unsigned char *)urb->transfer_buffer)[2]; |
1659 | 1659 | unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3; |
1660 | 1660 | int flag, throttled; |
1661 | - int i; | |
1662 | 1661 | int status = urb->status; |
1663 | 1662 | |
1664 | 1663 | /* do not process callbacks on closed ports */ |
1665 | 1664 | |
... | ... | @@ -1705,17 +1704,9 @@ |
1705 | 1704 | |
1706 | 1705 | /* data length is len-1 (one byte of len is port_status) */ |
1707 | 1706 | --len; |
1708 | - | |
1709 | - len = tty_buffer_request_room(tty, len); | |
1710 | 1707 | if (len > 0) { |
1711 | - /* Hot path */ | |
1712 | - if (flag == TTY_NORMAL) | |
1713 | - tty_insert_flip_string(tty, data, len); | |
1714 | - else { | |
1715 | - for (i = 0; i < len; i++) | |
1716 | - tty_insert_flip_char(tty, | |
1717 | - data[i], flag); | |
1718 | - } | |
1708 | + tty_insert_flip_string_fixed_flag(tty, data, len, | |
1709 | + flag); | |
1719 | 1710 | tty_flip_buffer_push(tty); |
1720 | 1711 | } |
1721 | 1712 | } |
drivers/usb/serial/empeg.c
... | ... | @@ -346,7 +346,6 @@ |
346 | 346 | tty = tty_port_tty_get(&port->port); |
347 | 347 | |
348 | 348 | if (urb->actual_length) { |
349 | - tty_buffer_request_room(tty, urb->actual_length); | |
350 | 349 | tty_insert_flip_string(tty, data, urb->actual_length); |
351 | 350 | tty_flip_buffer_push(tty); |
352 | 351 | bytes_in += urb->actual_length; |
drivers/usb/serial/garmin_gps.c
drivers/usb/serial/io_edgeport.c
... | ... | @@ -2055,18 +2055,13 @@ |
2055 | 2055 | { |
2056 | 2056 | int cnt; |
2057 | 2057 | |
2058 | - do { | |
2059 | - cnt = tty_buffer_request_room(tty, length); | |
2060 | - if (cnt < length) { | |
2061 | - dev_err(dev, "%s - dropping data, %d bytes lost\n", | |
2062 | - __func__, length - cnt); | |
2063 | - if (cnt == 0) | |
2064 | - break; | |
2065 | - } | |
2066 | - tty_insert_flip_string(tty, data, cnt); | |
2067 | - data += cnt; | |
2068 | - length -= cnt; | |
2069 | - } while (length > 0); | |
2058 | + cnt = tty_insert_flip_string(tty, data, length); | |
2059 | + if (cnt < length) { | |
2060 | + dev_err(dev, "%s - dropping data, %d bytes lost\n", | |
2061 | + __func__, length - cnt); | |
2062 | + } | |
2063 | + data += cnt; | |
2064 | + length -= cnt; | |
2070 | 2065 | |
2071 | 2066 | tty_flip_buffer_push(tty); |
2072 | 2067 | } |
drivers/usb/serial/io_ti.c
drivers/usb/serial/ipaq.c
... | ... | @@ -747,7 +747,6 @@ |
747 | 747 | |
748 | 748 | tty = tty_port_tty_get(&port->port); |
749 | 749 | if (tty && urb->actual_length) { |
750 | - tty_buffer_request_room(tty, urb->actual_length); | |
751 | 750 | tty_insert_flip_string(tty, data, urb->actual_length); |
752 | 751 | tty_flip_buffer_push(tty); |
753 | 752 | bytes_in += urb->actual_length; |
drivers/usb/serial/ipw.c
drivers/usb/serial/ir-usb.c
... | ... | @@ -462,10 +462,8 @@ |
462 | 462 | usb_serial_debug_data(debug, &port->dev, __func__, |
463 | 463 | urb->actual_length, data); |
464 | 464 | tty = tty_port_tty_get(&port->port); |
465 | - if (tty_buffer_request_room(tty, urb->actual_length - 1)) { | |
466 | - tty_insert_flip_string(tty, data+1, urb->actual_length - 1); | |
467 | - tty_flip_buffer_push(tty); | |
468 | - } | |
465 | + tty_insert_flip_string(tty, data+1, urb->actual_length - 1); | |
466 | + tty_flip_buffer_push(tty); | |
469 | 467 | tty_kref_put(tty); |
470 | 468 | |
471 | 469 | /* |
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/kobil_sct.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
... | ... | @@ -764,7 +764,6 @@ |
764 | 764 | if (urb->actual_length) { |
765 | 765 | tty = tty_port_tty_get(&mos7840_port->port->port); |
766 | 766 | if (tty) { |
767 | - tty_buffer_request_room(tty, urb->actual_length); | |
768 | 767 | tty_insert_flip_string(tty, data, urb->actual_length); |
769 | 768 | dbg(" %s ", data); |
770 | 769 | tty_flip_buffer_push(tty); |
drivers/usb/serial/navman.c
drivers/usb/serial/opticon.c
... | ... | @@ -55,7 +55,6 @@ |
55 | 55 | int status = urb->status; |
56 | 56 | struct tty_struct *tty; |
57 | 57 | int result; |
58 | - int available_room = 0; | |
59 | 58 | int data_length; |
60 | 59 | |
61 | 60 | dbg("%s - port %d", __func__, port->number); |
... | ... | @@ -96,13 +95,9 @@ |
96 | 95 | /* real data, send it to the tty layer */ |
97 | 96 | tty = tty_port_tty_get(&port->port); |
98 | 97 | if (tty) { |
99 | - available_room = tty_buffer_request_room(tty, | |
100 | - data_length); | |
101 | - if (available_room) { | |
102 | - tty_insert_flip_string(tty, data, | |
103 | - available_room); | |
104 | - tty_flip_buffer_push(tty); | |
105 | - } | |
98 | + tty_insert_flip_string(tty, data, | |
99 | + data_length); | |
100 | + tty_flip_buffer_push(tty); | |
106 | 101 | tty_kref_put(tty); |
107 | 102 | } |
108 | 103 | } else { |
drivers/usb/serial/option.c
drivers/usb/serial/pl2303.c
... | ... | @@ -1042,7 +1042,6 @@ |
1042 | 1042 | tty_flag = TTY_FRAME; |
1043 | 1043 | dbg("%s - tty_flag = %d", __func__, tty_flag); |
1044 | 1044 | |
1045 | - tty_buffer_request_room(tty, urb->actual_length + 1); | |
1046 | 1045 | /* overrun is special, not associated with a char */ |
1047 | 1046 | if (line_status & UART_OVERRUN_ERROR) |
1048 | 1047 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
drivers/usb/serial/sierra.c
drivers/usb/serial/spcp8x5.c
... | ... | @@ -677,7 +677,6 @@ |
677 | 677 | struct tty_struct *tty; |
678 | 678 | unsigned char *data = urb->transfer_buffer; |
679 | 679 | unsigned long flags; |
680 | - int i; | |
681 | 680 | int result = urb->status; |
682 | 681 | u8 status; |
683 | 682 | char tty_flag; |
684 | 683 | |
... | ... | @@ -726,12 +725,11 @@ |
726 | 725 | |
727 | 726 | tty = tty_port_tty_get(&port->port); |
728 | 727 | if (tty && urb->actual_length) { |
729 | - tty_buffer_request_room(tty, urb->actual_length + 1); | |
730 | 728 | /* overrun is special, not associated with a char */ |
731 | 729 | if (status & UART_OVERRUN_ERROR) |
732 | 730 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); |
733 | - for (i = 0; i < urb->actual_length; ++i) | |
734 | - tty_insert_flip_char(tty, data[i], tty_flag); | |
731 | + tty_insert_flip_string_fixed_flag(tty, data, | |
732 | + urb->actual_length, tty_flag); | |
735 | 733 | tty_flip_buffer_push(tty); |
736 | 734 | } |
737 | 735 | tty_kref_put(tty); |
drivers/usb/serial/symbolserial.c
... | ... | @@ -51,7 +51,6 @@ |
51 | 51 | int status = urb->status; |
52 | 52 | struct tty_struct *tty; |
53 | 53 | int result; |
54 | - int available_room = 0; | |
55 | 54 | int data_length; |
56 | 55 | |
57 | 56 | dbg("%s - port %d", __func__, port->number); |
... | ... | @@ -89,13 +88,8 @@ |
89 | 88 | */ |
90 | 89 | tty = tty_port_tty_get(&port->port); |
91 | 90 | if (tty) { |
92 | - available_room = tty_buffer_request_room(tty, | |
93 | - data_length); | |
94 | - if (available_room) { | |
95 | - tty_insert_flip_string(tty, &data[1], | |
96 | - available_room); | |
97 | - tty_flip_buffer_push(tty); | |
98 | - } | |
91 | + tty_insert_flip_string(tty, &data[1], data_length); | |
92 | + tty_flip_buffer_push(tty); | |
99 | 93 | tty_kref_put(tty); |
100 | 94 | } |
101 | 95 | } else { |
drivers/usb/serial/ti_usb_3410_5052.c
... | ... | @@ -1271,14 +1271,13 @@ |
1271 | 1271 | int cnt; |
1272 | 1272 | |
1273 | 1273 | do { |
1274 | - cnt = tty_buffer_request_room(tty, length); | |
1274 | + cnt = tty_insert_flip_string(tty, data, length); | |
1275 | 1275 | if (cnt < length) { |
1276 | 1276 | dev_err(dev, "%s - dropping data, %d bytes lost\n", |
1277 | 1277 | __func__, length - cnt); |
1278 | 1278 | if (cnt == 0) |
1279 | 1279 | break; |
1280 | 1280 | } |
1281 | - tty_insert_flip_string(tty, data, cnt); | |
1282 | 1281 | tty_flip_buffer_push(tty); |
1283 | 1282 | data += cnt; |
1284 | 1283 | length -= cnt; |
drivers/usb/serial/visor.c
... | ... | @@ -503,13 +503,9 @@ |
503 | 503 | if (urb->actual_length) { |
504 | 504 | tty = tty_port_tty_get(&port->port); |
505 | 505 | if (tty) { |
506 | - available_room = tty_buffer_request_room(tty, | |
507 | - urb->actual_length); | |
508 | - if (available_room) { | |
509 | - tty_insert_flip_string(tty, data, | |
510 | - available_room); | |
511 | - tty_flip_buffer_push(tty); | |
512 | - } | |
506 | + tty_insert_flip_string(tty, data, | |
507 | + urb->actual_length); | |
508 | + tty_flip_buffer_push(tty); | |
513 | 509 | tty_kref_put(tty); |
514 | 510 | } |
515 | 511 | spin_lock(&priv->lock); |