Skip to content

Commit 6732c8b

Browse files
Jiri Slabygregkh
authored andcommitted
TTY: switch tty_schedule_flip
Now, we start converting tty buffer functions to actually use tty_port. This will allow us to get rid of the need of tty in many call sites. Only tty_port will needed and hence no more tty_port_tty_get in those paths. This is the last one: tty_schedule_flip Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2e124b4 commit 6732c8b

11 files changed

Lines changed: 51 additions & 100 deletions

File tree

‎arch/alpha/kernel/srmcons.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ typedef union _srmcons_result {
4444

4545
/* called with callback_lock held */
4646
static int
47-
srmcons_do_receive_chars(struct tty_struct *tty)
47+
srmcons_do_receive_chars(struct tty_port *port)
4848
{
49-
struct tty_port *port = tty->port;
5049
srmcons_result result;
5150
int count = 0, loops = 0;
5251

@@ -59,7 +58,7 @@ srmcons_do_receive_chars(struct tty_struct *tty)
5958
} while((result.bits.status & 1) && (++loops < 10));
6059

6160
if (count)
62-
tty_schedule_flip(tty);
61+
tty_schedule_flip(port);
6362

6463
return count;
6564
}
@@ -74,7 +73,7 @@ srmcons_receive_chars(unsigned long data)
7473

7574
local_irq_save(flags);
7675
if (spin_trylock(&srmcons_callback_lock)) {
77-
if (!srmcons_do_receive_chars(port->tty))
76+
if (!srmcons_do_receive_chars(port))
7877
incr = 100;
7978
spin_unlock(&srmcons_callback_lock);
8079
}
@@ -89,7 +88,7 @@ srmcons_receive_chars(unsigned long data)
8988

9089
/* called with callback_lock held */
9190
static int
92-
srmcons_do_write(struct tty_struct *tty, const char *buf, int count)
91+
srmcons_do_write(struct tty_port *port, const char *buf, int count)
9392
{
9493
static char str_cr[1] = "\r";
9594
long c, remaining = count;
@@ -114,10 +113,10 @@ srmcons_do_write(struct tty_struct *tty, const char *buf, int count)
114113
cur += result.bits.c;
115114

116115
/*
117-
* Check for pending input iff a tty was provided
116+
* Check for pending input iff a tty port was provided
118117
*/
119-
if (tty)
120-
srmcons_do_receive_chars(tty);
118+
if (port)
119+
srmcons_do_receive_chars(port);
121120
}
122121

