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

TTY: switch tty_flip_buffer_push

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.

Now, the one where most of tty_port_tty_get gets removed:
tty_flip_buffer_push.

IOW we also closed all the races in drivers not using tty_port_tty_get
at all yet.

Also we move tty_flip_buffer_push declaration from include/linux/tty.h
to include/linux/tty_flip.h to all others while we are changing it
anyway.

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
2e124b4a d6c53c0e

+446 -988
+4 -14
arch/ia64/hp/sim/simserial.c
··· 53 53 54 54 static struct console *console; 55 55 56 - static void receive_chars(struct tty_struct *tty) 56 + static void receive_chars(struct tty_port *port) 57 57 { 58 - struct tty_port *port = tty->port; 59 58 unsigned char ch; 60 59 static unsigned char seen_esc = 0; 61 60 ··· 84 85 if (tty_insert_flip_char(port, ch, TTY_NORMAL) == 0) 85 86 break; 86 87 } 87 - tty_flip_buffer_push(tty); 88 + tty_flip_buffer_push(port); 88 89 } 89 90 90 91 /* ··· 93 94 static irqreturn_t rs_interrupt_single(int irq, void *dev_id) 94 95 { 95 96 struct serial_state *info = dev_id; 96 - struct tty_struct *tty = tty_port_tty_get(&info->port); 97 97 98 - if (!tty) { 99 - printk(KERN_INFO "%s: tty=0 problem\n", __func__); 100 - return IRQ_NONE; 101 - } 102 - /* 103 - * pretty simple in our case, because we only get interrupts 104 - * on inbound traffic 105 - */ 106 - receive_chars(tty); 107 - tty_kref_put(tty); 98 + receive_chars(&info->port); 99 + 108 100 return IRQ_HANDLED; 109 101 } 110 102
+3 -4
arch/mn10300/kernel/mn10300-serial.c
··· 525 525 { 526 526 struct uart_icount *icount = &port->uart.icount; 527 527 struct tty_port *port = &port->uart.state->port; 528 - struct tty_struct *tty = port->tty; 529 528 unsigned ix; 530 529 int count; 531 530 u8 st, ch, push, status, overrun; ··· 537 538 count = tty_buffer_request_room(port, count); 538 539 if (count == 0) { 539 540 if (!port->low_latency) 540 - tty_flip_buffer_push(tty); 541 + tty_flip_buffer_push(port); 541 542 return; 542 543 } 543 544 ··· 546 547 ix = ACCESS_ONCE(port->rx_outp); 547 548 if (CIRC_CNT(port->rx_inp, ix, MNSC_BUFFER_SIZE) == 0) { 548 549 if (push && !port->low_latency) 549 - tty_flip_buffer_push(tty); 550 + tty_flip_buffer_push(port); 550 551 return; 551 552 } 552 553 ··· 678 679 count--; 679 680 if (count <= 0) { 680 681 if (!port->low_latency) 681 - tty_flip_buffer_push(tty); 682 + tty_flip_buffer_push(port); 682 683 return; 683 684 } 684 685
+1 -7
arch/parisc/kernel/pdc_cons.c
··· 138 138 static void pdc_console_poll(unsigned long unused) 139 139 { 140 140 int data, count = 0; 141 - struct tty_struct *tty = tty_port_tty_get(&tty_port); 142 - 143 - if (!tty) 144 - return; 145 141 146 142 while (1) { 147 143 data = pdc_console_poll_key(NULL); ··· 148 152 } 149 153 150 154 if (count) 151 - tty_flip_buffer_push(tty); 152 - 153 - tty_kref_put(tty); 155 + tty_flip_buffer_push(&tty_port); 154 156 155 157 if (pdc_cons.flags & CON_ENABLED) 156 158 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
+1 -2
arch/um/drivers/chan.h
··· 27 27 void *data; 28 28 }; 29 29 30 - extern void chan_interrupt(struct line *line, 31 - struct tty_struct *tty, int irq); 30 + extern void chan_interrupt(struct line *line, int irq); 32 31 extern int parse_chan_pair(char *str, struct line *line, int device, 33 32 const struct chan_opts *opts, char **error_out); 34 33 extern int write_chan(struct chan *chan, const char *buf, int len,
+7 -7
arch/um/drivers/chan_kern.c
··· 131 131 static void line_timer_cb(struct work_struct *work) 132 132 { 133 133 struct line *line = container_of(work, struct line, task.work); 134 - struct tty_struct *tty = tty_port_tty_get(&line->port); 135 134 136 135 if (!line->throttled) 137 - chan_interrupt(line, tty, line->driver->read_irq); 138 - tty_kref_put(tty); 136 + chan_interrupt(line, line->driver->read_irq); 139 137 } 140 138 141 139 int enable_chan(struct line *line) ··· 544 546 return 0; 545 547 } 546 548 547 - void chan_interrupt(struct line *line, struct tty_struct *tty, int irq) 549 + void chan_interrupt(struct line *line, int irq) 548 550 { 549 551 struct tty_port *port = &line->port; 550 552 struct chan *chan = line->chan_in; ··· 568 570 reactivate_fd(chan->fd, irq); 569 571 if (err == -EIO) { 570 572 if (chan->primary) { 571 - if (tty != NULL) 573 + struct tty_struct *tty = tty_port_tty_get(&line->port); 574 + if (tty != NULL) { 572 575 tty_hangup(tty); 576 + tty_kref_put(tty); 577 + } 573 578 if (line->chan_out != chan) 574 579 close_one_chan(line->chan_out, 1); 575 580 } ··· 581 580 return; 582 581 } 583 582 out: 584 - if (tty) 585 - tty_flip_buffer_push(tty); 583 + tty_flip_buffer_push(port); 586 584 }
+3 -4
arch/um/drivers/line.c
··· 19 19 { 20 20 struct chan *chan = data; 21 21 struct line *line = chan->line; 22 - struct tty_struct *tty = tty_port_tty_get(&line->port); 23 22 24 23 if (line) 25 - chan_interrupt(line, tty, irq); 26 - tty_kref_put(tty); 24 + chan_interrupt(line, irq); 25 + 27 26 return IRQ_HANDLED; 28 27 } 29 28 ··· 233 234 struct line *line = tty->driver_data; 234 235 235 236 line->throttled = 0; 236 - chan_interrupt(line, tty, line->driver->read_irq); 237 + chan_interrupt(line, line->driver->read_irq); 237 238 238 239 /* 239 240 * Maybe there is enough stuff pending that calling the interrupt
+4 -5
arch/xtensa/platforms/iss/console.c
··· 58 58 tty->port = &serial_port; 59 59 spin_lock(&timer_lock); 60 60 if (tty->count == 1) { 61 - setup_timer(&serial_timer, rs_poll, (unsigned long)tty); 61 + setup_timer(&serial_timer, rs_poll, 62 + (unsigned long)&serial_port); 62 63 mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); 63 64 } 64 65 spin_unlock(&timer_lock); ··· 98 97 99 98 static void rs_poll(unsigned long priv) 100 99 { 101 - struct tty_struct* tty = (struct tty_struct*) priv; 102 - struct tty_port *port = tty->port; 103 - 100 + struct tty_port *port = (struct tty_port *)priv; 104 101 struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; 105 102 int i = 0; 106 103 unsigned char c; ··· 112 113 } 113 114 114 115 if (i) 115 - tty_flip_buffer_push(tty); 116 + tty_flip_buffer_push(port); 116 117 117 118 118 119 mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
+4 -10
drivers/ipack/devices/ipoctal.c
··· 133 133 return 0; 134 134 } 135 135 136 - static void ipoctal_irq_rx(struct ipoctal_channel *channel, 137 - struct tty_struct *tty, u8 sr) 136 + static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr) 138 137 { 139 138 struct tty_port *port = &channel->tty_port; 140 139 unsigned char value; ··· 175 176 sr = ioread8(&channel->regs->r.sr); 176 177 } while (isr & channel->isr_rx_rdy_mask); 177 178 178 - tty_flip_buffer_push(tty); 179 + tty_flip_buffer_push(port); 179 180 } 180 181 181 182 static void ipoctal_irq_tx(struct ipoctal_channel *channel) ··· 208 209 static void ipoctal_irq_channel(struct ipoctal_channel *channel) 209 210 { 210 211 u8 isr, sr; 211 - struct tty_struct *tty; 212 212 213 213 /* If there is no client, skip the check */ 214 214 if (!atomic_read(&channel->open)) 215 215 return; 216 216 217 - tty = tty_port_tty_get(&channel->tty_port); 218 - if (!tty) 219 - return; 220 217 /* The HW is organized in pair of channels. See which register we need 221 218 * to read from */ 222 219 isr = ioread8(&channel->block_regs->r.isr); ··· 231 236 232 237 /* RX data */ 233 238 if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY)) 234 - ipoctal_irq_rx(channel, tty, sr); 239 + ipoctal_irq_rx(channel, sr); 235 240 236 241 /* TX of each character */ 237 242 if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY)) 238 243 ipoctal_irq_tx(channel); 239 244 240 - tty_flip_buffer_push(tty); 241 - tty_kref_put(tty); 245 + tty_flip_buffer_push(&channel->tty_port); 242 246 } 243 247 244 248 static irqreturn_t ipoctal_irq_handler(void *arg)
+1 -9
drivers/isdn/gigaset/interface.c
··· 562 562 void gigaset_if_receive(struct cardstate *cs, 563 563 unsigned char *buffer, size_t len) 564 564 { 565 - struct tty_struct *tty = tty_port_tty_get(&cs->port); 566 - 567 - if (tty == NULL) { 568 - gig_dbg(DEBUG_IF, "receive on closed device"); 569 - return; 570 - } 571 - 572 565 tty_insert_flip_string(&cs->port, buffer, len); 573 - tty_flip_buffer_push(tty); 574 - tty_kref_put(tty); 566 + tty_flip_buffer_push(&cs->port); 575 567 } 576 568 EXPORT_SYMBOL_GPL(gigaset_if_receive); 577 569
+16 -23
drivers/isdn/i4l/isdn_tty.c
··· 63 63 struct tty_port *port = &info->port; 64 64 int c; 65 65 int len; 66 - struct tty_struct *tty; 67 66 char last; 68 67 69 68 if (!info->online) 70 - return 0; 71 - 72 - tty = port->tty; 73 - if (!tty) 74 69 return 0; 75 70 76 71 if (!(info->mcr & UART_MCR_RTS)) ··· 105 110 tty_insert_flip_char(port, last, 0xFF); 106 111 else 107 112 tty_insert_flip_char(port, last, TTY_NORMAL); 108 - tty_flip_buffer_push(tty); 113 + tty_flip_buffer_push(port); 109 114 kfree_skb(skb); 110 115 111 116 return 1; ··· 122 127 int midx; 123 128 int i; 124 129 int r; 125 - struct tty_struct *tty; 126 130 modem_info *info; 127 131 128 132 for (i = 0; i < ISDN_MAX_CHANNELS; i++) { ··· 139 145 if ((info->vonline & 1) && (info->emu.vpar[1])) 140 146 isdn_audio_eval_silence(info); 141 147 #endif 142 - tty = info->port.tty; 143 - if (tty) { 144 - if (info->mcr & UART_MCR_RTS) { 145 - /* CISCO AsyncPPP Hack */ 146 - if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) 147 - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 0); 148 - else 149 - r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 1); 150 - if (r) 151 - tty_flip_buffer_push(tty); 152 - } else 153 - r = 1; 148 + if (info->mcr & UART_MCR_RTS) { 149 + /* CISCO AsyncPPP Hack */ 150 + if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) 151 + r = isdn_readbchan_tty(info->isdn_driver, 152 + info->isdn_channel, 153 + &info->port, 0); 154 + else 155 + r = isdn_readbchan_tty(info->isdn_driver, 156 + info->isdn_channel, 157 + &info->port, 1); 158 + if (r) 159 + tty_flip_buffer_push(&info->port); 154 160 } else 155 161 r = 1; 162 + 156 163 if (r) { 157 164 info->rcvsched = 0; 158 165 resched = 1; ··· 2225 2230 void 2226 2231 isdn_tty_at_cout(char *msg, modem_info *info) 2227 2232 { 2228 - struct tty_struct *tty; 2229 2233 struct tty_port *port = &info->port; 2230 2234 atemu *m = &info->emu; 2231 2235 char *p; ··· 2242 2248 l = strlen(msg); 2243 2249 2244 2250 spin_lock_irqsave(&info->readlock, flags); 2245 - tty = port->tty; 2246 - if ((port->flags & ASYNC_CLOSING) || (!tty)) { 2251 + if (port->flags & ASYNC_CLOSING) { 2247 2252 spin_unlock_irqrestore(&info->readlock, flags); 2248 2253 return; 2249 2254 } ··· 2294 2301 2295 2302 } else { 2296 2303 spin_unlock_irqrestore(&info->readlock, flags); 2297 - tty_flip_buffer_push(tty); 2304 + tty_flip_buffer_push(port); 2298 2305 } 2299 2306 } 2300 2307
+4 -10
drivers/mmc/card/sdio_uart.c
··· 381 381 static void sdio_uart_receive_chars(struct sdio_uart_port *port, 382 382 unsigned int *status) 383 383 { 384 - struct tty_struct *tty = tty_port_tty_get(&port->port); 385 384 unsigned int ch, flag; 386 385 int max_count = 256; 387 386 ··· 417 418 } 418 419 419 420 if ((*status & port->ignore_status_mask & ~UART_LSR_OE) == 0) 420 - if (tty) 421 - tty_insert_flip_char(&port->port, ch, flag); 421 + tty_insert_flip_char(&port->port, ch, flag); 422 422 423 423 /* 424 424 * Overrun is special. Since it's reported immediately, 425 425 * it doesn't affect the current character. 426 426 */ 427 427 if (*status & ~port->ignore_status_mask & UART_LSR_OE) 428 - if (tty) 429 - tty_insert_flip_char(&port->port, 0, 430 - TTY_OVERRUN); 428 + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 431 429 432 430 *status = sdio_in(port, UART_LSR); 433 431 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 434 - if (tty) { 435 - tty_flip_buffer_push(tty); 436 - tty_kref_put(tty); 437 - } 432 + 433 + tty_flip_buffer_push(&port->port); 438 434 } 439 435 440 436 static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
+15 -16
drivers/net/usb/hso.c
··· 2035 2035 tty = tty_port_tty_get(&serial->port); 2036 2036 2037 2037 /* Push data to tty */ 2038 - if (tty) { 2039 - write_length_remaining = urb->actual_length - 2040 - serial->curr_rx_urb_offset; 2041 - D1("data to push to tty"); 2042 - while (write_length_remaining) { 2043 - if (test_bit(TTY_THROTTLED, &tty->flags)) { 2044 - tty_kref_put(tty); 2045 - return -1; 2046 - } 2047 - curr_write_len = tty_insert_flip_string(&serial->port, 2048 - urb->transfer_buffer + serial->curr_rx_urb_offset, 2049 - write_length_remaining); 2050 - serial->curr_rx_urb_offset += curr_write_len; 2051 - write_length_remaining -= curr_write_len; 2052 - tty_flip_buffer_push(tty); 2038 + write_length_remaining = urb->actual_length - 2039 + serial->curr_rx_urb_offset; 2040 + D1("data to push to tty"); 2041 + while (write_length_remaining) { 2042 + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { 2043 + tty_kref_put(tty); 2044 + return -1; 2053 2045 } 2054 - tty_kref_put(tty); 2046 + curr_write_len = tty_insert_flip_string(&serial->port, 2047 + urb->transfer_buffer + serial->curr_rx_urb_offset, 2048 + write_length_remaining); 2049 + serial->curr_rx_urb_offset += curr_write_len; 2050 + write_length_remaining -= curr_write_len; 2051 + tty_flip_buffer_push(&serial->port); 2055 2052 } 2053 + tty_kref_put(tty); 2054 + 2056 2055 if (write_length_remaining == 0) { 2057 2056 serial->curr_rx_urb_offset = 0; 2058 2057 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0;
+2 -2
drivers/s390/char/con3215.c
··· 413 413 case CTRLCHAR_CTRL: 414 414 tty_insert_flip_char(&raw->port, cchar, 415 415 TTY_NORMAL); 416 - tty_flip_buffer_push(tty); 416 + tty_flip_buffer_push(&raw->port); 417 417 break; 418 418 419 419 case CTRLCHAR_NONE: ··· 427 427 count -= 2; 428 428 tty_insert_flip_string(&raw->port, raw->inbuf, 429 429 count); 430 - tty_flip_buffer_push(tty); 430 + tty_flip_buffer_push(&raw->port); 431 431 break; 432 432 } 433 433 } else if (req->type == RAW3215_WRITE) {
+2 -2
drivers/s390/char/sclp_tty.c
··· 343 343 break; 344 344 case CTRLCHAR_CTRL: 345 345 tty_insert_flip_char(&sclp_port, cchar, TTY_NORMAL); 346 - tty_flip_buffer_push(tty); 346 + tty_flip_buffer_push(&sclp_port); 347 347 break; 348 348 case CTRLCHAR_NONE: 349 349 /* send (normal) input to line discipline */ ··· 355 355 tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL); 356 356 } else 357 357 tty_insert_flip_string(&sclp_port, buf, count - 2); 358 - tty_flip_buffer_push(tty); 358 + tty_flip_buffer_push(&sclp_port); 359 359 break; 360 360 } 361 361 tty_kref_put(tty);
+1 -7
drivers/s390/char/sclp_vt220.c
··· 461 461 static void 462 462 sclp_vt220_receiver_fn(struct evbuf_header *evbuf) 463 463 { 464 - struct tty_struct *tty = tty_port_tty_get(&sclp_vt220_port); 465 464 char *buffer; 466 465 unsigned int count; 467 - 468 - /* Ignore input if device is not open */ 469 - if (tty == NULL) 470 - return; 471 466 472 467 buffer = (char *) ((addr_t) evbuf + sizeof(struct evbuf_header)); 473 468 count = evbuf->length - sizeof(struct evbuf_header); ··· 476 481 buffer++; 477 482 count--; 478 483 tty_insert_flip_string(&sclp_vt220_port, buffer, count); 479 - tty_flip_buffer_push(tty); 484 + tty_flip_buffer_push(&sclp_vt220_port); 480 485 break; 481 486 } 482 - tty_kref_put(tty); 483 487 } 484 488 485 489 /*
+3 -8
drivers/staging/ccg/u_serial.c
··· 491 491 492 492 req = list_first_entry(queue, struct usb_request, list); 493 493 494 - /* discard data if tty was closed */ 495 - if (!tty) 496 - goto recycle; 497 - 498 494 /* leave data queued if tty was rx throttled */ 499 - if (test_bit(TTY_THROTTLED, &tty->flags)) 495 + if (tty && test_bit(TTY_THROTTLED, &tty->flags)) 500 496 break; 501 497 502 498 switch (req->status) { ··· 538 542 } 539 543 port->n_read = 0; 540 544 } 541 - recycle: 542 545 list_move(&req->list, &port->read_pool); 543 546 port->read_started--; 544 547 } ··· 545 550 /* Push from tty to ldisc; without low_latency set this is handled by 546 551 * a workqueue, so we won't get callbacks and can hold port_lock 547 552 */ 548 - if (tty && do_push) 549 - tty_flip_buffer_push(tty); 553 + if (do_push) 554 + tty_flip_buffer_push(&port->port); 550 555 551 556 552 557 /* We want our data queue to become empty ASAP, keeping data
+2 -2
drivers/staging/dgrp/dgrp_net_ops.c
··· 234 234 235 235 tty_insert_flip_string_flags(&ch->port, myflipbuf, 236 236 myflipflagbuf, len); 237 - tty_flip_buffer_push(tty); 237 + tty_flip_buffer_push(&ch->port); 238 238 239 239 ch->ch_rxcount += len; 240 240 } ··· 2958 2958 2959 2959 tty_buffer_request_room(&ch->port, 1); 2960 2960 tty_insert_flip_char(&ch->port, 0, TTY_BREAK); 2961 - tty_flip_buffer_push(ch->ch_tun.un_tty); 2961 + tty_flip_buffer_push(&ch->port); 2962 2962 2963 2963 } 2964 2964
+15 -26
drivers/staging/fwserial/fwserial.c
··· 489 489 static void fwtty_emit_breaks(struct work_struct *work) 490 490 { 491 491 struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); 492 - struct tty_struct *tty; 493 492 static const char buf[16]; 494 493 unsigned long now = jiffies; 495 494 unsigned long elapsed = now - port->break_last; 496 495 int n, t, c, brk = 0; 497 - 498 - tty = tty_port_tty_get(&port->port); 499 - if (!tty) 500 - return; 501 496 502 497 /* generate breaks at the line rate (but at least 1) */ 503 498 n = (elapsed * port->cps) / HZ + 1; ··· 509 514 if (c < t) 510 515 break; 511 516 } 512 - tty_flip_buffer_push(tty); 513 - 514 - tty_kref_put(tty); 517 + tty_flip_buffer_push(&port->port); 515 518 516 519 if (port->mstatus & (UART_LSR_BI << 24)) 517 520 schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); ··· 523 530 struct buffered_rx *buf, *next; 524 531 int n, c = 0; 525 532 526 - tty = tty_port_tty_get(&port->port); 527 - if (!tty) 528 - return; 529 - 530 533 spin_lock_bh(&port->lock); 531 534 list_for_each_entry_safe(buf, next, &port->buf_list, list) { 532 535 n = tty_insert_flip_string_fixed_flag(&port->port, buf->data, ··· 534 545 memmove(buf->data, buf->data + n, buf->n - n); 535 546 buf->n -= n; 536 547 } 537 - __fwtty_throttle(port, tty); 548 + tty = tty_port_tty_get(&port->port); 549 + if (tty) { 550 + __fwtty_throttle(port, tty); 551 + tty_kref_put(tty); 552 + } 538 553 break; 539 554 } else { 540 555 list_del(&buf->list); ··· 546 553 } 547 554 } 548 555 if (c > 0) 549 - tty_flip_buffer_push(tty); 556 + tty_flip_buffer_push(&port->port); 550 557 551 558 if (list_empty(&port->buf_list)) 552 559 clear_bit(BUFFERING_RX, &port->flags); 553 560 spin_unlock_bh(&port->lock); 554 - 555 - tty_kref_put(tty); 556 561 } 557 562 558 563 static int fwtty_buffer_rx(struct fwtty_port *port, unsigned char *d, size_t n) ··· 584 593 int c, n = len; 585 594 unsigned lsr; 586 595 int err = 0; 587 - 588 - tty = tty_port_tty_get(&port->port); 589 - if (!tty) 590 - return -ENOENT; 591 596 592 597 fwtty_dbg(port, "%d", n); 593 598 profile_size_distrib(port->stats.reads, n); ··· 621 634 c = tty_insert_flip_string_fixed_flag(&port->port, data, 622 635 TTY_NORMAL, n); 623 636 if (c > 0) 624 - tty_flip_buffer_push(tty); 637 + tty_flip_buffer_push(&port->port); 625 638 n -= c; 626 639 627 640 if (n) { 628 641 /* start buffering and throttling */ 629 642 n -= fwtty_buffer_rx(port, &data[c], n); 630 643 631 - spin_lock_bh(&port->lock); 632 - __fwtty_throttle(port, tty); 633 - spin_unlock_bh(&port->lock); 644 + tty = tty_port_tty_get(&port->port); 645 + if (tty) { 646 + spin_lock_bh(&port->lock); 647 + __fwtty_throttle(port, tty); 648 + spin_unlock_bh(&port->lock); 649 + tty_kref_put(tty); 650 + } 634 651 } 635 652 } else 636 653 n -= fwtty_buffer_rx(port, data, n); ··· 645 654 } 646 655 647 656 out: 648 - tty_kref_put(tty); 649 - 650 657 port->icount.rx += len; 651 658 port->stats.lost += n; 652 659 return err;
+4 -5
drivers/staging/serqt_usb2/serqt_usb2.c
··· 290 290 /* FIXME */ 291 291 } 292 292 293 - static void qt_status_change_check(struct tty_struct *tty, 294 - struct urb *urb, 293 + static void qt_status_change_check(struct urb *urb, 295 294 struct quatech_port *qt_port, 296 295 struct usb_serial_port *port) 297 296 { ··· 347 348 tty_insert_flip_char(&port->port, data[i], TTY_NORMAL); 348 349 349 350 } 350 - tty_flip_buffer_push(tty); 351 + tty_flip_buffer_push(&port->port); 351 352 } 352 353 353 354 static void qt_read_bulk_callback(struct urb *urb) ··· 410 411 } 411 412 412 413 if (urb->actual_length) 413 - qt_status_change_check(tty, urb, qt_port, port); 414 + qt_status_change_check(urb, qt_port, port); 414 415 415 416 /* Continue trying to always read */ 416 417 usb_fill_bulk_urb(port->read_urb, serial->dev, ··· 426 427 __func__, result); 427 428 else { 428 429 if (urb->actual_length) { 429 - tty_flip_buffer_push(tty); 430 + tty_flip_buffer_push(&port->port); 430 431 tty_schedule_flip(tty); 431 432 } 432 433 }
+2 -3
drivers/tty/amiserial.c
··· 251 251 { 252 252 int status; 253 253 int serdatr; 254 - struct tty_struct *tty = info->tport.tty; 255 254 unsigned char ch, flag; 256 255 struct async_icount *icount; 257 256 int oe = 0; ··· 313 314 #endif 314 315 flag = TTY_BREAK; 315 316 if (info->tport.flags & ASYNC_SAK) 316 - do_SAK(tty); 317 + do_SAK(info->tport.tty); 317 318 } else if (status & UART_LSR_PE) 318 319 flag = TTY_PARITY; 319 320 else if (status & UART_LSR_FE) ··· 330 331 tty_insert_flip_char(&info->tport, ch, flag); 331 332 if (oe == 1) 332 333 tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); 333 - tty_flip_buffer_push(tty); 334 + tty_flip_buffer_push(&info->tport); 334 335 out: 335 336 return; 336 337 }
+10 -12
drivers/tty/bfin_jtag_comm.c
··· 95 95 96 96 /* if incoming data is ready, eat it */ 97 97 if (bfin_read_DBGSTAT() & EMUDIF) { 98 - if (tty != NULL) { 99 - uint32_t emudat = bfin_read_emudat(); 100 - if (inbound_len == 0) { 101 - pr_debug("incoming length: 0x%08x\n", emudat); 102 - inbound_len = emudat; 103 - } else { 104 - size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); 105 - pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); 106 - inbound_len -= num_chars; 107 - tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); 108 - tty_flip_buffer_push(tty); 109 - } 98 + uint32_t emudat = bfin_read_emudat(); 99 + if (inbound_len == 0) { 100 + pr_debug("incoming length: 0x%08x\n", emudat); 101 + inbound_len = emudat; 102 + } else { 103 + size_t num_chars = (4 <= inbound_len ? 4 : inbound_len); 104 + pr_debug(" incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars); 105 + inbound_len -= num_chars; 106 + tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars); 107 + tty_flip_buffer_push(&port); 110 108 } 111 109 } 112 110
+1 -8
drivers/tty/ehv_bytechan.c
··· 371 371 static irqreturn_t ehv_bc_tty_rx_isr(int irq, void *data) 372 372 { 373 373 struct ehv_bc_data *bc = data; 374 - struct tty_struct *ttys = tty_port_tty_get(&bc->port); 375 374 unsigned int rx_count, tx_count, len; 376 375 int count; 377 376 char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; 378 377 int ret; 379 - 380 - /* ttys could be NULL during a hangup */ 381 - if (!ttys) 382 - return IRQ_HANDLED; 383 378 384 379 /* Find out how much data needs to be read, and then ask the TTY layer 385 380 * if it can handle that much. We want to ensure that every byte we ··· 417 422 } 418 423 419 424 /* Tell the tty layer that we're done. */ 420 - tty_flip_buffer_push(ttys); 421 - 422 - tty_kref_put(ttys); 425 + tty_flip_buffer_push(&bc->port); 423 426 424 427 return IRQ_HANDLED; 425 428 }
+1 -1
drivers/tty/hvc/hvc_console.c
··· 691 691 a minimum for performance. */ 692 692 timeout = MIN_TIMEOUT; 693 693 694 - tty_flip_buffer_push(tty); 694 + tty_flip_buffer_push(&hp->port); 695 695 } 696 696 tty_kref_put(tty); 697 697
+1 -1
drivers/tty/hvc/hvcs.c
··· 623 623 spin_unlock_irqrestore(&hvcsd->lock, flags); 624 624 /* This is synch because tty->low_latency == 1 */ 625 625 if(got) 626 - tty_flip_buffer_push(tty); 626 + tty_flip_buffer_push(&hvcsd->port); 627 627 628 628 if (!got) { 629 629 /* Do this _after_ the flip_buffer_push */
+3 -3
drivers/tty/hvc/hvsi.c
··· 465 465 compact_inbuf(hp, packet); 466 466 467 467 if (flip) 468 - tty_flip_buffer_push(tty); 468 + tty_flip_buffer_push(&hp->port); 469 469 470 470 return 1; 471 471 } ··· 511 511 /* we weren't hung up and we weren't throttled, so we can 512 512 * deliver the rest now */ 513 513 hvsi_send_overflow(hp); 514 - tty_flip_buffer_push(tty); 514 + tty_flip_buffer_push(&hp->port); 515 515 } 516 516 spin_unlock_irqrestore(&hp->lock, flags); 517 517 ··· 998 998 spin_lock_irqsave(&hp->lock, flags); 999 999 if (hp->n_throttle) { 1000 1000 hvsi_send_overflow(hp); 1001 - tty_flip_buffer_push(tty); 1001 + tty_flip_buffer_push(&hp->port); 1002 1002 } 1003 1003 spin_unlock_irqrestore(&hp->lock, flags); 1004 1004
+1 -7
drivers/tty/ipwireless/tty.c
··· 160 160 void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, 161 161 unsigned int length) 162 162 { 163 - struct tty_struct *linux_tty; 164 163 int work = 0; 165 164 166 165 mutex_lock(&tty->ipw_tty_mutex); 167 - linux_tty = tty->port.tty; 168 - if (linux_tty == NULL) { 169 - mutex_unlock(&tty->ipw_tty_mutex); 170 - return; 171 - } 172 166 173 167 if (!tty->port.count) { 174 168 mutex_unlock(&tty->ipw_tty_mutex); ··· 181 187 * This may sleep if ->low_latency is set 182 188 */ 183 189 if (work) 184 - tty_flip_buffer_push(linux_tty); 190 + tty_flip_buffer_push(&tty->port); 185 191 } 186 192 187 193 static void ipw_write_packet_sent_callback(void *callback_data,
+2 -2
drivers/tty/isicom.c
··· 637 637 tty_insert_flip_char(&port->port, 0, TTY_BREAK); 638 638 if (port->port.flags & ASYNC_SAK) 639 639 do_SAK(tty); 640 - tty_flip_buffer_push(tty); 640 + tty_flip_buffer_push(&port->port); 641 641 break; 642 642 643 643 case 2: /* Statistics */ ··· 671 671 byte_count -= 2; 672 672 } 673 673 } 674 - tty_flip_buffer_push(tty); 674 + tty_flip_buffer_push(&port->port); 675 675 } 676 676 outw(0x0000, base+0x04); /* enable interrupts */ 677 677 spin_unlock(&card->card_lock);
+1 -1
drivers/tty/mxser.c
··· 2145 2145 * recursive locking. 2146 2146 */ 2147 2147 spin_unlock(&port->slock); 2148 - tty_flip_buffer_push(tty); 2148 + tty_flip_buffer_push(&port->port); 2149 2149 spin_lock(&port->slock); 2150 2150 } 2151 2151
+28 -32
drivers/tty/n_gsm.c
··· 1141 1141 static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen) 1142 1142 { 1143 1143 struct tty_port *port; 1144 - struct tty_struct *tty; 1145 1144 unsigned int addr = 0 ; 1146 1145 u8 bits; 1147 1146 int len = clen; ··· 1173 1174 if (bits & 8) 1174 1175 tty_insert_flip_char(port, 0, TTY_FRAME); 1175 1176 1176 - /* See if we have an uplink tty */ 1177 - tty = tty_port_tty_get(port); 1178 - if (tty) { 1179 - tty_flip_buffer_push(tty); 1180 - tty_kref_put(tty); 1181 - } 1177 + tty_flip_buffer_push(port); 1178 + 1182 1179 gsm_control_reply(gsm, CMD_RLS, data, clen); 1183 1180 } 1184 1181 ··· 1547 1552 { 1548 1553 /* krefs .. */ 1549 1554 struct tty_port *port = &dlci->port; 1550 - struct tty_struct *tty = tty_port_tty_get(port); 1555 + struct tty_struct *tty; 1551 1556 unsigned int modem = 0; 1552 1557 int len = clen; 1553 1558 1554 1559 if (debug & 16) 1555 - pr_debug("%d bytes for tty %p\n", len, tty); 1556 - if (tty) { 1557 - switch (dlci->adaption) { 1558 - /* Unsupported types */ 1559 - /* Packetised interruptible data */ 1560 - case 4: 1561 - break; 1562 - /* Packetised uininterruptible voice/data */ 1563 - case 3: 1564 - break; 1565 - /* Asynchronous serial with line state in each frame */ 1566 - case 2: 1567 - while (gsm_read_ea(&modem, *data++) == 0) { 1568 - len--; 1569 - if (len == 0) 1570 - return; 1571 - } 1572 - gsm_process_modem(tty, dlci, modem, clen); 1573 - /* Line state will go via DLCI 0 controls only */ 1574 - case 1: 1575 - default: 1576 - tty_insert_flip_string(port, data, len); 1577 - tty_flip_buffer_push(tty); 1560 + pr_debug("%d bytes for tty\n", len); 1561 + switch (dlci->adaption) { 1562 + /* Unsupported types */ 1563 + /* Packetised interruptible data */ 1564 + case 4: 1565 + break; 1566 + /* Packetised uininterruptible voice/data */ 1567 + case 3: 1568 + break; 1569 + /* Asynchronous serial with line state in each frame */ 1570 + case 2: 1571 + while (gsm_read_ea(&modem, *data++) == 0) { 1572 + len--; 1573 + if (len == 0) 1574 + return; 1578 1575 } 1579 - tty_kref_put(tty); 1576 + tty = tty_port_tty_get(port); 1577 + if (tty) { 1578 + gsm_process_modem(tty, dlci, modem, clen); 1579 + tty_kref_put(tty); 1580 + } 1581 + /* Line state will go via DLCI 0 controls only */ 1582 + case 1: 1583 + default: 1584 + tty_insert_flip_string(port, data, len); 1585 + tty_flip_buffer_push(port); 1580 1586 } 1581 1587 } 1582 1588
+5 -9
drivers/tty/nozomi.c
··· 1272 1272 1273 1273 exit_handler: 1274 1274 spin_unlock(&dc->spin_mutex); 1275 - for (a = 0; a < NOZOMI_MAX_PORTS; a++) { 1276 - struct tty_struct *tty; 1277 - if (test_and_clear_bit(a, &dc->flip)) { 1278 - tty = tty_port_tty_get(&dc->port[a].port); 1279 - if (tty) 1280 - tty_flip_buffer_push(tty); 1281 - tty_kref_put(tty); 1282 - } 1283 - } 1275 + 1276 + for (a = 0; a < NOZOMI_MAX_PORTS; a++) 1277 + if (test_and_clear_bit(a, &dc->flip)) 1278 + tty_flip_buffer_push(&dc->port[a].port); 1279 + 1284 1280 return IRQ_HANDLED; 1285 1281 none: 1286 1282 spin_unlock(&dc->spin_mutex);
+1 -1
drivers/tty/pty.c
··· 123 123 c = tty_insert_flip_string(to->port, buf, c); 124 124 /* And shovel */ 125 125 if (c) { 126 - tty_flip_buffer_push(to); 126 + tty_flip_buffer_push(to->port); 127 127 tty_wakeup(tty); 128 128 } 129 129 }
+11 -14
drivers/tty/rocket.c
··· 315 315 * that receive data is present on a serial port. Pulls data from FIFO, moves it into the 316 316 * tty layer. 317 317 */ 318 - static void rp_do_receive(struct r_port *info, 319 - struct tty_struct *tty, 320 - CHANNEL_t * cp, unsigned int ChanStatus) 318 + static void rp_do_receive(struct r_port *info, CHANNEL_t *cp, 319 + unsigned int ChanStatus) 321 320 { 322 321 unsigned int CharNStat; 323 322 int ToRecv, wRecv, space; ··· 415 416 cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); 416 417 } 417 418 /* Push the data up to the tty layer */ 418 - tty_flip_buffer_push(tty); 419 + tty_flip_buffer_push(&info->port); 419 420 } 420 421 421 422 /* ··· 494 495 static void rp_handle_port(struct r_port *info) 495 496 { 496 497 CHANNEL_t *cp; 497 - struct tty_struct *tty; 498 498 unsigned int IntMask, ChanStatus; 499 499 500 500 if (!info) ··· 504 506 "info->flags & NOT_INIT\n"); 505 507 return; 506 508 } 507 - tty = tty_port_tty_get(&info->port); 508 - if (!tty) { 509 - printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " 510 - "tty==NULL\n"); 511 - return; 512 - } 509 + 513 510 cp = &info->channel; 514 511 515 512 IntMask = sGetChanIntID(cp) & info->intmask; ··· 513 520 #endif 514 521 ChanStatus = sGetChanStatus(cp); 515 522 if (IntMask & RXF_TRIG) { /* Rx FIFO trigger level */ 516 - rp_do_receive(info, tty, cp, ChanStatus); 523 + rp_do_receive(info, cp, ChanStatus); 517 524 } 518 525 if (IntMask & DELTA_CD) { /* CD change */ 519 526 #if (defined(ROCKET_DEBUG_OPEN) || defined(ROCKET_DEBUG_INTR) || defined(ROCKET_DEBUG_HANGUP)) ··· 521 528 (ChanStatus & CD_ACT) ? "on" : "off"); 522 529 #endif 523 530 if (!(ChanStatus & CD_ACT) && info->cd_status) { 531 + struct tty_struct *tty; 524 532 #ifdef ROCKET_DEBUG_HANGUP 525 533 printk(KERN_INFO "CD drop, calling hangup.\n"); 526 534 #endif 527 - tty_hangup(tty); 535 + tty = tty_port_tty_get(&info->port); 536 + if (tty) { 537 + tty_hangup(tty); 538 + tty_kref_put(tty); 539 + } 528 540 } 529 541 info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; 530 542 wake_up_interruptible(&info->port.open_wait); ··· 542 544 printk(KERN_INFO "DSR change...\n"); 543 545 } 544 546 #endif 545 - tty_kref_put(tty); 546 547 } 547 548 548 549 /*
+1 -2
drivers/tty/serial/21285.c
··· 85 85 static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) 86 86 { 87 87 struct uart_port *port = dev_id; 88 - struct tty_struct *tty = port->state->port.tty; 89 88 unsigned int status, ch, flag, rxs, max_count = 256; 90 89 91 90 status = *CSR_UARTFLG; ··· 114 115 115 116 status = *CSR_UARTFLG; 116 117 } 117 - tty_flip_buffer_push(tty); 118 + tty_flip_buffer_push(&port->state->port); 118 119 119 120 return IRQ_HANDLED; 120 121 }
+1 -2
drivers/tty/serial/8250/8250.c
··· 1323 1323 serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) 1324 1324 { 1325 1325 struct uart_port *port = &up->port; 1326 - struct tty_struct *tty = port->state->port.tty; 1327 1326 unsigned char ch; 1328 1327 int max_count = 256; 1329 1328 char flag; ··· 1387 1388 lsr = serial_in(up, UART_LSR); 1388 1389 } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); 1389 1390 spin_unlock(&port->lock); 1390 - tty_flip_buffer_push(tty); 1391 + tty_flip_buffer_push(&port->state->port); 1391 1392 spin_lock(&port->lock); 1392 1393 return lsr; 1393 1394 }
+1 -1
drivers/tty/serial/altera_jtaguart.c
··· 139 139 uart_insert_char(port, 0, 0, ch, flag); 140 140 } 141 141 142 - tty_flip_buffer_push(port->state->port.tty); 142 + tty_flip_buffer_push(&port->state->port); 143 143 } 144 144 145 145 static void altera_jtaguart_tx_chars(struct altera_jtaguart *pp)
+1 -1
drivers/tty/serial/altera_uart.c
··· 231 231 flag); 232 232 } 233 233 234 - tty_flip_buffer_push(port->state->port.tty); 234 + tty_flip_buffer_push(&port->state->port); 235 235 } 236 236 237 237 static void altera_uart_tx_chars(struct altera_uart *pp)
+1 -2
drivers/tty/serial/amba-pl010.c
··· 116 116 117 117 static void pl010_rx_chars(struct uart_amba_port *uap) 118 118 { 119 - struct tty_struct *tty = uap->port.state->port.tty; 120 119 unsigned int status, ch, flag, rsr, max_count = 256; 121 120 122 121 status = readb(uap->port.membase + UART01x_FR); ··· 164 165 status = readb(uap->port.membase + UART01x_FR); 165 166 } 166 167 spin_unlock(&uap->port.lock); 167 - tty_flip_buffer_push(tty); 168 + tty_flip_buffer_push(&uap->port.state->port); 168 169 spin_lock(&uap->port.lock); 169 170 } 170 171
+2 -5
drivers/tty/serial/amba-pl011.c
··· 699 699 bool readfifo) 700 700 { 701 701 struct tty_port *port = &uap->port.state->port; 702 - struct tty_struct *tty = port->tty; 703 702 struct pl011_sgbuf *sgbuf = use_buf_b ? 704 703 &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; 705 704 struct device *dev = uap->dmarx.chan->device->dev; ··· 753 754 dev_vdbg(uap->port.dev, 754 755 "Took %d chars from DMA buffer and %d chars from the FIFO\n", 755 756 dma_count, fifotaken); 756 - tty_flip_buffer_push(tty); 757 + tty_flip_buffer_push(port); 757 758 spin_lock(&uap->port.lock); 758 759 } 759 760 ··· 1075 1076 1076 1077 static void pl011_rx_chars(struct uart_amba_port *uap) 1077 1078 { 1078 - struct tty_struct *tty = uap->port.state->port.tty; 1079 - 1080 1079 pl011_fifo_to_tty(uap); 1081 1080 1082 1081 spin_unlock(&uap->port.lock); 1083 - tty_flip_buffer_push(tty); 1082 + tty_flip_buffer_push(&uap->port.state->port); 1084 1083 /* 1085 1084 * If we were temporarily out of DMA mode for a while, 1086 1085 * attempt to switch back to DMA mode again.
+1 -2
drivers/tty/serial/apbuart.c
··· 78 78 79 79 static void apbuart_rx_chars(struct uart_port *port) 80 80 { 81 - struct tty_struct *tty = port->state->port.tty; 82 81 unsigned int status, ch, rsr, flag; 83 82 unsigned int max_chars = port->fifosize; 84 83 ··· 125 126 status = UART_GET_STATUS(port); 126 127 } 127 128 128 - tty_flip_buffer_push(tty); 129 + tty_flip_buffer_push(&port->state->port); 129 130 } 130 131 131 132 static void apbuart_tx_chars(struct uart_port *port)
+1 -6
drivers/tty/serial/ar933x_uart.c
··· 298 298 static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) 299 299 { 300 300 struct tty_port *port = &up->port.state->port; 301 - struct tty_struct *tty; 302 301 int max_count = 256; 303 302 304 - tty = tty_port_tty_get(port); 305 303 do { 306 304 unsigned int rdata; 307 305 unsigned char ch; ··· 322 324 tty_insert_flip_char(port, ch, TTY_NORMAL); 323 325 } while (max_count-- > 0); 324 326 325 - if (tty) { 326 - tty_flip_buffer_push(tty); 327 - tty_kref_put(tty); 328 - } 327 + tty_flip_buffer_push(port); 329 328 } 330 329 331 330 static void ar933x_uart_tx_chars(struct ar933x_uart_port *up)
+1 -7
drivers/tty/serial/arc_uart.c
··· 211 211 212 212 static void arc_serial_rx_chars(struct arc_uart_port *uart) 213 213 { 214 - struct tty_struct *tty = tty_port_tty_get(&uart->port.state->port); 215 214 unsigned int status, ch, flg = 0; 216 - 217 - if (!tty) 218 - return; 219 215 220 216 /* 221 217 * UART has 4 deep RX-FIFO. Driver's recongnition of this fact ··· 248 252 uart_insert_char(&uart->port, status, RXOERR, ch, flg); 249 253 250 254 done: 251 - tty_flip_buffer_push(tty); 255 + tty_flip_buffer_push(&uart->port.state->port); 252 256 } 253 - 254 - tty_kref_put(tty); 255 257 } 256 258 257 259 /*
+2 -3
drivers/tty/serial/atmel_serial.c
··· 774 774 * uart_start(), which takes the lock. 775 775 */ 776 776 spin_unlock(&port->lock); 777 - tty_flip_buffer_push(port->state->port.tty); 777 + tty_flip_buffer_push(&port->state->port); 778 778 spin_lock(&port->lock); 779 779 } 780 780 ··· 782 782 { 783 783 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 784 784 struct tty_port *tport = &port->state->port; 785 - struct tty_struct *tty = tport->tty; 786 785 struct atmel_dma_buffer *pdc; 787 786 int rx_idx = atmel_port->pdc_rx_idx; 788 787 unsigned int head; ··· 849 850 * uart_start(), which takes the lock. 850 851 */ 851 852 spin_unlock(&port->lock); 852 - tty_flip_buffer_push(tty); 853 + tty_flip_buffer_push(tport); 853 854 spin_lock(&port->lock); 854 855 855 856 UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT);
+1 -3
drivers/tty/serial/bcm63xx_uart.c
··· 236 236 static void bcm_uart_do_rx(struct uart_port *port) 237 237 { 238 238 struct tty_port *port = &port->state->port; 239 - struct tty_struct *tty; 240 239 unsigned int max_count; 241 240 242 241 /* limit number of char read in interrupt, should not be 243 242 * higher than fifo size anyway since we're much faster than 244 243 * serial port */ 245 244 max_count = 32; 246 - tty = port->tty; 247 245 do { 248 246 unsigned int iestat, c, cstat; 249 247 char flag; ··· 303 305 304 306 } while (--max_count); 305 307 306 - tty_flip_buffer_push(tty); 308 + tty_flip_buffer_push(port); 307 309 } 308 310 309 311 /*
+2 -2
drivers/tty/serial/bfin_sport_uart.c
··· 150 150 { 151 151 struct sport_uart_port *up = dev_id; 152 152 struct tty_port *port = &up->port.state->port; 153 - struct tty_struct *tty = tport->tty; 154 153 unsigned int ch; 155 154 156 155 spin_lock(&up->port.lock); ··· 161 162 if (!uart_handle_sysrq_char(&up->port, ch)) 162 163 tty_insert_flip_char(port, ch, TTY_NORMAL); 163 164 } 164 - tty_flip_buffer_push(tty); 165 + /* XXX this won't deadlock with lowlat? */ 166 + tty_flip_buffer_push(port); 165 167 166 168 spin_unlock(&up->port.lock); 167 169
+3 -7
drivers/tty/serial/bfin_uart.c
··· 223 223 #ifdef CONFIG_SERIAL_BFIN_PIO 224 224 static void bfin_serial_rx_chars(struct bfin_serial_port *uart) 225 225 { 226 - struct tty_struct *tty = NULL; 227 226 unsigned int status, ch, flg; 228 227 static struct timeval anomaly_start = { .tv_sec = 0 }; 229 228 ··· 241 242 return; 242 243 } 243 244 244 - if (!uart->port.state || !uart->port.state->port.tty) 245 + if (!uart->port.state) 245 246 return; 246 247 #endif 247 - tty = uart->port.state->port.tty; 248 - 249 248 if (ANOMALY_05000363) { 250 249 /* The BF533 (and BF561) family of processors have a nice anomaly 251 250 * where they continuously generate characters for a "single" break. ··· 322 325 uart_insert_char(&uart->port, status, OE, ch, flg); 323 326 324 327 ignore_char: 325 - tty_flip_buffer_push(tty); 328 + tty_flip_buffer_push(&uart->port.state->port); 326 329 } 327 330 328 331 static void bfin_serial_tx_chars(struct bfin_serial_port *uart) ··· 423 426 424 427 static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) 425 428 { 426 - struct tty_struct *tty = uart->port.state->port.tty; 427 429 int i, flg, status; 428 430 429 431 status = UART_GET_LSR(uart); ··· 467 471 } 468 472 469 473 dma_ignore_char: 470 - tty_flip_buffer_push(tty); 474 + tty_flip_buffer_push(&uart->port.state->port); 471 475 } 472 476 473 477 void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
+1 -7
drivers/tty/serial/clps711x.c
··· 85 85 static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id) 86 86 { 87 87 struct uart_port *port = dev_id; 88 - struct tty_struct *tty = tty_port_tty_get(&port->state->port); 89 88 unsigned int status, ch, flg; 90 - 91 - if (!tty) 92 - return IRQ_HANDLED; 93 89 94 90 for (;;) { 95 91 status = clps_readl(SYSFLG(port)); ··· 126 130 uart_insert_char(port, status, UARTDR_OVERR, ch, flg); 127 131 } 128 132 129 - tty_flip_buffer_push(tty); 130 - 131 - tty_kref_put(tty); 133 + tty_flip_buffer_push(&port->state->port); 132 134 133 135 return IRQ_HANDLED; 134 136 }
+1 -2
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 246 246 unsigned char ch; 247 247 u8 *cp; 248 248 struct tty_port *tport = &port->state->port; 249 - struct tty_struct *tty = tport->tty; 250 249 struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 251 250 cbd_t __iomem *bdp; 252 251 u16 status; ··· 322 323 pinfo->rx_cur = bdp; 323 324 324 325 /* activate BH processing */ 325 - tty_flip_buffer_push(tty); 326 + tty_flip_buffer_push(tport); 326 327 327 328 return; 328 329
+2 -15
drivers/tty/serial/crisv10.c
··· 2104 2104 2105 2105 static void flush_to_flip_buffer(struct e100_serial *info) 2106 2106 { 2107 - struct tty_struct *tty; 2108 2107 struct etrax_recv_buffer *buffer; 2109 2108 unsigned long flags; 2110 2109 2111 2110 local_irq_save(flags); 2112 - tty = info->port.tty; 2113 - 2114 - if (!tty) { 2115 - local_irq_restore(flags); 2116 - return; 2117 - } 2118 2111 2119 2112 while ((buffer = info->first_recv_buffer) != NULL) { 2120 2113 unsigned int count = buffer->length; ··· 2131 2138 local_irq_restore(flags); 2132 2139 2133 2140 /* This includes a check for low-latency */ 2134 - tty_flip_buffer_push(tty); 2141 + tty_flip_buffer_push(&info->port); 2135 2142 } 2136 2143 2137 2144 static void check_flush_timeout(struct e100_serial *info) ··· 2267 2274 struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) 2268 2275 { 2269 2276 unsigned long data_read; 2270 - struct tty_struct *tty = info->port.tty; 2271 - 2272 - if (!tty) { 2273 - printk("!NO TTY!\n"); 2274 - return info; 2275 - } 2276 2277 2277 2278 /* Read data and status at the same time */ 2278 2279 data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); ··· 2369 2382 goto more_data; 2370 2383 } 2371 2384 2372 - tty_flip_buffer_push(info->port.tty); 2385 + tty_flip_buffer_push(&info->port); 2373 2386 return info; 2374 2387 } 2375 2388
+1 -3
drivers/tty/serial/dz.c
··· 187 187 { 188 188 struct uart_port *uport; 189 189 struct dz_port *dport = &mux->dport[0]; 190 - struct tty_struct *tty = NULL; 191 190 struct uart_icount *icount; 192 191 int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; 193 192 unsigned char ch, flag; ··· 196 197 while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) { 197 198 dport = &mux->dport[LINE(status)]; 198 199 uport = &dport->port; 199 - tty = uport->state->port.tty; /* point to the proper dev */ 200 200 201 201 ch = UCHAR(status); /* grab the char */ 202 202 flag = TTY_NORMAL; ··· 247 249 } 248 250 for (i = 0; i < DZ_NB_PORT; i++) 249 251 if (lines_rx[i]) 250 - tty_flip_buffer_push(mux->dport[i].port.state->port.tty); 252 + tty_flip_buffer_push(&mux->dport[i].port.state->port); 251 253 } 252 254 253 255 /*
+1 -7
drivers/tty/serial/efm32-uart.c
··· 249 249 int handled = IRQ_NONE; 250 250 struct uart_port *port = &efm_port->port; 251 251 struct tty_port *tport = &port->state->port; 252 - struct tty_struct *tty; 253 252 254 253 spin_lock(&port->lock); 255 - 256 - tty = tty_kref_get(tport->tty); 257 254 258 255 if (irqflag & UARTn_IF_RXDATAV) { 259 256 efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); ··· 267 270 handled = IRQ_HANDLED; 268 271 } 269 272 270 - if (tty) { 271 - tty_flip_buffer_push(tty); 272 - tty_kref_put(tty); 273 - } 273 + tty_flip_buffer_push(tport); 274 274 275 275 spin_unlock(&port->lock); 276 276
+1 -2
drivers/tty/serial/icom.c
··· 735 735 { 736 736 short int count, rcv_buff; 737 737 struct tty_port *port = &icom_port->uart_port.state->port; 738 - struct tty_struct *tty = port->tty; 739 738 unsigned short int status; 740 739 struct uart_icount *icount; 741 740 unsigned long offset; ··· 834 835 status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); 835 836 } 836 837 icom_port->next_rcv = rcv_buff; 837 - tty_flip_buffer_push(tty); 838 + tty_flip_buffer_push(port); 838 839 } 839 840 840 841 static void process_interrupt(u16 port_int_reg,
+1 -5
drivers/tty/serial/ifx6x60.c
··· 669 669 static void ifx_spi_insert_flip_string(struct ifx_spi_device *ifx_dev, 670 670 unsigned char *chars, size_t size) 671 671 { 672 - struct tty_struct *tty = tty_port_tty_get(&ifx_dev->tty_port); 673 - if (!tty) 674 - return; 675 672 tty_insert_flip_string(&ifx_dev->tty_port, chars, size); 676 - tty_flip_buffer_push(tty); 677 - tty_kref_put(tty); 673 + tty_flip_buffer_push(&ifx_dev->tty_port); 678 674 } 679 675 680 676 /**
+1 -2
drivers/tty/serial/imx.c
··· 518 518 unsigned int rx, flg, ignored = 0; 519 519 struct tty_struct *tty = sport->port.state->port.tty; 520 520 struct tty_port *port = &sport->port.state->port; 521 - struct tty_struct *tty = port->tty; 522 521 unsigned long flags, temp; 523 522 524 523 spin_lock_irqsave(&sport->port.lock, flags); ··· 575 576 576 577 out: 577 578 spin_unlock_irqrestore(&sport->port.lock, flags); 578 - tty_flip_buffer_push(tty); 579 + tty_flip_buffer_push(port); 579 580 return IRQ_HANDLED; 580 581 } 581 582
+1 -5
drivers/tty/serial/ioc3_serial.c
··· 1393 1393 */ 1394 1394 static int receive_chars(struct uart_port *the_port) 1395 1395 { 1396 - struct tty_struct *tty; 1397 1396 unsigned char ch[MAX_CHARS]; 1398 1397 int read_count = 0, read_room, flip = 0; 1399 1398 struct uart_state *state = the_port->state; ··· 1402 1403 /* Make sure all the pointers are "good" ones */ 1403 1404 if (!state) 1404 1405 return 0; 1405 - if (!state->port.tty) 1406 - return 0; 1407 1406 1408 1407 if (!(port->ip_flags & INPUT_ENABLE)) 1409 1408 return 0; 1410 1409 1411 1410 spin_lock_irqsave(&the_port->lock, pflags); 1412 - tty = state->port.tty; 1413 1411 1414 1412 read_count = do_read(the_port, ch, MAX_CHARS); 1415 1413 if (read_count > 0) { ··· 1418 1422 spin_unlock_irqrestore(&the_port->lock, pflags); 1419 1423 1420 1424 if (flip) 1421 - tty_flip_buffer_push(tty); 1425 + tty_flip_buffer_push(&state->port); 1422 1426 1423 1427 return read_count; 1424 1428 }
+1 -5
drivers/tty/serial/ioc4_serial.c
··· 2340 2340 */ 2341 2341 static void receive_chars(struct uart_port *the_port) 2342 2342 { 2343 - struct tty_struct *tty; 2344 2343 unsigned char ch[IOC4_MAX_CHARS]; 2345 2344 int read_count, request_count = IOC4_MAX_CHARS; 2346 2345 struct uart_icount *icount; ··· 2349 2350 /* Make sure all the pointers are "good" ones */ 2350 2351 if (!state) 2351 2352 return; 2352 - if (!state->port.tty) 2353 - return; 2354 2353 2355 2354 spin_lock_irqsave(&the_port->lock, pflags); 2356 - tty = state->port.tty; 2357 2355 2358 2356 request_count = tty_buffer_request_room(&state->port, IOC4_MAX_CHARS); 2359 2357 ··· 2365 2369 2366 2370 spin_unlock_irqrestore(&the_port->lock, pflags); 2367 2371 2368 - tty_flip_buffer_push(tty); 2372 + tty_flip_buffer_push(&state->port); 2369 2373 } 2370 2374 2371 2375 /**
+1 -1
drivers/tty/serial/jsm/jsm_tty.c
··· 654 654 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 655 655 656 656 /* Tell the tty layer its okay to "eat" the data now */ 657 - tty_flip_buffer_push(tp); 657 + tty_flip_buffer_push(port); 658 658 659 659 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "finish\n"); 660 660 }
+1 -9
drivers/tty/serial/kgdb_nmi.c
··· 202 202 static void kgdb_nmi_tty_receiver(unsigned long data) 203 203 { 204 204 struct kgdb_nmi_tty_priv *priv = (void *)data; 205 - struct tty_struct *tty; 206 205 char ch; 207 206 208 207 tasklet_schedule(&priv->tlet); ··· 209 210 if (likely(!kgdb_nmi_tty_enabled || !kfifo_len(&priv->fifo))) 210 211 return; 211 212 212 - /* Port is there, but tty might be hung up, check. */ 213 - tty = tty_port_tty_get(kgdb_nmi_port); 214 - if (!tty) 215 - return; 216 - 217 213 while (kfifo_out(&priv->fifo, &ch, 1)) 218 214 tty_insert_flip_char(&priv->port, ch, TTY_NORMAL); 219 - tty_flip_buffer_push(priv->port.tty); 220 - 221 - tty_kref_put(tty); 215 + tty_flip_buffer_push(&priv->port); 222 216 } 223 217 224 218 static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty)
+5 -10
drivers/tty/serial/lantiq.c
··· 163 163 lqasc_rx_chars(struct uart_port *port) 164 164 { 165 165 struct tty_port *tport = &port->state->port; 166 - struct tty_struct *tty = tty_port_tty_get(tport); 167 166 unsigned int ch = 0, rsr = 0, fifocnt; 168 167 169 - if (!tty) { 170 - dev_dbg(port->dev, "%s:tty is busy now", __func__); 171 - return -EBUSY; 172 - } 173 - fifocnt = 174 - ltq_r32(port->membase + LTQ_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; 168 + fifocnt = ltq_r32(port->membase + LTQ_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; 175 169 while (fifocnt--) { 176 170 u8 flag = TTY_NORMAL; 177 171 ch = ltq_r8(port->membase + LTQ_ASC_RBUF); 178 172 rsr = (ltq_r32(port->membase + LTQ_ASC_STATE) 179 173 & ASCSTATE_ANY) | UART_DUMMY_UER_RX; 180 - tty_flip_buffer_push(tty); 174 + tty_flip_buffer_push(tport); 181 175 port->icount.rx++; 182 176 183 177 /* ··· 213 219 */ 214 220 tty_insert_flip_char(tport, 0, TTY_OVERRUN); 215 221 } 222 + 216 223 if (ch != 0) 217 - tty_flip_buffer_push(tty); 218 - tty_kref_put(tty); 224 + tty_flip_buffer_push(tport); 225 + 219 226 return 0; 220 227 } 221 228
+2 -14
drivers/tty/serial/lpc32xx_hs.c
··· 259 259 { 260 260 struct tty_port *tport = &port->state->port; 261 261 unsigned int tmp, flag; 262 - struct tty_struct *tty = tty_port_tty_get(tport); 263 - 264 - if (!tty) { 265 - /* Discard data: no tty available */ 266 - while (!(readl(LPC32XX_HSUART_FIFO(port->membase)) & 267 - LPC32XX_HSU_RX_EMPTY)) 268 - ; 269 - 270 - return; 271 - } 272 262 273 263 /* Read data from FIFO and push into terminal */ 274 264 tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); ··· 279 289 280 290 tmp = readl(LPC32XX_HSUART_FIFO(port->membase)); 281 291 } 282 - tty_flip_buffer_push(tty); 283 - tty_kref_put(tty); 292 + tty_flip_buffer_push(tport); 284 293 } 285 294 286 295 static void __serial_lpc32xx_tx(struct uart_port *port) ··· 356 367 /* Data received? */ 357 368 if (status & (LPC32XX_HSU_RX_TIMEOUT_INT | LPC32XX_HSU_RX_TRIG_INT)) { 358 369 __serial_lpc32xx_rx(port); 359 - if (tty) 360 - tty_flip_buffer_push(tty); 370 + tty_flip_buffer_push(tport); 361 371 } 362 372 363 373 /* Transmit data request? */
+1 -2
drivers/tty/serial/m32r_sio.c
··· 301 301 static void receive_chars(struct uart_sio_port *up, int *status) 302 302 { 303 303 struct tty_port *port = &up->port.state->port; 304 - struct tty_struct *tty = tport->tty; 305 304 unsigned char ch; 306 305 unsigned char flag; 307 306 int max_count = 256; ··· 368 369 ignore_char: 369 370 *status = serial_in(up, UART_LSR); 370 371 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 371 - tty_flip_buffer_push(tty); 372 + tty_flip_buffer_push(port); 372 373 } 373 374 374 375 static void transmit_chars(struct uart_sio_port *up)
+4 -4
drivers/tty/serial/max3100.c
··· 311 311 } 312 312 } 313 313 314 - if (rxchars > 16 && s->port.state->port.tty != NULL) { 315 - tty_flip_buffer_push(s->port.state->port.tty); 314 + if (rxchars > 16) { 315 + tty_flip_buffer_push(&s->port.state->port); 316 316 rxchars = 0; 317 317 } 318 318 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) ··· 324 324 (!uart_circ_empty(xmit) && 325 325 !uart_tx_stopped(&s->port)))); 326 326 327 - if (rxchars > 0 && s->port.state->port.tty != NULL) 328 - tty_flip_buffer_push(s->port.state->port.tty); 327 + if (rxchars > 0) 328 + tty_flip_buffer_push(&s->port.state->port); 329 329 } 330 330 331 331 static irqreturn_t max3100_irq(int irqno, void *dev_id)
+1 -7
drivers/tty/serial/max310x.c
··· 460 460 static void max310x_handle_rx(struct max310x_port *s, unsigned int rxlen) 461 461 { 462 462 unsigned int sts = 0, ch = 0, flag; 463 - struct tty_struct *tty = tty_port_tty_get(&s->port.state->port); 464 - 465 - if (!tty) 466 - return; 467 463 468 464 if (unlikely(rxlen >= MAX310X_FIFO_SIZE)) { 469 465 dev_warn(s->port.dev, "Possible RX FIFO overrun %d\n", rxlen); ··· 512 516 ch, flag); 513 517 } 514 518 515 - tty_flip_buffer_push(tty); 516 - 517 - tty_kref_put(tty); 519 + tty_flip_buffer_push(&s->port.state->port); 518 520 } 519 521 520 522 static void max310x_handle_tx(struct max310x_port *s)
+1 -1
drivers/tty/serial/mcf.c
··· 310 310 uart_insert_char(port, status, MCFUART_USR_RXOVERRUN, ch, flag); 311 311 } 312 312 313 - tty_flip_buffer_push(port->state->port.tty); 313 + tty_flip_buffer_push(&port->state->port); 314 314 } 315 315 316 316 /****************************************************************************/
+2 -10
drivers/tty/serial/mfd.c
··· 388 388 struct hsu_dma_chan *chan = up->rxc; 389 389 struct uart_port *port = &up->port; 390 390 struct tty_port *tport = &port->state->port; 391 - struct tty_struct *tty = tport->tty; 392 391 int count; 393 - 394 - if (!tty) 395 - return; 396 392 397 393 /* 398 394 * First need to know how many is already transferred, ··· 434 438 | (0x1 << 16) 435 439 | (0x1 << 24) /* timeout bit, see HSU Errata 1 */ 436 440 ); 437 - tty_flip_buffer_push(tty); 441 + tty_flip_buffer_push(tport); 438 442 439 443 chan_writel(chan, HSU_CH_CR, 0x3); 440 444 ··· 457 461 458 462 static inline void receive_chars(struct uart_hsu_port *up, int *status) 459 463 { 460 - struct tty_struct *tty = up->port.state->port.tty; 461 464 unsigned int ch, flag; 462 465 unsigned int max_count = 256; 463 - 464 - if (!tty) 465 - return; 466 466 467 467 do { 468 468 ch = serial_in(up, UART_RX); ··· 515 523 ignore_char: 516 524 *status = serial_in(up, UART_LSR); 517 525 } while ((*status & UART_LSR_DR) && max_count--); 518 - tty_flip_buffer_push(tty); 526 + tty_flip_buffer_push(&up->port.state->port); 519 527 } 520 528 521 529 static void transmit_chars(struct uart_hsu_port *up)
+1 -2
drivers/tty/serial/mpc52xx_uart.c
··· 942 942 mpc52xx_uart_int_rx_chars(struct uart_port *port) 943 943 { 944 944 struct tty_port *tport = &port->state->port; 945 - struct tty_struct *tty = tport->tty; 946 945 unsigned char ch, flag; 947 946 unsigned short status; 948 947 ··· 999 1000 } 1000 1001 1001 1002 spin_unlock(&port->lock); 1002 - tty_flip_buffer_push(tty); 1003 + tty_flip_buffer_push(tport); 1003 1004 spin_lock(&port->lock); 1004 1005 1005 1006 return psc_ops->raw_rx_rdy(port);
+2 -3
drivers/tty/serial/mpsc.c
··· 938 938 { 939 939 struct mpsc_rx_desc *rxre; 940 940 struct tty_port *port = &pi->port.state->port; 941 - struct tty_struct *tty = port->tty; 942 941 u32 cmdstat, bytes_in, i; 943 942 int rc = 0; 944 943 u8 *bp; ··· 970 971 /* Following use of tty struct directly is deprecated */ 971 972 if (tty_buffer_request_room(port, bytes_in) < bytes_in) { 972 973 if (port->low_latency) 973 - tty_flip_buffer_push(tty); 974 + tty_flip_buffer_push(port); 974 975 /* 975 976 * If this failed then we will throw away the bytes 976 977 * but must do so to clear interrupts. ··· 1080 1081 if ((readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_ERD) == 0) 1081 1082 mpsc_start_rx(pi); 1082 1083 1083 - tty_flip_buffer_push(tty); 1084 + tty_flip_buffer_push(port); 1084 1085 return rc; 1085 1086 } 1086 1087
+2 -9
drivers/tty/serial/mrst_max3110.c
··· 340 340 { 341 341 struct uart_port *port = &max->port; 342 342 struct tty_port *tport; 343 - struct tty_struct *tty; 344 343 char buf[M3110_RX_FIFO_DEPTH]; 345 344 int r, w, usable; 346 345 ··· 348 349 return 0; 349 350 350 351 tport = &port->state->port; 351 - tty = tty_port_tty_get(tport); 352 - if (!tty) 353 - return 0; 354 352 355 353 for (r = 0, w = 0; r < len; r++) { 356 354 if (str[r] & MAX3110_BREAK && ··· 362 366 } 363 367 } 364 368 365 - if (!w) { 366 - tty_kref_put(tty); 369 + if (!w) 367 370 return 0; 368 - } 369 371 370 372 for (r = 0; w; r += usable, w -= usable) { 371 373 usable = tty_buffer_request_room(tport, w); ··· 372 378 port->icount.rx += usable; 373 379 } 374 380 } 375 - tty_flip_buffer_push(tty); 376 - tty_kref_put(tty); 381 + tty_flip_buffer_push(tport); 377 382 378 383 return r; 379 384 }
+2 -4
drivers/tty/serial/msm_serial.c
··· 92 92 static void handle_rx_dm(struct uart_port *port, unsigned int misr) 93 93 { 94 94 struct tty_port *tport = &port->state->port; 95 - struct tty_struct *tty = tport->tty; 96 95 unsigned int sr; 97 96 int count = 0; 98 97 struct msm_port *msm_port = UART_TO_MSM(port); ··· 137 138 count -= 4; 138 139 } 139 140 140 - tty_flip_buffer_push(tty); 141 + tty_flip_buffer_push(tport); 141 142 if (misr & (UART_IMR_RXSTALE)) 142 143 msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); 143 144 msm_write(port, 0xFFFFFF, UARTDM_DMRX); ··· 147 148 static void handle_rx(struct uart_port *port) 148 149 { 149 150 struct tty_port *tport = &port->state->port; 150 - struct tty_struct *tty = tport->tty; 151 151 unsigned int sr; 152 152 153 153 /* ··· 189 191 tty_insert_flip_char(tport, c, flag); 190 192 } 191 193 192 - tty_flip_buffer_push(tty); 194 + tty_flip_buffer_push(tport); 193 195 } 194 196 195 197 static void reset_dm_count(struct uart_port *port)
+1 -2
drivers/tty/serial/msm_serial_hs.c
··· 981 981 { 982 982 struct msm_hs_port *msm_uport = 983 983 container_of(work, struct msm_hs_port, rx.tty_work); 984 - struct tty_struct *tty = msm_uport->uport.state->port.tty; 985 984 986 - tty_flip_buffer_push(tty); 985 + tty_flip_buffer_push(&msm_uport->uport.state->port); 987 986 } 988 987 989 988 /*
+1 -1
drivers/tty/serial/msm_smd_tty.c
··· 80 80 pr_err("OOPS - smd_tty_buffer mismatch?!"); 81 81 } 82 82 83 - tty_flip_buffer_push(tty); 83 + tty_flip_buffer_push(&info->port); 84 84 } 85 85 86 86 /* XXX only when writable and necessary */
+2 -4
drivers/tty/serial/mux.c
··· 244 244 { 245 245 struct tty_port *tport = &port->state->port; 246 246 int data; 247 - struct tty_struct *tty = tport->tty; 248 247 __u32 start_count = port->icount.rx; 249 248 250 249 while(1) { ··· 269 270 tty_insert_flip_char(tport, data & 0xFF, TTY_NORMAL); 270 271 } 271 272 272 - if (start_count != port->icount.rx) { 273 - tty_flip_buffer_push(tty); 274 - } 273 + if (start_count != port->icount.rx) 274 + tty_flip_buffer_push(tport); 275 275 } 276 276 277 277 /**
+2 -4
drivers/tty/serial/mxs-auart.c
··· 364 364 365 365 static void mxs_auart_rx_chars(struct mxs_auart_port *s) 366 366 { 367 - struct tty_struct *tty = s->port.state->port.tty; 368 367 u32 stat = 0; 369 368 370 369 for (;;) { ··· 374 375 } 375 376 376 377 writel(stat, s->port.membase + AUART_STAT); 377 - tty_flip_buffer_push(tty); 378 + tty_flip_buffer_push(&s->port.state->port); 378 379 } 379 380 380 381 static int mxs_auart_request_port(struct uart_port *u) ··· 457 458 { 458 459 struct mxs_auart_port *s = (struct mxs_auart_port *) arg; 459 460 struct tty_port *port = &s->port.state->port; 460 - struct tty_struct *tty = port->tty; 461 461 int count; 462 462 u32 stat; 463 463 ··· 470 472 tty_insert_flip_string(port, s->rx_dma_buf, count); 471 473 472 474 writel(stat, s->port.membase + AUART_STAT); 473 - tty_flip_buffer_push(tty); 475 + tty_flip_buffer_push(port); 474 476 475 477 /* start the next DMA for RX. */ 476 478 mxs_auart_dma_prep_rx(s);
+1 -3
drivers/tty/serial/netx-serial.c
··· 199 199 static void netx_rxint(struct uart_port *port) 200 200 { 201 201 unsigned char rx, flg, status; 202 - struct tty_struct *tty = port->state->port.tty; 203 202 204 203 while (!(readl(port->membase + UART_FR) & FR_RXFE)) { 205 204 rx = readl(port->membase + UART_DR); ··· 236 237 uart_insert_char(port, status, SR_OE, rx, flg); 237 238 } 238 239 239 - tty_flip_buffer_push(tty); 240 - return; 240 + tty_flip_buffer_push(&port->state->port); 241 241 } 242 242 243 243 static irqreturn_t netx_int(int irq, void *dev_id)
+1 -2
drivers/tty/serial/nwpserial.c
··· 129 129 { 130 130 struct nwpserial_port *up = dev_id; 131 131 struct tty_port *port = &up->port.state->port; 132 - struct tty_struct *tty = port->tty; 133 132 irqreturn_t ret; 134 133 unsigned int iir; 135 134 unsigned char ch; ··· 149 150 tty_insert_flip_char(port, ch, TTY_NORMAL); 150 151 } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR); 151 152 152 - tty_flip_buffer_push(tty); 153 + tty_flip_buffer_push(port); 153 154 ret = IRQ_HANDLED; 154 155 155 156 /* clear interrupt */
+1 -2
drivers/tty/serial/omap-serial.c
··· 483 483 static irqreturn_t serial_omap_irq(int irq, void *dev_id) 484 484 { 485 485 struct uart_omap_port *up = dev_id; 486 - struct tty_struct *tty = up->port.state->port.tty; 487 486 unsigned int iir, lsr; 488 487 unsigned int type; 489 488 irqreturn_t ret = IRQ_NONE; ··· 529 530 530 531 spin_unlock(&up->port.lock); 531 532 532 - tty_flip_buffer_push(tty); 533 + tty_flip_buffer_push(&up->port.state->port); 533 534 534 535 pm_runtime_mark_last_busy(up->dev); 535 536 pm_runtime_put_autosuspend(up->dev);
+2 -17
drivers/tty/serial/pch_uart.c
··· 593 593 { 594 594 struct uart_port *port = &priv->port; 595 595 struct tty_port *tport = &port->state->port; 596 - struct tty_struct *tty; 597 - 598 - tty = tty_port_tty_get(tport); 599 - if (!tty) { 600 - dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); 601 - return -EBUSY; 602 - } 603 596 604 597 tty_insert_flip_string(tport, buf, size); 605 - tty_flip_buffer_push(tty); 606 - tty_kref_put(tty); 598 + tty_flip_buffer_push(tport); 607 599 608 600 return 0; 609 601 } ··· 736 744 { 737 745 struct eg20t_port *priv = arg; 738 746 struct uart_port *port = &priv->port; 739 - struct tty_struct *tty = tty_port_tty_get(&port->state->port); 740 747 int count; 741 - 742 - if (!tty) { 743 - dev_dbg(priv->port.dev, "%s:tty is busy now", __func__); 744 - return; 745 - } 746 748 747 749 dma_sync_sg_for_cpu(port->dev, &priv->sg_rx, 1, DMA_FROM_DEVICE); 748 750 count = dma_push_rx(priv, priv->trigger_level); 749 751 if (count) 750 - tty_flip_buffer_push(tty); 751 - tty_kref_put(tty); 752 + tty_flip_buffer_push(&port->state->port); 752 753 async_tx_ack(priv->desc_rx); 753 754 pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_RX_INT | 754 755 PCH_UART_HAL_RX_ERR_INT);
+14 -16
drivers/tty/serial/pmac_zilog.c
··· 227 227 write_zsreg(uap, R1, uap->curregs[1]); 228 228 } 229 229 230 - static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap) 230 + static bool pmz_receive_chars(struct uart_pmac_port *uap) 231 231 { 232 232 struct tty_port *port; 233 - struct tty_struct *tty = NULL; 234 233 unsigned char ch, r1, drop, error, flag; 235 234 int loops = 0; 236 235 237 236 /* Sanity check, make sure the old bug is no longer happening */ 238 - if (uap->port.state == NULL || uap->port.state->port.tty == NULL) { 237 + if (uap->port.state == NULL) { 239 238 WARN_ON(1); 240 239 (void)read_zsdata(uap); 241 - return NULL; 240 + return false; 242 241 } 243 242 port = &uap->port.state->port; 244 - tty = port->tty; /* TOCTOU above */ 245 243 246 244 while (1) { 247 245 error = 0; ··· 328 330 break; 329 331 } 330 332 331 - return tty; 333 + return true; 332 334 flood: 333 335 pmz_interrupt_control(uap, 0); 334 336 pmz_error("pmz: rx irq flood !\n"); 335 - return tty; 337 + return true; 336 338 } 337 339 338 340 static void pmz_status_handle(struct uart_pmac_port *uap) ··· 453 455 struct uart_pmac_port *uap_a; 454 456 struct uart_pmac_port *uap_b; 455 457 int rc = IRQ_NONE; 456 - struct tty_struct *tty; 458 + bool push; 457 459 u8 r3; 458 460 459 461 uap_a = pmz_get_port_A(uap); ··· 466 468 pmz_debug("irq, r3: %x\n", r3); 467 469 #endif 468 470 /* Channel A */ 469 - tty = NULL; 471 + push = false; 470 472 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { 471 473 if (!ZS_IS_OPEN(uap_a)) { 472 474 pmz_debug("ChanA interrupt while not open !\n"); ··· 477 479 if (r3 & CHAEXT) 478 480 pmz_status_handle(uap_a); 479 481 if (r3 & CHARxIP) 480 - tty = pmz_receive_chars(uap_a); 482 + push = pmz_receive_chars(uap_a); 481 483 if (r3 & CHATxIP) 482 484 pmz_transmit_chars(uap_a); 483 485 rc = IRQ_HANDLED; 484 486 } 485 487 skip_a: 486 488 spin_unlock(&uap_a->port.lock); 487 - if (tty != NULL) 488 - tty_flip_buffer_push(tty); 489 + if (push) 490 + tty_flip_buffer_push(&uap->port.state->port); 489 491 490 492 if (!uap_b) 491 493 goto out; 492 494 493 495 spin_lock(&uap_b->port.lock); 494 - tty = NULL; 496 + push = false; 495 497 if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { 496 498 if (!ZS_IS_OPEN(uap_b)) { 497 499 pmz_debug("ChanB interrupt while not open !\n"); ··· 502 504 if (r3 & CHBEXT) 503 505 pmz_status_handle(uap_b); 504 506 if (r3 & CHBRxIP) 505 - tty = pmz_receive_chars(uap_b); 507 + push = pmz_receive_chars(uap_b); 506 508 if (r3 & CHBTxIP) 507 509 pmz_transmit_chars(uap_b); 508 510 rc = IRQ_HANDLED; 509 511 } 510 512 skip_b: 511 513 spin_unlock(&uap_b->port.lock); 512 - if (tty != NULL) 513 - tty_flip_buffer_push(tty); 514 + if (push) 515 + tty_flip_buffer_push(&uap->port.state->port); 514 516 515 517 out: 516 518 return rc;
+1 -2
drivers/tty/serial/pnx8xxx_uart.c
··· 181 181 182 182 static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport) 183 183 { 184 - struct tty_struct *tty = sport->port.state->port.tty; 185 184 unsigned int status, ch, flg; 186 185 187 186 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | ··· 237 238 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | 238 239 ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); 239 240 } 240 - tty_flip_buffer_push(tty); 241 + tty_flip_buffer_push(&sport->port.state->port); 241 242 } 242 243 243 244 static void pnx8xxx_tx_chars(struct pnx8xxx_port *sport)
+1 -2
drivers/tty/serial/pxa.c
··· 98 98 99 99 static inline void receive_chars(struct uart_pxa_port *up, int *status) 100 100 { 101 - struct tty_struct *tty = up->port.state->port.tty; 102 101 unsigned int ch, flag; 103 102 int max_count = 256; 104 103 ··· 167 168 ignore_char: 168 169 *status = serial_in(up, UART_LSR); 169 170 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 170 - tty_flip_buffer_push(tty); 171 + tty_flip_buffer_push(&up->port.state->port); 171 172 172 173 /* work around Errata #20 according to 173 174 * Intel(R) PXA27x Processor Family
+1 -2
drivers/tty/serial/sa1100.c
··· 188 188 static void 189 189 sa1100_rx_chars(struct sa1100_port *sport) 190 190 { 191 - struct tty_struct *tty = sport->port.state->port.tty; 192 191 unsigned int status, ch, flg; 193 192 194 193 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | ··· 232 233 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 233 234 UTSR0_TO_SM(UART_GET_UTSR0(sport)); 234 235 } 235 - tty_flip_buffer_push(tty); 236 + tty_flip_buffer_push(&sport->port.state->port); 236 237 } 237 238 238 239 static void sa1100_tx_chars(struct sa1100_port *sport)
+1 -2
drivers/tty/serial/samsung.c
··· 220 220 { 221 221 struct s3c24xx_uart_port *ourport = dev_id; 222 222 struct uart_port *port = &ourport->port; 223 - struct tty_struct *tty = port->state->port.tty; 224 223 unsigned int ufcon, ch, flag, ufstat, uerstat; 225 224 unsigned long flags; 226 225 int max_count = 64; ··· 297 298 ignore_char: 298 299 continue; 299 300 } 300 - tty_flip_buffer_push(tty); 301 + tty_flip_buffer_push(&port->state->port); 301 302 302 303 out: 303 304 spin_unlock_irqrestore(&port->lock, flags);
+1 -1
drivers/tty/serial/sb1250-duart.c
··· 384 384 uart_insert_char(uport, status, M_DUART_OVRUN_ERR, ch, flag); 385 385 } 386 386 387 - tty_flip_buffer_push(uport->state->port.tty); 387 + tty_flip_buffer_push(&uport->state->port); 388 388 } 389 389 390 390 static void sbd_transmit_chars(struct sbd_port *sport)
+12 -15
drivers/tty/serial/sc26xx.c
··· 136 136 WRITE_SC(port, IMR, up->imr); 137 137 } 138 138 139 - static struct tty_struct *receive_chars(struct uart_port *port) 139 + static bool receive_chars(struct uart_port *port) 140 140 { 141 141 struct tty_port *tport = NULL; 142 - struct tty_struct *tty = NULL; 143 142 int limit = 10000; 144 143 unsigned char ch; 145 144 char flag; 146 145 u8 status; 147 146 148 147 /* FIXME what is this trying to achieve? */ 149 - if (port->state != NULL) { /* Unopened serial console */ 148 + if (port->state != NULL) /* Unopened serial console */ 150 149 tport = &port->state->port; 151 - tty = tport->tty; 152 - } 153 150 154 151 while (limit-- > 0) { 155 152 status = READ_SC_PORT(port, SR); ··· 188 191 189 192 tty_insert_flip_char(tport, ch, flag); 190 193 } 191 - return tty; 194 + return !!tport; 192 195 } 193 196 194 197 static void transmit_chars(struct uart_port *port) ··· 218 221 static irqreturn_t sc26xx_interrupt(int irq, void *dev_id) 219 222 { 220 223 struct uart_sc26xx_port *up = dev_id; 221 - struct tty_struct *tty; 222 224 unsigned long flags; 225 + bool push; 223 226 u8 isr; 224 227 225 228 spin_lock_irqsave(&up->port[0].lock, flags); 226 229 227 - tty = NULL; 230 + push = false; 228 231 isr = READ_SC(&up->port[0], ISR); 229 232 if (isr & ISR_TXRDYA) 230 233 transmit_chars(&up->port[0]); 231 234 if (isr & ISR_RXRDYA) 232 - tty = receive_chars(&up->port[0]); 235 + push = receive_chars(&up->port[0]); 233 236 234 237 spin_unlock(&up->port[0].lock); 235 238 236 - if (tty) 237 - tty_flip_buffer_push(tty); 239 + if (push) 240 + tty_flip_buffer_push(&up->port[0].state->port); 238 241 239 242 spin_lock(&up->port[1].lock); 240 243 241 - tty = NULL; 244 + push = false; 242 245 if (isr & ISR_TXRDYB) 243 246 transmit_chars(&up->port[1]); 244 247 if (isr & ISR_RXRDYB) 245 - tty = receive_chars(&up->port[1]); 248 + push = receive_chars(&up->port[1]); 246 249 247 250 spin_unlock_irqrestore(&up->port[1].lock, flags); 248 251 249 - if (tty) 250 - tty_flip_buffer_push(tty); 252 + if (push) 253 + tty_flip_buffer_push(&up->port[1].state->port); 251 254 252 255 return IRQ_HANDLED; 253 256 }
+1 -7
drivers/tty/serial/sccnxp.c
··· 285 285 { 286 286 u8 sr; 287 287 unsigned int ch, flag; 288 - struct tty_struct *tty = tty_port_tty_get(&port->state->port); 289 - 290 - if (!tty) 291 - return; 292 288 293 289 for (;;) { 294 290 sr = sccnxp_port_read(port, SCCNXP_SR_REG); ··· 329 333 uart_insert_char(port, sr, SR_OVR, ch, flag); 330 334 } 331 335 332 - tty_flip_buffer_push(tty); 333 - 334 - tty_kref_put(tty); 336 + tty_flip_buffer_push(&port->state->port); 335 337 } 336 338 337 339 static void sccnxp_handle_tx(struct uart_port *port)
+1 -2
drivers/tty/serial/serial_ks8695.c
··· 153 153 static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) 154 154 { 155 155 struct uart_port *port = dev_id; 156 - struct tty_struct *tty = port->state->port.tty; 157 156 unsigned int status, ch, lsr, flg, max_count = 256; 158 157 159 158 status = UART_GET_LSR(port); /* clears pending LSR interrupts */ ··· 199 200 ignore_char: 200 201 status = UART_GET_LSR(port); 201 202 } 202 - tty_flip_buffer_push(tty); 203 + tty_flip_buffer_push(&port->state->port); 203 204 204 205 return IRQ_HANDLED; 205 206 }
+1 -2
drivers/tty/serial/serial_txx9.c
··· 277 277 static inline void 278 278 receive_chars(struct uart_txx9_port *up, unsigned int *status) 279 279 { 280 - struct tty_struct *tty = up->port.state->port.tty; 281 280 unsigned char ch; 282 281 unsigned int disr = *status; 283 282 int max_count = 256; ··· 345 346 disr = sio_in(up, TXX9_SIDISR); 346 347 } while (!(disr & TXX9_SIDISR_UVALID) && (max_count-- > 0)); 347 348 spin_unlock(&up->port.lock); 348 - tty_flip_buffer_push(tty); 349 + tty_flip_buffer_push(&up->port.state->port); 349 350 spin_lock(&up->port.lock); 350 351 *status = disr; 351 352 }
+6 -12
drivers/tty/serial/sh-sci.c
··· 597 597 { 598 598 struct sci_port *sci_port = to_sci_port(port); 599 599 struct tty_port *tport = &port->state->port; 600 - struct tty_struct *tty = tport->tty; 601 600 int i, count, copied = 0; 602 601 unsigned short status; 603 602 unsigned char flag; ··· 674 675 675 676 if (copied) { 676 677 /* Tell the rest of the system the news. New characters! */ 677 - tty_flip_buffer_push(tty); 678 + tty_flip_buffer_push(tport); 678 679 } else { 679 680 serial_port_in(port, SCxSR); /* dummy read */ 680 681 serial_port_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); ··· 721 722 int copied = 0; 722 723 unsigned short status = serial_port_in(port, SCxSR); 723 724 struct tty_port *tport = &port->state->port; 724 - struct tty_struct *tty = tport->tty; 725 725 struct sci_port *s = to_sci_port(port); 726 726 727 727 /* ··· 781 783 } 782 784 783 785 if (copied) 784 - tty_flip_buffer_push(tty); 786 + tty_flip_buffer_push(tport); 785 787 786 788 return copied; 787 789 } ··· 789 791 static int sci_handle_fifo_overrun(struct uart_port *port) 790 792 { 791 793 struct tty_port *tport = &port->state->port; 792 - struct tty_struct *tty = tport->tty; 793 794 struct sci_port *s = to_sci_port(port); 794 795 struct plat_sci_reg *reg; 795 796 int copied = 0; ··· 803 806 port->icount.overrun++; 804 807 805 808 tty_insert_flip_char(tport, 0, TTY_OVERRUN); 806 - tty_flip_buffer_push(tty); 809 + tty_flip_buffer_push(tport); 807 810 808 811 dev_notice(port->dev, "overrun error\n"); 809 812 copied++; ··· 817 820 int copied = 0; 818 821 unsigned short status = serial_port_in(port, SCxSR); 819 822 struct tty_port *tport = &port->state->port; 820 - struct tty_struct *tty = tport->tty; 821 823 struct sci_port *s = to_sci_port(port); 822 824 823 825 if (uart_handle_break(port)) ··· 838 842 } 839 843 840 844 if (copied) 841 - tty_flip_buffer_push(tty); 845 + tty_flip_buffer_push(tport); 842 846 843 847 copied += sci_handle_fifo_overrun(port); 844 848 ··· 1295 1299 { 1296 1300 struct sci_port *s = arg; 1297 1301 struct uart_port *port = &s->port; 1298 - struct tty_struct *tty = port->state->port.tty; 1299 1302 unsigned long flags; 1300 1303 int count; 1301 1304 ··· 1309 1314 spin_unlock_irqrestore(&port->lock, flags); 1310 1315 1311 1316 if (count) 1312 - tty_flip_buffer_push(tty); 1317 + tty_flip_buffer_push(&port->state->port); 1313 1318 1314 1319 schedule_work(&s->work_rx); 1315 1320 } ··· 1403 1408 if (dma_async_is_tx_complete(s->chan_rx, s->active_rx, NULL, NULL) != 1404 1409 DMA_SUCCESS) { 1405 1410 /* Handle incomplete DMA receive */ 1406 - struct tty_struct *tty = port->state->port.tty; 1407 1411 struct dma_chan *chan = s->chan_rx; 1408 1412 struct shdma_desc *sh_desc = container_of(desc, 1409 1413 struct shdma_desc, async_tx); ··· 1418 1424 spin_unlock_irqrestore(&port->lock, flags); 1419 1425 1420 1426 if (count) 1421 - tty_flip_buffer_push(tty); 1427 + tty_flip_buffer_push(&port->state->port); 1422 1428 1423 1429 sci_submit_rx(s); 1424 1430
+1 -7
drivers/tty/serial/sirfsoc_uart.c
··· 206 206 sirfsoc_uart_pio_rx_chars(struct uart_port *port, unsigned int max_rx_count) 207 207 { 208 208 unsigned int ch, rx_count = 0; 209 - struct tty_struct *tty; 210 - 211 - tty = tty_port_tty_get(&port->state->port); 212 - if (!tty) 213 - return -ENODEV; 214 209 215 210 while (!(rd_regl(port, SIRFUART_RX_FIFO_STATUS) & 216 211 SIRFUART_FIFOEMPTY_MASK(port))) { ··· 219 224 } 220 225 221 226 port->icount.rx += rx_count; 222 - tty_flip_buffer_push(tty); 223 - tty_kref_put(tty); 227 + tty_flip_buffer_push(&port->state->port); 224 228 225 229 return rx_count; 226 230 }
+3 -9
drivers/tty/serial/sn_console.c
··· 459 459 { 460 460 struct tty_port *tport = NULL; 461 461 int ch; 462 - struct tty_struct *tty; 463 462 464 463 if (!port) { 465 464 printk(KERN_ERR "sn_receive_chars - port NULL so can't receive\n"); ··· 473 474 if (port->sc_port.state) { 474 475 /* The serial_core stuffs are initialized, use them */ 475 476 tport = &port->sc_port.state->port; 476 - tty = tport->tty; 477 - } 478 - else { 479 - /* Not registered yet - can't pass to tty layer. */ 480 - tty = NULL; 481 477 } 482 478 483 479 while (port->sc_ops->sal_input_pending()) { ··· 512 518 #endif /* CONFIG_MAGIC_SYSRQ */ 513 519 514 520 /* record the character to pass up to the tty layer */ 515 - if (tty) { 521 + if (tport) { 516 522 if (tty_insert_flip_char(tport, ch, TTY_NORMAL) == 0) 517 523 break; 518 524 } 519 525 port->sc_port.icount.rx++; 520 526 } 521 527 522 - if (tty) 523 - tty_flip_buffer_push(tty); 528 + if (tport) 529 + tty_flip_buffer_push(tport); 524 530 } 525 531 526 532 /**
+8 -8
drivers/tty/serial/sunhv.c
··· 181 181 182 182 static struct sunhv_ops *sunhv_ops = &bychar_ops; 183 183 184 - static struct tty_struct *receive_chars(struct uart_port *port) 184 + static struct tty_port *receive_chars(struct uart_port *port) 185 185 { 186 - struct tty_struct *tty = NULL; 186 + struct tty_port *tport = NULL; 187 187 188 188 if (port->state != NULL) /* Unopened serial console */ 189 - tty = port->state->port.tty; 189 + tport = &port->state->port; 190 190 191 191 if (sunhv_ops->receive_chars(port)) 192 192 sun_do_break(); 193 193 194 - return tty; 194 + return tport; 195 195 } 196 196 197 197 static void transmit_chars(struct uart_port *port) ··· 214 214 static irqreturn_t sunhv_interrupt(int irq, void *dev_id) 215 215 { 216 216 struct uart_port *port = dev_id; 217 - struct tty_struct *tty; 217 + struct tty_port *tport; 218 218 unsigned long flags; 219 219 220 220 spin_lock_irqsave(&port->lock, flags); 221 - tty = receive_chars(port); 221 + tport = receive_chars(port); 222 222 transmit_chars(port); 223 223 spin_unlock_irqrestore(&port->lock, flags); 224 224 225 - if (tty) 226 - tty_flip_buffer_push(tty); 225 + if (tport) 226 + tty_flip_buffer_push(tport); 227 227 228 228 return IRQ_HANDLED; 229 229 }
+8 -12
drivers/tty/serial/sunsab.c
··· 107 107 udelay(1); 108 108 } 109 109 110 - static struct tty_struct * 110 + static struct tty_port * 111 111 receive_chars(struct uart_sunsab_port *up, 112 112 union sab82532_irq_status *stat) 113 113 { 114 114 struct tty_port *port = NULL; 115 - struct tty_struct *tty = NULL; 116 115 unsigned char buf[32]; 117 116 int saw_console_brk = 0; 118 117 int free_fifo = 0; 119 118 int count = 0; 120 119 int i; 121 120 122 - if (up->port.state != NULL) { /* Unopened serial console */ 121 + if (up->port.state != NULL) /* Unopened serial console */ 123 122 port = &up->port.state->port; 124 - tty = port->tty; 125 - } 126 123 127 124 /* Read number of BYTES (Character + Status) available. */ 128 125 if (stat->sreg.isr0 & SAB82532_ISR0_RPF) { ··· 136 139 if (stat->sreg.isr0 & SAB82532_ISR0_TIME) { 137 140 sunsab_cec_wait(up); 138 141 writeb(SAB82532_CMDR_RFRD, &up->regs->w.cmdr); 139 - return tty; 142 + return port; 140 143 } 141 144 142 145 if (stat->sreg.isr0 & SAB82532_ISR0_RFO) ··· 216 219 if (saw_console_brk) 217 220 sun_do_break(); 218 221 219 - return tty; 222 + return port; 220 223 } 221 224 222 225 static void sunsab_stop_tx(struct uart_port *); ··· 299 302 static irqreturn_t sunsab_interrupt(int irq, void *dev_id) 300 303 { 301 304 struct uart_sunsab_port *up = dev_id; 302 - struct tty_struct *tty; 305 + struct tty_port *port = NULL; 303 306 union sab82532_irq_status status; 304 307 unsigned long flags; 305 308 unsigned char gis; ··· 313 316 if (gis & 2) 314 317 status.sreg.isr1 = readb(&up->regs->r.isr1); 315 318 316 - tty = NULL; 317 319 if (status.stat) { 318 320 if ((status.sreg.isr0 & (SAB82532_ISR0_TCD | SAB82532_ISR0_TIME | 319 321 SAB82532_ISR0_RFO | SAB82532_ISR0_RPF)) || 320 322 (status.sreg.isr1 & SAB82532_ISR1_BRK)) 321 - tty = receive_chars(up, &status); 323 + port = receive_chars(up, &status); 322 324 if ((status.sreg.isr0 & SAB82532_ISR0_CDSC) || 323 325 (status.sreg.isr1 & SAB82532_ISR1_CSC)) 324 326 check_status(up, &status); ··· 327 331 328 332 spin_unlock_irqrestore(&up->port.lock, flags); 329 333 330 - if (tty) 331 - tty_flip_buffer_push(tty); 334 + if (port) 335 + tty_flip_buffer_push(port); 332 336 333 337 return IRQ_HANDLED; 334 338 }
+3 -10
drivers/tty/serial/sunsu.c
··· 315 315 spin_unlock_irqrestore(&up->port.lock, flags); 316 316 } 317 317 318 - static struct tty_struct * 318 + static void 319 319 receive_chars(struct uart_sunsu_port *up, unsigned char *status) 320 320 { 321 321 struct tty_port *port = &up->port.state->port; 322 - struct tty_struct *tty = port->tty; 323 322 unsigned char ch, flag; 324 323 int max_count = 256; 325 324 int saw_console_brk = 0; ··· 390 391 391 392 if (saw_console_brk) 392 393 sun_do_break(); 393 - 394 - return tty; 395 394 } 396 395 397 396 static void transmit_chars(struct uart_sunsu_port *up) ··· 458 461 spin_lock_irqsave(&up->port.lock, flags); 459 462 460 463 do { 461 - struct tty_struct *tty; 462 - 463 464 status = serial_inp(up, UART_LSR); 464 - tty = NULL; 465 465 if (status & UART_LSR_DR) 466 - tty = receive_chars(up, &status); 466 + receive_chars(up, &status); 467 467 check_modem_status(up); 468 468 if (status & UART_LSR_THRE) 469 469 transmit_chars(up); 470 470 471 471 spin_unlock_irqrestore(&up->port.lock, flags); 472 472 473 - if (tty) 474 - tty_flip_buffer_push(tty); 473 + tty_flip_buffer_push(&up->port.state->port); 475 474 476 475 spin_lock_irqsave(&up->port.lock, flags); 477 476
+12 -16
drivers/tty/serial/sunzilog.c
··· 323 323 } 324 324 } 325 325 326 - static struct tty_struct * 326 + static struct tty_port * 327 327 sunzilog_receive_chars(struct uart_sunzilog_port *up, 328 328 struct zilog_channel __iomem *channel) 329 329 { 330 330 struct tty_port *port = NULL; 331 - struct tty_struct *tty; 332 331 unsigned char ch, r1, flag; 333 332 334 - tty = NULL; 335 - if (up->port.state != NULL) { /* Unopened serial console */ 333 + if (up->port.state != NULL) /* Unopened serial console */ 336 334 port = &up->port.state->port; 337 - tty = port->tty; /* mouse => tty is NULL */ 338 - } 339 335 340 336 for (;;) { 341 337 ··· 399 403 tty_insert_flip_char(port, 0, TTY_OVERRUN); 400 404 } 401 405 402 - return tty; 406 + return port; 403 407 } 404 408 405 409 static void sunzilog_status_handle(struct uart_sunzilog_port *up, ··· 532 536 while (up) { 533 537 struct zilog_channel __iomem *channel 534 538 = ZILOG_CHANNEL_FROM_PORT(&up->port); 535 - struct tty_struct *tty; 539 + struct tty_port *port; 536 540 unsigned char r3; 537 541 538 542 spin_lock(&up->port.lock); 539 543 r3 = read_zsreg(channel, R3); 540 544 541 545 /* Channel A */ 542 - tty = NULL; 546 + port = NULL; 543 547 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { 544 548 writeb(RES_H_IUS, &channel->control); 545 549 ZSDELAY(); 546 550 ZS_WSYNC(channel); 547 551 548 552 if (r3 & CHARxIP) 549 - tty = sunzilog_receive_chars(up, channel); 553 + port = sunzilog_receive_chars(up, channel); 550 554 if (r3 & CHAEXT) 551 555 sunzilog_status_handle(up, channel); 552 556 if (r3 & CHATxIP) ··· 554 558 } 555 559 spin_unlock(&up->port.lock); 556 560 557 - if (tty) 558 - tty_flip_buffer_push(tty); 561 + if (port) 562 + tty_flip_buffer_push(port); 559 563 560 564 /* Channel B */ 561 565 up = up->next; 562 566 channel = ZILOG_CHANNEL_FROM_PORT(&up->port); 563 567 564 568 spin_lock(&up->port.lock); 565 - tty = NULL; 569 + port = NULL; 566 570 if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { 567 571 writeb(RES_H_IUS, &channel->control); 568 572 ZSDELAY(); 569 573 ZS_WSYNC(channel); 570 574 571 575 if (r3 & CHBRxIP) 572 - tty = sunzilog_receive_chars(up, channel); 576 + port = sunzilog_receive_chars(up, channel); 573 577 if (r3 & CHBEXT) 574 578 sunzilog_status_handle(up, channel); 575 579 if (r3 & CHBTxIP) ··· 577 581 } 578 582 spin_unlock(&up->port.lock); 579 583 580 - if (tty) 581 - tty_flip_buffer_push(tty); 584 + if (port) 585 + tty_flip_buffer_push(port); 582 586 583 587 up = up->next; 584 588 }
+1 -1
drivers/tty/serial/timbuart.c
··· 100 100 } 101 101 102 102 spin_unlock(&port->lock); 103 - tty_flip_buffer_push(port->state->port.tty); 103 + tty_flip_buffer_push(tport); 104 104 spin_lock(&port->lock); 105 105 106 106 dev_dbg(port->dev, "%s - total read %d bytes\n",
+1 -1
drivers/tty/serial/uartlite.c
··· 156 156 157 157 /* work done? */ 158 158 if (n > 1) { 159 - tty_flip_buffer_push(port->state->port.tty); 159 + tty_flip_buffer_push(&port->state->port); 160 160 return IRQ_HANDLED; 161 161 } else { 162 162 return IRQ_NONE;
+1 -2
drivers/tty/serial/ucc_uart.c
··· 470 470 unsigned char ch, *cp; 471 471 struct uart_port *port = &qe_port->port; 472 472 struct tty_port *tport = &port->state->port; 473 - struct tty_struct *tty = tport->tty; 474 473 struct qe_bd *bdp; 475 474 u16 status; 476 475 unsigned int flg; ··· 530 531 qe_port->rx_cur = bdp; 531 532 532 533 /* Activate BH processing */ 533 - tty_flip_buffer_push(tty); 534 + tty_flip_buffer_push(tport); 534 535 535 536 return; 536 537
+1 -3
drivers/tty/serial/vr41xx_siu.c
··· 313 313 314 314 static inline void receive_chars(struct uart_port *port, uint8_t *status) 315 315 { 316 - struct tty_struct *tty; 317 316 uint8_t lsr, ch; 318 317 char flag; 319 318 int max_count = RX_MAX_COUNT; 320 319 321 - tty = port->state->port.tty; 322 320 lsr = *status; 323 321 324 322 do { ··· 363 365 lsr = siu_read(port, UART_LSR); 364 366 } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); 365 367 366 - tty_flip_buffer_push(tty); 368 + tty_flip_buffer_push(&port->state->port); 367 369 368 370 *status = lsr; 369 371 }
+1 -11
drivers/tty/serial/vt8500_serial.c
··· 137 137 static void handle_rx(struct uart_port *port) 138 138 { 139 139 struct tty_port *tport = &port->state->port; 140 - struct tty_struct *tty = tty_port_tty_get(tport); 141 - if (!tty) { 142 - /* Discard data: no tty available */ 143 - int count = (vt8500_read(port, VT8500_URFIDX) & 0x1f00) >> 8; 144 - u16 ch; 145 - while (count--) 146 - ch = readw(port->membase + VT8500_RXFIFO); 147 - return; 148 - } 149 140 150 141 /* 151 142 * Handle overrun ··· 169 178 tty_insert_flip_char(tport, c, flag); 170 179 } 171 180 172 - tty_flip_buffer_push(tty); 173 - tty_kref_put(tty); 181 + tty_flip_buffer_push(tport); 174 182 } 175 183 176 184 static void handle_tx(struct uart_port *port)
+3 -11
drivers/tty/serial/xilinx_uartps.c
··· 147 147 static irqreturn_t xuartps_isr(int irq, void *dev_id) 148 148 { 149 149 struct uart_port *port = (struct uart_port *)dev_id; 150 - struct tty_struct *tty; 151 150 unsigned long flags; 152 151 unsigned int isrstatus, numbytes; 153 152 unsigned int data; 154 153 char status = TTY_NORMAL; 155 - 156 - /* Get the tty which could be NULL so don't assume it's valid */ 157 - tty = tty_port_tty_get(&port->state->port); 158 154 159 155 spin_lock_irqsave(&port->lock, flags); 160 156 ··· 183 187 } else if (isrstatus & XUARTPS_IXR_OVERRUN) 184 188 port->icount.overrun++; 185 189 186 - if (tty) 187 - uart_insert_char(port, isrstatus, 188 - XUARTPS_IXR_OVERRUN, data, 189 - status); 190 + uart_insert_char(port, isrstatus, XUARTPS_IXR_OVERRUN, 191 + data, status); 190 192 } 191 193 spin_unlock(&port->lock); 192 - if (tty) 193 - tty_flip_buffer_push(tty); 194 + tty_flip_buffer_push(&port->state->port); 194 195 spin_lock(&port->lock); 195 196 } 196 197 ··· 230 237 231 238 /* be sure to release the lock and tty before leaving */ 232 239 spin_unlock_irqrestore(&port->lock, flags); 233 - tty_kref_put(tty); 234 240 235 241 return IRQ_HANDLED; 236 242 }
+1 -1
drivers/tty/serial/zs.c
··· 603 603 uart_insert_char(uport, status, Rx_OVR, ch, flag); 604 604 } 605 605 606 - tty_flip_buffer_push(uport->state->port.tty); 606 + tty_flip_buffer_push(&uport->state->port); 607 607 } 608 608 609 609 static void zs_raw_transmit_chars(struct zs_port *zport)
+2 -3
drivers/tty/synclink.c
··· 1439 1439 u16 status; 1440 1440 int work = 0; 1441 1441 unsigned char DataByte; 1442 - struct tty_struct *tty = info->port.tty; 1443 1442 struct mgsl_icount *icount = &info->icount; 1444 1443 1445 1444 if ( debug_level >= DEBUG_LEVEL_ISR ) ··· 1500 1501 if (status & RXSTATUS_BREAK_RECEIVED) { 1501 1502 flag = TTY_BREAK; 1502 1503 if (info->port.flags & ASYNC_SAK) 1503 - do_SAK(tty); 1504 + do_SAK(info->port.tty); 1504 1505 } else if (status & RXSTATUS_PARITY_ERROR) 1505 1506 flag = TTY_PARITY; 1506 1507 else if (status & RXSTATUS_FRAMING_ERROR) ··· 1523 1524 } 1524 1525 1525 1526 if(work) 1526 - tty_flip_buffer_push(tty); 1527 + tty_flip_buffer_push(&info->port); 1527 1528 } 1528 1529 1529 1530 /* mgsl_isr_misc()
+1 -3
drivers/tty/synclinkmp.c
··· 2167 2167 { 2168 2168 u16 status; 2169 2169 unsigned char DataByte; 2170 - struct tty_struct *tty = info->port.tty; 2171 2170 struct mgsl_icount *icount = &info->icount; 2172 2171 2173 2172 if ( debug_level >= DEBUG_LEVEL_ISR ) ··· 2224 2225 icount->frame,icount->overrun); 2225 2226 } 2226 2227 2227 - if ( tty ) 2228 - tty_flip_buffer_push(tty); 2228 + tty_flip_buffer_push(&info->port); 2229 2229 } 2230 2230 2231 2231 static void isr_txeom(SLMP_INFO * info, unsigned char status)
+4 -4
drivers/tty/tty_buffer.c
··· 544 544 545 545 /** 546 546 * tty_flip_buffer_push - terminal 547 - * @tty: tty to push 547 + * @port: tty port to push 548 548 * 549 549 * Queue a push of the terminal flip buffers to the line discipline. This 550 550 * function must not be called from IRQ context if port->low_latency is ··· 556 556 * Locking: tty buffer lock. Driver locks in low latency mode. 557 557 */ 558 558 559 - void tty_flip_buffer_push(struct tty_struct *tty) 559 + void tty_flip_buffer_push(struct tty_port *port) 560 560 { 561 - struct tty_bufhead *buf = &tty->port->buf; 561 + struct tty_bufhead *buf = &port->buf; 562 562 unsigned long flags; 563 563 564 564 spin_lock_irqsave(&buf->lock, flags); ··· 566 566 buf->tail->commit = buf->tail->used; 567 567 spin_unlock_irqrestore(&buf->lock, flags); 568 568 569 - if (tty->port->low_latency) 569 + if (port->low_latency) 570 570 flush_to_ldisc(&buf->work); 571 571 else 572 572 schedule_work(&buf->work);
+1 -9
drivers/usb/class/cdc-acm.c
··· 410 410 411 411 static void acm_process_read_urb(struct acm *acm, struct urb *urb) 412 412 { 413 - struct tty_struct *tty; 414 - 415 413 if (!urb->actual_length) 416 - return; 417 - 418 - tty = tty_port_tty_get(&acm->port); 419 - if (!tty) 420 414 return; 421 415 422 416 tty_insert_flip_string(&acm->port, urb->transfer_buffer, 423 417 urb->actual_length); 424 - tty_flip_buffer_push(tty); 425 - 426 - tty_kref_put(tty); 418 + tty_flip_buffer_push(&acm->port); 427 419 } 428 420 429 421 static void acm_read_bulk_callback(struct urb *urb)
+2 -2
drivers/usb/gadget/u_serial.c
··· 551 551 /* Push from tty to ldisc; without low_latency set this is handled by 552 552 * a workqueue, so we won't get callbacks and can hold port_lock 553 553 */ 554 - if (tty && do_push) 555 - tty_flip_buffer_push(tty); 554 + if (do_push) 555 + tty_flip_buffer_push(&port->port); 556 556 557 557 558 558 /* We want our data queue to become empty ASAP, keeping data
+1 -7
drivers/usb/serial/aircable.c
··· 140 140 { 141 141 struct usb_serial_port *port = urb->context; 142 142 char *data = (char *)urb->transfer_buffer; 143 - struct tty_struct *tty; 144 143 int has_headers; 145 144 int count; 146 145 int len; 147 146 int i; 148 - 149 - tty = tty_port_tty_get(&port->port); 150 - if (!tty) 151 - return; 152 147 153 148 has_headers = (urb->actual_length > 2 && data[0] == RX_HEADER_0); 154 149 ··· 155 160 } 156 161 157 162 if (count) 158 - tty_flip_buffer_push(tty); 159 - tty_kref_put(tty); 163 + tty_flip_buffer_push(&port->port); 160 164 } 161 165 162 166 static struct usb_serial_driver aircable_device = {
+1 -7
drivers/usb/serial/ark3116.c
··· 674 674 { 675 675 struct usb_serial_port *port = urb->context; 676 676 struct ark3116_private *priv = usb_get_serial_port_data(port); 677 - struct tty_struct *tty; 678 677 unsigned char *data = urb->transfer_buffer; 679 678 char tty_flag = TTY_NORMAL; 680 679 unsigned long flags; ··· 686 687 spin_unlock_irqrestore(&priv->status_lock, flags); 687 688 688 689 if (!urb->actual_length) 689 - return; 690 - 691 - tty = tty_port_tty_get(&port->port); 692 - if (!tty) 693 690 return; 694 691 695 692 if (lsr & UART_LSR_BRK_ERROR_BITS) { ··· 702 707 } 703 708 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 704 709 urb->actual_length); 705 - tty_flip_buffer_push(tty); 706 - tty_kref_put(tty); 710 + tty_flip_buffer_push(&port->port); 707 711 } 708 712 709 713 static struct usb_serial_driver ark3116_device = {
+1 -7
drivers/usb/serial/belkin_sa.c
··· 242 242 { 243 243 struct usb_serial_port *port = urb->context; 244 244 struct belkin_sa_private *priv = usb_get_serial_port_data(port); 245 - struct tty_struct *tty; 246 245 unsigned char *data = urb->transfer_buffer; 247 246 unsigned long flags; 248 247 unsigned char status; ··· 256 257 spin_unlock_irqrestore(&priv->lock, flags); 257 258 258 259 if (!urb->actual_length) 259 - return; 260 - 261 - tty = tty_port_tty_get(&port->port); 262 - if (!tty) 263 260 return; 264 261 265 262 if (status & BELKIN_SA_LSR_ERR) { ··· 276 281 277 282 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 278 283 urb->actual_length); 279 - tty_flip_buffer_push(tty); 280 - tty_kref_put(tty); 284 + tty_flip_buffer_push(&port->port); 281 285 } 282 286 283 287 static void belkin_sa_set_termios(struct tty_struct *tty,
+1 -8
drivers/usb/serial/cyberjack.c
··· 324 324 struct usb_serial_port *port = urb->context; 325 325 struct cyberjack_private *priv = usb_get_serial_port_data(port); 326 326 struct device *dev = &port->dev; 327 - struct tty_struct *tty; 328 327 unsigned char *data = urb->transfer_buffer; 329 328 short todo; 330 329 int result; ··· 336 337 return; 337 338 } 338 339 339 - tty = tty_port_tty_get(&port->port); 340 - if (!tty) { 341 - dev_dbg(dev, "%s - ignoring since device not open\n", __func__); 342 - return; 343 - } 344 340 if (urb->actual_length) { 345 341 tty_insert_flip_string(&port->port, data, urb->actual_length); 346 - tty_flip_buffer_push(tty); 342 + tty_flip_buffer_push(&port->port); 347 343 } 348 - tty_kref_put(tty); 349 344 350 345 spin_lock(&priv->lock); 351 346
+2 -2
drivers/usb/serial/cypress_m8.c
··· 1214 1214 spin_unlock_irqrestore(&priv->lock, flags); 1215 1215 1216 1216 /* process read if there is data other than line status */ 1217 - if (tty && bytes > i) { 1217 + if (bytes > i) { 1218 1218 tty_insert_flip_string_fixed_flag(&port->port, data + i, 1219 1219 tty_flag, bytes - i); 1220 - tty_flip_buffer_push(tty); 1220 + tty_flip_buffer_push(&port->port); 1221 1221 } 1222 1222 1223 1223 spin_lock_irqsave(&priv->lock, flags);
+2 -6
drivers/usb/serial/digi_acceleport.c
··· 1399 1399 1400 1400 static int digi_read_inb_callback(struct urb *urb) 1401 1401 { 1402 - 1403 1402 struct usb_serial_port *port = urb->context; 1404 - struct tty_struct *tty; 1405 1403 struct digi_port *priv = usb_get_serial_port_data(port); 1406 1404 int opcode = ((unsigned char *)urb->transfer_buffer)[0]; 1407 1405 int len = ((unsigned char *)urb->transfer_buffer)[1]; ··· 1423 1425 return -1; 1424 1426 } 1425 1427 1426 - tty = tty_port_tty_get(&port->port); 1427 1428 spin_lock(&priv->dp_port_lock); 1428 1429 1429 1430 /* check for throttle; if set, do not resubmit read urb */ ··· 1432 1435 priv->dp_throttle_restart = 1; 1433 1436 1434 1437 /* receive data */ 1435 - if (tty && opcode == DIGI_CMD_RECEIVE_DATA) { 1438 + if (opcode == DIGI_CMD_RECEIVE_DATA) { 1436 1439 /* get flag from port_status */ 1437 1440 flag = 0; 1438 1441 ··· 1454 1457 if (len > 0) { 1455 1458 tty_insert_flip_string_fixed_flag(&port->port, data, 1456 1459 flag, len); 1457 - tty_flip_buffer_push(tty); 1460 + tty_flip_buffer_push(&port->port); 1458 1461 } 1459 1462 } 1460 1463 spin_unlock(&priv->dp_port_lock); 1461 - tty_kref_put(tty); 1462 1464 1463 1465 if (opcode == DIGI_CMD_RECEIVE_DISABLE) 1464 1466 dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__);
+1 -7
drivers/usb/serial/f81232.c
··· 100 100 { 101 101 struct usb_serial_port *port = urb->context; 102 102 struct f81232_private *priv = usb_get_serial_port_data(port); 103 - struct tty_struct *tty; 104 103 unsigned char *data = urb->transfer_buffer; 105 104 char tty_flag = TTY_NORMAL; 106 105 unsigned long flags; ··· 114 115 wake_up_interruptible(&priv->delta_msr_wait); 115 116 116 117 if (!urb->actual_length) 117 - return; 118 - 119 - tty = tty_port_tty_get(&port->port); 120 - if (!tty) 121 118 return; 122 119 123 120 /* break takes precedence over parity, */ ··· 140 145 urb->actual_length); 141 146 } 142 147 143 - tty_flip_buffer_push(tty); 144 - tty_kref_put(tty); 148 + tty_flip_buffer_push(&port->port); 145 149 } 146 150 147 151 static int set_control_lines(struct usb_device *dev, u8 value)
+1 -7
drivers/usb/serial/ftdi_sio.c
··· 2040 2040 static void ftdi_process_read_urb(struct urb *urb) 2041 2041 { 2042 2042 struct usb_serial_port *port = urb->context; 2043 - struct tty_struct *tty; 2044 2043 struct ftdi_private *priv = usb_get_serial_port_data(port); 2045 2044 char *data = (char *)urb->transfer_buffer; 2046 2045 int i; 2047 2046 int len; 2048 2047 int count = 0; 2049 - 2050 - tty = tty_port_tty_get(&port->port); 2051 - if (!tty) 2052 - return; 2053 2048 2054 2049 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { 2055 2050 len = min_t(int, urb->actual_length - i, priv->max_packet_size); ··· 2052 2057 } 2053 2058 2054 2059 if (count) 2055 - tty_flip_buffer_push(tty); 2056 - tty_kref_put(tty); 2060 + tty_flip_buffer_push(&port->port); 2057 2061 } 2058 2062 2059 2063 static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
+2 -5
drivers/usb/serial/garmin_gps.c
··· 252 252 static void send_to_tty(struct usb_serial_port *port, 253 253 char *data, unsigned int actual_length) 254 254 { 255 - struct tty_struct *tty = tty_port_tty_get(&port->port); 256 - 257 - if (tty && actual_length) { 255 + if (actual_length) { 258 256 usb_serial_debug_data(&port->dev, __func__, actual_length, data); 259 257 tty_insert_flip_string(&port->port, data, actual_length); 260 - tty_flip_buffer_push(tty); 258 + tty_flip_buffer_push(&port->port); 261 259 } 262 - tty_kref_put(tty); 263 260 } 264 261 265 262
+1 -7
drivers/usb/serial/generic.c
··· 313 313 void usb_serial_generic_process_read_urb(struct urb *urb) 314 314 { 315 315 struct usb_serial_port *port = urb->context; 316 - struct tty_struct *tty; 317 316 char *ch = (char *)urb->transfer_buffer; 318 317 int i; 319 318 320 319 if (!urb->actual_length) 321 - return; 322 - 323 - tty = tty_port_tty_get(&port->port); 324 - if (!tty) 325 320 return; 326 321 327 322 /* The per character mucking around with sysrq path it too slow for ··· 330 335 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); 331 336 } 332 337 } 333 - tty_flip_buffer_push(tty); 334 - tty_kref_put(tty); 338 + tty_flip_buffer_push(&port->port); 335 339 } 336 340 EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb); 337 341
+13 -22
drivers/usb/serial/io_edgeport.c
··· 232 232 unsigned char *buffer, __u16 bufferLength); 233 233 static void process_rcvd_status(struct edgeport_serial *edge_serial, 234 234 __u8 byte2, __u8 byte3); 235 - static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 236 - unsigned char *data, int length); 235 + static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, 236 + int length); 237 237 static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr); 238 238 static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, 239 239 __u8 lsr, __u8 data); ··· 1752 1752 struct device *dev = &edge_serial->serial->dev->dev; 1753 1753 struct usb_serial_port *port; 1754 1754 struct edgeport_port *edge_port; 1755 - struct tty_struct *tty; 1756 1755 __u16 lastBufferLength; 1757 1756 __u16 rxLen; 1758 1757 ··· 1859 1860 edge_serial->rxPort]; 1860 1861 edge_port = usb_get_serial_port_data(port); 1861 1862 if (edge_port->open) { 1862 - tty = tty_port_tty_get( 1863 - &edge_port->port->port); 1864 - if (tty) { 1865 - dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", 1866 - __func__, rxLen, edge_serial->rxPort); 1867 - edge_tty_recv(edge_port->port, tty, buffer, rxLen); 1868 - tty_kref_put(tty); 1869 - } 1863 + dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n", 1864 + __func__, rxLen, 1865 + edge_serial->rxPort); 1866 + edge_tty_recv(edge_port->port, buffer, 1867 + rxLen); 1870 1868 edge_port->icount.rx += rxLen; 1871 1869 } 1872 1870 buffer += rxLen; ··· 2013 2017 * edge_tty_recv 2014 2018 * this function passes data on to the tty flip buffer 2015 2019 *****************************************************************************/ 2016 - static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 2017 - unsigned char *data, int length) 2020 + static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, 2021 + int length) 2018 2022 { 2019 2023 int cnt; 2020 2024 ··· 2026 2030 data += cnt; 2027 2031 length -= cnt; 2028 2032 2029 - tty_flip_buffer_push(tty); 2033 + tty_flip_buffer_push(&port->port); 2030 2034 } 2031 2035 2032 2036 ··· 2082 2086 } 2083 2087 2084 2088 /* Place LSR data byte into Rx buffer */ 2085 - if (lsrData) { 2086 - struct tty_struct *tty = 2087 - tty_port_tty_get(&edge_port->port->port); 2088 - if (tty) { 2089 - edge_tty_recv(edge_port->port, tty, &data, 1); 2090 - tty_kref_put(tty); 2091 - } 2092 - } 2089 + if (lsrData) 2090 + edge_tty_recv(edge_port->port, &data, 1); 2091 + 2093 2092 /* update input line counters */ 2094 2093 icount = &edge_port->icount; 2095 2094 if (newLsr & LSR_BREAK)
+9 -18
drivers/usb/serial/io_ti.c
··· 201 201 static bool ignore_cpu_rev; 202 202 static int default_uart_mode; /* RS232 */ 203 203 204 - static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 205 - unsigned char *data, int length); 204 + static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, 205 + int length); 206 206 207 207 static void stop_read(struct edgeport_port *edge_port); 208 208 static int restart_read(struct edgeport_port *edge_port); ··· 1540 1540 struct async_icount *icount; 1541 1541 __u8 new_lsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | 1542 1542 LSR_FRM_ERR | LSR_BREAK)); 1543 - struct tty_struct *tty; 1544 1543 1545 1544 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr); 1546 1545 ··· 1553 1554 new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK); 1554 1555 1555 1556 /* Place LSR data byte into Rx buffer */ 1556 - if (lsr_data) { 1557 - tty = tty_port_tty_get(&edge_port->port->port); 1558 - if (tty) { 1559 - edge_tty_recv(edge_port->port, tty, &data, 1); 1560 - tty_kref_put(tty); 1561 - } 1562 - } 1557 + if (lsr_data) 1558 + edge_tty_recv(edge_port->port, &data, 1); 1563 1559 1564 1560 /* update input line counters */ 1565 1561 icount = &edge_port->icount; ··· 1670 1676 struct edgeport_port *edge_port = urb->context; 1671 1677 struct device *dev = &edge_port->port->dev; 1672 1678 unsigned char *data = urb->transfer_buffer; 1673 - struct tty_struct *tty; 1674 1679 int retval = 0; 1675 1680 int port_number; 1676 1681 int status = urb->status; ··· 1708 1715 ++data; 1709 1716 } 1710 1717 1711 - tty = tty_port_tty_get(&edge_port->port->port); 1712 - if (tty && urb->actual_length) { 1718 + if (urb->actual_length) { 1713 1719 usb_serial_debug_data(dev, __func__, urb->actual_length, data); 1714 1720 if (edge_port->close_pending) 1715 1721 dev_dbg(dev, "%s - close pending, dropping data on the floor\n", 1716 1722 __func__); 1717 1723 else 1718 - edge_tty_recv(edge_port->port, tty, data, 1724 + edge_tty_recv(edge_port->port, data, 1719 1725 urb->actual_length); 1720 1726 edge_port->icount.rx += urb->actual_length; 1721 1727 } 1722 - tty_kref_put(tty); 1723 1728 1724 1729 exit: 1725 1730 /* continue read unless stopped */ ··· 1732 1741 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval); 1733 1742 } 1734 1743 1735 - static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty, 1736 - unsigned char *data, int length) 1744 + static void edge_tty_recv(struct usb_serial_port *port, unsigned char *data, 1745 + int length) 1737 1746 { 1738 1747 int queued; 1739 1748 ··· 1741 1750 if (queued < length) 1742 1751 dev_err(&port->dev, "%s - dropping data, %d bytes lost\n", 1743 1752 __func__, length - queued); 1744 - tty_flip_buffer_push(tty); 1753 + tty_flip_buffer_push(&port->port); 1745 1754 } 1746 1755 1747 1756 static void edge_bulk_out_callback(struct urb *urb)
+1 -6
drivers/usb/serial/ir-usb.c
··· 287 287 { 288 288 struct usb_serial_port *port = urb->context; 289 289 unsigned char *data = urb->transfer_buffer; 290 - struct tty_struct *tty; 291 290 292 291 if (!urb->actual_length) 293 292 return; ··· 301 302 if (urb->actual_length == 1) 302 303 return; 303 304 304 - tty = tty_port_tty_get(&port->port); 305 - if (!tty) 306 - return; 307 305 tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1); 308 - tty_flip_buffer_push(tty); 309 - tty_kref_put(tty); 306 + tty_flip_buffer_push(&port->port); 310 307 } 311 308 312 309 static void ir_set_termios_callback(struct urb *urb)
+2 -5
drivers/usb/serial/iuu_phoenix.c
··· 581 581 { 582 582 struct usb_serial_port *port = urb->context; 583 583 unsigned char *data = urb->transfer_buffer; 584 - struct tty_struct *tty; 585 584 int status = urb->status; 586 585 587 586 if (status) { ··· 591 592 } 592 593 593 594 dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length); 594 - tty = tty_port_tty_get(&port->port); 595 595 if (data == NULL) 596 596 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__); 597 - if (tty && urb->actual_length && data) { 597 + if (urb->actual_length && data) { 598 598 tty_insert_flip_string(&port->port, data, urb->actual_length); 599 - tty_flip_buffer_push(tty); 599 + tty_flip_buffer_push(&port->port); 600 600 } 601 - tty_kref_put(tty); 602 601 iuu_led_activity_on(urb); 603 602 } 604 603
+8 -23
drivers/usb/serial/keyspan.c
··· 291 291 int i, err; 292 292 int endpoint; 293 293 struct usb_serial_port *port; 294 - struct tty_struct *tty; 295 294 unsigned char *data = urb->transfer_buffer; 296 295 int status = urb->status; 297 296 ··· 303 304 } 304 305 305 306 port = urb->context; 306 - tty = tty_port_tty_get(&port->port); 307 - if (tty && urb->actual_length) { 307 + if (urb->actual_length) { 308 308 /* 0x80 bit is error flag */ 309 309 if ((data[0] & 0x80) == 0) { 310 310 /* no errors on individual bytes, only ··· 330 332 flag); 331 333 } 332 334 } 333 - tty_flip_buffer_push(tty); 335 + tty_flip_buffer_push(&port->port); 334 336 } 335 - tty_kref_put(tty); 336 337 337 338 /* Resubmit urb so we continue receiving */ 338 339 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 444 447 { 445 448 int err; 446 449 struct usb_serial_port *port; 447 - struct tty_struct *tty; 448 450 unsigned char *data; 449 451 struct keyspan_port_private *p_priv; 450 452 int status = urb->status; ··· 466 470 p_priv = usb_get_serial_port_data(port); 467 471 data = urb->transfer_buffer; 468 472 469 - tty = tty_port_tty_get(&port->port); 470 - if (tty && urb->actual_length) { 473 + if (urb->actual_length) { 471 474 tty_insert_flip_string(&port->port, data, 472 475 urb->actual_length); 473 - tty_flip_buffer_push(tty); 476 + tty_flip_buffer_push(&port->port); 474 477 } 475 - tty_kref_put(tty); 476 478 477 479 /* Resubmit urb so we continue receiving */ 478 480 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 665 671 int i, err; 666 672 int endpoint; 667 673 struct usb_serial_port *port; 668 - struct tty_struct *tty; 669 674 unsigned char *data = urb->transfer_buffer; 670 675 int status = urb->status; 671 676 ··· 677 684 } 678 685 679 686 port = urb->context; 680 - tty = tty_port_tty_get(&port->port); 681 - if (tty && urb->actual_length) { 687 + if (urb->actual_length) { 682 688 /* 0x80 bit is error flag */ 683 689 if ((data[0] & 0x80) == 0) { 684 690 /* no error on any byte */ ··· 698 706 flag); 699 707 } 700 708 } 701 - tty_flip_buffer_push(tty); 709 + tty_flip_buffer_push(&port->port); 702 710 } 703 - tty_kref_put(tty); 704 711 705 712 /* Resubmit urb so we continue receiving */ 706 713 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 712 721 int i, len, x, err; 713 722 struct usb_serial *serial; 714 723 struct usb_serial_port *port; 715 - struct tty_struct *tty; 716 724 unsigned char *data = urb->transfer_buffer; 717 725 int status = urb->status; 718 726 ··· 736 746 return; 737 747 } 738 748 port = serial->port[data[i++]]; 739 - tty = tty_port_tty_get(&port->port); 740 749 len = data[i++]; 741 750 742 751 /* 0x80 bit is error flag */ ··· 763 774 i += 2; 764 775 } 765 776 } 766 - tty_flip_buffer_push(tty); 767 - tty_kref_put(tty); 777 + tty_flip_buffer_push(&port->port); 768 778 } 769 779 } 770 780 ··· 784 796 int endpoint; 785 797 struct usb_serial_port *port; 786 798 struct keyspan_port_private *p_priv; 787 - struct tty_struct *tty; 788 799 unsigned char *data = urb->transfer_buffer; 789 800 int status = urb->status; 790 801 ··· 799 812 p_priv = usb_get_serial_port_data(port); 800 813 801 814 if (urb->actual_length) { 802 - tty = tty_port_tty_get(&port->port); 803 815 /* if current mode is DMA, looks like usa28 format 804 816 otherwise looks like usa26 data format */ 805 817 ··· 834 848 } 835 849 } 836 850 } 837 - tty_flip_buffer_push(tty); 838 - tty_kref_put(tty); 851 + tty_flip_buffer_push(&port->port); 839 852 } 840 853 841 854 /* Resubmit urb so we continue receiving */
+2 -5
drivers/usb/serial/keyspan_pda.c
··· 138 138 static void keyspan_pda_rx_interrupt(struct urb *urb) 139 139 { 140 140 struct usb_serial_port *port = urb->context; 141 - struct tty_struct *tty; 142 141 unsigned char *data = urb->transfer_buffer; 143 142 int retval; 144 143 int status = urb->status; ··· 162 163 /* see if the message is data or a status interrupt */ 163 164 switch (data[0]) { 164 165 case 0: 165 - tty = tty_port_tty_get(&port->port); 166 166 /* rest of message is rx data */ 167 - if (tty && urb->actual_length) { 167 + if (urb->actual_length) { 168 168 tty_insert_flip_string(&port->port, data + 1, 169 169 urb->actual_length - 1); 170 - tty_flip_buffer_push(tty); 170 + tty_flip_buffer_push(&port->port); 171 171 } 172 - tty_kref_put(tty); 173 172 break; 174 173 case 1: 175 174 /* status interrupt */
+1 -7
drivers/usb/serial/kl5kusb105.c
··· 389 389 { 390 390 struct usb_serial_port *port = urb->context; 391 391 unsigned char *data = urb->transfer_buffer; 392 - struct tty_struct *tty; 393 392 unsigned len; 394 393 395 394 /* empty urbs seem to happen, we ignore them */ ··· 400 401 return; 401 402 } 402 403 403 - tty = tty_port_tty_get(&port->port); 404 - if (!tty) 405 - return; 406 - 407 404 len = get_unaligned_le16(data); 408 405 if (len > urb->actual_length - KLSI_HDR_LEN) { 409 406 dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__); ··· 407 412 } 408 413 409 414 tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len); 410 - tty_flip_buffer_push(tty); 411 - tty_kref_put(tty); 415 + tty_flip_buffer_push(&port->port); 412 416 } 413 417 414 418 static void klsi_105_set_termios(struct tty_struct *tty,
+2 -5
drivers/usb/serial/kobil_sct.c
··· 324 324 { 325 325 int result; 326 326 struct usb_serial_port *port = urb->context; 327 - struct tty_struct *tty; 328 327 unsigned char *data = urb->transfer_buffer; 329 328 int status = urb->status; 330 329 ··· 332 333 return; 333 334 } 334 335 335 - tty = tty_port_tty_get(&port->port); 336 - if (tty && urb->actual_length) { 336 + if (urb->actual_length) { 337 337 338 338 /* BEGIN DEBUG */ 339 339 /* ··· 352 354 /* END DEBUG */ 353 355 354 356 tty_insert_flip_string(&port->port, data, urb->actual_length); 355 - tty_flip_buffer_push(tty); 357 + tty_flip_buffer_push(&port->port); 356 358 } 357 - tty_kref_put(tty); 358 359 359 360 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 360 361 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result);
+3 -8
drivers/usb/serial/mct_u232.c
··· 531 531 { 532 532 struct usb_serial_port *port = urb->context; 533 533 struct mct_u232_private *priv = usb_get_serial_port_data(port); 534 - struct tty_struct *tty; 535 534 unsigned char *data = urb->transfer_buffer; 536 535 int retval; 537 536 int status = urb->status; ··· 560 561 */ 561 562 if (urb->transfer_buffer_length > 2) { 562 563 if (urb->actual_length) { 563 - tty = tty_port_tty_get(&port->port); 564 - if (tty) { 565 - tty_insert_flip_string(&port->port, data, 566 - urb->actual_length); 567 - tty_flip_buffer_push(tty); 568 - } 569 - tty_kref_put(tty); 564 + tty_insert_flip_string(&port->port, data, 565 + urb->actual_length); 566 + tty_flip_buffer_push(&port->port); 570 567 } 571 568 goto exit; 572 569 }
+2 -5
drivers/usb/serial/metro-usb.c
··· 95 95 { 96 96 struct usb_serial_port *port = urb->context; 97 97 struct metrousb_private *metro_priv = usb_get_serial_port_data(port); 98 - struct tty_struct *tty; 99 98 unsigned char *data = urb->transfer_buffer; 100 99 int throttled = 0; 101 100 int result = 0; ··· 123 124 124 125 125 126 /* Set the data read from the usb port into the serial port buffer. */ 126 - tty = tty_port_tty_get(&port->port); 127 - if (tty && urb->actual_length) { 127 + if (urb->actual_length) { 128 128 /* Loop through the data copying each byte to the tty layer. */ 129 129 tty_insert_flip_string(&port->port, data, urb->actual_length); 130 130 131 131 /* Force the data to the tty layer. */ 132 - tty_flip_buffer_push(tty); 132 + tty_flip_buffer_push(&port->port); 133 133 } 134 - tty_kref_put(tty); 135 134 136 135 /* Set any port variables. */ 137 136 spin_lock_irqsave(&metro_priv->lock, flags);
+2 -5
drivers/usb/serial/mos7720.c
··· 899 899 int retval; 900 900 unsigned char *data ; 901 901 struct usb_serial_port *port; 902 - struct tty_struct *tty; 903 902 int status = urb->status; 904 903 905 904 if (status) { ··· 912 913 913 914 data = urb->transfer_buffer; 914 915 915 - tty = tty_port_tty_get(&port->port); 916 - if (tty && urb->actual_length) { 916 + if (urb->actual_length) { 917 917 tty_insert_flip_string(&port->port, data, urb->actual_length); 918 - tty_flip_buffer_push(tty); 918 + tty_flip_buffer_push(&port->port); 919 919 } 920 - tty_kref_put(tty); 921 920 922 921 if (port->read_urb->status != -EINPROGRESS) { 923 922 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
+2 -7
drivers/usb/serial/mos7840.c
··· 744 744 struct usb_serial *serial; 745 745 struct usb_serial_port *port; 746 746 struct moschip_port *mos7840_port; 747 - struct tty_struct *tty; 748 747 int status = urb->status; 749 748 750 749 mos7840_port = urb->context; ··· 773 774 774 775 if (urb->actual_length) { 775 776 struct tty_port *tport = &mos7840_port->port->port; 776 - tty = tty_port_tty_get(tport); 777 - if (tty) { 778 - tty_insert_flip_string(tport, data, urb->actual_length); 779 - tty_flip_buffer_push(tty); 780 - tty_kref_put(tty); 781 - } 777 + tty_insert_flip_string(tport, data, urb->actual_length); 778 + tty_flip_buffer_push(tport); 782 779 mos7840_port->icount.rx += urb->actual_length; 783 780 smp_wmb(); 784 781 dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx);
+2 -5
drivers/usb/serial/navman.c
··· 32 32 { 33 33 struct usb_serial_port *port = urb->context; 34 34 unsigned char *data = urb->transfer_buffer; 35 - struct tty_struct *tty; 36 35 int status = urb->status; 37 36 int result; 38 37 ··· 54 55 55 56 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); 56 57 57 - tty = tty_port_tty_get(&port->port); 58 - if (tty && urb->actual_length) { 58 + if (urb->actual_length) { 59 59 tty_insert_flip_string(&port->port, data, urb->actual_length); 60 - tty_flip_buffer_push(tty); 60 + tty_flip_buffer_push(&port->port); 61 61 } 62 - tty_kref_put(tty); 63 62 64 63 exit: 65 64 result = usb_submit_urb(urb, GFP_ATOMIC);
+3 -8
drivers/usb/serial/omninet.c
··· 174 174 } 175 175 176 176 if (urb->actual_length && header->oh_len) { 177 - struct tty_struct *tty = tty_port_tty_get(&port->port); 178 - if (tty) { 179 - tty_insert_flip_string(&port->port, 180 - data + OMNINET_DATAOFFSET, 181 - header->oh_len); 182 - tty_flip_buffer_push(tty); 183 - tty_kref_put(tty); 184 - } 177 + tty_insert_flip_string(&port->port, data + OMNINET_DATAOFFSET, 178 + header->oh_len); 179 + tty_flip_buffer_push(&port->port); 185 180 } 186 181 187 182 /* Continue trying to always read */
+1 -8
drivers/usb/serial/opticon.c
··· 51 51 static void opticon_process_data_packet(struct usb_serial_port *port, 52 52 const unsigned char *buf, size_t len) 53 53 { 54 - struct tty_struct *tty; 55 - 56 - tty = tty_port_tty_get(&port->port); 57 - if (!tty) 58 - return; 59 - 60 54 tty_insert_flip_string(&port->port, buf, len); 61 - tty_flip_buffer_push(tty); 62 - tty_kref_put(tty); 55 + tty_flip_buffer_push(&port->port); 63 56 } 64 57 65 58 static void opticon_process_status_packet(struct usb_serial_port *port,
+2 -5
drivers/usb/serial/oti6858.c
··· 820 820 { 821 821 struct usb_serial_port *port = urb->context; 822 822 struct oti6858_private *priv = usb_get_serial_port_data(port); 823 - struct tty_struct *tty; 824 823 unsigned char *data = urb->transfer_buffer; 825 824 unsigned long flags; 826 825 int status = urb->status; ··· 834 835 return; 835 836 } 836 837 837 - tty = tty_port_tty_get(&port->port); 838 - if (tty != NULL && urb->actual_length > 0) { 838 + if (urb->actual_length > 0) { 839 839 tty_insert_flip_string(&port->port, data, urb->actual_length); 840 - tty_flip_buffer_push(tty); 840 + tty_flip_buffer_push(&port->port); 841 841 } 842 - tty_kref_put(tty); 843 842 844 843 /* schedule the interrupt urb */ 845 844 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
+1 -7
drivers/usb/serial/pl2303.c
··· 772 772 { 773 773 struct usb_serial_port *port = urb->context; 774 774 struct pl2303_private *priv = usb_get_serial_port_data(port); 775 - struct tty_struct *tty; 776 775 unsigned char *data = urb->transfer_buffer; 777 776 char tty_flag = TTY_NORMAL; 778 777 unsigned long flags; ··· 786 787 wake_up_interruptible(&priv->delta_msr_wait); 787 788 788 789 if (!urb->actual_length) 789 - return; 790 - 791 - tty = tty_port_tty_get(&port->port); 792 - if (!tty) 793 790 return; 794 791 795 792 /* break takes precedence over parity, */ ··· 812 817 urb->actual_length); 813 818 } 814 819 815 - tty_flip_buffer_push(tty); 816 - tty_kref_put(tty); 820 + tty_flip_buffer_push(&port->port); 817 821 } 818 822 819 823 /* All of the device info needed for the PL2303 SIO serial converter */
+2 -17
drivers/usb/serial/quatech2.c
··· 609 609 struct qt2_serial_private *serial_priv; 610 610 struct usb_serial_port *port; 611 611 struct qt2_port_private *port_priv; 612 - struct tty_struct *tty; 613 612 bool escapeflag; 614 613 unsigned char *ch; 615 614 int i; ··· 619 620 return; 620 621 621 622 ch = urb->transfer_buffer; 622 - tty = NULL; 623 623 serial = urb->context; 624 624 serial_priv = usb_get_serial_data(serial); 625 625 port = serial->port[serial_priv->current_port]; 626 626 port_priv = usb_get_serial_port_data(port); 627 - 628 - if (port_priv->is_open) 629 - tty = tty_port_tty_get(&port->port); 630 627 631 628 for (i = 0; i < urb->actual_length; i++) { 632 629 ch = (unsigned char *)urb->transfer_buffer + i; ··· 661 666 __func__); 662 667 break; 663 668 } 664 - if (tty) { 665 - tty_flip_buffer_push(tty); 666 - tty_kref_put(tty); 667 - } 669 + tty_flip_buffer_push(&port->port); 668 670 669 671 newport = *(ch + 3); 670 672 ··· 675 683 serial_priv->current_port = newport; 676 684 port = serial->port[serial_priv->current_port]; 677 685 port_priv = usb_get_serial_port_data(port); 678 - if (port_priv->is_open) 679 - tty = tty_port_tty_get(&port->port); 680 - else 681 - tty = NULL; 682 686 i += 3; 683 687 escapeflag = true; 684 688 break; ··· 704 716 tty_insert_flip_string(&port->port, ch, 1); 705 717 } 706 718 707 - if (tty) { 708 - tty_flip_buffer_push(tty); 709 - tty_kref_put(tty); 710 - } 719 + tty_flip_buffer_push(&port->port); 711 720 } 712 721 713 722 static void qt2_write_bulk_callback(struct urb *urb)
+3 -10
drivers/usb/serial/safe_serial.c
··· 207 207 unsigned char *data = urb->transfer_buffer; 208 208 unsigned char length = urb->actual_length; 209 209 int actual_length; 210 - struct tty_struct *tty; 211 210 __u16 fcs; 212 211 213 212 if (!length) 214 - return; 215 - 216 - tty = tty_port_tty_get(&port->port); 217 - if (!tty) 218 213 return; 219 214 220 215 if (!safe) ··· 218 223 fcs = fcs_compute10(data, length, CRC10_INITFCS); 219 224 if (fcs) { 220 225 dev_err(&port->dev, "%s - bad CRC %x\n", __func__, fcs); 221 - goto err; 226 + return; 222 227 } 223 228 224 229 actual_length = data[length - 2] >> 2; 225 230 if (actual_length > (length - 2)) { 226 231 dev_err(&port->dev, "%s - inconsistent lengths %d:%d\n", 227 232 __func__, actual_length, length); 228 - goto err; 233 + return; 229 234 } 230 235 dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length); 231 236 length = actual_length; 232 237 out: 233 238 tty_insert_flip_string(&port->port, data, length); 234 - tty_flip_buffer_push(tty); 235 - err: 236 - tty_kref_put(tty); 239 + tty_flip_buffer_push(&port->port); 237 240 } 238 241 239 242 static int safe_prepare_write_buffer(struct usb_serial_port *port,
+5 -10
drivers/usb/serial/sierra.c
··· 569 569 int err; 570 570 int endpoint; 571 571 struct usb_serial_port *port; 572 - struct tty_struct *tty; 573 572 unsigned char *data = urb->transfer_buffer; 574 573 int status = urb->status; 575 574 ··· 580 581 " endpoint %02x\n", __func__, status, endpoint); 581 582 } else { 582 583 if (urb->actual_length) { 583 - tty = tty_port_tty_get(&port->port); 584 - if (tty) { 585 - tty_insert_flip_string(&port->port, data, 586 - urb->actual_length); 587 - tty_flip_buffer_push(tty); 584 + tty_insert_flip_string(&port->port, data, 585 + urb->actual_length); 586 + tty_flip_buffer_push(&port->port); 588 587 589 - tty_kref_put(tty); 590 - usb_serial_debug_data(&port->dev, __func__, 591 - urb->actual_length, data); 592 - } 588 + usb_serial_debug_data(&port->dev, __func__, 589 + urb->actual_length, data); 593 590 } else { 594 591 dev_dbg(&port->dev, "%s: empty read urb" 595 592 " received\n", __func__);
+9 -9
drivers/usb/serial/spcp8x5.c
··· 462 462 { 463 463 struct usb_serial_port *port = urb->context; 464 464 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 465 - struct tty_struct *tty; 466 465 unsigned char *data = urb->transfer_buffer; 467 466 unsigned long flags; 468 467 u8 status; ··· 480 481 if (!urb->actual_length) 481 482 return; 482 483 483 - tty = tty_port_tty_get(&port->port); 484 - if (!tty) 485 - return; 486 484 487 485 if (status & UART_STATE_TRANSIENT_MASK) { 488 486 /* break takes precedence over parity, which takes precedence ··· 496 500 if (status & UART_OVERRUN_ERROR) 497 501 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 498 502 499 - if (status & UART_DCD) 500 - usb_serial_handle_dcd_change(port, tty, 501 - priv->line_status & MSR_STATUS_LINE_DCD); 503 + if (status & UART_DCD) { 504 + struct tty_struct *tty = tty_port_tty_get(&port->port); 505 + if (tty) { 506 + usb_serial_handle_dcd_change(port, tty, 507 + priv->line_status & MSR_STATUS_LINE_DCD); 508 + tty_kref_put(tty); 509 + } 510 + } 502 511 } 503 512 504 513 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 505 514 urb->actual_length); 506 - tty_flip_buffer_push(tty); 507 - tty_kref_put(tty); 515 + tty_flip_buffer_push(&port->port); 508 516 } 509 517 510 518 static int spcp8x5_wait_modem_info(struct usb_serial_port *port,
+3 -20
drivers/usb/serial/ssu100.c
··· 582 582 583 583 } 584 584 585 - static int ssu100_process_packet(struct urb *urb) 585 + static void ssu100_process_read_urb(struct urb *urb) 586 586 { 587 587 struct usb_serial_port *port = urb->context; 588 588 char *packet = (char *)urb->transfer_buffer; ··· 609 609 ch = packet; 610 610 611 611 if (!len) 612 - return 0; /* status only */ 612 + return; /* status only */ 613 613 614 614 if (port->port.console && port->sysrq) { 615 615 for (i = 0; i < len; i++, ch++) { ··· 619 619 } else 620 620 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); 621 621 622 - return len; 623 - } 624 - 625 - static void ssu100_process_read_urb(struct urb *urb) 626 - { 627 - struct usb_serial_port *port = urb->context; 628 - struct tty_struct *tty; 629 - int count; 630 - 631 - tty = tty_port_tty_get(&port->port); 632 - if (!tty) 633 - return; 634 - 635 - count = ssu100_process_packet(urb); 636 - 637 - if (count) 638 - tty_flip_buffer_push(tty); 639 - tty_kref_put(tty); 622 + tty_flip_buffer_push(&port->port); 640 623 } 641 624 642 625 static struct usb_serial_driver ssu100_device = {
+2 -8
drivers/usb/serial/symbolserial.c
··· 48 48 unsigned char *data = urb->transfer_buffer; 49 49 struct usb_serial_port *port = priv->port; 50 50 int status = urb->status; 51 - struct tty_struct *tty; 52 51 int result; 53 52 int data_length; 54 53 ··· 81 82 * we pretty much just ignore the size and send everything 82 83 * else to the tty layer. 83 84 */ 84 - tty = tty_port_tty_get(&port->port); 85 - if (tty) { 86 - tty_insert_flip_string(&port->port, &data[1], 87 - data_length); 88 - tty_flip_buffer_push(tty); 89 - tty_kref_put(tty); 90 - } 85 + tty_insert_flip_string(&port->port, &data[1], data_length); 86 + tty_flip_buffer_push(&port->port); 91 87 } else { 92 88 dev_dbg(&priv->udev->dev, 93 89 "Improper amount of data received from the device, "
+16 -23
drivers/usb/serial/ti_usb_3410_5052.c
··· 121 121 static void ti_bulk_in_callback(struct urb *urb); 122 122 static void ti_bulk_out_callback(struct urb *urb); 123 123 124 - static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, 125 - unsigned char *data, int length); 124 + static void ti_recv(struct usb_serial_port *port, unsigned char *data, 125 + int length); 126 126 static void ti_send(struct ti_port *tport); 127 127 static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); 128 128 static int ti_get_lsr(struct ti_port *tport); ··· 1118 1118 struct device *dev = &urb->dev->dev; 1119 1119 int status = urb->status; 1120 1120 int retval = 0; 1121 - struct tty_struct *tty; 1122 1121 1123 1122 switch (status) { 1124 1123 case 0: ··· 1144 1145 return; 1145 1146 } 1146 1147 1147 - tty = tty_port_tty_get(&port->port); 1148 - if (tty) { 1149 - if (urb->actual_length) { 1150 - usb_serial_debug_data(dev, __func__, urb->actual_length, 1151 - urb->transfer_buffer); 1148 + if (urb->actual_length) { 1149 + usb_serial_debug_data(dev, __func__, urb->actual_length, 1150 + urb->transfer_buffer); 1152 1151 1153 - if (!tport->tp_is_open) 1154 - dev_dbg(dev, "%s - port closed, dropping data\n", 1155 - __func__); 1156 - else 1157 - ti_recv(port, tty, urb->transfer_buffer, 1158 - urb->actual_length); 1159 - spin_lock(&tport->tp_lock); 1160 - tport->tp_icount.rx += urb->actual_length; 1161 - spin_unlock(&tport->tp_lock); 1162 - } 1163 - tty_kref_put(tty); 1152 + if (!tport->tp_is_open) 1153 + dev_dbg(dev, "%s - port closed, dropping data\n", 1154 + __func__); 1155 + else 1156 + ti_recv(port, urb->transfer_buffer, urb->actual_length); 1157 + spin_lock(&tport->tp_lock); 1158 + tport->tp_icount.rx += urb->actual_length; 1159 + spin_unlock(&tport->tp_lock); 1164 1160 } 1165 1161 1166 1162 exit: ··· 1203 1209 } 1204 1210 1205 1211 1206 - static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty, 1207 - unsigned char *data, int length) 1212 + static void ti_recv(struct usb_serial_port *port, unsigned char *data, 1213 + int length) 1208 1214 { 1209 1215 int cnt; 1210 1216 ··· 1216 1222 if (cnt == 0) 1217 1223 break; 1218 1224 } 1219 - tty_flip_buffer_push(tty); 1225 + tty_flip_buffer_push(&port->port); 1220 1226 data += cnt; 1221 1227 length -= cnt; 1222 1228 } while (length > 0); 1223 - 1224 1229 } 1225 1230 1226 1231
+6 -11
drivers/usb/serial/usb_wwan.c
··· 275 275 int err; 276 276 int endpoint; 277 277 struct usb_serial_port *port; 278 - struct tty_struct *tty; 279 278 struct device *dev; 280 279 unsigned char *data = urb->transfer_buffer; 281 280 int status = urb->status; ··· 287 288 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n", 288 289 __func__, status, endpoint); 289 290 } else { 290 - tty = tty_port_tty_get(&port->port); 291 - if (tty) { 292 - if (urb->actual_length) { 293 - tty_insert_flip_string(&port->port, data, 294 - urb->actual_length); 295 - tty_flip_buffer_push(tty); 296 - } else 297 - dev_dbg(dev, "%s: empty read urb received\n", __func__); 298 - tty_kref_put(tty); 299 - } 291 + if (urb->actual_length) { 292 + tty_insert_flip_string(&port->port, data, 293 + urb->actual_length); 294 + tty_flip_buffer_push(&port->port); 295 + } else 296 + dev_dbg(dev, "%s: empty read urb received\n", __func__); 300 297 301 298 /* Resubmit urb so we continue receiving */ 302 299 err = usb_submit_urb(urb, GFP_ATOMIC);
-1
include/linux/tty.h
··· 387 387 extern void __do_SAK(struct tty_struct *tty); 388 388 extern void disassociate_ctty(int priv); 389 389 extern void no_tty(void); 390 - extern void tty_flip_buffer_push(struct tty_struct *tty); 391 390 extern void tty_flush_to_ldisc(struct tty_struct *tty); 392 391 extern void tty_buffer_free_all(struct tty_port *port); 393 392 extern void tty_buffer_flush(struct tty_struct *tty);
+1
include/linux/tty_flip.h
··· 10 10 unsigned char **chars, size_t size); 11 11 extern int tty_prepare_flip_string_flags(struct tty_port *port, 12 12 unsigned char **chars, char **flags, size_t size); 13 + extern void tty_flip_buffer_push(struct tty_port *port); 13 14 void tty_schedule_flip(struct tty_struct *tty); 14 15 15 16 static inline int tty_insert_flip_char(struct tty_port *port,
+5 -11
net/bluetooth/rfcomm/tty.c
··· 541 541 static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) 542 542 { 543 543 struct rfcomm_dev *dev = dlc->owner; 544 - struct tty_struct *tty; 545 544 546 545 if (!dev) { 547 546 kfree_skb(skb); 548 547 return; 549 548 } 550 549 551 - tty = dev->port.tty; 552 - if (!tty || !skb_queue_empty(&dev->pending)) { 550 + if (!skb_queue_empty(&dev->pending)) { 553 551 skb_queue_tail(&dev->pending, skb); 554 552 return; 555 553 } 556 554 557 - BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len); 555 + BT_DBG("dlc %p len %d", dlc, skb->len); 558 556 559 557 tty_insert_flip_string(&dev->port, skb->data, skb->len); 560 - tty_flip_buffer_push(tty); 558 + tty_flip_buffer_push(&dev->port); 561 559 562 560 kfree_skb(skb); 563 561 } ··· 619 621 /* ---- TTY functions ---- */ 620 622 static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev) 621 623 { 622 - struct tty_struct *tty = dev->port.tty; 623 624 struct sk_buff *skb; 624 625 int inserted = 0; 625 626 626 - if (!tty) 627 - return; 628 - 629 - BT_DBG("dev %p tty %p", dev, tty); 627 + BT_DBG("dev %p", dev); 630 628 631 629 rfcomm_dlc_lock(dev->dlc); 632 630 ··· 635 641 rfcomm_dlc_unlock(dev->dlc); 636 642 637 643 if (inserted > 0) 638 - tty_flip_buffer_push(tty); 644 + tty_flip_buffer_push(&dev->port); 639 645 } 640 646 641 647 static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
+2 -2
net/irda/ircomm/ircomm_tty.c
··· 1136 1136 ircomm_tty_send_initial_parameters(self); 1137 1137 ircomm_tty_link_established(self); 1138 1138 } 1139 + tty_kref_put(tty); 1139 1140 1140 1141 /* 1141 1142 * Use flip buffer functions since the code may be called from interrupt 1142 1143 * context 1143 1144 */ 1144 1145 tty_insert_flip_string(&self->port, skb->data, skb->len); 1145 - tty_flip_buffer_push(tty); 1146 - tty_kref_put(tty); 1146 + tty_flip_buffer_push(&self->port); 1147 1147 1148 1148 /* No need to kfree_skb - see ircomm_ttp_data_indication() */ 1149 1149