Commit a108bfcb372d8c4452701039308fb95747911c59

Authored by Alan Cox
Committed by Greg Kroah-Hartman
1 parent 2832fc11f1

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
... ... @@ -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
... ... @@ -395,7 +395,6 @@
395 395 return;
396 396 }
397 397 if (urb->actual_length) {
398   - tty_buffer_request_room(tty, urb->actual_length);
399 398 tty_insert_flip_string(tty, data, urb->actual_length);
400 399 tty_flip_buffer_push(tty);
401 400 }
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
... ... @@ -271,7 +271,6 @@
271 271 usb_serial_debug_data(debug, &port->dev,
272 272 __func__, actual_length, data);
273 273  
274   - tty_buffer_request_room(tty, actual_length);
275 274 tty_insert_flip_string(tty, data, actual_length);
276 275 tty_flip_buffer_push(tty);
277 276 }
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
... ... @@ -1820,7 +1820,6 @@
1820 1820 {
1821 1821 int queued;
1822 1822  
1823   - tty_buffer_request_room(tty, length);
1824 1823 queued = tty_insert_flip_string(tty, data, length);
1825 1824 if (queued < length)
1826 1825 dev_err(dev, "%s - dropping data, %d bytes lost\n",
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
... ... @@ -172,7 +172,6 @@
172 172  
173 173 tty = tty_port_tty_get(&port->port);
174 174 if (tty && urb->actual_length) {
175   - tty_buffer_request_room(tty, urb->actual_length);
176 175 tty_insert_flip_string(tty, data, urb->actual_length);
177 176 tty_flip_buffer_push(tty);
178 177 }
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
... ... @@ -699,7 +699,6 @@
699 699 bytes_sent = urb->actual_length - 2;
700 700 }
701 701  
702   - tty_buffer_request_room(tty, bytes_sent);
703 702 tty_insert_flip_string(tty, data + 2, bytes_sent);
704 703 tty_flip_buffer_push(tty);
705 704 tty_kref_put(tty);
drivers/usb/serial/kobil_sct.c
... ... @@ -388,7 +388,6 @@
388 388 */
389 389 /* END DEBUG */
390 390  
391   - tty_buffer_request_room(tty, urb->actual_length);
392 391 tty_insert_flip_string(tty, data, urb->actual_length);
393 392 tty_flip_buffer_push(tty);
394 393 }
drivers/usb/serial/mos7720.c
... ... @@ -290,7 +290,6 @@
290 290  
291 291 tty = tty_port_tty_get(&port->port);
292 292 if (tty && urb->actual_length) {
293   - tty_buffer_request_room(tty, urb->actual_length);
294 293 tty_insert_flip_string(tty, data, urb->actual_length);
295 294 tty_flip_buffer_push(tty);
296 295 }
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
... ... @@ -66,7 +66,6 @@
66 66  
67 67 tty = tty_port_tty_get(&port->port);
68 68 if (tty && urb->actual_length) {
69   - tty_buffer_request_room(tty, urb->actual_length);
70 69 tty_insert_flip_string(tty, data, urb->actual_length);
71 70 tty_flip_buffer_push(tty);
72 71 }
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
... ... @@ -964,7 +964,6 @@
964 964 } else {
965 965 tty = tty_port_tty_get(&port->port);
966 966 if (urb->actual_length) {
967   - tty_buffer_request_room(tty, urb->actual_length);
968 967 tty_insert_flip_string(tty, data, urb->actual_length);
969 968 tty_flip_buffer_push(tty);
970 969 } else
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
... ... @@ -595,8 +595,6 @@
595 595 if (urb->actual_length) {
596 596 tty = tty_port_tty_get(&port->port);
597 597 if (tty) {
598   - tty_buffer_request_room(tty,
599   - urb->actual_length);
600 598 tty_insert_flip_string(tty, data,
601 599 urb->actual_length);
602 600 tty_flip_buffer_push(tty);
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);