123122
while (need_cr) {
@@ -136,7 +135,7 @@ srmcons_write(struct tty_struct *tty,
136135
unsigned long flags;
137136

138137
spin_lock_irqsave(&srmcons_callback_lock, flags);
139-
srmcons_do_write(tty, (const char *) buf, count);
138+
srmcons_do_write(tty->port, (const char *) buf, count);
140139
spin_unlock_irqrestore(&srmcons_callback_lock, flags);
141140

142141
return count;

‎drivers/s390/char/keyboard.h‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,14 @@ int kbd_ioctl(struct kbd_data *, unsigned int, unsigned long);
4343
static inline void
4444
kbd_put_queue(struct tty_port *port, int ch)
4545
{
46-
struct tty_struct *tty = tty_port_tty_get(port);
47-
if (!tty)
48-
return;
4946
tty_insert_flip_char(port, ch, 0);
50-
tty_schedule_flip(tty);
51-
tty_kref_put(tty);
47+
tty_schedule_flip(port);
5248
}
5349

5450
static inline void
5551
kbd_puts_queue(struct tty_port *port, char *cp)
5652
{
57-
struct tty_struct *tty = tty_port_tty_get(port);
58-
if (!tty)
59-
return;
6053
while (*cp)
6154
tty_insert_flip_char(port, *cp++, 0);
62-
tty_schedule_flip(tty);
63-
tty_kref_put(tty);
55+
tty_schedule_flip(port);
6456
}

‎drivers/staging/serqt_usb2/serqt_usb2.c‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ static void qt_read_bulk_callback(struct urb *urb)
356356
struct usb_serial_port *port = urb->context;
357357
struct usb_serial *serial = get_usb_serial(port, __func__);
358358
struct quatech_port *qt_port = qt_get_port_private(port);
359-
struct tty_struct *tty;
360359
int result;
361360

362361
if (urb->status) {
@@ -367,27 +366,23 @@ static void qt_read_bulk_callback(struct urb *urb)
367366
return;
368367
}
369368

370-
tty = tty_port_tty_get(&port->port);
371-
if (!tty)
372-
return;
373-
374369
dev_dbg(&port->dev,
375370
"%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding);
376371

377372
if (port_paranoia_check(port, __func__) != 0) {
378373
qt_port->ReadBulkStopped = 1;
379-
goto exit;
374+
return;
380375
}
381376

382377
if (!serial)
383-
goto exit;
378+
return;
384379

385380
if (qt_port->closePending == 1) {
386381
/* Were closing , stop reading */
387382
dev_dbg(&port->dev,
388383
"%s - (qt_port->closepending == 1\n", __func__);
389384
qt_port->ReadBulkStopped = 1;
390-
goto exit;
385+
return;
391386
}
392387

393388
/*
@@ -397,7 +392,7 @@ static void qt_read_bulk_callback(struct urb *urb)
397392
*/
398393
if (qt_port->RxHolding == 1) {
399394
qt_port->ReadBulkStopped = 1;
400-
goto exit;
395+
return;
401396
}
402397

403398
if (urb->status) {
@@ -406,7 +401,7 @@ static void qt_read_bulk_callback(struct urb *urb)
406401
dev_dbg(&port->dev,
407402
"%s - nonzero read bulk status received: %d\n",
408403
__func__, urb->status);
409-
goto exit;
404+
return;
410405
}
411406

412407
if (urb->actual_length)
@@ -427,13 +422,11 @@ static void qt_read_bulk_callback(struct urb *urb)
427422
else {
428423
if (urb->actual_length) {
429424
tty_flip_buffer_push(&port->port);
430-
tty_schedule_flip(tty);
425+
tty_schedule_flip(&port->port);
431426
}
432427
}
433428

434429
schedule_work(&port->work);
435-
exit:
436-
tty_kref_put(tty);
437430
}
438431

439432
/*

‎drivers/tty/cyclades.c‎

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
441441
void __iomem *base_addr)
442442
{
443443
struct cyclades_port *info;
444-
struct tty_struct *tty;
445444
struct tty_port *port;
446445
int len, index = cinfo->bus_index;
447446
u8 ivr, save_xir, channel, save_car, data, char_count;
@@ -458,18 +457,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
458457
cyy_writeb(info, CyCAR, save_xir);
459458
ivr = cyy_readb(info, CyRIVR) & CyIVRMask;
460459

461-
tty = tty_port_tty_get(port);
462-
/* if there is nowhere to put the data, discard it */
463-
if (tty == NULL) {
464-
if (ivr == CyIVRRxEx) { /* exception */
465-
data = cyy_readb(info, CyRDSR);
466-
} else { /* normal character reception */
467-
char_count = cyy_readb(info, CyRDCR);
468-
while (char_count--)
469-
data = cyy_readb(info, CyRDSR);
470-
}
471-
goto end;
472-
}
473460
/* there is an open port for this data */
474461
if (ivr == CyIVRRxEx) { /* exception */
475462
data = cyy_readb(info, CyRDSR);
@@ -486,7 +473,6 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
486473

487474
if (data & info->ignore_status_mask) {
488475
info->icount.rx++;
489-
tty_kref_put(tty);
490476
return;
491477
}
492478
if (tty_buffer_request_room(port, 1)) {
@@ -496,8 +482,14 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
496482
cyy_readb(info, CyRDSR),
497483
TTY_BREAK);
498484
info->icount.rx++;
499-
if (port->flags & ASYNC_SAK)
500-
do_SAK(tty);
485+
if (port->flags & ASYNC_SAK) {
486+
struct tty_struct *tty =
487+
tty_port_tty_get(port);
488+
if (tty) {
489+
do_SAK(tty);
490+
tty_kref_put(tty);
491+
}
492+
}
501493
} else if (data & CyFRAME) {
502494
tty_insert_flip_char(port,
503495
cyy_readb(info, CyRDSR),
@@ -566,9 +558,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
566558
}
567559
info->idle_stats.recv_idle = jiffies;
568560
}
569-
tty_schedule_flip(tty);
570-
tty_kref_put(tty);
571-
end:
561+
tty_schedule_flip(port);
562+
572563
/* end of service */
573564
cyy_writeb(info, CyRIR, save_xir & 0x3f);
574565
cyy_writeb(info, CyCAR, save_car);
@@ -1012,7 +1003,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct tty_struct *tty)
10121003
jiffies + 1);
10131004
#endif
10141005
info->idle_stats.recv_idle = jiffies;
1015-
tty_schedule_flip(tty);
1006+
tty_schedule_flip(&info->port);
10161007
}
10171008
/* Update rx_get */
10181009
cy_writel(&buf_ctrl->rx_get, new_rx_get);
@@ -1191,7 +1182,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
11911182
if (delta_count)
11921183
wake_up_interruptible(&info->port.delta_msr_wait);
11931184
if (special_count)
1194-
tty_schedule_flip(tty);
1185+
tty_schedule_flip(&info->port);
11951186
tty_kref_put(tty);
11961187
}
11971188
}

