Skip to content

Commit adc8d74

Browse files
Alan Coxgregkh
authored andcommitted
tty: move the termios object into the tty
This will let us sort out a whole pile of tty related races. The alternative would be to keep points and refcount the termios objects. However 1. They are tiny anyway 2. Many devices don't use the stored copies 3. We can remove a pty special case Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6d31a88 commit adc8d74

65 files changed

Lines changed: 409 additions & 435 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/ia64/hp/sim/simserial.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
338338
{
339339
/* Handle turning off CRTSCTS */
340340
if ((old_termios->c_cflag & CRTSCTS) &&
341-
!(tty->termios->c_cflag & CRTSCTS)) {
341+
!(tty->termios.c_cflag & CRTSCTS)) {
342342
tty->hw_stopped = 0;
343343
}
344344
}

‎drivers/bluetooth/hci_ath.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int ath_wakeup_ar3k(struct tty_struct *tty)
5858
return status;
5959

6060
/* Disable Automatic RTSCTS */
61-
memcpy(&ktermios, tty->termios, sizeof(ktermios));
61+
ktermios = tty->termios;
6262
ktermios.c_cflag &= ~CRTSCTS;
6363
tty_set_termios(tty, &ktermios);
6464

‎drivers/isdn/gigaset/interface.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
446446
goto out;
447447
}
448448

449-
iflag = tty->termios->c_iflag;
450-
cflag = tty->termios->c_cflag;
449+
iflag = tty->termios.c_iflag;
450+
cflag = tty->termios.c_cflag;
451451
old_cflag = old ? old->c_cflag : cflag;
452452
gig_dbg(DEBUG_IF, "%u: iflag %x cflag %x old %x",
453453
cs->minor_index, iflag, cflag, old_cflag);

‎drivers/isdn/i4l/isdn_tty.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,15 +1009,15 @@ isdn_tty_change_speed(modem_info *info)
10091009
quot;
10101010
int i;
10111011

1012-
if (!port->tty || !port->tty->termios)
1012+
if (!port->tty)
10131013
return;
1014-
cflag = port->tty->termios->c_cflag;
1014+
cflag = port->tty->termios.c_cflag;
10151015

