Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

TTY: switch tty_schedule_flip

Now, we start converting tty buffer functions to actually use
tty_port. This will allow us to get rid of the need of tty in many
call sites. Only tty_port will needed and hence no more
tty_port_tty_get in those paths.

This is the last one: tty_schedule_flip

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
6732c8bb 2e124b4a

+51 -100
+8 -9
arch/alpha/kernel/srmcons.c
··· 44 44 45 45 /* called with callback_lock held */ 46 46 static int 47 - srmcons_do_receive_chars(struct tty_struct *tty) 47 + srmcons_do_receive_chars(struct tty_port *port) 48 48 { 49 - struct tty_port *port = tty->port; 50 49 srmcons_result result; 51 50 int count = 0, loops = 0; 52 51 ··· 58 59 } while((result.bits.status & 1) && (++loops < 10)); 59 60 60 61 if (count) 61 - tty_schedule_flip(tty); 62 + tty_schedule_flip(port); 62 63 63 64 return count; 64 65 } ··· 73 74 74 75 local_irq_save(flags); 75 76 if (spin_trylock(&srmcons_callback_lock)) { 76 - if (!srmcons_do_receive_chars(port->tty)) 77 + if (!srmcons_do_receive_chars(port)) 77 78 incr = 100; 78 79 spin_unlock(&srmcons_callback_lock); 79 80 } ··· 88 89 89 90 /* called with callback_lock held */ 90 91 static int 91 - srmcons_do_write(struct tty_struct *tty, const char *buf, int count) 92 + srmcons_do_write(struct tty_port *port, const char *buf, int count) 92 93 { 93 94 static char str_cr[1] = "\r"; 94 95 long c, remaining = count; ··· 113 114 cur += result.bits.c; 114 115 115 116 /* 116 - * Check for pending input iff a tty was provided 117 + * Check for pending input iff a tty port was provided 117 118 */ 118 - if (tty) 119 - srmcons_do_receive_chars(tty); 119 + if (port) 120 + srmcons_do_receive_chars(port); 120 121 } 121 122 122 123 while (need_cr) { ··· 135 136 unsigned long flags; 136 137 137 138 spin_lock_irqsave(&srmcons_callback_lock, flags); 138 - srmcons_do_write(tty, (const char *) buf, count); 139 + srmcons_do_write(tty->port, (const char *) buf, count); 139 140 spin_unlock_irqrestore(&srmcons_callback_lock, flags); 140 141 141 142 return count;
+2 -10
drivers/s390/char/keyboard.h
··· 43 43 static inline void 44 44 kbd_put_queue(struct tty_port *port, int ch) 45 45 { 46 - struct tty_struct *tty = tty_port_tty_get(port); 47 - if (!tty) 48 - return; 49 46 tty_insert_flip_char(port, ch, 0); 50 - tty_schedule_flip(tty); 51 - tty_kref_put(tty); 47 + tty_schedule_flip(port); 52 48 } 53 49 54 50 static inline void 55 51 kbd_puts_queue(struct tty_port *port, char *cp) 56 52 { 57 - struct tty_struct *tty = tty_port_tty_get(port); 58 - if (!tty) 59 - return; 60 53 while (*cp) 61 54 tty_insert_flip_char(port, *cp++, 0); 62 - tty_schedule_flip(tty); 63 - tty_kref_put(tty); 55 + tty_schedule_flip(port); 64 56 }
+6 -13
drivers/staging/serqt_usb2/serqt_usb2.c
··· 356 356 struct usb_serial_port *port = urb->context; 357 357 struct usb_serial *serial = get_usb_serial(port, __func__); 358 358 struct quatech_port *qt_port = qt_get_port_private(port); 359 - struct tty_struct *tty; 360 359 int result; 361 360 362 361 if (urb->status) { ··· 366 367 return; 367 368 } 368 369 369 - tty = tty_port_tty_get(&port->port); 370 - if (!tty) 371 - return; 372 - 373 370 dev_dbg(&port->dev, 374 371 "%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding); 375 372 376 373 if (port_paranoia_check(port, __func__) != 0) { 377 374 qt_port->ReadBulkStopped = 1; 378 - goto exit; 375 + return; 379 376 } 380 377 381 378 if (!serial) 382 - goto exit; 379 + return; 383 380 384 381 if (qt_port->closePending == 1) { 385 382 /* Were closing , stop reading */ 386 383 dev_dbg(&port->dev, 387 384 "%s - (qt_port->closepending == 1\n", __func__); 388 385 qt_port->ReadBulkStopped = 1; 389 - goto exit; 386 + return; 390 387 } 391 388 392 389 /* ··· 392 397 */ 393 398 if (qt_port->RxHolding == 1) { 394 399 qt_port->ReadBulkStopped = 1; 395 - goto exit; 400 + return; 396 401 } 397 402 398 403 if (urb->status) { ··· 401 406 dev_dbg(&port->dev, 402 407 "%s - nonzero read bulk status received: %d\n", 403 408 __func__, urb->status); 404 - goto exit; 409 + return; 405 410 } 406 411 407 412 if (urb->actual_length) ··· 422 427 else { 423 428 if (urb->actual_length) { 424 429 tty_flip_buffer_push(&port->port); 425 - tty_schedule_flip(tty); 430 + tty_schedule_flip(&port->port); 426 431 } 427 432 } 428 433 429 434 schedule_work(&port->work); 430 - exit: 431 - tty_kref_put(tty); 432 435 } 433 436 434 437 /*
+12 -21
drivers/tty/cyclades.c
··· 441 441 void __iomem *base_addr) 442 442 { 443 443 struct cyclades_port *info; 444 - struct tty_struct *tty; 445 444 struct tty_port *port; 446 445 int len, index = cinfo->bus_index; 447 446 u8 ivr, save_xir, channel, save_car, data, char_count; ··· 457 458 cyy_writeb(info, CyCAR, save_xir); 458 459 ivr = cyy_readb(info, CyRIVR) & CyIVRMask; 459 460 460 - tty = tty_port_tty_get(port); 461 - /* if there is nowhere to put the data, discard it */ 462 - if (tty == NULL) { 463 - if (ivr == CyIVRRxEx) { /* exception */ 464 - data = cyy_readb(info, CyRDSR); 465 - } else { /* normal character reception */ 466 - char_count = cyy_readb(info, CyRDCR); 467 - while (char_count--) 468 - data = cyy_readb(info, CyRDSR); 469 - } 470 - goto end; 471 - } 472 461 /* there is an open port for this data */ 473 462 if (ivr == CyIVRRxEx) { /* exception */ 474 463 data = cyy_readb(info, CyRDSR); ··· 473 486 474 487 if (data & info->ignore_status_mask) { 475 488 info->icount.rx++; 476 - tty_kref_put(tty); 477 489 return; 478 490 } 479 491 if (tty_buffer_request_room(port, 1)) { ··· 482 496 cyy_readb(info, CyRDSR), 483 497 TTY_BREAK); 484 498 info->icount.rx++; 485 - if (port->flags & ASYNC_SAK) 486 - do_SAK(tty); 499 + if (port->flags & ASYNC_SAK) { 500 + struct tty_struct *tty = 501 + tty_port_tty_get(port); 502 + if (tty) { 503 + do_SAK(tty); 504 + tty_kref_put(tty); 505 + } 506 + } 487 507 } else if (data & CyFRAME) { 488 508 tty_insert_flip_char(port, 489 509 cyy_readb(info, CyRDSR), ··· 558 566 } 559 567 info->idle_stats.recv_idle = jiffies; 560 568 } 561 - tty_schedule_flip(tty); 562 - tty_kref_put(tty); 563 - end: 569 + tty_schedule_flip(port); 570 + 564 571 /* end of service */ 565 572 cyy_writeb(info, CyRIR, save_xir & 0x3f); 566 573 cyy_writeb(info, CyCAR, save_car); ··· 1003 1012 jiffies + 1); 1004 1013 #endif 1005 1014 info->idle_stats.recv_idle = jiffies; 1006 - tty_schedule_flip(tty); 1015 + tty_schedule_flip(&info->port); 1007 1016 } 1008 1017 /* Update rx_get */ 1009 1018 cy_writel(&buf_ctrl->rx_get, new_rx_get); ··· 1182 1191 if (delta_count) 1183 1192 wake_up_interruptible(&info->port.delta_msr_wait); 1184 1193 if (special_count) 1185 - tty_schedule_flip(tty); 1194 + tty_schedule_flip(&info->port); 1186 1195 tty_kref_put(tty); 1187 1196 } 1188 1197 }
+2 -2
drivers/tty/moxa.c
··· 1405 1405 if (inited && !test_bit(TTY_THROTTLED, &tty->flags) && 1406 1406 MoxaPortRxQueue(p) > 0) { /* RX */ 1407 1407 MoxaPortReadData(p); 1408 - tty_schedule_flip(tty); 1408 + tty_schedule_flip(&p->port); 1409 1409 } 1410 1410 } else { 1411 1411 clear_bit(EMPTYWAIT, &p->statusflags); ··· 1430 1430 1431 1431 if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */ 1432 1432 tty_insert_flip_char(&p->port, 0, TTY_BREAK); 1433 - tty_schedule_flip(tty); 1433 + tty_schedule_flip(&p->port); 1434 1434 } 1435 1435 1436 1436 if (intr & IntrLine)
+4 -11
drivers/tty/serial/68328serial.c
··· 262 262 local_irq_restore(flags); 263 263 } 264 264 265 - static void receive_chars(struct m68k_serial *info, struct tty_struct *tty, 266 - unsigned short rx) 265 + static void receive_chars(struct m68k_serial *info, unsigned short rx) 267 266 { 268 267 m68328_uart *uart = &uart_addr[info->line]; 269 268 unsigned char ch, flag; ··· 292 293 } 293 294 } 294 295 295 - if(!tty) 296 - goto clear_and_exit; 297 - 298 296 flag = TTY_NORMAL; 299 297 300 298 if (rx & URX_PARITY_ERROR) ··· 306 310 } while((rx = uart->urx.w) & URX_DATA_READY); 307 311 #endif 308 312 309 - tty_schedule_flip(tty); 310 - 311 - clear_and_exit: 312 - return; 313 + tty_schedule_flip(&info->tport); 313 314 } 314 315 315 316 static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty) ··· 360 367 tx = uart->utx.w; 361 368 362 369 if (rx & URX_DATA_READY) 363 - receive_chars(info, tty, rx); 370 + receive_chars(info, rx); 364 371 if (tx & UTX_TX_AVAIL) 365 372 transmit_chars(info, tty); 366 373 #else 367 - receive_chars(info, tty, rx); 374 + receive_chars(info, rx); 368 375 #endif 369 376 tty_kref_put(tty); 370 377
+1 -5
drivers/tty/serial/lpc32xx_hs.c
··· 323 323 { 324 324 struct uart_port *port = dev_id; 325 325 struct tty_port *port = &port->state->port; 326 - struct tty_struct *tty = tty_port_tty_get(tport); 327 326 u32 status; 328 327 329 328 spin_lock(&port->lock); ··· 347 348 LPC32XX_HSUART_IIR(port->membase)); 348 349 port->icount.overrun++; 349 350 tty_insert_flip_char(tport, 0, TTY_OVERRUN); 350 - if (tty) { 351 - tty_schedule_flip(tty); 352 - } 351 + tty_schedule_flip(tport); 353 352 } 354 353 355 354 /* Data received? */ ··· 363 366 } 364 367 365 368 spin_unlock(&port->lock); 366 - tty_kref_put(tty); 367 369 368 370 return IRQ_HANDLED; 369 371 }
+4 -4
drivers/tty/tty_buffer.c
··· 349 349 350 350 /** 351 351 * tty_schedule_flip - push characters to ldisc 352 - * @tty: tty to push from 352 + * @port: tty port to push from 353 353 * 354 354 * Takes any pending buffers and transfers their ownership to the 355 355 * ldisc side of the queue. It then schedules those characters for ··· 360 360 * Locking: Takes port->buf.lock 361 361 */ 362 362 363 - void tty_schedule_flip(struct tty_struct *tty) 363 + void tty_schedule_flip(struct tty_port *port) 364 364 { 365 - struct tty_bufhead *buf = &tty->port->buf; 365 + struct tty_bufhead *buf = &port->buf; 366 366 unsigned long flags; 367 - WARN_ON(tty->port->low_latency); 367 + WARN_ON(port->low_latency); 368 368 369 369 spin_lock_irqsave(&buf->lock, flags); 370 370 if (buf->tail != NULL)
+3 -16
drivers/tty/vt/keyboard.c
··· 307 307 */ 308 308 static void put_queue(struct vc_data *vc, int ch) 309 309 { 310 - struct tty_struct *tty = vc->port.tty; 311 - 312 310 tty_insert_flip_char(&vc->port, ch, 0); 313 - if (tty) { 314 - tty_schedule_flip(tty); 315 - } 311 + tty_schedule_flip(&vc->port); 316 312 } 317 313 318 314 static void puts_queue(struct vc_data *vc, char *cp) 319 315 { 320 - struct tty_struct *tty = vc->port.tty; 321 - 322 - if (!tty) 323 - return; 324 - 325 316 while (*cp) { 326 317 tty_insert_flip_char(&vc->port, *cp, 0); 327 318 cp++; 328 319 } 329 - tty_schedule_flip(tty); 320 + tty_schedule_flip(&vc->port); 330 321 } 331 322 332 323 static void applkey(struct vc_data *vc, int key, char mode) ··· 573 582 574 583 static void fn_send_intr(struct vc_data *vc) 575 584 { 576 - struct tty_struct *tty = vc->port.tty; 577 - 578 - if (!tty) 579 - return; 580 585 tty_insert_flip_char(&vc->port, 0, TTY_BREAK); 581 - tty_schedule_flip(tty); 586 + tty_schedule_flip(&vc->port); 582 587 } 583 588 584 589 static void fn_scroll_forw(struct vc_data *vc)
+8 -8
drivers/tty/vt/vt.c
··· 1333 1333 update_attr(vc); 1334 1334 } 1335 1335 1336 - static void respond_string(const char *p, struct tty_struct *tty) 1336 + static void respond_string(const char *p, struct tty_port *port) 1337 1337 { 1338 1338 while (*p) { 1339 - tty_insert_flip_char(tty->port, *p, 0); 1339 + tty_insert_flip_char(port, *p, 0); 1340 1340 p++; 1341 1341 } 1342 - tty_schedule_flip(tty); 1342 + tty_schedule_flip(port); 1343 1343 } 1344 1344 1345 1345 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) ··· 1347 1347 char buf[40]; 1348 1348 1349 1349 sprintf(buf, "\033[%d;%dR", vc->vc_y + (vc->vc_decom ? vc->vc_top + 1 : 1), vc->vc_x + 1); 1350 - respond_string(buf, tty); 1350 + respond_string(buf, tty->port); 1351 1351 } 1352 1352 1353 1353 static inline void status_report(struct tty_struct *tty) 1354 1354 { 1355 - respond_string("\033[0n", tty); /* Terminal ok */ 1355 + respond_string("\033[0n", tty->port); /* Terminal ok */ 1356 1356 } 1357 1357 1358 - static inline void respond_ID(struct tty_struct * tty) 1358 + static inline void respond_ID(struct tty_struct *tty) 1359 1359 { 1360 - respond_string(VT102ID, tty); 1360 + respond_string(VT102ID, tty->port); 1361 1361 } 1362 1362 1363 1363 void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry) ··· 1366 1366 1367 1367 sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx), 1368 1368 (char)('!' + mry)); 1369 - respond_string(buf, tty); 1369 + respond_string(buf, tty->port); 1370 1370 } 1371 1371 1372 1372 /* invoked via ioctl(TIOCLINUX) and through set_selection */
+1 -1
include/linux/tty_flip.h
··· 11 11 extern int tty_prepare_flip_string_flags(struct tty_port *port, 12 12 unsigned char **chars, char **flags, size_t size); 13 13 extern void tty_flip_buffer_push(struct tty_port *port); 14 - void tty_schedule_flip(struct tty_struct *tty); 14 + void tty_schedule_flip(struct tty_port *port); 15 15 16 16 static inline int tty_insert_flip_char(struct tty_port *port, 17 17 unsigned char ch, char flag)