‎drivers/tty/moxa.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
14051405
if (inited && !test_bit(TTY_THROTTLED, &tty->flags) &&
14061406
MoxaPortRxQueue(p) > 0) { /* RX */
14071407
MoxaPortReadData(p);
1408-
tty_schedule_flip(tty);
1408+
tty_schedule_flip(&p->port);
14091409
}
14101410
} else {
14111411
clear_bit(EMPTYWAIT, &p->statusflags);
@@ -1430,7 +1430,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
14301430

14311431
if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */
14321432
tty_insert_flip_char(&p->port, 0, TTY_BREAK);
1433-
tty_schedule_flip(tty);
1433+
tty_schedule_flip(&p->port);
14341434
}
14351435

14361436
if (intr & IntrLine)

‎drivers/tty/serial/68328serial.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ static void rs_start(struct tty_struct *tty)
262262
local_irq_restore(flags);
263263
}
264264

265-
static void receive_chars(struct m68k_serial *info, struct tty_struct *tty,
266-
unsigned short rx)
265+
static void receive_chars(struct m68k_serial *info, unsigned short rx)
267266
{
268267
m68328_uart *uart = &uart_addr[info->line];
269268
unsigned char ch, flag;
@@ -293,9 +292,6 @@ static void receive_chars(struct m68k_serial *info, struct tty_struct *tty,
293292
}
294293
}
295294

296-
if(!tty)
297-
goto clear_and_exit;
298-
299295
flag = TTY_NORMAL;
300296

301297
if (rx & URX_PARITY_ERROR)
@@ -310,10 +306,7 @@ static void receive_chars(struct m68k_serial *info, struct tty_struct *tty,
310306
} while((rx = uart->urx.w) & URX_DATA_READY);
311307
#endif
312308

313-
tty_schedule_flip(tty);
314-
315-
clear_and_exit:
316-
return;
309+
tty_schedule_flip(&info->tport);
317310
}
318311

319312
static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty)
@@ -367,11 +360,11 @@ irqreturn_t rs_interrupt(int irq, void *dev_id)
367360
tx = uart->utx.w;
368361