10161016
quot = i = cflag & CBAUD;
10171017
if (i & CBAUDEX) {
10181018
i &= ~CBAUDEX;
10191019
if (i < 1 || i > 2)
1020-
port->tty->termios->c_cflag &= ~CBAUDEX;
1020+
port->tty->termios.c_cflag &= ~CBAUDEX;
10211021
else
10221022
i += 15;
10231023
}
@@ -1097,7 +1097,7 @@ isdn_tty_shutdown(modem_info *info)
10971097
#endif
10981098
isdn_unlock_drivers();
10991099
info->msr &= ~UART_MSR_RI;
1100-
if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) {
1100+
if (!info->port.tty || (info->port.tty->termios.c_cflag & HUPCL)) {
11011101
info->mcr &= ~(UART_MCR_DTR | UART_MCR_RTS);
11021102
if (info->emu.mdmreg[REG_DTRHUP] & BIT_DTRHUP) {
11031103
isdn_tty_modem_reset_regs(info, 0);
@@ -1469,13 +1469,13 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
14691469
if (!old_termios)
14701470
isdn_tty_change_speed(info);
14711471
else {
1472-
if (tty->termios->c_cflag == old_termios->c_cflag &&
1473-
tty->termios->c_ispeed == old_termios->c_ispeed &&
1474-
tty->termios->c_ospeed == old_termios->c_ospeed)
1472+
if (tty->termios.c_cflag == old_termios->c_cflag &&
1473+
tty->termios.c_ispeed == old_termios->c_ispeed &&
1474+
tty->termios.c_ospeed == old_termios->c_ospeed)
14751475
return;
14761476
isdn_tty_change_speed(info);
14771477
if ((old_termios->c_cflag & CRTSCTS) &&
1478-
!(tty->termios->c_cflag & CRTSCTS))
1478+
!(tty->termios.c_cflag & CRTSCTS))
14791479
tty->hw_stopped = 0;
14801480
}
14811481
}

‎drivers/mmc/card/sdio_uart.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port)
518518
if (status & UART_MSR_DCTS) {
519519
port->icount.cts++;
520520
tty = tty_port_tty_get(&port->port);
521-
if (tty && (tty->termios->c_cflag & CRTSCTS)) {
521+
if (tty && (tty->termios.c_cflag & CRTSCTS)) {
522522
int cts = (status & UART_MSR_CTS);
523523
if (tty->hw_stopped) {
524524
if (cts) {
@@ -671,12 +671,12 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty)
671671
port->ier = UART_IER_RLSI|UART_IER_RDI|UART_IER_RTOIE|UART_IER_UUE;
672672
port->mctrl = TIOCM_OUT2;
673673

674-
sdio_uart_change_speed(port, tty->termios, NULL);
674+
sdio_uart_change_speed(port, &tty->termios, NULL);
675675

676-
if (tty->termios->c_cflag & CBAUD)
676+
if (tty->termios.c_cflag & CBAUD)
677677
sdio_uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
678678

679-
if (tty->termios->c_cflag & CRTSCTS)
679+
if (tty->termios.c_cflag & CRTSCTS)
680680
if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS))
681681
tty->hw_stopped = 1;
682682

@@ -850,7 +850,7 @@ static void sdio_uart_throttle(struct tty_struct *tty)
850850
{
851851
struct sdio_uart_port *port = tty->driver_data;
852852

853-
if (!I_IXOFF(tty) && !(tty->termios->c_cflag & CRTSCTS))
853+
if (!I_IXOFF(tty) && !(tty->termios.c_cflag & CRTSCTS))
854854
return;
855855

856856
if (sdio_uart_claim_func(port) != 0)
@@ -861,7 +861,7 @@ static void sdio_uart_throttle(struct tty_struct *tty)
861861
sdio_uart_start_tx(port);
862862
}
863863

864-
if (tty->termios->c_cflag & CRTSCTS)
864+
if (tty->termios.c_cflag & CRTSCTS)
865865
sdio_uart_clear_mctrl(port, TIOCM_RTS);
866866

867867
sdio_uart_irq(port->func);
@@ -872,7 +872,7 @@ static void sdio_uart_unthrottle(struct tty_struct *tty)
872872
{
873873
struct sdio_uart_port *port = tty->driver_data;
874874

875-
if (!I_IXOFF(tty) && !(tty->termios->c_cflag & CRTSCTS))
875+
if (!I_IXOFF(tty) && !(tty->termios.c_cflag & CRTSCTS))
876876
return;
877877

878878
if (sdio_uart_claim_func(port) != 0)
@@ -887,7 +887,7 @@ static void sdio_uart_unthrottle(struct tty_struct *tty)
887887
}
888888
}
889889

890-
if (tty->termios->c_cflag & CRTSCTS)
890+
if (tty->termios.c_cflag & CRTSCTS)
891891
sdio_uart_set_mctrl(port, TIOCM_RTS);
892892

893893
sdio_uart_irq(port->func);
@@ -898,12 +898,12 @@ static void sdio_uart_set_termios(struct tty_struct *tty,
898898
struct ktermios *old_termios)
899899
{
900900
struct sdio_uart_port *port = tty->driver_data;
901-
unsigned int cflag = tty->termios->c_cflag;
901+
unsigned int cflag = tty->termios.c_cflag;
902902

903903
if (sdio_uart_claim_func(port) != 0)
904904
return;
905905

906-
sdio_uart_change_speed(port, tty->termios, old_termios);
906+
sdio_uart_change_speed(port, &tty->termios, old_termios);
907907

908908
/* Handle transition to B0 status */
909909
if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD))

‎drivers/net/irda/irtty-sir.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ static int irtty_change_speed(struct sir_dev *dev, unsigned speed)
124124
tty = priv->tty;
125125

126126
mutex_lock(&tty->termios_mutex);
127-
old_termios = *(tty->termios);
128-
cflag = tty->termios->c_cflag;
127+
old_termios = tty->termios;
128+
cflag = tty->termios.c_cflag;
129129
tty_encode_baud_rate(tty, speed, speed);
130130
if (tty->ops->set_termios)
131131
tty->ops->set_termios(tty, &old_termios);
@@ -281,15 +281,15 @@ static inline void irtty_stop_receiver(struct tty_struct *tty, int stop)
281281
int cflag;
282282

283283
mutex_lock(&tty->termios_mutex);
284-
old_termios = *(tty->termios);
285-
cflag = tty->termios->c_cflag;
284+
old_termios = tty->termios;
285+
cflag = tty->termios.c_cflag;
286286

287287
if (stop)
288288
cflag &= ~CREAD;
289289
else
290290
cflag |= CREAD;
291291

292-
tty->termios->c_cflag = cflag;
292+
tty->termios.c_cflag = cflag;
293293
if (tty->ops->set_termios)
294294
tty->ops->set_termios(tty, &old_termios);
295295
mutex_unlock(&tty->termios_mutex);

‎drivers/net/usb/hso.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,6 @@ static void _hso_serial_set_termios(struct tty_struct *tty,
11071107
struct ktermios *old)
11081108
{
11091109
struct hso_serial *serial = tty->driver_data;
1110-
struct ktermios *termios;
11111110

11121111
if (!serial) {
11131112
printk(KERN_ERR "%s: no tty structures", __func__);
@@ -1119,16 +1118,15 @@ static void _hso_serial_set_termios(struct tty_struct *tty,
11191118
/*
11201119
* Fix up unsupported bits
11211120
*/
1122-
termios = tty->termios;
1123-
termios->c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */
1121+
tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */
11241122

1125-
termios->c_cflag &=
1123+
tty->termios.c_cflag &=
11261124
~(CSIZE /* no size */
11271125
| PARENB /* disable parity bit */
11281126
| CBAUD /* clear current baud rate */
11291127
| CBAUDEX); /* clear current buad rate */
11301128

1131-
termios->c_cflag |= CS8; /* character size 8 bits */
1129+
tty->termios.c_cflag |= CS8; /* character size 8 bits */
11321130

11331131
/* baud rate 115200 */
11341132
tty_encode_baud_rate(tty, 115200, 115200);
@@ -1425,14 +1423,14 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
14251423

14261424
if (old)
14271425
D5("Termios called with: cflags new[%d] - old[%d]",
1428-
tty->termios->c_cflag, old->c_cflag);
1426+
tty->termios.c_cflag, old->c_cflag);
14291427

14301428
/* the actual setup */
14311429
spin_lock_irqsave(&serial->serial_lock, flags);
14321430
if (serial->port.count)
14331431
_hso_serial_set_termios(tty, old);
14341432
else
1435-
tty->termios = old;
1433+
tty->termios = *old;
14361434
spin_unlock_irqrestore(&serial->serial_lock, flags);
14371435

14381436
/* done */

‎drivers/tty/amiserial.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
646646
custom.adkcon = AC_UARTBRK;
647647
mb();
648648

649-
if (tty->termios->c_cflag & HUPCL)
649+
if (tty->termios.c_cflag & HUPCL)
650650
info->MCR &= ~(SER_DTR|SER_RTS);
651651
rtsdtr_ctrl(info->MCR);
652652

@@ -670,7 +670,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
670670
int bits;
671671
unsigned long flags;
672672

673-
cflag = tty->termios->c_cflag;
673+
cflag = tty->termios.c_cflag;
674674

675675
/* Byte size is always 8 bits plus parity bit if requested */
676676

@@ -707,8 +707,8 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
707707
/* If the quotient is zero refuse the change */
708708
if (!quot && old_termios) {
709709
/* FIXME: Will need updating for new tty in the end */
710-
tty->termios->c_cflag &= ~CBAUD;
711-
tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD);
710+
tty->termios.c_cflag &= ~CBAUD;
711+
tty->termios.c_cflag |= (old_termios->c_cflag & CBAUD);
712712
baud = tty_get_baud_rate(tty);
713713
if (!baud)
714714
baud = 9600;
@@ -984,7 +984,7 @@ static void rs_throttle(struct tty_struct * tty)
984984
if (I_IXOFF(tty))
985985
rs_send_xchar(tty, STOP_CHAR(tty));
986986

987-
if (tty->termios->c_cflag & CRTSCTS)
987+
if (tty->termios.c_cflag & CRTSCTS)
988988
info->MCR &= ~SER_RTS;
989989

990990
local_irq_save(flags);
@@ -1012,7 +1012,7 @@ static void rs_unthrottle(struct tty_struct * tty)
10121012
else
10131013
rs_send_xchar(tty, START_CHAR(tty));
10141014
}
1015-
if (tty->termios->c_cflag & CRTSCTS)
1015+
if (tty->termios.c_cflag & CRTSCTS)
10161016
info->MCR |= SER_RTS;
10171017
local_irq_save(flags);
10181018
rtsdtr_ctrl(info->MCR);
@@ -1330,7 +1330,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
13301330
{
13311331
struct serial_state *info = tty->driver_data;
13321332
unsigned long flags;
1333-
unsigned int cflag = tty->termios->c_cflag;
1333+
unsigned int cflag = tty->termios.c_cflag;
13341334

13351335
change_speed(tty, info, old_termios);
13361336

@@ -1347,7 +1347,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
13471347
if (!(old_termios->c_cflag & CBAUD) &&
13481348
(cflag & CBAUD)) {
13491349
info->MCR |= SER_DTR;
1350-
if (!(tty->termios->c_cflag & CRTSCTS) ||
1350+
if (!(tty->termios.c_cflag & CRTSCTS) ||
13511351
!test_bit(TTY_THROTTLED, &tty->flags)) {
13521352
info->MCR |= SER_RTS;
13531353
}
@@ -1358,7 +1358,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
13581358

13591359
/* Handle turning off CRTSCTS */
13601360
if ((old_termios->c_cflag & CRTSCTS) &&
1361-
!(tty->termios->c_cflag & CRTSCTS)) {
1361+
!(tty->termios.c_cflag & CRTSCTS)) {
13621362
tty->hw_stopped = 0;
13631363
rs_start(tty);
13641364
}
@@ -1371,7 +1371,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
13711371
* or not. Hence, this may change.....
13721372
*/
13731373
if (!(old_termios->c_cflag & CLOCAL) &&
1374-
(tty->termios->c_cflag & CLOCAL))
1374+
(tty->termios.c_cflag & CLOCAL))
13751375
wake_up_interruptible(&info->open_wait);
13761376
#endif
13771377
}

‎drivers/tty/cyclades.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
14591459
info->port.xmit_buf = NULL;
14601460
free_page((unsigned long)temp);
14611461
}
1462-
if (tty->termios->c_cflag & HUPCL)
1462+
if (tty->termios.c_cflag & HUPCL)
14631463
cyy_change_rts_dtr(info, 0, TIOCM_RTS | TIOCM_DTR);
14641464

14651465
cyy_issue_cmd(info, CyCHAN_CTL | CyDIS_RCVR);
@@ -1488,7 +1488,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
14881488
free_page((unsigned long)temp);
14891489
}
14901490