369362
if (rx & URX_DATA_READY)
370-
receive_chars(info, tty, rx);
363+
receive_chars(info, rx);
371364
if (tx & UTX_TX_AVAIL)
372365
transmit_chars(info, tty);
373366
#else
374-
receive_chars(info, tty, rx);
367+
receive_chars(info, rx);
375368
#endif
376369
tty_kref_put(tty);
377370

‎drivers/tty/serial/lpc32xx_hs.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id)
323323
{
324324
struct uart_port *port = dev_id;
325325
struct tty_port *port = &port->state->port;
326-
struct tty_struct *tty = tty_port_tty_get(tport);
327326
u32 status;
328327

329328
spin_lock(&port->lock);
@@ -348,9 +347,7 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id)
348347
LPC32XX_HSUART_IIR(port->membase));
349348
port->icount.overrun++;
350349
tty_insert_flip_char(tport, 0, TTY_OVERRUN);
351-
if (tty) {
352-
tty_schedule_flip(tty);
353-
}
350+
tty_schedule_flip(tport);
354351
}
355352

356353
/* Data received? */
@@ -366,7 +363,6 @@ static irqreturn_t serial_lpc32xx_interrupt(int irq, void *dev_id)
366363
}
367364

368365
spin_unlock(&port->lock);
369-
tty_kref_put(tty);
370366

371367
return IRQ_HANDLED;
372368
}

‎drivers/tty/tty_buffer.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);
349349

350350
/**
351351
* tty_schedule_flip - push characters to ldisc
352-
* @tty: tty to push from
352+
* @port: tty port to push from
353353
*
354354
* Takes any pending buffers and transfers their ownership to the
355355
* ldisc side of the queue. It then schedules those characters for
@@ -360,11 +360,11 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags);
360360
* Locking: Takes port->buf.lock
361361
*/
362362

363-
void tty_schedule_flip(struct tty_struct *tty)
363+
void tty_schedule_flip(struct tty_port *port)
364364
{
365-
struct tty_bufhead *buf = &tty->port->buf;
365+
struct tty_bufhead *buf = &port->buf;
366366
unsigned long flags;
367-
WARN_ON(tty->port->low_latency);
367+
WARN_ON(port->low_latency);
368368

369369
spin_lock_irqsave(&buf->lock, flags);
370370
if (buf->tail != NULL)

‎drivers/tty/vt/keyboard.c‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -307,26 +307,17 @@ int kbd_rate(struct kbd_repeat *rep)
307307
*/
308308
static void put_queue(struct vc_data *vc, int ch)
309309
{
310-
struct tty_struct *tty = vc->port.tty;
311-
312310
tty_insert_flip_char(&vc->port, ch, 0);
313-
if (tty) {
314-
tty_schedule_flip(tty);
315-
}
311+
tty_schedule_flip(&vc->port);
316312
}
317313

318314
static void puts_queue(struct vc_data *vc, char *cp)
319315
{
320-
struct tty_struct *tty = vc->port.tty;
321-
322-
if (!tty)
323-
return;
324-
325316
while (*cp) {
326317
tty_insert_flip_char(&vc->port, *cp, 0);
327318
cp++;
328319
}
329-
tty_schedule_flip(tty);
320+
tty_schedule_flip(&vc->port);
330321
}
331322

332323
static void applkey(struct vc_data *vc, int key, char mode)
@@ -582,12 +573,8 @@ static void fn_inc_console(struct vc_data *vc)
582573

583574
static void fn_send_intr(struct vc_data *vc)
584575
{
585-
struct tty_struct *tty = vc->port.tty;
586-
587-
if (!tty)
588-
return;
589576
tty_insert_flip_char(&vc->port, 0, TTY_BREAK);
590-
tty_schedule_flip(tty);
577+
tty_schedule_flip(&vc->port);
591578
}
592579

593580
static void fn_scroll_forw(struct vc_data *vc)

0 commit comments

Comments
 (0)