1491-
if (tty->termios->c_cflag & HUPCL)
1491+
if (tty->termios.c_cflag & HUPCL)
14921492
tty_port_lower_dtr_rts(&info->port);
14931493

14941494
set_bit(TTY_IO_ERROR, &tty->flags);
@@ -1999,14 +1999,11 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
19991999
int baud, baud_rate = 0;
20002000
int i;
20012001

2002-
if (!tty->termios) /* XXX can this happen at all? */
2003-
return;
2004-
20052002
if (info->line == -1)
20062003
return;
20072004

2008-
cflag = tty->termios->c_cflag;
2009-
iflag = tty->termios->c_iflag;
2005+
cflag = tty->termios.c_cflag;
2006+
iflag = tty->termios.c_iflag;
20102007

20112008
/*
20122009
* Set up the tty->alt_speed kludge
@@ -2825,7 +2822,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
28252822
cy_set_line_char(info, tty);
28262823

28272824
if ((old_termios->c_cflag & CRTSCTS) &&
2828-
!(tty->termios->c_cflag & CRTSCTS)) {
2825+
!(tty->termios.c_cflag & CRTSCTS)) {
28292826
tty->hw_stopped = 0;
28302827
cy_start(tty);
28312828
}
@@ -2837,7 +2834,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
28372834
* or not. Hence, this may change.....
28382835
*/
28392836
if (!(old_termios->c_cflag & CLOCAL) &&
2840-
(tty->termios->c_cflag & CLOCAL))
2837+
(tty->termios.c_cflag & CLOCAL))
28412838
wake_up_interruptible(&info->port.open_wait);
28422839
#endif
28432840
} /* cy_set_termios */
@@ -2899,7 +2896,7 @@ static void cy_throttle(struct tty_struct *tty)
28992896
info->throttle = 1;
29002897
}
29012898

2902-
if (tty->termios->c_cflag & CRTSCTS) {
2899+
if (tty->termios.c_cflag & CRTSCTS) {
29032900
if (!cy_is_Z(card)) {
29042901
spin_lock_irqsave(&card->card_lock, flags);
29052902
cyy_change_rts_dtr(info, 0, TIOCM_RTS);
@@ -2938,7 +2935,7 @@ static void cy_unthrottle(struct tty_struct *tty)
29382935
cy_send_xchar(tty, START_CHAR(tty));
29392936
}
29402937

2941-
if (tty->termios->c_cflag & CRTSCTS) {
2938+
if (tty->termios.c_cflag & CRTSCTS) {
29422939
card = info->card;
29432940
if (!cy_is_Z(card)) {
29442941
spin_lock_irqsave(&card->card_lock, flags);

‎drivers/tty/hvc/hvsi_lib.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp)
400400
spin_unlock_irqrestore(&hp->lock, flags);
401401

402402
/* Clear our own DTR */
403-
if (!pv->tty || (pv->tty->termios->c_cflag & HUPCL))
403+
if (!pv->tty || (pv->tty->termios.c_cflag & HUPCL))
404404
hvsilib_write_mctrl(pv, 0);
405405

406406
/* Tear down the connection */

0 commit comments

Comments
 (0)