All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] tty: tty_struct dependency clean-ups
@ 2016-09-09 22:37 Rob Herring
  2016-09-09 22:37 ` [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped Rob Herring
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

This patch series removes or prepares to remove some of the dependencies 
on tty_struct within tty_port drivers. This will allow using tty_ports 
directly for so called UART slave devices. 

The first patch fixes a regression from the last round with tty 
closing. Patches 2-4 are mechanical conversions generated with 
coccinelle. This is my first adventure into coccinelle, so hopefully I 
didn't screw things up. :) Only serial_core has some of its tty_struct 
dependencies removed as those are the drivers we immediately care about 
supporting slave devices with.

Next up after this are moving some functions to the tty_port ops. I've 
got some WIP patches for some of that, but nothing ready to send out 
quite yet.

Rob

Rob Herring (9):
  tty: serial_core: add tty NULL check to uart_tx_stopped
  tty: remove tty_struct dependency in tty flag macros
  tty: move hw_stopped flag to tty_port
  tty: move TTY_IO_ERROR flag to tty_port iflags
  tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup
  tty: serial_core: introduce tty_port_to_uart_state
  tty: serial_core: convert private functions to use tty_port instead of
    tty_struct
  tty: serial_core: remove dependence on tty->driver_data
  tty: serial_core: add tty NULL check in uart_port_startup

 arch/ia64/hp/sim/simserial.c          |   8 +-
 drivers/char/pcmcia/synclink_cs.c     |  50 +++----
 drivers/dma/at_xdmac.c                |   4 +-
 drivers/isdn/i4l/isdn_tty.c           |  12 +-
 drivers/mmc/card/sdio_uart.c          |  40 +++---
 drivers/net/ppp/ppp_async.c           |   6 +-
 drivers/s390/char/ctrlchar.c          |   6 +-
 drivers/s390/char/tty3270.c           |   4 +-
 drivers/staging/dgnc/dgnc_cls.c       |   4 +-
 drivers/staging/dgnc/dgnc_neo.c       |   4 +-
 drivers/staging/dgnc/dgnc_tty.c       |   6 +-
 drivers/staging/fwserial/fwserial.c   |  56 ++++----
 drivers/tty/amiserial.c               |  74 +++++-----
 drivers/tty/cyclades.c                |  54 +++----
 drivers/tty/hvc/hvc_console.c         |   4 +-
 drivers/tty/hvc/hvsi.c                |   2 +-
 drivers/tty/isicom.c                  |  41 +++---
 drivers/tty/moxa.c                    |   4 +-
 drivers/tty/mxser.c                   |  72 +++++-----
 drivers/tty/n_gsm.c                   |   8 +-
 drivers/tty/n_tty.c                   | 259 +++++++++++++++++-----------------
 drivers/tty/pty.c                     |  14 +-
 drivers/tty/rocket.c                  |  36 ++---
 drivers/tty/serial/bfin_uart.c        |   6 +-
 drivers/tty/serial/crisv10.c          |  32 +++--
 drivers/tty/serial/etraxfs-uart.c     |   2 +-
 drivers/tty/serial/ioc4_serial.c      |   2 +-
 drivers/tty/serial/jsm/jsm_cls.c      |   2 +-
 drivers/tty/serial/jsm/jsm_neo.c      |   2 +-
 drivers/tty/serial/jsm/jsm_tty.c      |   4 +-
 drivers/tty/serial/serial_core.c      | 152 ++++++++++----------
 drivers/tty/synclink.c                |  56 ++++----
 drivers/tty/synclink_gt.c             |  52 +++----
 drivers/tty/synclinkmp.c              |  54 +++----
 drivers/tty/tty_audit.c               |   4 +-
 drivers/tty/tty_ioctl.c               |  22 +--
 drivers/tty/tty_port.c                |  16 +--
 drivers/tty/vt/keyboard.c             |   2 +-
 drivers/usb/class/cdc-acm.c           |   2 +-
 drivers/usb/serial/ark3116.c          |   2 +-
 drivers/usb/serial/cypress_m8.c       |   2 +-
 drivers/usb/serial/digi_acceleport.c  |   4 +-
 drivers/usb/serial/f81232.c           |  12 +-
 drivers/usb/serial/ftdi_sio.c         |   2 +-
 drivers/usb/serial/generic.c          |   2 +-
 drivers/usb/serial/io_edgeport.c      |  22 +--
 drivers/usb/serial/io_ti.c            |  22 +--
 drivers/usb/serial/mct_u232.c         |   8 +-
 drivers/usb/serial/mos7720.c          |  12 +-
 drivers/usb/serial/mos7840.c          |  12 +-
 drivers/usb/serial/mxuport.c          |  26 ++--
 drivers/usb/serial/pl2303.c           |  18 +--
 drivers/usb/serial/quatech2.c         |   4 +-
 drivers/usb/serial/ssu100.c           |   4 +-
 drivers/usb/serial/ti_usb_3410_5052.c |  16 +--
 drivers/usb/serial/whiteheat.c        |   6 +-
 include/linux/serial_core.h           |   2 +-
 include/linux/tty.h                   | 171 +++++++++++-----------
 net/bluetooth/rfcomm/tty.c            |   2 +-
 net/irda/ircomm/ircomm_tty.c          |  40 +++---
 net/irda/ircomm/ircomm_tty_attach.c   |   6 +-
 net/irda/ircomm/ircomm_tty_ioctl.c    |   6 +-
 62 files changed, 795 insertions(+), 784 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-09 22:37 ` [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros Rob Herring
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

Commit 761ed4a94582 ("tty: serial_core: convert uart_close to use
tty_port_close") created a case where a port used for a console does not
get shutdown on tty closing. Then a call to uart_tx_stopped() segfaults
because the tty is NULL. This could be fixed to restore old behavior,
but we also want to allow tty_ports to work without a tty attached. So
this change to allow a NULL tty_struct is needed either way.

Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Reported-by: kernel test robot <xiaolong.ye@intel.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 include/linux/serial_core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index cdba6f144f72..378d80a8dd43 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -412,7 +412,7 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
 static inline int uart_tx_stopped(struct uart_port *port)
 {
 	struct tty_struct *tty = port->state->port.tty;
-	if (tty->stopped || port->hw_stopped)
+	if ((tty && tty->stopped) || port->hw_stopped)
 		return 1;
 	return 0;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
  2016-09-09 22:37 ` [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-10  1:02   ` Rob Herring
  2016-09-09 22:37 ` [PATCH 3/9] tty: move hw_stopped flag to tty_port Rob Herring
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

In preparation to support tty drivers having only a tty_port and
possibly not a tty_struct, convert all the termios flag macros to take a
termios ptr instead of the tty_struct ptr. After this change drivers can
be converted to support a termios struct other than tty->termios.

Yes, this is a big, treewide change, but it is mostly contained to
drivers/tty and drivers/usb/serial. I don't see another way to do it
other than defining a new set of macros.

Converted with the following coccinelle script:

@@
expression tty;
identifier x =~ "(I_IGNBRK|I_BRKINT|I_IGNPAR|I_PARMRK|I_INPCK|\
I_ISTRIP|I_INLCR|I_IGNCR|I_ICRNL|I_IUCLC|I_IXON|I_IXANY|I_IXOFF|\
I_IMAXBEL|I_IUTF8|O_OPOST|O_OLCUC|O_ONLCR|O_OCRNL|O_ONOCR|O_ONLRET|\
O_OFILL|O_OFDEL|O_NLDLY|O_CRDLY|O_TABDLY|O_BSDLY|O_VTDLY|O_FFDLY|\
C_BAUD|C_CSIZE|C_CSTOPB|C_CREAD|C_PARENB|C_PARODD|C_HUPCL|C_CLOCAL|\
C_CIBAUD|C_CRTSCTS|C_CMSPAR|L_ISIG|L_ICANON|L_XCASE|L_ECHO|L_ECHOE|\
L_ECHOK|L_ECHONL|L_NOFLSH|L_TOSTOP|L_ECHOCTL|L_ECHOPRT|L_ECHOKE|\
L_FLUSHO|L_PENDIN|L_IEXTEN|L_EXTPROC|INTR_CHAR|QUIT_CHAR|ERASE_CHAR|\
KILL_CHAR|EOF_CHAR|TIME_CHAR|MIN_CHAR|SWTC_CHAR|START_CHAR|STOP_CHAR|\
SUSP_CHAR|EOL_CHAR|REPRINT_CHAR|DISCARD_CHAR|WERASE_CHAR|LNEXT_CHAR|\
EOL2_CHAR)";

@@
- x(tty)
+ x(&tty->termios)

@@
expression tty;
expression flag;
identifier x =~ "_(I|O|C|L)_FLAG";

@@
- x(tty, flag)
+ x(&tty->termios, flag)

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Alan Cox <alan@linux.intel.com>
Cc: linux-serial@vger.kernel.org
---
 arch/ia64/hp/sim/simserial.c          |   8 +-
 drivers/char/pcmcia/synclink_cs.c     |  28 ++--
 drivers/dma/at_xdmac.c                |   4 +-
 drivers/isdn/i4l/isdn_tty.c           |   8 +-
 drivers/mmc/card/sdio_uart.c          |  22 +--
 drivers/net/ppp/ppp_async.c           |   6 +-
 drivers/s390/char/ctrlchar.c          |   6 +-
 drivers/s390/char/tty3270.c           |   4 +-
 drivers/staging/dgnc/dgnc_cls.c       |   4 +-
 drivers/staging/dgnc/dgnc_neo.c       |   4 +-
 drivers/staging/dgnc/dgnc_tty.c       |   6 +-
 drivers/staging/fwserial/fwserial.c   |  32 ++---
 drivers/tty/amiserial.c               |  30 ++--
 drivers/tty/cyclades.c                |  28 ++--
 drivers/tty/hvc/hvc_console.c         |   4 +-
 drivers/tty/hvc/hvsi.c                |   2 +-
 drivers/tty/isicom.c                  |  27 ++--
 drivers/tty/moxa.c                    |   4 +-
 drivers/tty/mxser.c                   |  38 ++---
 drivers/tty/n_gsm.c                   |   8 +-
 drivers/tty/n_tty.c                   | 259 +++++++++++++++++-----------------
 drivers/tty/pty.c                     |   8 +-
 drivers/tty/rocket.c                  |  36 ++---
 drivers/tty/serial/crisv10.c          |  28 ++--
 drivers/tty/serial/etraxfs-uart.c     |   2 +-
 drivers/tty/serial/jsm/jsm_cls.c      |   2 +-
 drivers/tty/serial/jsm/jsm_neo.c      |   2 +-
 drivers/tty/serial/jsm/jsm_tty.c      |   4 +-
 drivers/tty/serial/serial_core.c      |  16 +--
 drivers/tty/synclink.c                |  34 ++---
 drivers/tty/synclink_gt.c             |  34 ++---
 drivers/tty/synclinkmp.c              |  34 ++---
 drivers/tty/tty_audit.c               |   4 +-
 drivers/tty/tty_ioctl.c               |  22 +--
 drivers/tty/tty_port.c                |  10 +-
 drivers/tty/vt/keyboard.c             |   2 +-
 drivers/usb/class/cdc-acm.c           |   2 +-
 drivers/usb/serial/ark3116.c          |   2 +-
 drivers/usb/serial/cypress_m8.c       |   2 +-
 drivers/usb/serial/digi_acceleport.c  |   4 +-
 drivers/usb/serial/f81232.c           |  12 +-
 drivers/usb/serial/ftdi_sio.c         |   2 +-
 drivers/usb/serial/generic.c          |   2 +-
 drivers/usb/serial/io_edgeport.c      |  22 +--
 drivers/usb/serial/io_ti.c            |  22 +--
 drivers/usb/serial/mct_u232.c         |   8 +-
 drivers/usb/serial/mos7720.c          |  12 +-
 drivers/usb/serial/mos7840.c          |  12 +-
 drivers/usb/serial/mxuport.c          |  26 ++--
 drivers/usb/serial/pl2303.c           |  18 +--
 drivers/usb/serial/quatech2.c         |   4 +-
 drivers/usb/serial/ssu100.c           |   4 +-
 drivers/usb/serial/ti_usb_3410_5052.c |  16 +--
 drivers/usb/serial/whiteheat.c        |   6 +-
 include/linux/tty.h                   | 164 ++++++++++-----------
 net/irda/ircomm/ircomm_tty.c          |  18 +--
 net/irda/ircomm/ircomm_tty_ioctl.c    |   4 +-
 57 files changed, 571 insertions(+), 561 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 21fd50def270..f276e6e96e64 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -276,8 +276,8 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
  */
 static void rs_throttle(struct tty_struct * tty)
 {
-	if (I_IXOFF(tty))
-		rs_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		rs_send_xchar(tty, STOP_CHAR(&tty->termios));
 
 	printk(KERN_INFO "simrs_throttle called\n");
 }
@@ -286,11 +286,11 @@ static void rs_unthrottle(struct tty_struct * tty)
 {
 	struct serial_state *info = tty->driver_data;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			rs_send_xchar(tty, START_CHAR(tty));
+			rs_send_xchar(tty, START_CHAR(&tty->termios));
 	}
 	printk(KERN_INFO "simrs_unthrottle called\n");
 }
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index d28922df01d7..8f5528abc390 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -1349,7 +1349,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty)
 	/* TODO:disable interrupts instead of reset to preserve signal states */
 	reset_device(info);
 
-	if (!tty || C_HUPCL(tty)) {
+	if (!tty || C_HUPCL(&tty->termios)) {
 		info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
 		set_signals(info);
 	}
@@ -1390,7 +1390,7 @@ static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty)
 	port_irq_enable(info, (unsigned char) PVR_DSR | PVR_RI);
 	get_signals(info);
 
-	if (info->netcount || (tty && C_CREAD(tty)))
+	if (info->netcount || (tty && C_CREAD(&tty->termios)))
 		rx_start(info);
 
 	spin_unlock_irqrestore(&info->lock, flags);
@@ -1472,9 +1472,9 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty)
 	/* process tty input control flags */
 
 	info->read_status_mask = 0;
-	if (I_INPCK(tty))
+	if (I_INPCK(&tty->termios))
 		info->read_status_mask |= BIT7 | BIT6;
-	if (I_IGNPAR(tty))
+	if (I_IGNPAR(&tty->termios))
 		info->ignore_status_mask |= BIT7 | BIT6;
 
 	mgslpc_program_hw(info, tty);
@@ -1723,10 +1723,10 @@ static void mgslpc_throttle(struct tty_struct * tty)
 	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle"))
 		return;
 
-	if (I_IXOFF(tty))
-		mgslpc_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		mgslpc_send_xchar(tty, STOP_CHAR(&tty->termios));
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->lock, flags);
 		info->serial_signals &= ~SerialSignal_RTS;
 		set_signals(info);
@@ -1748,14 +1748,14 @@ static void mgslpc_unthrottle(struct tty_struct * tty)
 	if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle"))
 		return;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			mgslpc_send_xchar(tty, START_CHAR(tty));
+			mgslpc_send_xchar(tty, START_CHAR(&tty->termios));
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->lock, flags);
 		info->serial_signals |= SerialSignal_RTS;
 		set_signals(info);
@@ -2299,7 +2299,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term
 	mgslpc_change_params(info, tty);
 
 	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) {
+	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(&tty->termios)) {
 		info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
 		spin_lock_irqsave(&info->lock, flags);
 		set_signals(info);
@@ -2307,9 +2307,9 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term
 	}
 
 	/* Handle transition away from B0 status */
-	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
+	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(&tty->termios)) {
 		info->serial_signals |= SerialSignal_DTR;
-		if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			info->serial_signals |= SerialSignal_RTS;
 		spin_lock_irqsave(&info->lock, flags);
 		set_signals(info);
@@ -2317,7 +2317,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term
 	}
 
 	/* Handle turning off CRTSCTS */
-	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(tty)) {
+	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		tx_release(tty);
 	}
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 832cbd647145..e5d7e4db6bdc 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -560,7 +560,7 @@ static int at_xdmac_compute_chan_conf(struct dma_chan *chan,
 			dev_err(chan2dev(chan), "invalid src maxburst value\n");
 			return -EINVAL;
 		}
-		atchan->cfg |= AT_XDMAC_CC_CSIZE(csize);
+		atchan->cfg |= AT_XDMAC_CC_CSIZE(&csize->termios);
 		dwidth = ffs(atchan->sconfig.src_addr_width) - 1;
 		if (dwidth < 0) {
 			dev_err(chan2dev(chan), "invalid src addr width value\n");
@@ -583,7 +583,7 @@ static int at_xdmac_compute_chan_conf(struct dma_chan *chan,
 			dev_err(chan2dev(chan), "invalid src maxburst value\n");
 			return -EINVAL;
 		}
-		atchan->cfg |= AT_XDMAC_CC_CSIZE(csize);
+		atchan->cfg |= AT_XDMAC_CC_CSIZE(&csize->termios);
 		dwidth = ffs(atchan->sconfig.dst_addr_width) - 1;
 		if (dwidth < 0) {
 			dev_err(chan2dev(chan), "invalid dst addr width value\n");
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 63eaa0a9f8a1..ca5ea73a3fc9 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1290,8 +1290,8 @@ isdn_tty_throttle(struct tty_struct *tty)
 
 	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_throttle"))
 		return;
-	if (I_IXOFF(tty))
-		info->x_char = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios))
+		info->x_char = STOP_CHAR(&tty->termios);
 	info->mcr &= ~UART_MCR_RTS;
 }
 
@@ -1302,11 +1302,11 @@ isdn_tty_unthrottle(struct tty_struct *tty)
 
 	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_unthrottle"))
 		return;
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			info->x_char = START_CHAR(tty);
+			info->x_char = START_CHAR(&tty->termios);
 	}
 	info->mcr |= UART_MCR_RTS;
 }
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index 5af6fb9a9ce2..4a6decfcad03 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -493,7 +493,7 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port)
 	if (status & UART_MSR_DCTS) {
 		port->icount.cts++;
 		tty = tty_port_tty_get(&port->port);
-		if (tty && C_CRTSCTS(tty)) {
+		if (tty && C_CRTSCTS(&tty->termios)) {
 			int cts = (status & UART_MSR_CTS);
 			if (tty->hw_stopped) {
 				if (cts) {
@@ -648,10 +648,10 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty)
 
 	sdio_uart_change_speed(port, &tty->termios, NULL);
 
-	if (C_BAUD(tty))
+	if (C_BAUD(&tty->termios))
 		sdio_uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
 
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS))
 			tty->hw_stopped = 1;
 
@@ -833,18 +833,18 @@ static void sdio_uart_throttle(struct tty_struct *tty)
 {
 	struct sdio_uart_port *port = tty->driver_data;
 
-	if (!I_IXOFF(tty) && !C_CRTSCTS(tty))
+	if (!I_IXOFF(&tty->termios) && !C_CRTSCTS(&tty->termios))
 		return;
 
 	if (sdio_uart_claim_func(port) != 0)
 		return;
 
-	if (I_IXOFF(tty)) {
-		port->x_char = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		port->x_char = STOP_CHAR(&tty->termios);
 		sdio_uart_start_tx(port);
 	}
 
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		sdio_uart_clear_mctrl(port, TIOCM_RTS);
 
 	sdio_uart_irq(port->func);
@@ -855,22 +855,22 @@ static void sdio_uart_unthrottle(struct tty_struct *tty)
 {
 	struct sdio_uart_port *port = tty->driver_data;
 
-	if (!I_IXOFF(tty) && !C_CRTSCTS(tty))
+	if (!I_IXOFF(&tty->termios) && !C_CRTSCTS(&tty->termios))
 		return;
 
 	if (sdio_uart_claim_func(port) != 0)
 		return;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (port->x_char) {
 			port->x_char = 0;
 		} else {
-			port->x_char = START_CHAR(tty);
+			port->x_char = START_CHAR(&tty->termios);
 			sdio_uart_start_tx(port);
 		}
 	}
 
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		sdio_uart_set_mctrl(port, TIOCM_RTS);
 
 	sdio_uart_irq(port->func);
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index 9c889e0303dd..a1f8f0ce9e4c 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -913,10 +913,10 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
 			process_input_packet(ap);
 		} else if (c == PPP_ESCAPE) {
 			ap->state |= SC_ESCAPE;
-		} else if (I_IXON(ap->tty)) {
-			if (c == START_CHAR(ap->tty))
+		} else if (I_IXON(&ap->tty->termios)) {
+			if (c == START_CHAR(&ap->tty->termios))
 				start_tty(ap->tty);
-			else if (c == STOP_CHAR(ap->tty))
+			else if (c == STOP_CHAR(&ap->tty->termios))
 				stop_tty(ap->tty);
 		}
 		/* otherwise it's a char in the recv ACCM */
diff --git a/drivers/s390/char/ctrlchar.c b/drivers/s390/char/ctrlchar.c
index f7d92584b993..dc25c2bb1e3b 100644
--- a/drivers/s390/char/ctrlchar.c
+++ b/drivers/s390/char/ctrlchar.c
@@ -68,11 +68,11 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty)
 
 	switch (tolower(buf[1])) {
 	case 'c':
-		return INTR_CHAR(tty) | CTRLCHAR_CTRL;
+		return INTR_CHAR(&tty->termios) | CTRLCHAR_CTRL;
 	case 'd':
-		return EOF_CHAR(tty)  | CTRLCHAR_CTRL;
+		return EOF_CHAR(&tty->termios)  | CTRLCHAR_CTRL;
 	case 'z':
-		return SUSP_CHAR(tty) | CTRLCHAR_CTRL;
+		return SUSP_CHAR(&tty->termios) | CTRLCHAR_CTRL;
 	}
 	return CTRLCHAR_NONE;
 }
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 272cb6cd1b2a..9aef796819cf 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -1782,8 +1782,8 @@ tty3270_set_termios(struct tty_struct *tty, struct ktermios *old)
 	if (!tp)
 		return;
 	spin_lock_bh(&tp->view.lock);
-	if (L_ICANON(tty)) {
-		new = L_ECHO(tty) ? TF_INPUT: TF_INPUTN;
+	if (L_ICANON(&tty->termios)) {
+		new = L_ECHO(&tty->termios) ? TF_INPUT: TF_INPUTN;
 		if (new != tp->inattr) {
 			tp->inattr = new;
 			tty3270_update_prompt(tp, NULL, 0);
diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index 46c050cc7dbe..71a5e015aad0 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -519,9 +519,9 @@ static void cls_param(struct tty_struct *tty)
 		 */
 		if (!(ch->ch_tun.un_flags & UN_ISOPEN) &&
 		    (un->un_type == DGNC_PRINT))
-			baud = C_BAUD(ch->ch_pun.un_tty) & 0xff;
+			baud = C_BAUD(&ch->ch_pun.un_tty->termios) & 0xff;
 		else
-			baud = C_BAUD(ch->ch_tun.un_tty) & 0xff;
+			baud = C_BAUD(&ch->ch_tun.un_tty->termios) & 0xff;
 
 		if (ch->ch_c_cflag & CBAUDEX)
 			iindex = 1;
diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index ba57e9546f72..1c85254304b5 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -668,9 +668,9 @@ static void neo_param(struct tty_struct *tty)
 		/* Only use the TXPrint baud rate if the terminal unit is NOT open */
 		if (!(ch->ch_tun.un_flags & UN_ISOPEN) &&
 		    (un->un_type == DGNC_PRINT))
-			baud = C_BAUD(ch->ch_pun.un_tty) & 0xff;
+			baud = C_BAUD(&ch->ch_pun.un_tty->termios) & 0xff;
 		else
-			baud = C_BAUD(ch->ch_tun.un_tty) & 0xff;
+			baud = C_BAUD(&ch->ch_tun.un_tty->termios) & 0xff;
 
 		if (ch->ch_c_cflag & CBAUDEX)
 			iindex = 1;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 4eeecc992a02..e96ef44417ee 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -509,7 +509,7 @@ void dgnc_input(struct channel_t *ch)
 	 */
 	if (!tp || (tp->magic != TTY_MAGIC) ||
 	    !(ch->ch_tun.un_flags & UN_ISOPEN) ||
-	    !C_CREAD(tp) ||
+	    !C_CREAD(&tp->termios) ||
 	    (ch->ch_tun.un_flags & UN_CLOSING)) {
 		ch->ch_r_head = tail;
 
@@ -592,7 +592,7 @@ void dgnc_input(struct channel_t *ch)
 		 * and error byte and send them to the buffer one at
 		 * a time.
 		 */
-		if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
+		if (I_PARMRK(&tp->termios) || I_BRKINT(&tp->termios) || I_INPCK(&tp->termios)) {
 			for (i = 0; i < s; i++) {
 				unsigned char ch = *(ch_pos + i);
 				char flag = TTY_NORMAL;
@@ -2593,7 +2593,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 
 		spin_unlock_irqrestore(&ch->ch_lock, flags);
 
-		rc = put_user(C_CLOCAL(tty) ? 1 : 0,
+		rc = put_user(C_CLOCAL(&tty->termios) ? 1 : 0,
 			      (unsigned long __user *)arg);
 		return rc;
 
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index c241c0ae3f20..e391344d227c 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -328,7 +328,7 @@ static void fwtty_update_port_status(struct fwtty_port *port,
 
 	if (delta & TIOCM_CAR) {
 		tty = tty_port_tty_get(&port->port);
-		if (tty && !C_CLOCAL(tty)) {
+		if (tty && !C_CLOCAL(&tty->termios)) {
 			if (status & TIOCM_CAR)
 				wake_up_interruptible(&port->port.open_wait);
 			else
@@ -339,7 +339,7 @@ static void fwtty_update_port_status(struct fwtty_port *port,
 
 	if (delta & TIOCM_CTS) {
 		tty = tty_port_tty_get(&port->port);
-		if (tty && C_CRTSCTS(tty)) {
+		if (tty && C_CRTSCTS(&tty->termios)) {
 			if (tty->hw_stopped) {
 				if (status & TIOCM_CTS) {
 					tty->hw_stopped = 0;
@@ -465,7 +465,7 @@ static void fwtty_throttle_port(struct fwtty_port *port)
 
 	old = port->mctrl;
 	port->mctrl |= OOB_RX_THROTTLE;
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		port->mctrl &= ~TIOCM_RTS;
 	if (~old & OOB_RX_THROTTLE)
 		__fwtty_write_port_status(port);
@@ -943,11 +943,11 @@ static unsigned int set_termios(struct fwtty_port *port, struct tty_struct *tty)
 	tty_termios_encode_baud_rate(&tty->termios, baud, baud);
 
 	/* compute bit count of 2 frames */
-	frame = 12 + ((C_CSTOPB(tty)) ? 4 : 2) + ((C_PARENB(tty)) ? 2 : 0);
+	frame = 12 + ((C_CSTOPB(&tty->termios)) ? 4 : 2) + ((C_PARENB(&tty->termios)) ? 2 : 0);
 
-	switch (C_CSIZE(tty)) {
+	switch (C_CSIZE(&tty->termios)) {
 	case CS5:
-		frame -= (C_CSTOPB(tty)) ? 1 : 0;
+		frame -= (C_CSTOPB(&tty->termios)) ? 1 : 0;
 		break;
 	case CS6:
 		frame += 2;
@@ -963,17 +963,17 @@ static unsigned int set_termios(struct fwtty_port *port, struct tty_struct *tty)
 	port->cps = (baud << 1) / frame;
 
 	port->status_mask = UART_LSR_OE;
-	if (_I_FLAG(tty, BRKINT | PARMRK))
+	if (_I_FLAG(&tty->termios, BRKINT | PARMRK))
 		port->status_mask |= UART_LSR_BI;
 
 	port->ignore_mask = 0;
-	if (I_IGNBRK(tty)) {
+	if (I_IGNBRK(&tty->termios)) {
 		port->ignore_mask |= UART_LSR_BI;
-		if (I_IGNPAR(tty))
+		if (I_IGNPAR(&tty->termios))
 			port->ignore_mask |= UART_LSR_OE;
 	}
 
-	port->write_only = !C_CREAD(tty);
+	port->write_only = !C_CREAD(&tty->termios);
 
 	/* turn off echo and newline xlat if loopback */
 	if (port->loopback) {
@@ -1013,7 +1013,7 @@ static int fwtty_port_activate(struct tty_port *tty_port,
 			port->mctrl = TIOCM_DTR | TIOCM_RTS;
 	}
 
-	if (C_CRTSCTS(tty) && ~port->mstatus & TIOCM_CTS)
+	if (C_CRTSCTS(&tty->termios) && ~port->mstatus & TIOCM_CTS)
 		tty->hw_stopped = 1;
 
 	__fwtty_write_port_status(port);
@@ -1185,13 +1185,13 @@ static void fwtty_unthrottle(struct tty_struct *tty)
 {
 	struct fwtty_port *port = tty->driver_data;
 
-	fwtty_dbg(port, "CRTSCTS: %d\n", C_CRTSCTS(tty) != 0);
+	fwtty_dbg(port, "CRTSCTS: %d\n", C_CRTSCTS(&tty->termios) != 0);
 
 	fwtty_profile_fifo(port, port->stats.unthrottle);
 
 	spin_lock_bh(&port->lock);
 	port->mctrl &= ~OOB_RX_THROTTLE;
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		port->mctrl |= TIOCM_RTS;
 	__fwtty_write_port_status(port);
 	spin_unlock_bh(&port->lock);
@@ -1306,7 +1306,7 @@ static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old)
 	if ((baud == 0) && (old->c_cflag & CBAUD)) {
 		port->mctrl &= ~(TIOCM_DTR | TIOCM_RTS);
 	} else if ((baud != 0) && !(old->c_cflag & CBAUD)) {
-		if (C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			port->mctrl |= TIOCM_DTR | TIOCM_RTS;
 		else
 			port->mctrl |= TIOCM_DTR;
@@ -1315,11 +1315,11 @@ static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old)
 	spin_unlock_bh(&port->lock);
 
 	if (old->c_cflag & CRTSCTS) {
-		if (!C_CRTSCTS(tty)) {
+		if (!C_CRTSCTS(&tty->termios)) {
 			tty->hw_stopped = 0;
 			fwtty_restart_tx(port);
 		}
-	} else if (C_CRTSCTS(tty) && ~port->mstatus & TIOCM_CTS) {
+	} else if (C_CRTSCTS(&tty->termios) && ~port->mstatus & TIOCM_CTS) {
 		tty->hw_stopped = 1;
 	}
 }
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 208f573495dc..16483a6cc347 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -562,7 +562,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
 	current_ctl_bits = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
 
 	info->MCR = 0;
-	if (C_BAUD(tty))
+	if (C_BAUD(&tty->termios))
 	  info->MCR = SER_DTR | SER_RTS;
 	rtsdtr_ctrl(info->MCR);
 
@@ -639,7 +639,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
 	custom.adkcon = AC_UARTBRK;
 	mb();
 
-	if (C_HUPCL(tty))
+	if (C_HUPCL(&tty->termios))
 		info->MCR &= ~(SER_DTR|SER_RTS);
 	rtsdtr_ctrl(info->MCR);
 
@@ -742,24 +742,24 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
 	 */
 
 	info->read_status_mask = UART_LSR_OE | UART_LSR_DR;
-	if (I_INPCK(tty))
+	if (I_INPCK(&tty->termios))
 		info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
-	if (I_BRKINT(tty) || I_PARMRK(tty))
+	if (I_BRKINT(&tty->termios) || I_PARMRK(&tty->termios))
 		info->read_status_mask |= UART_LSR_BI;
 
 	/*
 	 * Characters to ignore
 	 */
 	info->ignore_status_mask = 0;
-	if (I_IGNPAR(tty))
+	if (I_IGNPAR(&tty->termios))
 		info->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
-	if (I_IGNBRK(tty)) {
+	if (I_IGNBRK(&tty->termios)) {
 		info->ignore_status_mask |= UART_LSR_BI;
 		/*
 		 * If we're ignore parity and break indicators, ignore 
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(tty))
+		if (I_IGNPAR(&tty->termios))
 			info->ignore_status_mask |= UART_LSR_OE;
 	}
 	/*
@@ -966,10 +966,10 @@ static void rs_throttle(struct tty_struct * tty)
 	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
 		return;
 
-	if (I_IXOFF(tty))
-		rs_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		rs_send_xchar(tty, STOP_CHAR(&tty->termios));
 
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		info->MCR &= ~SER_RTS;
 
 	local_irq_save(flags);
@@ -988,13 +988,13 @@ static void rs_unthrottle(struct tty_struct * tty)
 	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
 		return;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			rs_send_xchar(tty, START_CHAR(tty));
+			rs_send_xchar(tty, START_CHAR(&tty->termios));
 	}
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		info->MCR |= SER_RTS;
 	local_irq_save(flags);
 	rtsdtr_ctrl(info->MCR);
@@ -1337,7 +1337,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	/* Handle transition away from B0 status */
 	if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
 		info->MCR |= SER_DTR;
-		if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			info->MCR |= SER_RTS;
 		local_irq_save(flags);
 		rtsdtr_ctrl(info->MCR);
@@ -1345,7 +1345,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	}
 
 	/* Handle turning off CRTSCTS */
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		rs_start(tty);
 	}
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 5e4fa9206861..2d165282f483 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -1438,7 +1438,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
 			info->port.xmit_buf = NULL;
 			free_page((unsigned long)temp);
 		}
-		if (C_HUPCL(tty))
+		if (C_HUPCL(&tty->termios))
 			cyy_change_rts_dtr(info, 0, TIOCM_RTS | TIOCM_DTR);
 
 		cyy_issue_cmd(info, CyCHAN_CTL | CyDIS_RCVR);
@@ -1467,7 +1467,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
 			free_page((unsigned long)temp);
 		}
 
-		if (C_HUPCL(tty))
+		if (C_HUPCL(&tty->termios))
 			tty_port_lower_dtr_rts(&info->port);
 
 		set_bit(TTY_IO_ERROR, &tty->flags);
@@ -2112,8 +2112,8 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
 
 		/* set line characteristics  according configuration */
 
-		cyy_writeb(info, CySCHR1, START_CHAR(tty));
-		cyy_writeb(info, CySCHR2, STOP_CHAR(tty));
+		cyy_writeb(info, CySCHR1, START_CHAR(&tty->termios));
+		cyy_writeb(info, CySCHR2, STOP_CHAR(&tty->termios));
 		cyy_writeb(info, CyCOR1, info->cor1);
 		cyy_writeb(info, CyCOR2, info->cor2);
 		cyy_writeb(info, CyCOR3, info->cor3);
@@ -2130,7 +2130,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
 		/* 10ms rx timeout */
 
 		cflags = CyCTS;
-		if (!C_CLOCAL(tty))
+		if (!C_CLOCAL(&tty->termios))
 			cflags |= CyDSR | CyRI | CyDCD;
 		/* without modem intr */
 		cyy_writeb(info, CySRER, cyy_readb(info, CySRER) | CyMdmCh);
@@ -2784,7 +2784,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 
 	cy_set_line_char(info, tty);
 
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		cy_start(tty);
 	}
@@ -2821,9 +2821,9 @@ static void cy_send_xchar(struct tty_struct *tty, char ch)
 	channel = info->line - card->first_line;
 
 	if (cy_is_Z(card)) {
-		if (ch == STOP_CHAR(tty))
+		if (ch == STOP_CHAR(&tty->termios))
 			cyz_issue_cmd(card, channel, C_CM_SENDXOFF, 0L);
-		else if (ch == START_CHAR(tty))
+		else if (ch == START_CHAR(&tty->termios))
 			cyz_issue_cmd(card, channel, C_CM_SENDXON, 0L);
 	}
 }
@@ -2848,14 +2848,14 @@ static void cy_throttle(struct tty_struct *tty)
 
 	card = info->card;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (!cy_is_Z(card))
-			cy_send_xchar(tty, STOP_CHAR(tty));
+			cy_send_xchar(tty, STOP_CHAR(&tty->termios));
 		else
 			info->throttle = 1;
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		if (!cy_is_Z(card)) {
 			spin_lock_irqsave(&card->card_lock, flags);
 			cyy_change_rts_dtr(info, 0, TIOCM_RTS);
@@ -2885,14 +2885,14 @@ static void cy_unthrottle(struct tty_struct *tty)
 	if (serial_paranoia_check(info, tty->name, "cy_unthrottle"))
 		return;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			cy_send_xchar(tty, START_CHAR(tty));
+			cy_send_xchar(tty, START_CHAR(&tty->termios));
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		card = info->card;
 		if (!cy_is_Z(card)) {
 			spin_lock_irqsave(&card->card_lock, flags);
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index ce864875330e..630a2a0f0ddf 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -368,7 +368,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
 		printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
 	} else
 		/* We are ready... raise DTR/RTS */
-		if (C_BAUD(tty))
+		if (C_BAUD(&tty->termios))
 			if (hp->ops->dtr_rts)
 				hp->ops->dtr_rts(hp, 1);
 
@@ -403,7 +403,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
 		/* We are done with the tty pointer now. */
 		tty_port_tty_set(&hp->port, NULL);
 
-		if (C_HUPCL(tty))
+		if (C_HUPCL(&tty->termios))
 			if (hp->ops->dtr_rts)
 				hp->ops->dtr_rts(hp, 0);
 
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index 96ce6bd1cc6f..d293a5ffcd18 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -246,7 +246,7 @@ static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet,
 				/* CD went away; no more connection */
 				pr_debug("hvsi%i: CD dropped\n", hp->index);
 				hp->mctrl &= TIOCM_CD;
-				if (tty && !C_CLOCAL(tty))
+				if (tty && !C_CLOCAL(&tty->termios))
 					tty_hangup(tty);
 			}
 			break;
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index b70187b46d9d..2478aa559834 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -691,7 +691,7 @@ static void isicom_config_port(struct tty_struct *tty)
 	unsigned char flow_ctrl;
 
 	/* FIXME: Switch to new tty baud API */
-	baud = C_BAUD(tty);
+	baud = C_BAUD(&tty->termios);
 	if (baud & CBAUDEX) {
 		baud &= ~CBAUDEX;
 
@@ -733,7 +733,7 @@ static void isicom_config_port(struct tty_struct *tty)
 		outw(0x8000 | (channel << shift_count) | 0x03, base);
 		outw(linuxb_to_isib[baud] << 8 | 0x03, base);
 		channel_setup = 0;
-		switch (C_CSIZE(tty)) {
+		switch (C_CSIZE(&tty->termios)) {
 		case CS5:
 			channel_setup |= ISICOM_CS5;
 			break;
@@ -748,37 +748,38 @@ static void isicom_config_port(struct tty_struct *tty)
 			break;
 		}
 
-		if (C_CSTOPB(tty))
+		if (C_CSTOPB(&tty->termios))
 			channel_setup |= ISICOM_2SB;
-		if (C_PARENB(tty)) {
+		if (C_PARENB(&tty->termios)) {
 			channel_setup |= ISICOM_EVPAR;
-			if (C_PARODD(tty))
+			if (C_PARODD(&tty->termios))
 				channel_setup |= ISICOM_ODPAR;
 		}
 		outw(channel_setup, base);
 		InterruptTheCard(base);
 	}
-	tty_port_set_check_carrier(&port->port, !C_CLOCAL(tty));
+	tty_port_set_check_carrier(&port->port, !C_CLOCAL(&tty->termios));
 
 	/* flow control settings ...*/
 	flow_ctrl = 0;
-	tty_port_set_cts_flow(&port->port, C_CRTSCTS(tty));
-	if (C_CRTSCTS(tty))
+	tty_port_set_cts_flow(&port->port, C_CRTSCTS(&tty->termios));
+	if (C_CRTSCTS(&tty->termios))
 		flow_ctrl |= ISICOM_CTSRTS;
-	if (I_IXON(tty))
+	if (I_IXON(&tty->termios))
 		flow_ctrl |= ISICOM_RESPOND_XONXOFF;
-	if (I_IXOFF(tty))
+	if (I_IXOFF(&tty->termios))
 		flow_ctrl |= ISICOM_INITIATE_XONXOFF;
 
 	if (WaitTillCardIsFree(base) == 0) {
 		outw(0x8000 | (channel << shift_count) | 0x04, base);
 		outw(flow_ctrl << 8 | 0x05, base);
-		outw((STOP_CHAR(tty)) << 8 | (START_CHAR(tty)), base);
+		outw((STOP_CHAR(&tty->termios)) << 8 | (START_CHAR(&tty->termios)),
+		     base);
 		InterruptTheCard(base);
 	}
 
 	/*	rx enabled -> enable port for rx on the card	*/
-	if (C_CREAD(tty)) {
+	if (C_CREAD(&tty->termios)) {
 		card->port_status |= (1 << channel);
 		outw(card->port_status, base + 0x02);
 	}
@@ -1199,7 +1200,7 @@ static void isicom_set_termios(struct tty_struct *tty,
 	isicom_config_port(tty);
 	spin_unlock_irqrestore(&port->card->card_lock, flags);
 
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		isicom_start(tty);
 	}
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index 60d37b225589..f6e693d91c0e 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1323,7 +1323,7 @@ static void moxa_set_termios(struct tty_struct *tty,
 	if (ch == NULL)
 		return;
 	moxa_set_tty_param(tty, old_termios);
-	if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty))
+	if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(&tty->termios))
 		wake_up_interruptible(&ch->port.open_wait);
 }
 
@@ -1420,7 +1420,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
 	if (!inited)
 		goto put;
 
-	if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */
+	if (tty && (intr & IntrBreak) && !I_IGNBRK(&tty->termios)) { /* BREAK */
 		tty_insert_flip_char(&p->port, 0, TTY_BREAK);
 		tty_schedule_flip(&p->port);
 	}
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 69294ae154be..1a5fb2887b0e 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -615,7 +615,7 @@ static int mxser_set_baud(struct tty_struct *tty, long newspd)
 	outb(cval, info->ioaddr + UART_LCR);	/* reset DLAB */
 
 #ifdef BOTHER
-	if (C_BAUD(tty) == BOTHER) {
+	if (C_BAUD(&tty->termios) == BOTHER) {
 		quot = info->baud_base % newspd;
 		quot *= 8;
 		if (quot % newspd > newspd / 2) {
@@ -755,21 +755,21 @@ static int mxser_change_speed(struct tty_struct *tty,
 	 * Set up parity check flag
 	 */
 	info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
-	if (I_INPCK(tty))
+	if (I_INPCK(&tty->termios))
 		info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
-	if (I_BRKINT(tty) || I_PARMRK(tty))
+	if (I_BRKINT(&tty->termios) || I_PARMRK(&tty->termios))
 		info->read_status_mask |= UART_LSR_BI;
 
 	info->ignore_status_mask = 0;
 
-	if (I_IGNBRK(tty)) {
+	if (I_IGNBRK(&tty->termios)) {
 		info->ignore_status_mask |= UART_LSR_BI;
 		info->read_status_mask |= UART_LSR_BI;
 		/*
 		 * If we're ignore parity and break indicators, ignore
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(tty)) {
+		if (I_IGNPAR(&tty->termios)) {
 			info->ignore_status_mask |=
 						UART_LSR_OE |
 						UART_LSR_PE |
@@ -781,16 +781,18 @@ static int mxser_change_speed(struct tty_struct *tty,
 		}
 	}
 	if (info->board->chip_flag) {
-		mxser_set_must_xon1_value(info->ioaddr, START_CHAR(tty));
-		mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(tty));
-		if (I_IXON(tty)) {
+		mxser_set_must_xon1_value(info->ioaddr,
+					  START_CHAR(&tty->termios));
+		mxser_set_must_xoff1_value(info->ioaddr,
+					   STOP_CHAR(&tty->termios));
+		if (I_IXON(&tty->termios)) {
 			mxser_enable_must_rx_software_flow_control(
 					info->ioaddr);
 		} else {
 			mxser_disable_must_rx_software_flow_control(
 					info->ioaddr);
 		}
-		if (I_IXOFF(tty)) {
+		if (I_IXOFF(&tty->termios)) {
 			mxser_enable_must_tx_software_flow_control(
 					info->ioaddr);
 		} else {
@@ -1081,7 +1083,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 	mutex_lock(&port->mutex);
 	mxser_close_port(port);
 	mxser_flush_buffer(tty);
-	if (tty_port_initialized(port) && C_HUPCL(tty))
+	if (tty_port_initialized(port) && C_HUPCL(&tty->termios))
 		tty_port_lower_dtr_rts(port);
 	mxser_shutdown_port(port);
 	tty_port_set_initialized(port, 0);
@@ -1846,19 +1848,19 @@ static void mxser_stoprx(struct tty_struct *tty)
 	struct mxser_port *info = tty->driver_data;
 
 	info->ldisc_stop_rx = 1;
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->board->chip_flag) {
 			info->IER &= ~MOXA_MUST_RECV_ISR;
 			outb(info->IER, info->ioaddr + UART_IER);
 		} else {
-			info->x_char = STOP_CHAR(tty);
+			info->x_char = STOP_CHAR(&tty->termios);
 			outb(0, info->ioaddr + UART_IER);
 			info->IER |= UART_IER_THRI;
 			outb(info->IER, info->ioaddr + UART_IER);
 		}
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		info->MCR &= ~UART_MCR_RTS;
 		outb(info->MCR, info->ioaddr + UART_MCR);
 	}
@@ -1879,7 +1881,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
 
 	/* startrx */
 	info->ldisc_stop_rx = 0;
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else {
@@ -1887,7 +1889,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
 				info->IER |= MOXA_MUST_RECV_ISR;
 				outb(info->IER, info->ioaddr + UART_IER);
 			} else {
-				info->x_char = START_CHAR(tty);
+				info->x_char = START_CHAR(&tty->termios);
 				outb(0, info->ioaddr + UART_IER);
 				info->IER |= UART_IER_THRI;
 				outb(info->IER, info->ioaddr + UART_IER);
@@ -1895,7 +1897,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
 		}
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		info->MCR |= UART_MCR_RTS;
 		outb(info->MCR, info->ioaddr + UART_MCR);
 	}
@@ -1943,13 +1945,13 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
 	mxser_change_speed(tty, old_termios);
 	spin_unlock_irqrestore(&info->slock, flags);
 
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		mxser_start(tty);
 	}
 
 	/* Handle sw stopped */
-	if ((old_termios->c_iflag & IXON) && !I_IXON(tty)) {
+	if ((old_termios->c_iflag & IXON) && !I_IXON(&tty->termios)) {
 		tty->stopped = 0;
 
 		if (info->board->chip_flag) {
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 54cab59e20ed..37ec4736ecc1 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1066,7 +1066,7 @@ static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
 	/* Carrier drop -> hangup */
 	if (tty) {
 		if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD))
-			if (!C_CLOCAL(tty))
+			if (!C_CLOCAL(&tty->termios))
 				tty_hangup(tty);
 	}
 	if (brk & 0x01)
@@ -2972,7 +2972,7 @@ static void gsmtty_close(struct tty_struct *tty, struct file *filp)
 	if (tty_port_close_start(&dlci->port, tty, filp) == 0)
 		return;
 	gsm_dlci_begin_close(dlci);
-	if (tty_port_initialized(&dlci->port) && C_HUPCL(tty))
+	if (tty_port_initialized(&dlci->port) && C_HUPCL(&tty->termios))
 		tty_port_lower_dtr_rts(&dlci->port);
 	tty_port_close_end(&dlci->port, tty);
 	tty_port_tty_set(&dlci->port, NULL);
@@ -3116,7 +3116,7 @@ static void gsmtty_throttle(struct tty_struct *tty)
 	struct gsm_dlci *dlci = tty->driver_data;
 	if (dlci->state == DLCI_CLOSED)
 		return;
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		dlci->modem_tx &= ~TIOCM_DTR;
 	dlci->throttled = 1;
 	/* Send an MSC with DTR cleared */
@@ -3128,7 +3128,7 @@ static void gsmtty_unthrottle(struct tty_struct *tty)
 	struct gsm_dlci *dlci = tty->driver_data;
 	if (dlci->state == DLCI_CLOSED)
 		return;
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		dlci->modem_tx |= TIOCM_DTR;
 	dlci->throttled = 0;
 	/* Send an MSC with DTR set */
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index bdf0e6e89991..b3b6b018da12 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -389,7 +389,7 @@ static inline int is_utf8_continuation(unsigned char c)
 
 static inline int is_continuation(unsigned char c, struct tty_struct *tty)
 {
-	return I_IUTF8(tty) && is_utf8_continuation(c);
+	return I_IUTF8(&tty->termios) && is_utf8_continuation(c);
 }
 
 /**
@@ -424,9 +424,9 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
 
 	switch (c) {
 	case '\n':
-		if (O_ONLRET(tty))
+		if (O_ONLRET(&tty->termios))
 			ldata->column = 0;
-		if (O_ONLCR(tty)) {
+		if (O_ONLCR(&tty->termios)) {
 			if (space < 2)
 				return -1;
 			ldata->canon_column = ldata->column = 0;
@@ -436,11 +436,11 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
 		ldata->canon_column = ldata->column;
 		break;
 	case '\r':
-		if (O_ONOCR(tty) && ldata->column == 0)
+		if (O_ONOCR(&tty->termios) && ldata->column == 0)
 			return 0;
-		if (O_OCRNL(tty)) {
+		if (O_OCRNL(&tty->termios)) {
 			c = '\n';
-			if (O_ONLRET(tty))
+			if (O_ONLRET(&tty->termios))
 				ldata->canon_column = ldata->column = 0;
 			break;
 		}
@@ -448,7 +448,7 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
 		break;
 	case '\t':
 		spaces = 8 - (ldata->column & 7);
-		if (O_TABDLY(tty) == XTABS) {
+		if (O_TABDLY(&tty->termios) == XTABS) {
 			if (space < spaces)
 				return -1;
 			ldata->column += spaces;
@@ -463,7 +463,7 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
 		break;
 	default:
 		if (!iscntrl(c)) {
-			if (O_OLCUC(tty))
+			if (O_OLCUC(&tty->termios))
 				c = toupper(c);
 			if (!is_continuation(c, tty))
 				ldata->column++;
@@ -548,16 +548,16 @@ static ssize_t process_output_block(struct tty_struct *tty,
 
 		switch (c) {
 		case '\n':
-			if (O_ONLRET(tty))
+			if (O_ONLRET(&tty->termios))
 				ldata->column = 0;
-			if (O_ONLCR(tty))
+			if (O_ONLCR(&tty->termios))
 				goto break_out;
 			ldata->canon_column = ldata->column;
 			break;
 		case '\r':
-			if (O_ONOCR(tty) && ldata->column == 0)
+			if (O_ONOCR(&tty->termios) && ldata->column == 0)
 				goto break_out;
-			if (O_OCRNL(tty))
+			if (O_OCRNL(&tty->termios))
 				goto break_out;
 			ldata->canon_column = ldata->column = 0;
 			break;
@@ -569,7 +569,7 @@ static ssize_t process_output_block(struct tty_struct *tty,
 			break;
 		default:
 			if (!iscntrl(c)) {
-				if (O_OLCUC(tty))
+				if (O_OLCUC(&tty->termios))
 					goto break_out;
 				if (!is_continuation(c, tty))
 					ldata->column++;
@@ -712,7 +712,7 @@ static size_t __process_echoes(struct tty_struct *tty)
 			if (no_space_left)
 				break;
 		} else {
-			if (O_OPOST(tty)) {
+			if (O_OPOST(&tty->termios)) {
 				int retval = do_output_char(c, tty, space);
 				if (retval < 0)
 					break;
@@ -792,7 +792,7 @@ static void flush_echoes(struct tty_struct *tty)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if ((!L_ECHO(tty) && !L_ECHONL(tty)) ||
+	if ((!L_ECHO(&tty->termios) && !L_ECHONL(&tty->termios)) ||
 	    ldata->echo_commit == ldata->echo_head)
 		return;
 
@@ -914,7 +914,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty)
 		add_echo_byte(ECHO_OP_START, ldata);
 		add_echo_byte(ECHO_OP_START, ldata);
 	} else {
-		if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t')
+		if (L_ECHOCTL(&tty->termios) && iscntrl(c) && c != '\t')
 			add_echo_byte(ECHO_OP_START, ldata);
 		add_echo_byte(c, ldata);
 	}
@@ -958,21 +958,21 @@ static void eraser(unsigned char c, struct tty_struct *tty)
 		/* process_output('\a', tty); */ /* what do you think? */
 		return;
 	}
-	if (c == ERASE_CHAR(tty))
+	if (c == ERASE_CHAR(&tty->termios))
 		kill_type = ERASE;
-	else if (c == WERASE_CHAR(tty))
+	else if (c == WERASE_CHAR(&tty->termios))
 		kill_type = WERASE;
 	else {
-		if (!L_ECHO(tty)) {
+		if (!L_ECHO(&tty->termios)) {
 			ldata->read_head = ldata->canon_head;
 			return;
 		}
-		if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) {
+		if (!L_ECHOK(&tty->termios) || !L_ECHOKE(&tty->termios) || !L_ECHOE(&tty->termios)) {
 			ldata->read_head = ldata->canon_head;
 			finish_erasing(ldata);
-			echo_char(KILL_CHAR(tty), tty);
+			echo_char(KILL_CHAR(&tty->termios), tty);
 			/* Add a newline if ECHOK is on and ECHOKE is off. */
-			if (L_ECHOK(tty))
+			if (L_ECHOK(&tty->termios))
 				echo_char_raw('\n', ldata);
 			return;
 		}
@@ -1002,8 +1002,8 @@ static void eraser(unsigned char c, struct tty_struct *tty)
 		}
 		cnt = ldata->read_head - head;
 		ldata->read_head = head;
-		if (L_ECHO(tty)) {
-			if (L_ECHOPRT(tty)) {
+		if (L_ECHO(&tty->termios)) {
+			if (L_ECHOPRT(&tty->termios)) {
 				if (!ldata->erasing) {
 					echo_char_raw('\\', ldata);
 					ldata->erasing = 1;
@@ -1015,8 +1015,8 @@ static void eraser(unsigned char c, struct tty_struct *tty)
 					echo_char_raw(read_buf(ldata, head), ldata);
 					echo_move_back_col(ldata);
 				}
-			} else if (kill_type == ERASE && !L_ECHOE(tty)) {
-				echo_char(ERASE_CHAR(tty), tty);
+			} else if (kill_type == ERASE && !L_ECHOE(&tty->termios)) {
+				echo_char(ERASE_CHAR(&tty->termios), tty);
 			} else if (c == '\t') {
 				unsigned int num_chars = 0;
 				int after_tab = 0;
@@ -1036,7 +1036,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
 						after_tab = 1;
 						break;
 					} else if (iscntrl(c)) {
-						if (L_ECHOCTL(tty))
+						if (L_ECHOCTL(&tty->termios))
 							num_chars += 2;
 					} else if (!is_continuation(c, tty)) {
 						num_chars++;
@@ -1044,12 +1044,12 @@ static void eraser(unsigned char c, struct tty_struct *tty)
 				}
 				echo_erase_tab(num_chars, after_tab, ldata);
 			} else {
-				if (iscntrl(c) && L_ECHOCTL(tty)) {
+				if (iscntrl(c) && L_ECHOCTL(&tty->termios)) {
 					echo_char_raw('\b', ldata);
 					echo_char_raw(' ', ldata);
 					echo_char_raw('\b', ldata);
 				}
-				if (!iscntrl(c) || L_ECHOCTL(tty)) {
+				if (!iscntrl(c) || L_ECHOCTL(&tty->termios)) {
 					echo_char_raw('\b', ldata);
 					echo_char_raw(' ', ldata);
 					echo_char_raw('\b', ldata);
@@ -1059,7 +1059,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
 		if (kill_type == ERASE)
 			break;
 	}
-	if (ldata->read_head == ldata->canon_head && L_ECHO(tty))
+	if (ldata->read_head == ldata->canon_head && L_ECHO(&tty->termios))
 		finish_erasing(ldata);
 }
 
@@ -1091,7 +1091,7 @@ static void isig(int sig, struct tty_struct *tty)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if (L_NOFLSH(tty)) {
+	if (L_NOFLSH(&tty->termios)) {
 		/* signal only */
 		__isig(sig, tty);
 
@@ -1139,13 +1139,13 @@ static void n_tty_receive_break(struct tty_struct *tty)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if (I_IGNBRK(tty))
+	if (I_IGNBRK(&tty->termios))
 		return;
-	if (I_BRKINT(tty)) {
+	if (I_BRKINT(&tty->termios)) {
 		isig(SIGINT, tty);
 		return;
 	}
-	if (I_PARMRK(tty)) {
+	if (I_PARMRK(&tty->termios)) {
 		put_tty_queue('\377', ldata);
 		put_tty_queue('\0', ldata);
 	}
@@ -1193,10 +1193,10 @@ static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if (I_INPCK(tty)) {
-		if (I_IGNPAR(tty))
+	if (I_INPCK(&tty->termios)) {
+		if (I_IGNPAR(&tty->termios))
 			return;
-		if (I_PARMRK(tty)) {
+		if (I_PARMRK(&tty->termios)) {
 			put_tty_queue('\377', ldata);
 			put_tty_queue('\0', ldata);
 			put_tty_queue(c, ldata);
@@ -1210,9 +1210,9 @@ static void
 n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c)
 {
 	isig(signal, tty);
-	if (I_IXON(tty))
+	if (I_IXON(&tty->termios))
 		start_tty(tty);
-	if (L_ECHO(tty)) {
+	if (L_ECHO(&tty->termios)) {
 		echo_char(c, tty);
 		commit_echoes(tty);
 	} else
@@ -1241,56 +1241,56 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if (I_IXON(tty)) {
-		if (c == START_CHAR(tty)) {
+	if (I_IXON(&tty->termios)) {
+		if (c == START_CHAR(&tty->termios)) {
 			start_tty(tty);
 			process_echoes(tty);
 			return 0;
 		}
-		if (c == STOP_CHAR(tty)) {
+		if (c == STOP_CHAR(&tty->termios)) {
 			stop_tty(tty);
 			return 0;
 		}
 	}
 
-	if (L_ISIG(tty)) {
-		if (c == INTR_CHAR(tty)) {
+	if (L_ISIG(&tty->termios)) {
+		if (c == INTR_CHAR(&tty->termios)) {
 			n_tty_receive_signal_char(tty, SIGINT, c);
 			return 0;
-		} else if (c == QUIT_CHAR(tty)) {
+		} else if (c == QUIT_CHAR(&tty->termios)) {
 			n_tty_receive_signal_char(tty, SIGQUIT, c);
 			return 0;
-		} else if (c == SUSP_CHAR(tty)) {
+		} else if (c == SUSP_CHAR(&tty->termios)) {
 			n_tty_receive_signal_char(tty, SIGTSTP, c);
 			return 0;
 		}
 	}
 
-	if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) {
+	if (tty->stopped && !tty->flow_stopped && I_IXON(&tty->termios) && I_IXANY(&tty->termios)) {
 		start_tty(tty);
 		process_echoes(tty);
 	}
 
 	if (c == '\r') {
-		if (I_IGNCR(tty))
+		if (I_IGNCR(&tty->termios))
 			return 0;
-		if (I_ICRNL(tty))
+		if (I_ICRNL(&tty->termios))
 			c = '\n';
-	} else if (c == '\n' && I_INLCR(tty))
+	} else if (c == '\n' && I_INLCR(&tty->termios))
 		c = '\r';
 
 	if (ldata->icanon) {
-		if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) ||
-		    (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) {
+		if (c == ERASE_CHAR(&tty->termios) || c == KILL_CHAR(&tty->termios) ||
+		    (c == WERASE_CHAR(&tty->termios) && L_IEXTEN(&tty->termios))) {
 			eraser(c, tty);
 			commit_echoes(tty);
 			return 0;
 		}
-		if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) {
+		if (c == LNEXT_CHAR(&tty->termios) && L_IEXTEN(&tty->termios)) {
 			ldata->lnext = 1;
-			if (L_ECHO(tty)) {
+			if (L_ECHO(&tty->termios)) {
 				finish_erasing(ldata);
-				if (L_ECHOCTL(tty)) {
+				if (L_ECHOCTL(&tty->termios)) {
 					echo_char_raw('^', ldata);
 					echo_char_raw('\b', ldata);
 					commit_echoes(tty);
@@ -1298,7 +1298,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
 			}
 			return 1;
 		}
-		if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) {
+		if (c == REPRINT_CHAR(&tty->termios) && L_ECHO(&tty->termios) && L_IEXTEN(&tty->termios)) {
 			size_t tail = ldata->canon_head;
 
 			finish_erasing(ldata);
@@ -1312,22 +1312,22 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
 			return 0;
 		}
 		if (c == '\n') {
-			if (L_ECHO(tty) || L_ECHONL(tty)) {
+			if (L_ECHO(&tty->termios) || L_ECHONL(&tty->termios)) {
 				echo_char_raw('\n', ldata);
 				commit_echoes(tty);
 			}
 			goto handle_newline;
 		}
-		if (c == EOF_CHAR(tty)) {
+		if (c == EOF_CHAR(&tty->termios)) {
 			c = __DISABLED_CHAR;
 			goto handle_newline;
 		}
-		if ((c == EOL_CHAR(tty)) ||
-		    (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) {
+		if ((c == EOL_CHAR(&tty->termios)) ||
+		    (c == EOL2_CHAR(&tty->termios) && L_IEXTEN(&tty->termios))) {
 			/*
 			 * XXX are EOL_CHAR and EOL2_CHAR echoed?!?
 			 */
-			if (L_ECHO(tty)) {
+			if (L_ECHO(&tty->termios)) {
 				/* Record the column of first canon char. */
 				if (ldata->canon_head == ldata->read_head)
 					echo_set_canon_col(ldata);
@@ -1338,7 +1338,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
 			 * XXX does PARMRK doubling happen for
 			 * EOL_CHAR and EOL2_CHAR?
 			 */
-			if (c == (unsigned char) '\377' && I_PARMRK(tty))
+			if (c == (unsigned char) '\377' && I_PARMRK(&tty->termios))
 				put_tty_queue(c, ldata);
 
 handle_newline:
@@ -1351,7 +1351,7 @@ handle_newline:
 		}
 	}
 
-	if (L_ECHO(tty)) {
+	if (L_ECHO(&tty->termios)) {
 		finish_erasing(ldata);
 		if (c == '\n')
 			echo_char_raw('\n', ldata);
@@ -1365,7 +1365,7 @@ handle_newline:
 	}
 
 	/* PARMRK doubling check */
-	if (c == (unsigned char) '\377' && I_PARMRK(tty))
+	if (c == (unsigned char) '\377' && I_PARMRK(&tty->termios))
 		put_tty_queue(c, ldata);
 
 	put_tty_queue(c, ldata);
@@ -1377,11 +1377,11 @@ n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) {
+	if (tty->stopped && !tty->flow_stopped && I_IXON(&tty->termios) && I_IXANY(&tty->termios)) {
 		start_tty(tty);
 		process_echoes(tty);
 	}
-	if (L_ECHO(tty)) {
+	if (L_ECHO(&tty->termios)) {
 		finish_erasing(ldata);
 		/* Record the column of first canon char. */
 		if (ldata->canon_head == ldata->read_head)
@@ -1390,7 +1390,7 @@ n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c)
 		commit_echoes(tty);
 	}
 	/* PARMRK doubling check */
-	if (c == (unsigned char) '\377' && I_PARMRK(tty))
+	if (c == (unsigned char) '\377' && I_PARMRK(&tty->termios))
 		put_tty_queue(c, ldata);
 	put_tty_queue(c, ldata);
 }
@@ -1405,11 +1405,11 @@ n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c)
 {
 	struct n_tty_data *ldata = tty->disc_data;
 
-	if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) {
+	if (tty->stopped && !tty->flow_stopped && I_IXON(&tty->termios) && I_IXANY(&tty->termios)) {
 		start_tty(tty);
 		process_echoes(tty);
 	}
-	if (L_ECHO(tty)) {
+	if (L_ECHO(&tty->termios)) {
 		finish_erasing(ldata);
 		/* Record the column of first canon char. */
 		if (ldata->canon_head == ldata->read_head)
@@ -1422,18 +1422,18 @@ n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c)
 
 static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c)
 {
-	if (I_ISTRIP(tty))
+	if (I_ISTRIP(&tty->termios))
 		c &= 0x7f;
-	if (I_IUCLC(tty) && L_IEXTEN(tty))
+	if (I_IUCLC(&tty->termios) && L_IEXTEN(&tty->termios))
 		c = tolower(c);
 
-	if (I_IXON(tty)) {
-		if (c == STOP_CHAR(tty))
+	if (I_IXON(&tty->termios)) {
+		if (c == STOP_CHAR(&tty->termios))
 			stop_tty(tty);
-		else if (c == START_CHAR(tty) ||
-			 (tty->stopped && !tty->flow_stopped && I_IXANY(tty) &&
-			  c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) &&
-			  c != SUSP_CHAR(tty))) {
+		else if (c == START_CHAR(&tty->termios) ||
+			 (tty->stopped && !tty->flow_stopped && I_IXANY(&tty->termios) &&
+			  c != INTR_CHAR(&tty->termios) && c != QUIT_CHAR(&tty->termios) &&
+			  c != SUSP_CHAR(&tty->termios))) {
 			start_tty(tty);
 			process_echoes(tty);
 		}
@@ -1467,9 +1467,9 @@ n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag)
 
 	ldata->lnext = 0;
 	if (likely(flag == TTY_NORMAL)) {
-		if (I_ISTRIP(tty))
+		if (I_ISTRIP(&tty->termios))
 			c &= 0x7f;
-		if (I_IUCLC(tty) && L_IEXTEN(tty))
+		if (I_IUCLC(&tty->termios) && L_IEXTEN(&tty->termios))
 			c = tolower(c);
 		n_tty_receive_char(tty, c);
 	} else
@@ -1540,11 +1540,11 @@ n_tty_receive_buf_standard(struct tty_struct *tty, const unsigned char *cp,
 		if (likely(flag == TTY_NORMAL)) {
 			unsigned char c = *cp++;
 
-			if (I_ISTRIP(tty))
+			if (I_ISTRIP(&tty->termios))
 				c &= 0x7f;
-			if (I_IUCLC(tty) && L_IEXTEN(tty))
+			if (I_IUCLC(&tty->termios) && L_IEXTEN(&tty->termios))
 				c = tolower(c);
-			if (L_EXTPROC(tty)) {
+			if (L_EXTPROC(&tty->termios)) {
 				put_tty_queue(c, ldata);
 				continue;
 			}
@@ -1591,13 +1591,13 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
 			  char *fp, int count)
 {
 	struct n_tty_data *ldata = tty->disc_data;
-	bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty));
+	bool preops = I_ISTRIP(&tty->termios) || (I_IUCLC(&tty->termios) && L_IEXTEN(&tty->termios));
 
 	if (ldata->real_raw)
 		n_tty_receive_buf_real_raw(tty, cp, fp, count);
-	else if (ldata->raw || (L_EXTPROC(tty) && !preops))
+	else if (ldata->raw || (L_EXTPROC(&tty->termios) && !preops))
 		n_tty_receive_buf_raw(tty, cp, fp, count);
-	else if (tty->closing && !L_EXTPROC(tty))
+	else if (tty->closing && !L_EXTPROC(&tty->termios))
 		n_tty_receive_buf_closing(tty, cp, fp, count);
 	else {
 		if (ldata->lnext) {
@@ -1609,7 +1609,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
 			count--;
 		}
 
-		if (!preops && !I_PARMRK(tty))
+		if (!preops && !I_PARMRK(&tty->termios))
 			n_tty_receive_buf_fast(tty, cp, fp, count);
 		else
 			n_tty_receive_buf_standard(tty, cp, fp, count);
@@ -1619,7 +1619,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
 			tty->ops->flush_chars(tty);
 	}
 
-	if (ldata->icanon && !L_EXTPROC(tty))
+	if (ldata->icanon && !L_EXTPROC(&tty->termios))
 		return;
 
 	/* publish read_head to consumer */
@@ -1690,7 +1690,7 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
 		size_t tail = smp_load_acquire(&ldata->read_tail);
 
 		room = N_TTY_BUF_SIZE - (ldata->read_head - tail);
-		if (I_PARMRK(tty))
+		if (I_PARMRK(&tty->termios))
 			room = (room + 2) / 3;
 		room--;
 		if (room <= 0) {
@@ -1767,7 +1767,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
 	if (!old || (old->c_lflag ^ tty->termios.c_lflag) & ICANON) {
 		bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
 		ldata->line_start = ldata->read_tail;
-		if (!L_ICANON(tty) || !read_cnt(ldata)) {
+		if (!L_ICANON(&tty->termios) || !read_cnt(ldata)) {
 			ldata->canon_head = ldata->read_tail;
 			ldata->push = 0;
 		} else {
@@ -1781,50 +1781,53 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
 		ldata->lnext = 0;
 	}
 
-	ldata->icanon = (L_ICANON(tty) != 0);
+	ldata->icanon = (L_ICANON(&tty->termios) != 0);
 
-	if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) ||
-	    I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) ||
-	    I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) ||
-	    I_PARMRK(tty)) {
+	if (I_ISTRIP(&tty->termios) || I_IUCLC(&tty->termios) || I_IGNCR(&tty->termios) ||
+	    I_ICRNL(&tty->termios) || I_INLCR(&tty->termios) || L_ICANON(&tty->termios) ||
+	    I_IXON(&tty->termios) || L_ISIG(&tty->termios) || L_ECHO(&tty->termios) ||
+	    I_PARMRK(&tty->termios)) {
 		bitmap_zero(ldata->char_map, 256);
 
-		if (I_IGNCR(tty) || I_ICRNL(tty))
+		if (I_IGNCR(&tty->termios) || I_ICRNL(&tty->termios))
 			set_bit('\r', ldata->char_map);
-		if (I_INLCR(tty))
+		if (I_INLCR(&tty->termios))
 			set_bit('\n', ldata->char_map);
 
-		if (L_ICANON(tty)) {
-			set_bit(ERASE_CHAR(tty), ldata->char_map);
-			set_bit(KILL_CHAR(tty), ldata->char_map);
-			set_bit(EOF_CHAR(tty), ldata->char_map);
+		if (L_ICANON(&tty->termios)) {
+			set_bit(ERASE_CHAR(&tty->termios), ldata->char_map);
+			set_bit(KILL_CHAR(&tty->termios), ldata->char_map);
+			set_bit(EOF_CHAR(&tty->termios), ldata->char_map);
 			set_bit('\n', ldata->char_map);
-			set_bit(EOL_CHAR(tty), ldata->char_map);
-			if (L_IEXTEN(tty)) {
-				set_bit(WERASE_CHAR(tty), ldata->char_map);
-				set_bit(LNEXT_CHAR(tty), ldata->char_map);
-				set_bit(EOL2_CHAR(tty), ldata->char_map);
-				if (L_ECHO(tty))
-					set_bit(REPRINT_CHAR(tty),
+			set_bit(EOL_CHAR(&tty->termios), ldata->char_map);
+			if (L_IEXTEN(&tty->termios)) {
+				set_bit(WERASE_CHAR(&tty->termios),
+					ldata->char_map);
+				set_bit(LNEXT_CHAR(&tty->termios),
+					ldata->char_map);
+				set_bit(EOL2_CHAR(&tty->termios),
+					ldata->char_map);
+				if (L_ECHO(&tty->termios))
+					set_bit(REPRINT_CHAR(&tty->termios),
 						ldata->char_map);
 			}
 		}
-		if (I_IXON(tty)) {
-			set_bit(START_CHAR(tty), ldata->char_map);
-			set_bit(STOP_CHAR(tty), ldata->char_map);
+		if (I_IXON(&tty->termios)) {
+			set_bit(START_CHAR(&tty->termios), ldata->char_map);
+			set_bit(STOP_CHAR(&tty->termios), ldata->char_map);
 		}
-		if (L_ISIG(tty)) {
-			set_bit(INTR_CHAR(tty), ldata->char_map);
-			set_bit(QUIT_CHAR(tty), ldata->char_map);
-			set_bit(SUSP_CHAR(tty), ldata->char_map);
+		if (L_ISIG(&tty->termios)) {
+			set_bit(INTR_CHAR(&tty->termios), ldata->char_map);
+			set_bit(QUIT_CHAR(&tty->termios), ldata->char_map);
+			set_bit(SUSP_CHAR(&tty->termios), ldata->char_map);
 		}
 		clear_bit(__DISABLED_CHAR, ldata->char_map);
 		ldata->raw = 0;
 		ldata->real_raw = 0;
 	} else {
 		ldata->raw = 1;
-		if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) &&
-		    (I_IGNPAR(tty) || !I_INPCK(tty)) &&
+		if ((I_IGNBRK(&tty->termios) || (!I_BRKINT(&tty->termios) && !I_PARMRK(&tty->termios))) &&
+		    (I_IGNPAR(&tty->termios) || !I_INPCK(&tty->termios)) &&
 		    (tty->driver->flags & TTY_DRIVER_REAL_RAW))
 			ldata->real_raw = 1;
 		else
@@ -1834,7 +1837,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
 	 * Fix tty hang when I_IXON(tty) is cleared, but the tty
 	 * been stopped by STOP_CHAR(tty) before it.
 	 */
-	if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) {
+	if (!I_IXON(&tty->termios) && old && (old->c_iflag & IXON) && !tty->flow_stopped) {
 		start_tty(tty);
 		process_echoes(tty);
 	}
@@ -1909,9 +1912,9 @@ err:
 static inline int input_available_p(struct tty_struct *tty, int poll)
 {
 	struct n_tty_data *ldata = tty->disc_data;
-	int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1;
+	int amt = poll && !TIME_CHAR(&tty->termios) && MIN_CHAR(&tty->termios) ? MIN_CHAR(&tty->termios) : 1;
 
-	if (ldata->icanon && !L_EXTPROC(tty))
+	if (ldata->icanon && !L_EXTPROC(&tty->termios))
 		return ldata->canon_head != ldata->read_tail;
 	else
 		return ldata->commit_head - ldata->read_tail >= amt;
@@ -1956,11 +1959,11 @@ static int copy_from_read_buf(struct tty_struct *tty,
 		const unsigned char *from = read_buf_addr(ldata, tail);
 		retval = copy_to_user(*b, from, n);
 		n -= retval;
-		is_eof = n == 1 && *from == EOF_CHAR(tty);
+		is_eof = n == 1 && *from == EOF_CHAR(&tty->termios);
 		tty_audit_add_data(tty, from, n);
 		smp_store_release(&ldata->read_tail, ldata->read_tail + n);
 		/* Turn single EOF into zero-length read */
-		if (L_EXTPROC(tty) && ldata->icanon && is_eof &&
+		if (L_EXTPROC(&tty->termios) && ldata->icanon && is_eof &&
 		    (head == ldata->read_tail))
 			n = 0;
 		*b += n;
@@ -2139,11 +2142,11 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
 	minimum = time = 0;
 	timeout = MAX_SCHEDULE_TIMEOUT;
 	if (!ldata->icanon) {
-		minimum = MIN_CHAR(tty);
+		minimum = MIN_CHAR(&tty->termios);
 		if (minimum) {
-			time = (HZ / 10) * TIME_CHAR(tty);
+			time = (HZ / 10) * TIME_CHAR(&tty->termios);
 		} else {
-			timeout = (HZ / 10) * TIME_CHAR(tty);
+			timeout = (HZ / 10) * TIME_CHAR(&tty->termios);
 			minimum = 1;
 		}
 	}
@@ -2202,7 +2205,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
 			}
 		}
 
-		if (ldata->icanon && !L_EXTPROC(tty)) {
+		if (ldata->icanon && !L_EXTPROC(&tty->termios)) {
 			retval = canon_copy_from_read_buf(tty, &b, &nr);
 			if (retval)
 				break;
@@ -2278,7 +2281,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
 	ssize_t retval = 0;
 
 	/* Job control check -- must be done at start (POSIX.1 7.1.1.4). */
-	if (L_TOSTOP(tty) && file->f_op->write != redirected_tty_write) {
+	if (L_TOSTOP(&tty->termios) && file->f_op->write != redirected_tty_write) {
 		retval = tty_check_change(tty);
 		if (retval)
 			return retval;
@@ -2299,7 +2302,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
 			retval = -EIO;
 			break;
 		}
-		if (O_OPOST(tty)) {
+		if (O_OPOST(&tty->termios)) {
 			while (nr > 0) {
 				ssize_t num = process_output_block(tty, b, nr);
 				if (num < 0) {
@@ -2427,7 +2430,7 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
 		return put_user(tty_chars_in_buffer(tty), (int __user *) arg);
 	case TIOCINQ:
 		down_write(&tty->termios_rwsem);
-		if (L_ICANON(tty))
+		if (L_ICANON(&tty->termios))
 			retval = inq_canon(ldata);
 		else
 			retval = read_cnt(ldata);
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 51e0d32883ba..7c51ff7f9030 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -261,13 +261,13 @@ static void pty_set_termios(struct tty_struct *tty,
 {
 	/* See if packet mode change of state. */
 	if (tty->link && tty->link->packet) {
-		int extproc = (old_termios->c_lflag & EXTPROC) | L_EXTPROC(tty);
+		int extproc = (old_termios->c_lflag & EXTPROC) | L_EXTPROC(&tty->termios);
 		int old_flow = ((old_termios->c_iflag & IXON) &&
 				(old_termios->c_cc[VSTOP] == '\023') &&
 				(old_termios->c_cc[VSTART] == '\021'));
-		int new_flow = (I_IXON(tty) &&
-				STOP_CHAR(tty) == '\023' &&
-				START_CHAR(tty) == '\021');
+		int new_flow = (I_IXON(&tty->termios) &&
+				STOP_CHAR(&tty->termios) == '\023' &&
+				START_CHAR(&tty->termios) == '\021');
 		if ((old_flow != new_flow) || extproc) {
 			spin_lock_irq(&tty->ctrl_lock);
 			if (old_flow != new_flow) {
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index b0cc47c77b40..a41dda82747a 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -786,15 +786,15 @@ static void configure_r_port(struct tty_struct *tty, struct r_port *info,
 	 * Handle software flow control in the board
 	 */
 #ifdef ROCKET_SOFT_FLOW
-	if (I_IXON(tty)) {
+	if (I_IXON(&tty->termios)) {
 		sEnTxSoftFlowCtl(cp);
-		if (I_IXANY(tty)) {
+		if (I_IXANY(&tty->termios)) {
 			sEnIXANY(cp);
 		} else {
 			sDisIXANY(cp);
 		}
-		sSetTxXONChar(cp, START_CHAR(tty));
-		sSetTxXOFFChar(cp, STOP_CHAR(tty));
+		sSetTxXONChar(cp, START_CHAR(&tty->termios));
+		sSetTxXOFFChar(cp, STOP_CHAR(&tty->termios));
 	} else {
 		sDisTxSoftFlowCtl(cp);
 		sDisIXANY(cp);
@@ -806,24 +806,24 @@ static void configure_r_port(struct tty_struct *tty, struct r_port *info,
 	 * Set up ignore/read mask words
 	 */
 	info->read_status_mask = STMRCVROVRH | 0xFF;
-	if (I_INPCK(tty))
+	if (I_INPCK(&tty->termios))
 		info->read_status_mask |= STMFRAMEH | STMPARITYH;
-	if (I_BRKINT(tty) || I_PARMRK(tty))
+	if (I_BRKINT(&tty->termios) || I_PARMRK(&tty->termios))
 		info->read_status_mask |= STMBREAKH;
 
 	/*
 	 * Characters to ignore
 	 */
 	info->ignore_status_mask = 0;
-	if (I_IGNPAR(tty))
+	if (I_IGNPAR(&tty->termios))
 		info->ignore_status_mask |= STMFRAMEH | STMPARITYH;
-	if (I_IGNBRK(tty)) {
+	if (I_IGNBRK(&tty->termios)) {
 		info->ignore_status_mask |= STMBREAKH;
 		/*
 		 * If we're ignoring parity and break indicators,
 		 * ignore overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(tty))
+		if (I_IGNPAR(&tty->termios))
 			info->ignore_status_mask |= STMRCVROVRH;
 	}
 
@@ -960,7 +960,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 			tty->alt_speed = 460800;
 
 		configure_r_port(tty, info, NULL);
-		if (C_BAUD(tty)) {
+		if (C_BAUD(&tty->termios)) {
 			sSetDTR(cp);
 			sSetRTS(cp);
 		}
@@ -1019,7 +1019,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 	sFlushRxFIFO(cp);
 	sFlushTxFIFO(cp);
 	sClrRTS(cp);
-	if (C_HUPCL(tty))
+	if (C_HUPCL(&tty->termios))
 		sClrDTR(cp);
 
 	rp_flush_buffer(tty);
@@ -1086,18 +1086,18 @@ static void rp_set_termios(struct tty_struct *tty,
 	cp = &info->channel;
 
 	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) {
+	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(&tty->termios)) {
 		sClrDTR(cp);
 		sClrRTS(cp);
 	}
 
 	/* Handle transition away from B0 status */
-	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
+	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(&tty->termios)) {
 		sSetRTS(cp);
 		sSetDTR(cp);
 	}
 
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty))
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios))
 		rp_start(tty);
 }
 
@@ -1366,8 +1366,8 @@ static void rp_throttle(struct tty_struct *tty)
 	if (rocket_paranoia_check(info, "rp_throttle"))
 		return;
 
-	if (I_IXOFF(tty))
-		rp_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		rp_send_xchar(tty, STOP_CHAR(&tty->termios));
 
 	sClrRTS(&info->channel);
 }
@@ -1382,8 +1382,8 @@ static void rp_unthrottle(struct tty_struct *tty)
 	if (rocket_paranoia_check(info, "rp_unthrottle"))
 		return;
 
-	if (I_IXOFF(tty))
-		rp_send_xchar(tty, START_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		rp_send_xchar(tty, START_CHAR(&tty->termios));
 
 	sSetRTS(&info->channel);
 }
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index 315c84979b18..a45dc9d27b87 100644
--- a/drivers/tty/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
@@ -1411,9 +1411,9 @@ rs_stop(struct tty_struct *tty)
 					 info->xmit.tail,SERIAL_XMIT_SIZE)));
 
 		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char,
-				STOP_CHAR(info->port.tty));
+				STOP_CHAR(&info->port.tty->termios));
 		xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, stop);
-		if (I_IXON(tty))
+		if (I_IXON(&tty->termios))
 			xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
 
 		*((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
@@ -1433,9 +1433,10 @@ rs_start(struct tty_struct *tty)
 		DFLOW(DEBUG_LOG(info->line, "XOFF rs_start xmit %i\n",
 				CIRC_CNT(info->xmit.head,
 					 info->xmit.tail,SERIAL_XMIT_SIZE)));
-		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(tty));
+		xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char,
+				STOP_CHAR(&tty->termios));
 		xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
-		if (I_IXON(tty))
+		if (I_IXON(&tty->termios))
 			xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable);
 
 		*((unsigned long *)&info->ioport[REG_XOFF]) = xoff;
@@ -2906,7 +2907,8 @@ change_speed(struct e100_serial *info)
 
 	info->ioport[REG_TR_CTRL] = info->tx_ctrl;
 	info->ioport[REG_REC_CTRL] = info->rx_ctrl;
-	xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty));
+	xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char,
+			STOP_CHAR(&info->port.tty->termios));
 	xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable);
 	if (info->port.tty->termios.c_iflag & IXON ) {
 		DFLOW(DEBUG_LOG(info->line, "FLOW XOFF enabled 0x%02X\n",
@@ -3164,12 +3166,12 @@ rs_throttle(struct tty_struct * tty)
 	DFLOW(DEBUG_LOG(info->line,"rs_throttle\n"));
 
 	/* Do RTS before XOFF since XOFF might take some time */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		/* Turn off RTS line */
 		e100_rts(info, 0);
 	}
-	if (I_IXOFF(tty))
-		rs_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		rs_send_xchar(tty, STOP_CHAR(&tty->termios));
 
 }
 
@@ -3183,16 +3185,16 @@ rs_unthrottle(struct tty_struct * tty)
 	DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc\n"));
 	DFLOW(DEBUG_LOG(info->line,"rs_unthrottle flip.count: %i\n", tty->flip.count));
 	/* Do RTS before XOFF since XOFF might take some time */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		/* Assert RTS line  */
 		e100_rts(info, 1);
 	}
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			rs_send_xchar(tty, START_CHAR(tty));
+			rs_send_xchar(tty, START_CHAR(&tty->termios));
 	}
 
 }
@@ -3551,7 +3553,7 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	change_speed(info);
 
 	/* Handle turning off CRTSCTS */
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty))
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios))
 		rs_start(tty);
 
 }
@@ -3760,7 +3762,7 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
 		return 0;
 	}
 
-	if (C_CLOCAL(tty))
+	if (C_CLOCAL(&tty->termios))
 		do_clocal = 1;
 
 	/*
diff --git a/drivers/tty/serial/etraxfs-uart.c b/drivers/tty/serial/etraxfs-uart.c
index 2f80bc7e44fb..8dd313fc2054 100644
--- a/drivers/tty/serial/etraxfs-uart.c
+++ b/drivers/tty/serial/etraxfs-uart.c
@@ -777,7 +777,7 @@ etraxfs_uart_set_termios(struct uart_port *port, struct ktermios *termios,
 
 	if (up->port.state && up->port.state->port.tty &&
 	    (up->port.state->port.tty->termios.c_iflag & IXON)) {
-		xoff.chr = STOP_CHAR(up->port.state->port.tty);
+		xoff.chr = STOP_CHAR(&up->port.state->port.tty->termios);
 		xoff.automatic = regk_ser_yes;
 	} else
 		xoff.automatic = regk_ser_no;
diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
index 4eb12a9cae76..6f3e050f9526 100644
--- a/drivers/tty/serial/jsm/jsm_cls.c
+++ b/drivers/tty/serial/jsm/jsm_cls.c
@@ -718,7 +718,7 @@ static void cls_param(struct jsm_channel *ch)
 		return;
 	}
 
-	cflag = C_BAUD(ch->uart_port.state->port.tty);
+	cflag = C_BAUD(&ch->uart_port.state->port.tty->termios);
 	baud = 9600;
 	for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
 		if (baud_rates[i].cflag == cflag) {
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index c6fdd6369534..bba1772fb59c 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -987,7 +987,7 @@ static void neo_param(struct jsm_channel *ch)
 			{     50, B50     },
 		};
 
-		cflag = C_BAUD(ch->uart_port.state->port.tty);
+		cflag = C_BAUD(&ch->uart_port.state->port.tty->termios);
 		baud = 9600;
 		for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
 			if (baud_rates[i].cflag == cflag) {
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index ec7d8383900f..5588e6c3c679 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -568,7 +568,7 @@ void jsm_input(struct jsm_channel *ch)
 	 *If the device is not open, or CREAD is off, flush
 	 *input data and return immediately.
 	 */
-	if (!tp || !C_CREAD(tp)) {
+	if (!tp || !C_CREAD(&tp->termios)) {
 
 		jsm_dbg(READ, &ch->ch_bd->pci_dev,
 			"input. dropping %d bytes on port %d...\n",
@@ -616,7 +616,7 @@ void jsm_input(struct jsm_channel *ch)
 			 * a time.
 			 */
 
-		if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
+		if (I_PARMRK(&tp->termios) || I_BRKINT(&tp->termios) || I_INPCK(&tp->termios)) {
 			for (i = 0; i < s; i++) {
 				/*
 				 * Give the Linux ld the flags in the
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 240d3e7a548c..73b7a7ae7862 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -211,7 +211,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
 		 * Setup the RTS and DTR signals once the
 		 * port is open and ready to respond.
 		 */
-		if (init_hw && C_BAUD(tty))
+		if (init_hw && C_BAUD(&tty->termios))
 			uart_set_mctrl(uport, TIOCM_RTS | TIOCM_DTR);
 	}
 
@@ -269,7 +269,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 		if (uport && uart_console(uport) && tty)
 			uport->cons->cflag = tty->termios.c_cflag;
 
-		if (!tty || C_HUPCL(tty))
+		if (!tty || C_HUPCL(&tty->termios))
 			uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
 
 		uart_port_shutdown(port);
@@ -671,9 +671,9 @@ static void uart_throttle(struct tty_struct *tty)
 	if (!port)
 		return;
 
-	if (I_IXOFF(tty))
+	if (I_IXOFF(&tty->termios))
 		mask |= UPSTAT_AUTOXOFF;
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		mask |= UPSTAT_AUTORTS;
 
 	if (port->status & mask) {
@@ -685,7 +685,7 @@ static void uart_throttle(struct tty_struct *tty)
 		uart_clear_mctrl(port, TIOCM_RTS);
 
 	if (mask & UPSTAT_AUTOXOFF)
-		uart_send_xchar(tty, STOP_CHAR(tty));
+		uart_send_xchar(tty, STOP_CHAR(&tty->termios));
 
 	uart_port_deref(port);
 }
@@ -700,9 +700,9 @@ static void uart_unthrottle(struct tty_struct *tty)
 	if (!port)
 		return;
 
-	if (I_IXOFF(tty))
+	if (I_IXOFF(&tty->termios))
 		mask |= UPSTAT_AUTOXOFF;
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		mask |= UPSTAT_AUTORTS;
 
 	if (port->status & mask) {
@@ -714,7 +714,7 @@ static void uart_unthrottle(struct tty_struct *tty)
 		uart_set_mctrl(port, TIOCM_RTS);
 
 	if (mask & UPSTAT_AUTOXOFF)
-		uart_send_xchar(tty, START_CHAR(tty));
+		uart_send_xchar(tty, START_CHAR(&tty->termios));
 
 	uart_port_deref(port);
 }
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index c13e27ecb0b7..712776cf7ab7 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -1969,19 +1969,19 @@ static void mgsl_change_params(struct mgsl_struct *info)
 	/* process tty input control flags */
 	
 	info->read_status_mask = RXSTATUS_OVERRUN;
-	if (I_INPCK(info->port.tty))
+	if (I_INPCK(&info->port.tty->termios))
 		info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
- 	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
+ 	if (I_BRKINT(&info->port.tty->termios) || I_PARMRK(&info->port.tty->termios))
  		info->read_status_mask |= RXSTATUS_BREAK_RECEIVED;
 	
-	if (I_IGNPAR(info->port.tty))
+	if (I_IGNPAR(&info->port.tty->termios))
 		info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
-	if (I_IGNBRK(info->port.tty)) {
+	if (I_IGNBRK(&info->port.tty->termios)) {
 		info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED;
 		/* If ignoring parity and break indicators, ignore 
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->port.tty))
+		if (I_IGNPAR(&info->port.tty->termios))
 			info->ignore_status_mask |= RXSTATUS_OVERRUN;
 	}
 
@@ -2350,10 +2350,10 @@ static void mgsl_throttle(struct tty_struct * tty)
 	if (mgsl_paranoia_check(info, tty->name, "mgsl_throttle"))
 		return;
 	
-	if (I_IXOFF(tty))
-		mgsl_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		mgsl_send_xchar(tty, STOP_CHAR(&tty->termios));
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->irq_spinlock,flags);
 		info->serial_signals &= ~SerialSignal_RTS;
 	 	usc_set_serial_signals(info);
@@ -2380,14 +2380,14 @@ static void mgsl_unthrottle(struct tty_struct * tty)
 	if (mgsl_paranoia_check(info, tty->name, "mgsl_unthrottle"))
 		return;
 	
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			mgsl_send_xchar(tty, START_CHAR(tty));
+			mgsl_send_xchar(tty, START_CHAR(&tty->termios));
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->irq_spinlock,flags);
 		info->serial_signals |= SerialSignal_RTS;
 	 	usc_set_serial_signals(info);
@@ -3029,7 +3029,7 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio
 	mgsl_change_params(info);
 
 	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) {
+	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(&tty->termios)) {
 		info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
 		spin_lock_irqsave(&info->irq_spinlock,flags);
 	 	usc_set_serial_signals(info);
@@ -3037,9 +3037,9 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio
 	}
 
 	/* Handle transition away from B0 status */
-	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
+	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(&tty->termios)) {
 		info->serial_signals |= SerialSignal_DTR;
-		if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			info->serial_signals |= SerialSignal_RTS;
 		spin_lock_irqsave(&info->irq_spinlock,flags);
 	 	usc_set_serial_signals(info);
@@ -3047,7 +3047,7 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio
 	}
 
 	/* Handle turning off CRTSCTS */
-	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(tty)) {
+	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		mgsl_start(tty);
 	}
@@ -3266,7 +3266,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 		return 0;
 	}
 
-	if (C_CLOCAL(tty))
+	if (C_CLOCAL(&tty->termios))
 		do_clocal = true;
 
 	/* Wait for carrier detect and the line to become
@@ -3289,7 +3289,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 	port->blocked_open++;
 
 	while (1) {
-		if (C_BAUD(tty) && tty_port_initialized(port))
+		if (C_BAUD(&tty->termios) && tty_port_initialized(port))
 			tty_port_raise_dtr_rts(port);
 
 		set_current_state(TASK_INTERRUPTIBLE);
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 7aca2d4670e4..055fa71bc2fb 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -774,7 +774,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	change_params(info);
 
 	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) {
+	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(&tty->termios)) {
 		info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
 		spin_lock_irqsave(&info->lock,flags);
 		set_signals(info);
@@ -782,9 +782,9 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	}
 
 	/* Handle transition away from B0 status */
-	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
+	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(&tty->termios)) {
 		info->signals |= SerialSignal_DTR;
-		if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			info->signals |= SerialSignal_RTS;
 		spin_lock_irqsave(&info->lock,flags);
 	 	set_signals(info);
@@ -792,7 +792,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	}
 
 	/* Handle turning off CRTSCTS */
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) {
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		tx_release(tty);
 	}
@@ -1355,9 +1355,9 @@ static void throttle(struct tty_struct * tty)
 	if (sanity_check(info, tty->name, "throttle"))
 		return;
 	DBGINFO(("%s throttle\n", info->device_name));
-	if (I_IXOFF(tty))
-		send_xchar(tty, STOP_CHAR(tty));
- 	if (C_CRTSCTS(tty)) {
+	if (I_IXOFF(&tty->termios))
+		send_xchar(tty, STOP_CHAR(&tty->termios));
+ 	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->lock,flags);
 		info->signals &= ~SerialSignal_RTS;
 	 	set_signals(info);
@@ -1376,13 +1376,13 @@ static void unthrottle(struct tty_struct * tty)
 	if (sanity_check(info, tty->name, "unthrottle"))
 		return;
 	DBGINFO(("%s unthrottle\n", info->device_name));
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			send_xchar(tty, START_CHAR(tty));
+			send_xchar(tty, START_CHAR(&tty->termios));
 	}
- 	if (C_CRTSCTS(tty)) {
+ 	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->lock,flags);
 		info->signals |= SerialSignal_RTS;
 	 	set_signals(info);
@@ -2582,18 +2582,18 @@ static void change_params(struct slgt_info *info)
 	/* process tty input control flags */
 
 	info->read_status_mask = IRQ_RXOVER;
-	if (I_INPCK(info->port.tty))
+	if (I_INPCK(&info->port.tty->termios))
 		info->read_status_mask |= MASK_PARITY | MASK_FRAMING;
- 	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
+ 	if (I_BRKINT(&info->port.tty->termios) || I_PARMRK(&info->port.tty->termios))
  		info->read_status_mask |= MASK_BREAK;
-	if (I_IGNPAR(info->port.tty))
+	if (I_IGNPAR(&info->port.tty->termios))
 		info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING;
-	if (I_IGNBRK(info->port.tty)) {
+	if (I_IGNBRK(&info->port.tty->termios)) {
 		info->ignore_status_mask |= MASK_BREAK;
 		/* If ignoring parity and break indicators, ignore
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->port.tty))
+		if (I_IGNPAR(&info->port.tty->termios))
 			info->ignore_status_mask |= MASK_OVERRUN;
 	}
 
@@ -3268,7 +3268,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		return 0;
 	}
 
-	if (C_CLOCAL(tty))
+	if (C_CLOCAL(&tty->termios))
 		do_clocal = true;
 
 	/* Wait for carrier detect and the line to become
@@ -3287,7 +3287,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	port->blocked_open++;
 
 	while (1) {
-		if (C_BAUD(tty) && tty_port_initialized(port))
+		if (C_BAUD(&tty->termios) && tty_port_initialized(port))
 			tty_port_raise_dtr_rts(port);
 
 		set_current_state(TASK_INTERRUPTIBLE);
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index dec156586de1..ffefc5e6d66c 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -871,7 +871,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	change_params(info);
 
 	/* Handle transition to B0 status */
-	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) {
+	if ((old_termios->c_cflag & CBAUD) && !C_BAUD(&tty->termios)) {
 		info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
 		spin_lock_irqsave(&info->lock,flags);
 	 	set_signals(info);
@@ -879,9 +879,9 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	}
 
 	/* Handle transition away from B0 status */
-	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(tty)) {
+	if (!(old_termios->c_cflag & CBAUD) && C_BAUD(&tty->termios)) {
 		info->serial_signals |= SerialSignal_DTR;
-		if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			info->serial_signals |= SerialSignal_RTS;
 		spin_lock_irqsave(&info->lock,flags);
 	 	set_signals(info);
@@ -889,7 +889,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	}
 
 	/* Handle turning off CRTSCTS */
-	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(tty)) {
+	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(&tty->termios)) {
 		tty->hw_stopped = 0;
 		tx_release(tty);
 	}
@@ -1464,10 +1464,10 @@ static void throttle(struct tty_struct * tty)
 	if (sanity_check(info, tty->name, "throttle"))
 		return;
 
-	if (I_IXOFF(tty))
-		send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		send_xchar(tty, STOP_CHAR(&tty->termios));
 
- 	if (C_CRTSCTS(tty)) {
+ 	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->lock,flags);
 		info->serial_signals &= ~SerialSignal_RTS;
 	 	set_signals(info);
@@ -1489,14 +1489,14 @@ static void unthrottle(struct tty_struct * tty)
 	if (sanity_check(info, tty->name, "unthrottle"))
 		return;
 
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		if (info->x_char)
 			info->x_char = 0;
 		else
-			send_xchar(tty, START_CHAR(tty));
+			send_xchar(tty, START_CHAR(&tty->termios));
 	}
 
- 	if (C_CRTSCTS(tty)) {
+ 	if (C_CRTSCTS(&tty->termios)) {
 		spin_lock_irqsave(&info->lock,flags);
 		info->serial_signals |= SerialSignal_RTS;
 	 	set_signals(info);
@@ -2819,18 +2819,18 @@ static void change_params(SLMP_INFO *info)
 	/* process tty input control flags */
 
 	info->read_status_mask2 = OVRN;
-	if (I_INPCK(info->port.tty))
+	if (I_INPCK(&info->port.tty->termios))
 		info->read_status_mask2 |= PE | FRME;
- 	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
+ 	if (I_BRKINT(&info->port.tty->termios) || I_PARMRK(&info->port.tty->termios))
  		info->read_status_mask1 |= BRKD;
-	if (I_IGNPAR(info->port.tty))
+	if (I_IGNPAR(&info->port.tty->termios))
 		info->ignore_status_mask2 |= PE | FRME;
-	if (I_IGNBRK(info->port.tty)) {
+	if (I_IGNBRK(&info->port.tty->termios)) {
 		info->ignore_status_mask1 |= BRKD;
 		/* If ignoring parity and break indicators, ignore
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->port.tty))
+		if (I_IGNPAR(&info->port.tty->termios))
 			info->ignore_status_mask2 |= OVRN;
 	}
 
@@ -3285,7 +3285,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		return 0;
 	}
 
-	if (C_CLOCAL(tty))
+	if (C_CLOCAL(&tty->termios))
 		do_clocal = true;
 
 	/* Wait for carrier detect and the line to become
@@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	port->blocked_open++;
 
 	while (1) {
-		if (C_BAUD(tty) && tty_port_initialized(port))
+		if (C_BAUD(&tty->termios) && tty_port_initialized(port))
 			tty_port_raise_dtr_rts(port);
 
 		set_current_state(TASK_INTERRUPTIBLE);
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index df2d735338e2..bc0ac47424d0 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -204,7 +204,7 @@ static struct tty_audit_buf *tty_audit_buf_get(void)
 void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size)
 {
 	struct tty_audit_buf *buf;
-	unsigned int icanon = !!L_ICANON(tty);
+	unsigned int icanon = !!L_ICANON(&tty->termios);
 	unsigned int audit_tty;
 	dev_t dev;
 
@@ -219,7 +219,7 @@ void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size)
 	    && tty->driver->subtype == PTY_TYPE_MASTER)
 		return;
 
-	if ((~audit_tty & AUDIT_TTY_LOG_PASSWD) && icanon && !L_ECHO(tty))
+	if ((~audit_tty & AUDIT_TTY_LOG_PASSWD) && icanon && !L_ECHO(&tty->termios))
 		return;
 
 	buf = tty_audit_buf_get();
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index bf36ac9aee41..5d311c6baa7a 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -719,16 +719,16 @@ static int get_sgflags(struct tty_struct *tty)
 {
 	int flags = 0;
 
-	if (!L_ICANON(tty)) {
-		if (L_ISIG(tty))
+	if (!L_ICANON(&tty->termios)) {
+		if (L_ISIG(&tty->termios))
 			flags |= 0x02;		/* cbreak */
 		else
 			flags |= 0x20;		/* raw */
 	}
-	if (L_ECHO(tty))
+	if (L_ECHO(&tty->termios))
 		flags |= 0x08;			/* echo */
-	if (O_OPOST(tty))
-		if (O_ONLCR(tty))
+	if (O_OPOST(&tty->termios))
+		if (O_ONLCR(&tty->termios))
 			flags |= 0x10;		/* crmod */
 	return flags;
 }
@@ -908,7 +908,7 @@ static int tty_change_softcar(struct tty_struct *tty, int arg)
 	tty->termios.c_cflag |= bit;
 	if (tty->ops->set_termios)
 		tty->ops->set_termios(tty, &old);
-	if (C_CLOCAL(tty) != bit)
+	if (C_CLOCAL(&tty->termios) != bit)
 		ret = -EINVAL;
 	up_write(&tty->termios_rwsem);
 	return ret;
@@ -1140,12 +1140,14 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 			spin_unlock_irq(&tty->flow_lock);
 			break;
 		case TCIOFF:
-			if (STOP_CHAR(tty) != __DISABLED_CHAR)
-				retval = tty_send_xchar(tty, STOP_CHAR(tty));
+			if (STOP_CHAR(&tty->termios) != __DISABLED_CHAR)
+				retval = tty_send_xchar(tty,
+							STOP_CHAR(&tty->termios));
 			break;
 		case TCION:
-			if (START_CHAR(tty) != __DISABLED_CHAR)
-				retval = tty_send_xchar(tty, START_CHAR(tty));
+			if (START_CHAR(&tty->termios) != __DISABLED_CHAR)
+				retval = tty_send_xchar(tty,
+							START_CHAR(&tty->termios));
 			break;
 		default:
 			return -EINVAL;
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index c3f9d93ba227..5ad4bda512e2 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -210,7 +210,7 @@ static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty)
 		 * Drop DTR/RTS if HUPCL is set. This causes any attached
 		 * modem to hang up the line.
 		 */
-		if (tty && C_HUPCL(tty))
+		if (tty && C_HUPCL(&tty->termios))
 			tty_port_lower_dtr_rts(port);
 
 		if (port->ops->shutdown)
@@ -260,7 +260,7 @@ void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
 {
 	struct tty_struct *tty = tty_port_tty_get(port);
 
-	if (tty && (!check_clocal || !C_CLOCAL(tty)))
+	if (tty && (!check_clocal || !C_CLOCAL(&tty->termios)))
 		tty_hangup(tty);
 	tty_kref_put(tty);
 }
@@ -371,13 +371,13 @@ int tty_port_block_til_ready(struct tty_port *port,
 	}
 	if (filp->f_flags & O_NONBLOCK) {
 		/* Indicate we are open */
-		if (C_BAUD(tty))
+		if (C_BAUD(&tty->termios))
 			tty_port_raise_dtr_rts(port);
 		tty_port_set_active(port, 1);
 		return 0;
 	}
 
-	if (C_CLOCAL(tty))
+	if (C_CLOCAL(&tty->termios))
 		do_clocal = 1;
 
 	/* Block waiting until we can proceed. We may need to wait for the
@@ -394,7 +394,7 @@ int tty_port_block_til_ready(struct tty_port *port,
 
 	while (1) {
 		/* Indicate we are open */
-		if (C_BAUD(tty) && tty_port_initialized(port))
+		if (C_BAUD(&tty->termios) && tty_port_initialized(port))
 			tty_port_raise_dtr_rts(port);
 
 		prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE);
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 0f8caae4267d..93c72688a497 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1380,7 +1380,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
 
 	if (rep &&
 	    (!vc_kbd_mode(kbd, VC_REPEAT) ||
-	     (tty && !L_ECHO(tty) && tty_chars_in_buffer(tty)))) {
+	     (tty && !L_ECHO(&tty->termios) && tty_chars_in_buffer(tty)))) {
 		/*
 		 * Don't repeat a key if the input buffers are not empty and the
 		 * characters get aren't echoed locally. This makes key repeat
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0f3f62e81e5b..9a91ae55d880 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1067,7 +1067,7 @@ static void acm_tty_set_termios(struct tty_struct *tty,
 	/* FIXME: Needs to clear unsupported bits in the termios */
 	acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
 
-	if (C_BAUD(tty) == B0) {
+	if (C_BAUD(&tty->termios) == B0) {
 		newline.dwDTERate = acm->line.dwDTERate;
 		newctrl &= ~ACM_CTRL_DTR;
 	} else if (termios_old && (termios_old->c_cflag & CBAUD) == B0) {
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 1532cde8a437..37f5ed6fc071 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -324,7 +324,7 @@ static void ark3116_set_termios(struct tty_struct *tty,
 	mutex_unlock(&priv->hw_lock);
 
 	/* check for software flow control */
-	if (I_IXOFF(tty) || I_IXON(tty)) {
+	if (I_IXOFF(&tty->termios) || I_IXON(&tty->termios)) {
 		dev_warn(&serial->dev->dev,
 			 "%s: don't know how to do software flow control\n",
 			 KBUILD_MODNAME);
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index bbeeb2bd55a8..4e157e9e0173 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1164,7 +1164,7 @@ static void cypress_read_int_callback(struct urb *urb)
 
 	/* hangup, as defined in acm.c... this might be a bad place for it
 	 * though */
-	if (tty && !C_CLOCAL(tty) && !(priv->current_status & UART_CD)) {
+	if (tty && !C_CLOCAL(&tty->termios) && !(priv->current_status & UART_CD)) {
 		dev_dbg(dev, "%s - calling hangup\n", __func__);
 		tty_hangup(tty);
 		goto continue_read;
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 6a1df9e824ca..391e42ce1ce7 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -699,7 +699,7 @@ static void digi_set_termios(struct tty_struct *tty,
 			/* don't set RTS if using hardware flow control */
 			/* and throttling input */
 			modem_signals = TIOCM_DTR;
-			if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+			if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 				modem_signals |= TIOCM_RTS;
 			digi_set_modem_signals(port, modem_signals, 1);
 		}
@@ -1509,7 +1509,7 @@ static int digi_read_oob_callback(struct urb *urb)
 
 		rts = 0;
 		if (tty)
-			rts = C_CRTSCTS(tty);
+			rts = C_CRTSCTS(&tty->termios);
 
 		if (tty && opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
 			spin_lock(&priv->dp_port_lock);
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 972f5a5fe577..3f103645af02 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -447,7 +447,7 @@ static void f81232_set_termios(struct tty_struct *tty,
 	if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
 		return;
 
-	if (C_BAUD(tty) == B0)
+	if (C_BAUD(&tty->termios) == B0)
 		f81232_set_mctrl(port, 0, TIOCM_DTR | TIOCM_RTS);
 	else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
 		f81232_set_mctrl(port, TIOCM_DTR | TIOCM_RTS, 0);
@@ -461,20 +461,20 @@ static void f81232_set_termios(struct tty_struct *tty,
 		f81232_set_baudrate(port, baudrate);
 	}
 
-	if (C_PARENB(tty)) {
+	if (C_PARENB(&tty->termios)) {
 		new_lcr |= UART_LCR_PARITY;
 
-		if (!C_PARODD(tty))
+		if (!C_PARODD(&tty->termios))
 			new_lcr |= UART_LCR_EPAR;
 
-		if (C_CMSPAR(tty))
+		if (C_CMSPAR(&tty->termios))
 			new_lcr |= UART_LCR_SPAR;
 	}
 
-	if (C_CSTOPB(tty))
+	if (C_CSTOPB(&tty->termios))
 		new_lcr |= UART_LCR_STOP;
 
-	switch (C_CSIZE(tty)) {
+	switch (C_CSIZE(&tty->termios)) {
 	case CS5:
 		new_lcr |= UART_LCR_WLEN5;
 		break;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b2d767e743fc..ab2c8098d1ff 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2224,7 +2224,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
 	 *       The vendor didn't bother with a custom VID/PID of
 	 *       course.
 	 */
-	if (C_CSIZE(tty) == CS6) {
+	if (C_CSIZE(&tty->termios) == CS6) {
 		dev_warn(ddev, "requested CSIZE setting not supported\n");
 
 		termios->c_cflag &= ~CSIZE;
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 944de657a07a..2b1ba969c1b1 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -596,7 +596,7 @@ void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
 
 	if (status)
 		wake_up_interruptible(&port->open_wait);
-	else if (tty && !C_CLOCAL(tty))
+	else if (tty && !C_CLOCAL(&tty->termios))
 		tty_hangup(tty);
 }
 EXPORT_SYMBOL_GPL(usb_serial_handle_dcd_change);
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 11c05ce2f35f..74d1253c5a6d 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1390,15 +1390,15 @@ static void edge_throttle(struct tty_struct *tty)
 	}
 
 	/* if we are implementing XON/XOFF, send the stop character */
-	if (I_IXOFF(tty)) {
-		unsigned char stop_char = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char stop_char = STOP_CHAR(&tty->termios);
 		status = edge_write(tty, port, &stop_char, 1);
 		if (status <= 0)
 			return;
 	}
 
 	/* if we are implementing RTS/CTS, toggle that line */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		edge_port->shadowMCR &= ~MCR_RTS;
 		status = send_cmd_write_uart_register(edge_port, MCR,
 							edge_port->shadowMCR);
@@ -1428,14 +1428,14 @@ static void edge_unthrottle(struct tty_struct *tty)
 	}
 
 	/* if we are implementing XON/XOFF, send the start character */
-	if (I_IXOFF(tty)) {
-		unsigned char start_char = START_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char start_char = START_CHAR(&tty->termios);
 		status = edge_write(tty, port, &start_char, 1);
 		if (status <= 0)
 			return;
 	}
 	/* if we are implementing RTS/CTS, toggle that line */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		edge_port->shadowMCR |= MCR_RTS;
 		send_cmd_write_uart_register(edge_port, MCR,
 						edge_port->shadowMCR);
@@ -2457,9 +2457,9 @@ static void change_port_settings(struct tty_struct *tty,
 
 	/* if we are implementing XON/XOFF, set the start and stop character
 	   in the device */
-	if (I_IXOFF(tty) || I_IXON(tty)) {
-		unsigned char stop_char  = STOP_CHAR(tty);
-		unsigned char start_char = START_CHAR(tty);
+	if (I_IXOFF(&tty->termios) || I_IXON(&tty->termios)) {
+		unsigned char stop_char  = STOP_CHAR(&tty->termios);
+		unsigned char start_char = START_CHAR(&tty->termios);
 
 		if (!edge_serial->is_epic ||
 		    edge_serial->epic_descriptor.Supports.IOSPSetXChar) {
@@ -2470,7 +2470,7 @@ static void change_port_settings(struct tty_struct *tty,
 		}
 
 		/* if we are implementing INBOUND XON/XOFF */
-		if (I_IXOFF(tty)) {
+		if (I_IXOFF(&tty->termios)) {
 			rxFlow |= IOSP_RX_FLOW_XON_XOFF;
 			dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
 				__func__, start_char, stop_char);
@@ -2479,7 +2479,7 @@ static void change_port_settings(struct tty_struct *tty,
 		}
 
 		/* if we are implementing OUTBOUND XON/XOFF */
-		if (I_IXON(tty)) {
+		if (I_IXON(&tty->termios)) {
 			txFlow |= IOSP_TX_FLOW_XON_XOFF;
 			dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
 				__func__, start_char, stop_char);
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index fce82fd79f77..910447ea32b7 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -1585,7 +1585,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
 
 	tty = tty_port_tty_get(&edge_port->port->port);
 	/* handle CTS flow control */
-	if (tty && C_CRTSCTS(tty)) {
+	if (tty && C_CRTSCTS(&tty->termios)) {
 		if (msr & EDGEPORT_MSR_CTS)
 			tty_wakeup(tty);
 	}
@@ -2155,8 +2155,8 @@ static void edge_throttle(struct tty_struct *tty)
 		return;
 
 	/* if we are implementing XON/XOFF, send the stop character */
-	if (I_IXOFF(tty)) {
-		unsigned char stop_char = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char stop_char = STOP_CHAR(&tty->termios);
 		status = edge_write(tty, port, &stop_char, 1);
 		if (status <= 0) {
 			dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status);
@@ -2167,7 +2167,7 @@ static void edge_throttle(struct tty_struct *tty)
 	 * if we are implementing RTS/CTS, stop reads
 	 * and the Edgeport will clear the RTS line
 	 */
-	if (C_CRTSCTS(tty))
+	if (C_CRTSCTS(&tty->termios))
 		stop_read(edge_port);
 
 }
@@ -2182,8 +2182,8 @@ static void edge_unthrottle(struct tty_struct *tty)
 		return;
 
 	/* if we are implementing XON/XOFF, send the start character */
-	if (I_IXOFF(tty)) {
-		unsigned char start_char = START_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char start_char = START_CHAR(&tty->termios);
 		status = edge_write(tty, port, &start_char, 1);
 		if (status <= 0) {
 			dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
@@ -2193,7 +2193,7 @@ static void edge_unthrottle(struct tty_struct *tty)
 	 * if we are implementing RTS/CTS, restart reads
 	 * are the Edgeport will assert the RTS line
 	 */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		status = restart_read(edge_port);
 		if (status)
 			dev_err(&port->dev,
@@ -2318,11 +2318,11 @@ static void change_port_settings(struct tty_struct *tty,
 	 * if we are implementing XON/XOFF, set the start and stop
 	 * character in the device
 	 */
-	config->cXon  = START_CHAR(tty);
-	config->cXoff = STOP_CHAR(tty);
+	config->cXon  = START_CHAR(&tty->termios);
+	config->cXoff = STOP_CHAR(&tty->termios);
 
 	/* if we are implementing INBOUND XON/XOFF */
-	if (I_IXOFF(tty)) {
+	if (I_IXOFF(&tty->termios)) {
 		config->wFlags |= UMP_MASK_UART_FLAGS_IN_X;
 		dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
 			__func__, config->cXon, config->cXoff);
@@ -2330,7 +2330,7 @@ static void change_port_settings(struct tty_struct *tty,
 		dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__);
 
 	/* if we are implementing OUTBOUND XON/XOFF */
-	if (I_IXON(tty)) {
+	if (I_IXON(&tty->termios)) {
 		config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X;
 		dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
 			__func__, config->cXon, config->cXoff);
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 885655315de1..8f97b8acea99 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -230,7 +230,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
 			"failed (error = %d)\n", MCT_U232_SET_UNKNOWN1_REQUEST,
 			rc);
 
-	if (port && C_CRTSCTS(tty))
+	if (port && C_CRTSCTS(&tty->termios))
 	   cts_enable_byte = 1;
 
 	dev_dbg(&port->dev, "set_baud_rate: send second control message, data = %02X\n",
@@ -435,7 +435,7 @@ static int  mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port)
 	 * either.
 	 */
 	spin_lock_irqsave(&priv->lock, flags);
-	if (tty && C_BAUD(tty))
+	if (tty && C_BAUD(&tty->termios))
 		priv->control_state = TIOCM_DTR | TIOCM_RTS;
 	else
 		priv->control_state = 0;
@@ -743,7 +743,7 @@ static void mct_u232_throttle(struct tty_struct *tty)
 
 	spin_lock_irq(&priv->lock);
 	priv->rx_flags |= THROTTLED;
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		priv->control_state &= ~TIOCM_RTS;
 		control_state = priv->control_state;
 		spin_unlock_irq(&priv->lock);
@@ -760,7 +760,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty)
 	unsigned int control_state;
 
 	spin_lock_irq(&priv->lock);
-	if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) {
+	if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(&tty->termios)) {
 		priv->rx_flags &= ~THROTTLED;
 		priv->control_state |= TIOCM_RTS;
 		control_state = priv->control_state;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index de9992b492b0..9bd79ff04713 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1300,15 +1300,15 @@ static void mos7720_throttle(struct tty_struct *tty)
 	}
 
 	/* if we are implementing XON/XOFF, send the stop character */
-	if (I_IXOFF(tty)) {
-		unsigned char stop_char = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char stop_char = STOP_CHAR(&tty->termios);
 		status = mos7720_write(tty, port, &stop_char, 1);
 		if (status <= 0)
 			return;
 	}
 
 	/* if we are implementing RTS/CTS, toggle that line */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		mos7720_port->shadowMCR &= ~UART_MCR_RTS;
 		write_mos_reg(port->serial, port->port_number, MOS7720_MCR,
 			      mos7720_port->shadowMCR);
@@ -1330,15 +1330,15 @@ static void mos7720_unthrottle(struct tty_struct *tty)
 	}
 
 	/* if we are implementing XON/XOFF, send the start character */
-	if (I_IXOFF(tty)) {
-		unsigned char start_char = START_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char start_char = START_CHAR(&tty->termios);
 		status = mos7720_write(tty, port, &start_char, 1);
 		if (status <= 0)
 			return;
 	}
 
 	/* if we are implementing RTS/CTS, toggle that line */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		mos7720_port->shadowMCR |= UART_MCR_RTS;
 		write_mos_reg(port->serial, port->port_number, MOS7720_MCR,
 			      mos7720_port->shadowMCR);
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 57426d703a09..a6d104697e76 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1418,14 +1418,14 @@ static void mos7840_throttle(struct tty_struct *tty)
 	}
 
 	/* if we are implementing XON/XOFF, send the stop character */
-	if (I_IXOFF(tty)) {
-		unsigned char stop_char = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char stop_char = STOP_CHAR(&tty->termios);
 		status = mos7840_write(tty, port, &stop_char, 1);
 		if (status <= 0)
 			return;
 	}
 	/* if we are implementing RTS/CTS, toggle that line */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		mos7840_port->shadowMCR &= ~MCR_RTS;
 		status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
 					 mos7840_port->shadowMCR);
@@ -1458,15 +1458,15 @@ static void mos7840_unthrottle(struct tty_struct *tty)
 	}
 
 	/* if we are implementing XON/XOFF, send the start character */
-	if (I_IXOFF(tty)) {
-		unsigned char start_char = START_CHAR(tty);
+	if (I_IXOFF(&tty->termios)) {
+		unsigned char start_char = START_CHAR(&tty->termios);
 		status = mos7840_write(tty, port, &start_char, 1);
 		if (status <= 0)
 			return;
 	}
 
 	/* if we are implementing RTS/CTS, toggle that line */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		mos7840_port->shadowMCR |= MCR_RTS;
 		status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
 					 mos7840_port->shadowMCR);
diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index c88215a0fa3d..a57cac60f048 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -775,8 +775,8 @@ static int mxuport_set_termios_flow(struct tty_struct *tty,
 				    struct usb_serial_port *port,
 				    struct usb_serial *serial)
 {
-	u8 xon = START_CHAR(tty);
-	u8 xoff = STOP_CHAR(tty);
+	u8 xon = START_CHAR(&tty->termios);
+	u8 xoff = STOP_CHAR(&tty->termios);
 	int enable;
 	int err;
 	u8 *buf;
@@ -787,7 +787,7 @@ static int mxuport_set_termios_flow(struct tty_struct *tty,
 		return -ENOMEM;
 
 	/* S/W flow control settings */
-	if (I_IXOFF(tty) || I_IXON(tty)) {
+	if (I_IXOFF(&tty->termios) || I_IXON(&tty->termios)) {
 		enable = 1;
 		buf[0] = xon;
 		buf[1] = xoff;
@@ -813,17 +813,17 @@ static int mxuport_set_termios_flow(struct tty_struct *tty,
 
 	/* H/W flow control settings */
 	if (!old_termios ||
-	    C_CRTSCTS(tty) != (old_termios->c_cflag & CRTSCTS)) {
-		if (C_CRTSCTS(tty))
+	    C_CRTSCTS(&tty->termios) != (old_termios->c_cflag & CRTSCTS)) {
+		if (C_CRTSCTS(&tty->termios))
 			rts = MX_RTS_HW;
 		else
 			rts = MX_RTS_ENABLE;
 	}
 
-	if (C_BAUD(tty)) {
+	if (C_BAUD(&tty->termios)) {
 		if (old_termios && (old_termios->c_cflag & CBAUD) == B0) {
 			/* Raise DTR and RTS */
-			if (C_CRTSCTS(tty))
+			if (C_CRTSCTS(&tty->termios))
 				rts = MX_RTS_HW;
 			else
 				rts = MX_RTS_ENABLE;
@@ -867,7 +867,7 @@ static void mxuport_set_termios(struct tty_struct *tty,
 		return;
 
 	/* Set data bit of termios */
-	switch (C_CSIZE(tty)) {
+	switch (C_CSIZE(&tty->termios)) {
 	case CS5:
 		data_bits = MX_WORDLENGTH_5;
 		break;
@@ -884,14 +884,14 @@ static void mxuport_set_termios(struct tty_struct *tty,
 	}
 
 	/* Set parity of termios */
-	if (C_PARENB(tty)) {
-		if (C_CMSPAR(tty)) {
-			if (C_PARODD(tty))
+	if (C_PARENB(&tty->termios)) {
+		if (C_CMSPAR(&tty->termios)) {
+			if (C_PARODD(&tty->termios))
 				parity = MX_PARITY_MARK;
 			else
 				parity = MX_PARITY_SPACE;
 		} else {
-			if (C_PARODD(tty))
+			if (C_PARODD(&tty->termios))
 				parity = MX_PARITY_ODD;
 			else
 				parity = MX_PARITY_EVEN;
@@ -901,7 +901,7 @@ static void mxuport_set_termios(struct tty_struct *tty,
 	}
 
 	/* Set stop bit of termios */
-	if (C_CSTOPB(tty))
+	if (C_CSTOPB(&tty->termios))
 		stop_bits = MX_STOP_BITS_2;
 	else
 		stop_bits = MX_STOP_BITS_1;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ae682e4eeaef..7f64e081defa 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -499,7 +499,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
 
 	pl2303_get_line_request(port, buf);
 
-	switch (C_CSIZE(tty)) {
+	switch (C_CSIZE(&tty->termios)) {
 	case CS5:
 		buf[6] = 5;
 		break;
@@ -521,12 +521,12 @@ static void pl2303_set_termios(struct tty_struct *tty,
 	/* For reference buf[4]=0 is 1 stop bits */
 	/* For reference buf[4]=1 is 1.5 stop bits */
 	/* For reference buf[4]=2 is 2 stop bits */
-	if (C_CSTOPB(tty)) {
+	if (C_CSTOPB(&tty->termios)) {
 		/*
 		 * NOTE: Comply with "real" UARTs / RS232:
 		 *       use 1.5 instead of 2 stop bits with 5 data bits
 		 */
-		if (C_CSIZE(tty) == CS5) {
+		if (C_CSIZE(&tty->termios) == CS5) {
 			buf[4] = 1;
 			dev_dbg(&port->dev, "stop bits = 1.5\n");
 		} else {
@@ -538,14 +538,14 @@ static void pl2303_set_termios(struct tty_struct *tty,
 		dev_dbg(&port->dev, "stop bits = 1\n");
 	}
 
-	if (C_PARENB(tty)) {
+	if (C_PARENB(&tty->termios)) {
 		/* For reference buf[5]=0 is none parity */
 		/* For reference buf[5]=1 is odd parity */
 		/* For reference buf[5]=2 is even parity */
 		/* For reference buf[5]=3 is mark parity */
 		/* For reference buf[5]=4 is space parity */
-		if (C_PARODD(tty)) {
-			if (C_CMSPAR(tty)) {
+		if (C_PARODD(&tty->termios)) {
+			if (C_CMSPAR(&tty->termios)) {
 				buf[5] = 3;
 				dev_dbg(&port->dev, "parity = mark\n");
 			} else {
@@ -553,7 +553,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
 				dev_dbg(&port->dev, "parity = odd\n");
 			}
 		} else {
-			if (C_CMSPAR(tty)) {
+			if (C_CMSPAR(&tty->termios)) {
 				buf[5] = 4;
 				dev_dbg(&port->dev, "parity = space\n");
 			} else {
@@ -587,7 +587,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
 	/* change control lines if we are switching to or from B0 */
 	spin_lock_irqsave(&priv->lock, flags);
 	control = priv->line_control;
-	if (C_BAUD(tty) == B0)
+	if (C_BAUD(&tty->termios) == B0)
 		priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
 	else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
 		priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
@@ -599,7 +599,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
 		spin_unlock_irqrestore(&priv->lock, flags);
 	}
 
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		if (spriv->quirks & PL2303_QUIRK_LEGACY)
 			pl2303_vendor_write(serial, 0x0, 0x41);
 		else
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 85acb50a7ee2..e301099b6814 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -321,8 +321,8 @@ static void qt2_set_termios(struct tty_struct *tty,
 		dev_err(&port->dev, "%s - set HW flow control failed: %i\n",
 			__func__, status);
 
-	if (I_IXOFF(tty) || I_IXON(tty)) {
-		u16 x = ((u16) (START_CHAR(tty) << 8) | (u16) (STOP_CHAR(tty)));
+	if (I_IXOFF(&tty->termios) || I_IXON(&tty->termios)) {
+		u16 x = ((u16) (START_CHAR(&tty->termios) << 8) | (u16) (STOP_CHAR(&tty->termios)));
 
 		status = qt2_control_msg(dev, QT_SW_FLOW_CONTROL_MASK,
 					 x, port_priv->device_port);
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 70a098de429f..a889e2c5d542 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -258,8 +258,8 @@ static void ssu100_set_termios(struct tty_struct *tty,
 	if (result < 0)
 		dev_dbg(&port->dev, "%s - set HW flow control failed\n", __func__);
 
-	if (I_IXOFF(tty) || I_IXON(tty)) {
-		u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty)));
+	if (I_IXOFF(&tty->termios) || I_IXON(&tty->termios)) {
+		u16 x = ((u16)(START_CHAR(&tty->termios) << 8) | (u16)(STOP_CHAR(&tty->termios)));
 
 		result = ssu100_control_msg(dev, QT_SW_FLOW_CONTROL_MASK,
 					    x, 0);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 07b4bf01061d..3e1c1a42d14a 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -903,7 +903,7 @@ static void ti_throttle(struct tty_struct *tty)
 	if (tport == NULL)
 		return;
 
-	if (I_IXOFF(tty) || C_CRTSCTS(tty))
+	if (I_IXOFF(&tty->termios) || C_CRTSCTS(&tty->termios))
 		ti_stop_read(tport, tty);
 
 }
@@ -918,7 +918,7 @@ static void ti_unthrottle(struct tty_struct *tty)
 	if (tport == NULL)
 		return;
 
-	if (I_IXOFF(tty) || C_CRTSCTS(tty)) {
+	if (I_IXOFF(&tty->termios) || C_CRTSCTS(&tty->termios)) {
 		status = ti_restart_read(tport, tty);
 		if (status)
 			dev_err(&port->dev, "%s - cannot restart read, %d\n",
@@ -1027,16 +1027,16 @@ static void ti_set_termios(struct tty_struct *tty,
 		ti_restart_read(tport, tty);
 	}
 
-	if (I_IXOFF(tty) || I_IXON(tty)) {
-		config->cXon  = START_CHAR(tty);
-		config->cXoff = STOP_CHAR(tty);
+	if (I_IXOFF(&tty->termios) || I_IXON(&tty->termios)) {
+		config->cXon  = START_CHAR(&tty->termios);
+		config->cXoff = STOP_CHAR(&tty->termios);
 
-		if (I_IXOFF(tty))
+		if (I_IXOFF(&tty->termios))
 			config->wFlags |= TI_UART_ENABLE_X_IN;
 		else
 			ti_restart_read(tport, tty);
 
-		if (I_IXON(tty))
+		if (I_IXON(&tty->termios))
 			config->wFlags |= TI_UART_ENABLE_X_OUT;
 	}
 
@@ -1549,7 +1549,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
 
 	/* handle CTS flow control */
 	tty = tty_port_tty_get(&tport->tp_port->port);
-	if (tty && C_CRTSCTS(tty)) {
+	if (tty && C_CRTSCTS(&tty->termios)) {
 		if (msr & TI_MSR_CTS)
 			tty_wakeup(tty);
 	}
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index d3ea90bef84d..d11edb41db75 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -726,14 +726,14 @@ static void firm_setup_port(struct tty_struct *tty)
 	    (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : "");
 
 	/* determine software flow control */
-	if (I_IXOFF(tty))
+	if (I_IXOFF(&tty->termios))
 		port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
 	else
 		port_settings.sflow = WHITEHEAT_SFLOW_NONE;
 	dev_dbg(dev, "%s - software flow control = %c\n", __func__, port_settings.sflow);
 
-	port_settings.xon = START_CHAR(tty);
-	port_settings.xoff = STOP_CHAR(tty);
+	port_settings.xon = START_CHAR(&tty->termios);
+	port_settings.xoff = STOP_CHAR(&tty->termios);
 	dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff);
 
 	/* get the baud rate wanted */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 40144f382516..73a8c38987f5 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -101,88 +101,88 @@ struct tty_bufhead {
 #define TTY_PARITY	3
 #define TTY_OVERRUN	4
 
-#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
-#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
-#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
-#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
-#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
-#define TIME_CHAR(tty) ((tty)->termios.c_cc[VTIME])
-#define MIN_CHAR(tty) ((tty)->termios.c_cc[VMIN])
-#define SWTC_CHAR(tty) ((tty)->termios.c_cc[VSWTC])
-#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
-#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
-#define SUSP_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
-#define EOL_CHAR(tty) ((tty)->termios.c_cc[VEOL])
-#define REPRINT_CHAR(tty) ((tty)->termios.c_cc[VREPRINT])
-#define DISCARD_CHAR(tty) ((tty)->termios.c_cc[VDISCARD])
-#define WERASE_CHAR(tty) ((tty)->termios.c_cc[VWERASE])
-#define LNEXT_CHAR(tty)	((tty)->termios.c_cc[VLNEXT])
-#define EOL2_CHAR(tty) ((tty)->termios.c_cc[VEOL2])
-
-#define _I_FLAG(tty, f)	((tty)->termios.c_iflag & (f))
-#define _O_FLAG(tty, f)	((tty)->termios.c_oflag & (f))
-#define _C_FLAG(tty, f)	((tty)->termios.c_cflag & (f))
-#define _L_FLAG(tty, f)	((tty)->termios.c_lflag & (f))
-
-#define I_IGNBRK(tty)	_I_FLAG((tty), IGNBRK)
-#define I_BRKINT(tty)	_I_FLAG((tty), BRKINT)
-#define I_IGNPAR(tty)	_I_FLAG((tty), IGNPAR)
-#define I_PARMRK(tty)	_I_FLAG((tty), PARMRK)
-#define I_INPCK(tty)	_I_FLAG((tty), INPCK)
-#define I_ISTRIP(tty)	_I_FLAG((tty), ISTRIP)
-#define I_INLCR(tty)	_I_FLAG((tty), INLCR)
-#define I_IGNCR(tty)	_I_FLAG((tty), IGNCR)
-#define I_ICRNL(tty)	_I_FLAG((tty), ICRNL)
-#define I_IUCLC(tty)	_I_FLAG((tty), IUCLC)
-#define I_IXON(tty)	_I_FLAG((tty), IXON)
-#define I_IXANY(tty)	_I_FLAG((tty), IXANY)
-#define I_IXOFF(tty)	_I_FLAG((tty), IXOFF)
-#define I_IMAXBEL(tty)	_I_FLAG((tty), IMAXBEL)
-#define I_IUTF8(tty)	_I_FLAG((tty), IUTF8)
-
-#define O_OPOST(tty)	_O_FLAG((tty), OPOST)
-#define O_OLCUC(tty)	_O_FLAG((tty), OLCUC)
-#define O_ONLCR(tty)	_O_FLAG((tty), ONLCR)
-#define O_OCRNL(tty)	_O_FLAG((tty), OCRNL)
-#define O_ONOCR(tty)	_O_FLAG((tty), ONOCR)
-#define O_ONLRET(tty)	_O_FLAG((tty), ONLRET)
-#define O_OFILL(tty)	_O_FLAG((tty), OFILL)
-#define O_OFDEL(tty)	_O_FLAG((tty), OFDEL)
-#define O_NLDLY(tty)	_O_FLAG((tty), NLDLY)
-#define O_CRDLY(tty)	_O_FLAG((tty), CRDLY)
-#define O_TABDLY(tty)	_O_FLAG((tty), TABDLY)
-#define O_BSDLY(tty)	_O_FLAG((tty), BSDLY)
-#define O_VTDLY(tty)	_O_FLAG((tty), VTDLY)
-#define O_FFDLY(tty)	_O_FLAG((tty), FFDLY)
-
-#define C_BAUD(tty)	_C_FLAG((tty), CBAUD)
-#define C_CSIZE(tty)	_C_FLAG((tty), CSIZE)
-#define C_CSTOPB(tty)	_C_FLAG((tty), CSTOPB)
-#define C_CREAD(tty)	_C_FLAG((tty), CREAD)
-#define C_PARENB(tty)	_C_FLAG((tty), PARENB)
-#define C_PARODD(tty)	_C_FLAG((tty), PARODD)
-#define C_HUPCL(tty)	_C_FLAG((tty), HUPCL)
-#define C_CLOCAL(tty)	_C_FLAG((tty), CLOCAL)
-#define C_CIBAUD(tty)	_C_FLAG((tty), CIBAUD)
-#define C_CRTSCTS(tty)	_C_FLAG((tty), CRTSCTS)
-#define C_CMSPAR(tty)	_C_FLAG((tty), CMSPAR)
-
-#define L_ISIG(tty)	_L_FLAG((tty), ISIG)
-#define L_ICANON(tty)	_L_FLAG((tty), ICANON)
-#define L_XCASE(tty)	_L_FLAG((tty), XCASE)
-#define L_ECHO(tty)	_L_FLAG((tty), ECHO)
-#define L_ECHOE(tty)	_L_FLAG((tty), ECHOE)
-#define L_ECHOK(tty)	_L_FLAG((tty), ECHOK)
-#define L_ECHONL(tty)	_L_FLAG((tty), ECHONL)
-#define L_NOFLSH(tty)	_L_FLAG((tty), NOFLSH)
-#define L_TOSTOP(tty)	_L_FLAG((tty), TOSTOP)
-#define L_ECHOCTL(tty)	_L_FLAG((tty), ECHOCTL)
-#define L_ECHOPRT(tty)	_L_FLAG((tty), ECHOPRT)
-#define L_ECHOKE(tty)	_L_FLAG((tty), ECHOKE)
-#define L_FLUSHO(tty)	_L_FLAG((tty), FLUSHO)
-#define L_PENDIN(tty)	_L_FLAG((tty), PENDIN)
-#define L_IEXTEN(tty)	_L_FLAG((tty), IEXTEN)
-#define L_EXTPROC(tty)	_L_FLAG((tty), EXTPROC)
+#define INTR_CHAR(termios)	((termios)->c_cc[VINTR])
+#define QUIT_CHAR(termios)	((termios)->c_cc[VQUIT])
+#define ERASE_CHAR(termios)	((termios)->c_cc[VERASE])
+#define KILL_CHAR(termios)	((termios)->c_cc[VKILL])
+#define EOF_CHAR(termios)	((termios)->c_cc[VEOF])
+#define TIME_CHAR(termios)	((termios)->c_cc[VTIME])
+#define MIN_CHAR(termios)	((termios)->c_cc[VMIN])
+#define SWTC_CHAR(termios)	((termios)->c_cc[VSWTC])
+#define START_CHAR(termios)	((termios)->c_cc[VSTART])
+#define STOP_CHAR(termios)	((termios)->c_cc[VSTOP])
+#define SUSP_CHAR(termios)	((termios)->c_cc[VSUSP])
+#define EOL_CHAR(termios)	((termios)->c_cc[VEOL])
+#define REPRINT_CHAR(termios)	((termios)->c_cc[VREPRINT])
+#define DISCARD_CHAR(termios)	((termios)->c_cc[VDISCARD])
+#define WERASE_CHAR(termios)	((termios)->c_cc[VWERASE])
+#define LNEXT_CHAR(termios)	((termios)->c_cc[VLNEXT])
+#define EOL2_CHAR(termios)	((termios)->c_cc[VEOL2])
+
+#define _I_FLAG(termios, f)	((termios)->c_iflag & (f))
+#define _O_FLAG(termios, f)	((termios)->c_oflag & (f))
+#define _C_FLAG(termios, f)	((termios)->c_cflag & (f))
+#define _L_FLAG(termios, f)	((termios)->c_lflag & (f))
+
+#define I_IGNBRK(termios)	_I_FLAG((termios), IGNBRK)
+#define I_BRKINT(termios)	_I_FLAG((termios), BRKINT)
+#define I_IGNPAR(termios)	_I_FLAG((termios), IGNPAR)
+#define I_PARMRK(termios)	_I_FLAG((termios), PARMRK)
+#define I_INPCK(termios)	_I_FLAG((termios), INPCK)
+#define I_ISTRIP(termios)	_I_FLAG((termios), ISTRIP)
+#define I_INLCR(termios)	_I_FLAG((termios), INLCR)
+#define I_IGNCR(termios)	_I_FLAG((termios), IGNCR)
+#define I_ICRNL(termios)	_I_FLAG((termios), ICRNL)
+#define I_IUCLC(termios)	_I_FLAG((termios), IUCLC)
+#define I_IXON(termios)		_I_FLAG((termios), IXON)
+#define I_IXANY(termios)	_I_FLAG((termios), IXANY)
+#define I_IXOFF(termios)	_I_FLAG((termios), IXOFF)
+#define I_IMAXBEL(termios)	_I_FLAG((termios), IMAXBEL)
+#define I_IUTF8(termios)	_I_FLAG((termios), IUTF8)
+
+#define O_OPOST(termios)	_O_FLAG((termios), OPOST)
+#define O_OLCUC(termios)	_O_FLAG((termios), OLCUC)
+#define O_ONLCR(termios)	_O_FLAG((termios), ONLCR)
+#define O_OCRNL(termios)	_O_FLAG((termios), OCRNL)
+#define O_ONOCR(termios)	_O_FLAG((termios), ONOCR)
+#define O_ONLRET(termios)	_O_FLAG((termios), ONLRET)
+#define O_OFILL(termios)	_O_FLAG((termios), OFILL)
+#define O_OFDEL(termios)	_O_FLAG((termios), OFDEL)
+#define O_NLDLY(termios)	_O_FLAG((termios), NLDLY)
+#define O_CRDLY(termios)	_O_FLAG((termios), CRDLY)
+#define O_TABDLY(termios)	_O_FLAG((termios), TABDLY)
+#define O_BSDLY(termios)	_O_FLAG((termios), BSDLY)
+#define O_VTDLY(termios)	_O_FLAG((termios), VTDLY)
+#define O_FFDLY(termios)	_O_FLAG((termios), FFDLY)
+
+#define C_BAUD(termios)		_C_FLAG((termios), CBAUD)
+#define C_CSIZE(termios)	_C_FLAG((termios), CSIZE)
+#define C_CSTOPB(termios)	_C_FLAG((termios), CSTOPB)
+#define C_CREAD(termios)	_C_FLAG((termios), CREAD)
+#define C_PARENB(termios)	_C_FLAG((termios), PARENB)
+#define C_PARODD(termios)	_C_FLAG((termios), PARODD)
+#define C_HUPCL(termios)	_C_FLAG((termios), HUPCL)
+#define C_CLOCAL(termios)	_C_FLAG((termios), CLOCAL)
+#define C_CIBAUD(termios)	_C_FLAG((termios), CIBAUD)
+#define C_CRTSCTS(termios)	_C_FLAG((termios), CRTSCTS)
+#define C_CMSPAR(termios)	_C_FLAG((termios), CMSPAR)
+
+#define L_ISIG(termios)		_L_FLAG((termios), ISIG)
+#define L_ICANON(termios)	_L_FLAG((termios), ICANON)
+#define L_XCASE(termios)	_L_FLAG((termios), XCASE)
+#define L_ECHO(termios)		_L_FLAG((termios), ECHO)
+#define L_ECHOE(termios)	_L_FLAG((termios), ECHOE)
+#define L_ECHOK(termios)	_L_FLAG((termios), ECHOK)
+#define L_ECHONL(termios)	_L_FLAG((termios), ECHONL)
+#define L_NOFLSH(termios)	_L_FLAG((termios), NOFLSH)
+#define L_TOSTOP(termios)	_L_FLAG((termios), TOSTOP)
+#define L_ECHOCTL(termios)	_L_FLAG((termios), ECHOCTL)
+#define L_ECHOPRT(termios)	_L_FLAG((termios), ECHOPRT)
+#define L_ECHOKE(termios)	_L_FLAG((termios), ECHOKE)
+#define L_FLUSHO(termios)	_L_FLAG((termios), FLUSHO)
+#define L_PENDIN(termios)	_L_FLAG((termios), PENDIN)
+#define L_IEXTEN(termios)	_L_FLAG((termios), IEXTEN)
+#define L_EXTPROC(termios)	_L_FLAG((termios), EXTPROC)
 
 struct device;
 struct signal_struct;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 873c4b707d6a..ccfff1c1d278 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -288,14 +288,14 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
 
 	if (filp->f_flags & O_NONBLOCK) {
 		/* nonblock mode is set */
-		if (C_BAUD(tty))
+		if (C_BAUD(&tty->termios))
 			tty_port_raise_dtr_rts(port);
 		tty_port_set_active(port, 1);
 		pr_debug("%s(), O_NONBLOCK requested!\n", __func__);
 		return 0;
 	}
 
-	if (C_CLOCAL(tty)) {
+	if (C_CLOCAL(&tty->termios)) {
 		pr_debug("%s(), doing CLOCAL!\n", __func__);
 		do_clocal = 1;
 	}
@@ -319,7 +319,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
 	spin_unlock_irqrestore(&port->lock, flags);
 
 	while (1) {
-		if (C_BAUD(tty) && tty_port_initialized(port))
+		if (C_BAUD(&tty->termios) && tty_port_initialized(port))
 			tty_port_raise_dtr_rts(port);
 
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -802,11 +802,11 @@ static void ircomm_tty_throttle(struct tty_struct *tty)
 	IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
 	/* Software flow control? */
-	if (I_IXOFF(tty))
-		ircomm_tty_send_xchar(tty, STOP_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		ircomm_tty_send_xchar(tty, STOP_CHAR(&tty->termios));
 
 	/* Hardware flow control? */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		self->settings.dte &= ~IRCOMM_RTS;
 		self->settings.dte |= IRCOMM_DELTA_RTS;
 
@@ -831,11 +831,11 @@ static void ircomm_tty_unthrottle(struct tty_struct *tty)
 	IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
 
 	/* Using software flow control? */
-	if (I_IXOFF(tty))
-		ircomm_tty_send_xchar(tty, START_CHAR(tty));
+	if (I_IXOFF(&tty->termios))
+		ircomm_tty_send_xchar(tty, START_CHAR(&tty->termios));
 
 	/* Using hardware flow control? */
-	if (C_CRTSCTS(tty)) {
+	if (C_CRTSCTS(&tty->termios)) {
 		self->settings.dte |= (IRCOMM_RTS|IRCOMM_DELTA_RTS);
 
 		ircomm_param_request(self, IRCOMM_DTE, TRUE);
diff --git a/net/irda/ircomm/ircomm_tty_ioctl.c b/net/irda/ircomm/ircomm_tty_ioctl.c
index 8f5678cb6263..78349fc346f3 100644
--- a/net/irda/ircomm/ircomm_tty_ioctl.c
+++ b/net/irda/ircomm/ircomm_tty_ioctl.c
@@ -162,13 +162,13 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
 	/* Handle transition away from B0 status */
 	if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
 		self->settings.dte |= IRCOMM_DTR;
-		if (!C_CRTSCTS(tty) || !tty_throttled(tty))
+		if (!C_CRTSCTS(&tty->termios) || !tty_throttled(tty))
 			self->settings.dte |= IRCOMM_RTS;
 		ircomm_param_request(self, IRCOMM_DTE, TRUE);
 	}
 
 	/* Handle turning off CRTSCTS */
-	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty))
+	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios))
 	{
 		tty->hw_stopped = 0;
 		ircomm_tty_start(tty);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/9] tty: move hw_stopped flag to tty_port
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
  2016-09-09 22:37 ` [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped Rob Herring
  2016-09-09 22:37 ` [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-11 21:15   ` One Thousand Gnomes
  2016-09-09 22:37 ` [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags Rob Herring
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

hw_stopped is a property of the tty port rather than the tty, so move it
to tty_port struct and remove another dependency on tty_struct from
drivers.

Converted with coccinelle:

@@
identifier t;
@@
- t->hw_stopped
+ t->port->hw_stopped

@@
expression port;
@@
- port.tty->hw_stopped
+ port.hw_stopped

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/char/pcmcia/synclink_cs.c   | 16 ++++++++--------
 drivers/mmc/card/sdio_uart.c        | 14 +++++++-------
 drivers/staging/fwserial/fwserial.c | 20 +++++++++----------
 drivers/tty/amiserial.c             | 38 ++++++++++++++++++-------------------
 drivers/tty/cyclades.c              | 14 +++++++-------
 drivers/tty/isicom.c                | 14 +++++++-------
 drivers/tty/mxser.c                 | 28 +++++++++++++--------------
 drivers/tty/serial/bfin_uart.c      |  6 +++---
 drivers/tty/synclink.c              | 16 ++++++++--------
 drivers/tty/synclink_gt.c           | 14 +++++++-------
 drivers/tty/synclinkmp.c            | 16 ++++++++--------
 include/linux/tty.h                 |  2 +-
 net/irda/ircomm/ircomm_tty.c        | 20 +++++++++----------
 net/irda/ircomm/ircomm_tty_attach.c |  6 +++---
 net/irda/ircomm/ircomm_tty_ioctl.c  |  2 +-
 15 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 8f5528abc390..39a3748ef6c9 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -987,7 +987,7 @@ static void tx_done(MGSLPC_INFO *info, struct tty_struct *tty)
 	else
 #endif
 	{
-		if (tty && (tty->stopped || tty->hw_stopped)) {
+		if (tty && (tty->stopped || tty->port->hw_stopped)) {
 			tx_stop(info);
 			return;
 		}
@@ -1007,7 +1007,7 @@ static void tx_ready(MGSLPC_INFO *info, struct tty_struct *tty)
 		if (!info->tx_active)
 			return;
 	} else {
-		if (tty && (tty->stopped || tty->hw_stopped)) {
+		if (tty && (tty->stopped || tty->port->hw_stopped)) {
 			tx_stop(info);
 			return;
 		}
@@ -1058,11 +1058,11 @@ static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty)
 	wake_up_interruptible(&info->event_wait_q);
 
 	if (tty && tty_port_cts_enabled(&info->port)) {
-		if (tty->hw_stopped) {
+		if (tty->port->hw_stopped) {
 			if (info->serial_signals & SerialSignal_CTS) {
 				if (debug_level >= DEBUG_LEVEL_ISR)
 					printk("CTS tx start...");
-				tty->hw_stopped = 0;
+				tty->port->hw_stopped = 0;
 				tx_start(info, tty);
 				info->pending_bh |= BH_TRANSMIT;
 				return;
@@ -1071,7 +1071,7 @@ static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty)
 			if (!(info->serial_signals & SerialSignal_CTS)) {
 				if (debug_level >= DEBUG_LEVEL_ISR)
 					printk("CTS tx stop...");
-				tty->hw_stopped = 1;
+				tty->port->hw_stopped = 1;
 				tx_stop(info);
 			}
 		}
@@ -1528,7 +1528,7 @@ static void mgslpc_flush_chars(struct tty_struct *tty)
 		return;
 
 	if (info->tx_count <= 0 || tty->stopped ||
-	    tty->hw_stopped || !info->tx_buf)
+	    tty->port->hw_stopped || !info->tx_buf)
 		return;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -1596,7 +1596,7 @@ static int mgslpc_write(struct tty_struct * tty,
 		ret += c;
 	}
 start:
-	if (info->tx_count && !tty->stopped && !tty->hw_stopped) {
+	if (info->tx_count && !tty->stopped && !tty->port->hw_stopped) {
 		spin_lock_irqsave(&info->lock, flags);
 		if (!info->tx_active)
 			tx_start(info, tty);
@@ -2318,7 +2318,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term
 
 	/* Handle turning off CRTSCTS */
 	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		tx_release(tty);
 	}
 }
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index 4a6decfcad03..d6d6a2e345ea 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -445,7 +445,7 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
 	tty = tty_port_tty_get(&port->port);
 
 	if (tty == NULL || !kfifo_len(xmit) ||
-				tty->stopped || tty->hw_stopped) {
+				tty->stopped || tty->port->hw_stopped) {
 		sdio_uart_stop_tx(port);
 		tty_kref_put(tty);
 		return;
@@ -495,15 +495,15 @@ static void sdio_uart_check_modem_status(struct sdio_uart_port *port)
 		tty = tty_port_tty_get(&port->port);
 		if (tty && C_CRTSCTS(&tty->termios)) {
 			int cts = (status & UART_MSR_CTS);
-			if (tty->hw_stopped) {
+			if (tty->port->hw_stopped) {
 				if (cts) {
-					tty->hw_stopped = 0;
+					tty->port->hw_stopped = 0;
 					sdio_uart_start_tx(port);
 					tty_wakeup(tty);
 				}
 			} else {
 				if (!cts) {
-					tty->hw_stopped = 1;
+					tty->port->hw_stopped = 1;
 					sdio_uart_stop_tx(port);
 				}
 			}
@@ -653,7 +653,7 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty)
 
 	if (C_CRTSCTS(&tty->termios))
 		if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS))
-			tty->hw_stopped = 1;
+			tty->port->hw_stopped = 1;
 
 	clear_bit(TTY_IO_ERROR, &tty->flags);
 
@@ -902,14 +902,14 @@ static void sdio_uart_set_termios(struct tty_struct *tty,
 
 	/* Handle turning off CRTSCTS */
 	if ((old_termios->c_cflag & CRTSCTS) && !(cflag & CRTSCTS)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		sdio_uart_start_tx(port);
 	}
 
 	/* Handle turning on CRTSCTS */
 	if (!(old_termios->c_cflag & CRTSCTS) && (cflag & CRTSCTS)) {
 		if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS)) {
-			tty->hw_stopped = 1;
+			tty->port->hw_stopped = 1;
 			sdio_uart_stop_tx(port);
 		}
 	}
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index e391344d227c..0dfdc9dc9672 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -340,9 +340,9 @@ static void fwtty_update_port_status(struct fwtty_port *port,
 	if (delta & TIOCM_CTS) {
 		tty = tty_port_tty_get(&port->port);
 		if (tty && C_CRTSCTS(&tty->termios)) {
-			if (tty->hw_stopped) {
+			if (tty->port->hw_stopped) {
 				if (status & TIOCM_CTS) {
-					tty->hw_stopped = 0;
+					tty->port->hw_stopped = 0;
 					if (port->loopback)
 						__fwtty_restart_tx(port);
 					else
@@ -350,7 +350,7 @@ static void fwtty_update_port_status(struct fwtty_port *port,
 				}
 			} else {
 				if (~status & TIOCM_CTS)
-					tty->hw_stopped = 1;
+					tty->port->hw_stopped = 1;
 			}
 		}
 		tty_kref_put(tty);
@@ -358,9 +358,9 @@ static void fwtty_update_port_status(struct fwtty_port *port,
 	} else if (delta & OOB_TX_THROTTLE) {
 		tty = tty_port_tty_get(&port->port);
 		if (tty) {
-			if (tty->hw_stopped) {
+			if (tty->port->hw_stopped) {
 				if (~status & OOB_TX_THROTTLE) {
-					tty->hw_stopped = 0;
+					tty->port->hw_stopped = 0;
 					if (port->loopback)
 						__fwtty_restart_tx(port);
 					else
@@ -368,7 +368,7 @@ static void fwtty_update_port_status(struct fwtty_port *port,
 				}
 			} else {
 				if (status & OOB_TX_THROTTLE)
-					tty->hw_stopped = 1;
+					tty->port->hw_stopped = 1;
 			}
 		}
 		tty_kref_put(tty);
@@ -735,7 +735,7 @@ static int fwtty_tx(struct fwtty_port *port, bool drain)
 
 	/* try to write as many dma transactions out as possible */
 	n = -EAGAIN;
-	while (!tty->stopped && !tty->hw_stopped &&
+	while (!tty->stopped && !tty->port->hw_stopped &&
 	       !test_bit(STOP_TX, &port->flags)) {
 		txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC);
 		if (!txn) {
@@ -1014,7 +1014,7 @@ static int fwtty_port_activate(struct tty_port *tty_port,
 	}
 
 	if (C_CRTSCTS(&tty->termios) && ~port->mstatus & TIOCM_CTS)
-		tty->hw_stopped = 1;
+		tty->port->hw_stopped = 1;
 
 	__fwtty_write_port_status(port);
 	spin_unlock_bh(&port->lock);
@@ -1316,11 +1316,11 @@ static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old)
 
 	if (old->c_cflag & CRTSCTS) {
 		if (!C_CRTSCTS(&tty->termios)) {
-			tty->hw_stopped = 0;
+			tty->port->hw_stopped = 0;
 			fwtty_restart_tx(port);
 		}
 	} else if (C_CRTSCTS(&tty->termios) && ~port->mstatus & TIOCM_CTS) {
-		tty->hw_stopped = 1;
+		tty->port->hw_stopped = 1;
 	}
 }
 
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 16483a6cc347..be6d59b910f8 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -16,7 +16,7 @@
  * Richard Lucock 28/12/99
  *
  *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 
+ *  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997,
  * 		1998, 1999  Theodore Ts'o
  *
  */
@@ -237,7 +237,7 @@ static void rs_start(struct tty_struct *tty)
  * rs_interrupt() should try to keep the interrupt handler as fast as
  * possible.  After you are done making modifications, it is not a bad
  * idea to do:
- * 
+ *
  * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
  *
  * and look at the resulting assemble code in serial.s.
@@ -347,7 +347,7 @@ static void transmit_chars(struct serial_state *info)
 	}
 	if (info->xmit.head == info->xmit.tail
 	    || info->tport.tty->stopped
-	    || info->tport.tty->hw_stopped) {
+	    || info->tport.hw_stopped) {
 		info->IER &= ~UART_IER_THRI;
 	        custom.intena = IF_TBE;
 		mb();
@@ -414,12 +414,12 @@ static void check_modem_status(struct serial_state *info)
 		}
 	}
 	if (tty_port_cts_enabled(port)) {
-		if (port->tty->hw_stopped) {
+		if (port->hw_stopped) {
 			if (!(status & SER_CTS)) {
 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
 				printk("CTS tx start...");
 #endif
-				port->tty->hw_stopped = 0;
+				port->hw_stopped = 0;
 				info->IER |= UART_IER_THRI;
 				custom.intena = IF_SETCLR | IF_TBE;
 				mb();
@@ -434,7 +434,7 @@ static void check_modem_status(struct serial_state *info)
 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
 				printk("CTS tx stop...");
 #endif
-				port->tty->hw_stopped = 1;
+				port->hw_stopped = 1;
 				info->IER &= ~UART_IER_THRI;
 				/* disable Tx interrupt and remove any pending interrupts */
 				custom.intena = IF_TBE;
@@ -756,7 +756,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
 	if (I_IGNBRK(&tty->termios)) {
 		info->ignore_status_mask |= UART_LSR_BI;
 		/*
-		 * If we're ignore parity and break indicators, ignore 
+		 * If we're ignore parity and break indicators, ignore
 		 * overruns too.  (For real raw support).
 		 */
 		if (I_IGNPAR(&tty->termios))
@@ -824,7 +824,7 @@ static void rs_flush_chars(struct tty_struct *tty)
 
 	if (info->xmit.head == info->xmit.tail
 	    || tty->stopped
-	    || tty->hw_stopped
+	    || tty->port->hw_stopped
 	    || !info->xmit.buf)
 		return;
 
@@ -871,7 +871,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
 
 	if (info->xmit.head != info->xmit.tail
 	    && !tty->stopped
-	    && !tty->hw_stopped
+	    && !tty->port->hw_stopped
 	    && !(info->IER & UART_IER_THRI)) {
 		info->IER |= UART_IER_THRI;
 		local_irq_disable();
@@ -950,7 +950,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
 /*
  * ------------------------------------------------------------
  * rs_throttle()
- * 
+ *
  * This routine is called by the upper-layer tty layer to signal that
  * incoming characters should be throttled.
  * ------------------------------------------------------------
@@ -1011,7 +1011,7 @@ static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
 			   struct serial_struct __user * retinfo)
 {
 	struct serial_struct tmp;
-   
+
 	if (!retinfo)
 		return -EFAULT;
 	memset(&tmp, 0, sizeof(tmp));
@@ -1049,7 +1049,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
 		tty_unlock(tty);
 		return -EINVAL;
 	}
-  
+
 	if (!serial_isroot()) {
 		if ((new_serial.baud_base != state->baud_base) ||
 		    (new_serial.close_delay != port->close_delay) ||
@@ -1111,7 +1111,7 @@ check_and_exit:
  * 	    release the bus after transmitting. This must be done when
  * 	    the transmit shift register is empty, not be done when the
  * 	    transmit holding register is empty.  This functionality
- * 	    allows an RS485 driver to be written in user space. 
+ * 	    allows an RS485 driver to be written in user space.
  */
 static int get_lsr_info(struct serial_state *info, unsigned int __user *value)
 {
@@ -1283,7 +1283,7 @@ static int rs_ioctl(struct tty_struct *tty,
 				local_irq_save(flags);
 				cnow = info->icount; /* atomic copy */
 				local_irq_restore(flags);
-				if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 
+				if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
 				    cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
 					ret = -EIO; /* no change => error */
 					break;
@@ -1346,7 +1346,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 
 	/* Handle turning off CRTSCTS */
 	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		rs_start(tty);
 	}
 
@@ -1365,7 +1365,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 /*
  * ------------------------------------------------------------
  * rs_close()
- * 
+ *
  * This routine is called when the serial port gets closed.  First, we
  * wait for the last remaining data to be sent.  Then, we unlink its
  * async structure from the interrupt chain if necessary, and we free
@@ -1407,7 +1407,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	}
 	shutdown(tty, state);
 	rs_flush_buffer(tty);
-		
+
 	tty_ldisc_flush(tty);
 	port->tty = NULL;
 
@@ -1435,7 +1435,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
 	 * Set the check interval to be 1/5 of the estimated time to
 	 * send a single character, and make it at least 1.  The check
 	 * interval should also be less than the timeout.
-	 * 
+	 *
 	 * Note: we have to use pretty tight timings here to satisfy
 	 * the NIST-PCTS.
 	 */
@@ -1699,7 +1699,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 	state = rs_table;
 	state->port = (int)&custom.serdatr; /* Just to give it a value */
 	state->custom_divisor = 0;
-	state->icount.cts = state->icount.dsr = 
+	state->icount.cts = state->icount.dsr =
 	  state->icount.rng = state->icount.dcd = 0;
 	state->icount.rx = state->icount.tx = 0;
 	state->icount.frame = state->icount.parity = 0;
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 2d165282f483..07f92c04cd6d 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -633,7 +633,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
 				cyy_readb(info, CySRER) & ~CyTxRdy);
 			goto done;
 		}
-		if (tty->stopped || tty->hw_stopped) {
+		if (tty->stopped || tty->port->hw_stopped) {
 			cyy_writeb(info, CySRER,
 				cyy_readb(info, CySRER) & ~CyTxRdy);
 			goto done;
@@ -719,11 +719,11 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
 			tty_hangup(tty);
 	}
 	if ((mdm_change & CyCTS) && tty_port_cts_enabled(&info->port)) {
-		if (tty->hw_stopped) {
+		if (tty->port->hw_stopped) {
 			if (mdm_status & CyCTS) {
 				/* cy_start isn't used
 				   because... !!! */
-				tty->hw_stopped = 0;
+				tty->port->hw_stopped = 0;
 				cyy_writeb(info, CySRER,
 					cyy_readb(info, CySRER) | CyTxRdy);
 				tty_wakeup(tty);
@@ -732,7 +732,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
 			if (!(mdm_status & CyCTS)) {
 				/* cy_stop isn't used
 				   because ... !!! */
-				tty->hw_stopped = 1;
+				tty->port->hw_stopped = 1;
 				cyy_writeb(info, CySRER,
 					cyy_readb(info, CySRER) & ~CyTxRdy);
 			}
@@ -1800,7 +1800,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
 	info->idle_stats.xmit_bytes += ret;
 	info->idle_stats.xmit_idle = jiffies;
 
-	if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped)
+	if (info->xmit_cnt && !tty->stopped && !tty->port->hw_stopped)
 		start_xmit(info);
 
 	return ret;
@@ -1858,7 +1858,7 @@ static void cy_flush_chars(struct tty_struct *tty)
 	if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
 		return;
 
-	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
+	if (info->xmit_cnt <= 0 || tty->stopped || tty->port->hw_stopped ||
 			!info->port.xmit_buf)
 		return;
 
@@ -2785,7 +2785,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	cy_set_line_char(info, tty);
 
 	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		cy_start(tty);
 	}
 #if 0
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 2478aa559834..240c766b4a04 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -443,7 +443,7 @@ static void isicom_tx(unsigned long _data)
 			continue;
 
 		txcount = min_t(short, TX_SIZE, port->xmit_cnt);
-		if (txcount <= 0 || tty->stopped || tty->hw_stopped)
+		if (txcount <= 0 || tty->stopped || tty->port->hw_stopped)
 			continue;
 
 		if (!(inw(base + 0x02) & (1 << port->channel)))
@@ -601,16 +601,16 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 			}
 
 			if (tty_port_cts_enabled(&port->port)) {
-				if (tty->hw_stopped) {
+				if (tty->port->hw_stopped) {
 					if (header & ISI_CTS) {
-						tty->hw_stopped = 0;
+						tty->port->hw_stopped = 0;
 						/* start tx ing */
 						port->status |= (ISI_TXOK
 							| ISI_CTS);
 						tty_wakeup(tty);
 					}
 				} else if (!(header & ISI_CTS)) {
-					tty->hw_stopped = 1;
+					tty->port->hw_stopped = 1;
 					/* stop tx ing */
 					port->status &= ~(ISI_TXOK | ISI_CTS);
 				}
@@ -966,7 +966,7 @@ static int isicom_write(struct tty_struct *tty,	const unsigned char *buf,
 		count -= cnt;
 		total += cnt;
 	}
-	if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped)
+	if (port->xmit_cnt && !tty->stopped && !tty->port->hw_stopped)
 		port->status |= ISI_TXOK;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 	return total;
@@ -1003,7 +1003,7 @@ static void isicom_flush_chars(struct tty_struct *tty)
 	if (isicom_paranoia_check(port, tty->name, "isicom_flush_chars"))
 		return;
 
-	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
+	if (port->xmit_cnt <= 0 || tty->stopped || tty->port->hw_stopped ||
 			!port->port.xmit_buf)
 		return;
 
@@ -1201,7 +1201,7 @@ static void isicom_set_termios(struct tty_struct *tty,
 	spin_unlock_irqrestore(&port->card->card_lock, flags);
 
 	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		isicom_start(tty);
 	}
 }
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 1a5fb2887b0e..72ae8a990a79 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -718,9 +718,9 @@ static int mxser_change_speed(struct tty_struct *tty,
 			info->MCR |= UART_MCR_AFE;
 		} else {
 			status = inb(info->ioaddr + UART_MSR);
-			if (tty->hw_stopped) {
+			if (tty->port->hw_stopped) {
 				if (status & UART_MSR_CTS) {
-					tty->hw_stopped = 0;
+					tty->port->hw_stopped = 0;
 					if (info->type != PORT_16550A &&
 							!info->board->chip_flag) {
 						outb(info->IER & ~UART_IER_THRI,
@@ -734,7 +734,7 @@ static int mxser_change_speed(struct tty_struct *tty,
 				}
 			} else {
 				if (!(status & UART_MSR_CTS)) {
-					tty->hw_stopped = 1;
+					tty->port->hw_stopped = 1;
 					if ((info->type != PORT_16550A) &&
 							(!info->board->chip_flag)) {
 						info->IER &= ~UART_IER_THRI;
@@ -829,9 +829,9 @@ static void mxser_check_modem_status(struct tty_struct *tty,
 	}
 
 	if (tty_port_cts_enabled(&port->port)) {
-		if (tty->hw_stopped) {
+		if (tty->port->hw_stopped) {
 			if (status & UART_MSR_CTS) {
-				tty->hw_stopped = 0;
+				tty->port->hw_stopped = 0;
 
 				if ((port->type != PORT_16550A) &&
 						(!port->board->chip_flag)) {
@@ -845,7 +845,7 @@ static void mxser_check_modem_status(struct tty_struct *tty,
 			}
 		} else {
 			if (!(status & UART_MSR_CTS)) {
-				tty->hw_stopped = 1;
+				tty->port->hw_stopped = 1;
 				if (port->type != PORT_16550A &&
 						!port->board->chip_flag) {
 					port->IER &= ~UART_IER_THRI;
@@ -1123,7 +1123,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
 	}
 
 	if (info->xmit_cnt && !tty->stopped) {
-		if (!tty->hw_stopped ||
+		if (!tty->port->hw_stopped ||
 				(info->type == PORT_16550A) ||
 				(info->board->chip_flag)) {
 			spin_lock_irqsave(&info->slock, flags);
@@ -1154,7 +1154,7 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
 	info->xmit_cnt++;
 	spin_unlock_irqrestore(&info->slock, flags);
 	if (!tty->stopped) {
-		if (!tty->hw_stopped ||
+		if (!tty->port->hw_stopped ||
 				(info->type == PORT_16550A) ||
 				info->board->chip_flag) {
 			spin_lock_irqsave(&info->slock, flags);
@@ -1174,7 +1174,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
 	unsigned long flags;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || !info->port.xmit_buf ||
-			(tty->hw_stopped && info->type != PORT_16550A &&
+			(tty->port->hw_stopped && info->type != PORT_16550A &&
 			 !info->board->chip_flag))
 		return;
 
@@ -1778,7 +1778,7 @@ static int mxser_ioctl(struct tty_struct *tty,
 		else
 			info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT;
 
-		if (tty->hw_stopped)
+		if (tty->port->hw_stopped)
 			info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
 		else
 			info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
@@ -1946,7 +1946,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
 	spin_unlock_irqrestore(&info->slock, flags);
 
 	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		mxser_start(tty);
 	}
 
@@ -2172,9 +2172,9 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 		return;
 
 	if (port->xmit_cnt <= 0 || tty->stopped ||
-			(tty->hw_stopped &&
-			(port->type != PORT_16550A) &&
-			(!port->board->chip_flag))) {
+			(tty->port->hw_stopped &&
+			 (port->type != PORT_16550A) &&
+			 (!port->board->chip_flag))) {
 		port->IER &= ~UART_IER_THRI;
 		outb(port->IER, port->ioaddr + UART_IER);
 		return;
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 293ecbb00684..fc24c9ec1935 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -113,14 +113,14 @@ static irqreturn_t bfin_serial_mctrl_cts_int(int irq, void *dev_id)
 #ifdef SERIAL_BFIN_HARD_CTSRTS
 
 	UART_CLEAR_SCTS(uart);
-	if (uport->hw_stopped) {
+	if (uport->port->hw_stopped) {
 		if (status) {
-			uport->hw_stopped = 0;
+			uport->port->hw_stopped = 0;
 			uart_write_wakeup(uport);
 		}
 	} else {
 		if (!status)
-			uport->hw_stopped = 1;
+			uport->port->hw_stopped = 1;
 	}
 #else
 	uart_handle_cts_change(uport, status & TIOCM_CTS);
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index 712776cf7ab7..57f678c6484e 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -1259,7 +1259,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
 	else 
 #endif
 	{
-		if (info->port.tty->stopped || info->port.tty->hw_stopped) {
+		if (info->port.tty->stopped || info->port.hw_stopped) {
 			usc_stop_transmitter(info);
 			return;
 		}
@@ -1357,11 +1357,11 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
 	
 		if (tty_port_cts_enabled(&info->port) &&
 		     (status & MISCSTATUS_CTS_LATCHED) ) {
-			if (info->port.tty->hw_stopped) {
+			if (info->port.hw_stopped) {
 				if (status & MISCSTATUS_CTS) {
 					if ( debug_level >= DEBUG_LEVEL_ISR )
 						printk("CTS tx start...");
-					info->port.tty->hw_stopped = 0;
+					info->port.hw_stopped = 0;
 					usc_start_transmitter(info);
 					info->pending_bh |= BH_TRANSMIT;
 					return;
@@ -1371,7 +1371,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
 					if ( debug_level >= DEBUG_LEVEL_ISR )
 						printk("CTS tx stop...");
 					if (info->port.tty)
-						info->port.tty->hw_stopped = 1;
+						info->port.hw_stopped = 1;
 					usc_stop_transmitter(info);
 				}
 			}
@@ -1405,7 +1405,7 @@ static void mgsl_isr_transmit_data( struct mgsl_struct *info )
 			
 	usc_ClearIrqPendingBits( info, TRANSMIT_DATA );
 	
-	if (info->port.tty->stopped || info->port.tty->hw_stopped) {
+	if (info->port.tty->stopped || info->port.hw_stopped) {
 		usc_stop_transmitter(info);
 		return;
 	}
@@ -2050,7 +2050,7 @@ static void mgsl_flush_chars(struct tty_struct *tty)
 	if (mgsl_paranoia_check(info, tty->name, "mgsl_flush_chars"))
 		return;
 
-	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
+	if (info->xmit_cnt <= 0 || tty->stopped || tty->port->hw_stopped ||
 	    !info->xmit_buf)
 		return;
 
@@ -2190,7 +2190,7 @@ static int mgsl_write(struct tty_struct * tty,
 		}
 	}	
 	
- 	if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
+ 	if (info->xmit_cnt && !tty->stopped && !tty->port->hw_stopped) {
 		spin_lock_irqsave(&info->irq_spinlock,flags);
 		if (!info->tx_active)
 		 	usc_start_transmitter(info);
@@ -3048,7 +3048,7 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio
 
 	/* Handle turning off CRTSCTS */
 	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		mgsl_start(tty);
 	}
 
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 055fa71bc2fb..7e56d62039e8 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -793,7 +793,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 
 	/* Handle turning off CRTSCTS */
 	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		tx_release(tty);
 	}
 }
@@ -825,7 +825,7 @@ static int write(struct tty_struct *tty,
 	if (!info->tx_buf || (count > info->max_frame_size))
 		return -EIO;
 
-	if (!count || tty->stopped || tty->hw_stopped)
+	if (!count || tty->stopped || tty->port->hw_stopped)
 		return 0;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -947,7 +947,7 @@ static void flush_chars(struct tty_struct *tty)
 	DBGINFO(("%s flush_chars entry tx_count=%d\n", info->device_name, info->tx_count));
 
 	if (info->tx_count <= 0 || tty->stopped ||
-	    tty->hw_stopped || !info->tx_buf)
+	    tty->port->hw_stopped || !info->tx_buf)
 		return;
 
 	DBGINFO(("%s flush_chars start transmit\n", info->device_name));
@@ -2039,15 +2039,15 @@ static void cts_change(struct slgt_info *info, unsigned short status)
 
 	if (tty_port_cts_enabled(&info->port)) {
 		if (info->port.tty) {
-			if (info->port.tty->hw_stopped) {
+			if (info->port.hw_stopped) {
 				if (info->signals & SerialSignal_CTS) {
-		 			info->port.tty->hw_stopped = 0;
+		 			info->port.hw_stopped = 0;
 					info->pending_bh |= BH_TRANSMIT;
 					return;
 				}
 			} else {
 				if (!(info->signals & SerialSignal_CTS))
-		 			info->port.tty->hw_stopped = 1;
+		 			info->port.hw_stopped = 1;
 			}
 		}
 	}
@@ -2323,7 +2323,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
 		else
 #endif
 		{
-			if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
+			if (info->port.tty && (info->port.tty->stopped || info->port.hw_stopped)) {
 				tx_stop(info);
 				return;
 			}
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index ffefc5e6d66c..46ab0c9808f7 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -890,7 +890,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 
 	/* Handle turning off CRTSCTS */
 	if (old_termios->c_cflag & CRTSCTS && !C_CRTSCTS(&tty->termios)) {
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		tx_release(tty);
 	}
 }
@@ -969,7 +969,7 @@ static int write(struct tty_struct *tty,
 		tx_load_dma_buffer(info, info->tx_buf, info->tx_count);
 	}
 start:
- 	if (info->tx_count && !tty->stopped && !tty->hw_stopped) {
+ 	if (info->tx_count && !tty->stopped && !tty->port->hw_stopped) {
 		spin_lock_irqsave(&info->lock,flags);
 		if (!info->tx_active)
 		 	tx_start(info);
@@ -1149,7 +1149,7 @@ static void flush_chars(struct tty_struct *tty)
 	if (sanity_check(info, tty->name, "flush_chars"))
 		return;
 
-	if (info->tx_count <= 0 || tty->stopped || tty->hw_stopped ||
+	if (info->tx_count <= 0 || tty->stopped || tty->port->hw_stopped ||
 	    !info->tx_buf)
 		return;
 
@@ -2261,7 +2261,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
 		else
 #endif
 		{
-			if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
+			if (info->port.tty && (info->port.tty->stopped || info->port.hw_stopped)) {
 				tx_stop(info);
 				return;
 			}
@@ -2316,7 +2316,7 @@ static void isr_txrdy(SLMP_INFO * info)
 		return;
 	}
 
-	if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
+	if (info->port.tty && (info->port.tty->stopped || info->port.hw_stopped)) {
 		tx_stop(info);
 		return;
 	}
@@ -2481,11 +2481,11 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
 		if (tty_port_cts_enabled(&info->port) &&
 		     (status & MISCSTATUS_CTS_LATCHED) ) {
 			if ( info->port.tty ) {
-				if (info->port.tty->hw_stopped) {
+				if (info->port.hw_stopped) {
 					if (status & SerialSignal_CTS) {
 						if ( debug_level >= DEBUG_LEVEL_ISR )
 							printk("CTS tx start...");
-			 			info->port.tty->hw_stopped = 0;
+			 			info->port.hw_stopped = 0;
 						tx_start(info);
 						info->pending_bh |= BH_TRANSMIT;
 						return;
@@ -2494,7 +2494,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
 					if (!(status & SerialSignal_CTS)) {
 						if ( debug_level >= DEBUG_LEVEL_ISR )
 							printk("CTS tx stop...");
-			 			info->port.tty->hw_stopped = 1;
+			 			info->port.hw_stopped = 1;
 						tx_stop(info);
 					}
 				}
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 73a8c38987f5..3b0de8ac7ee4 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -228,6 +228,7 @@ struct tty_port {
 	int			count;		/* Usage count */
 	wait_queue_head_t	open_wait;	/* Open waiters */
 	wait_queue_head_t	delta_msr_wait;	/* Modem status change */
+	int hw_stopped;
 	unsigned long		flags;		/* User TTY flags ASYNC_ */
 	unsigned long		iflags;		/* Internal flags TTY_PORT_ */
 	unsigned char		console:1,	/* port is a console */
@@ -300,7 +301,6 @@ struct tty_struct {
 	unsigned long stopped:1,	/* flow_lock */
 		      flow_stopped:1,
 		      unused:BITS_PER_LONG - 2;
-	int hw_stopped;
 	unsigned long ctrl_status:8,	/* ctrl_lock */
 		      packet:1,
 		      unused_ctrl:BITS_PER_LONG - 9;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index ccfff1c1d278..c55dd956d309 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -552,7 +552,7 @@ static void ircomm_tty_do_softint(struct work_struct *work)
 		dev_kfree_skb(ctrl_skb);
 	}
 
-	if (tty->hw_stopped)
+	if (tty->port->hw_stopped)
 		goto put;
 
 	/* Unlink transmit buffer */
@@ -595,7 +595,7 @@ static int ircomm_tty_write(struct tty_struct *tty,
 	int size;
 
 	pr_debug("%s(), count=%d, hw_stopped=%d\n", __func__ , count,
-		 tty->hw_stopped);
+		 tty->port->hw_stopped);
 
 	IRDA_ASSERT(self != NULL, return -1;);
 	IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
@@ -736,7 +736,7 @@ static int ircomm_tty_write_room(struct tty_struct *tty)
 	/* Check if we are allowed to transmit any data.
 	 * hw_stopped is the regular flow control.
 	 * Jean II */
-	if (tty->hw_stopped)
+	if (tty->port->hw_stopped)
 		ret = 0;
 	else {
 		spin_lock_irqsave(&self->spinlock, flags);
@@ -1016,10 +1016,10 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
 		}
 	}
 	if (tty && tty_port_cts_enabled(&self->port)) {
-		if (tty->hw_stopped) {
+		if (tty->port->hw_stopped) {
 			if (status & IRCOMM_CTS) {
 				pr_debug("%s(), CTS tx start...\n", __func__);
-				tty->hw_stopped = 0;
+				tty->port->hw_stopped = 0;
 
 				/* Wake up processes blocked on open */
 				wake_up_interruptible(&self->port.open_wait);
@@ -1030,7 +1030,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
 		} else {
 			if (!(status & IRCOMM_CTS)) {
 				pr_debug("%s(), CTS tx stop...\n", __func__);
-				tty->hw_stopped = 1;
+				tty->port->hw_stopped = 1;
 			}
 		}
 	}
@@ -1066,7 +1066,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
 	 * Devices like WinCE can do this, and since they don't send any
 	 * params, we can just as well declare the hardware for running.
 	 */
-	if (tty->hw_stopped && (self->flow == FLOW_START)) {
+	if (tty->port->hw_stopped && (self->flow == FLOW_START)) {
 		pr_debug("%s(), polling for line settings!\n", __func__);
 		ircomm_param_request(self, IRCOMM_POLL, TRUE);
 
@@ -1136,7 +1136,7 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
 	case FLOW_START:
 		pr_debug("%s(), hw start!\n", __func__);
 		if (tty)
-			tty->hw_stopped = 0;
+			tty->port->hw_stopped = 0;
 
 		/* ircomm_tty_do_softint will take care of the rest */
 		schedule_work(&self->tqueue);
@@ -1145,7 +1145,7 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
 	case FLOW_STOP:
 		pr_debug("%s(), hw stopped!\n", __func__);
 		if (tty)
-			tty->hw_stopped = 1;
+			tty->port->hw_stopped = 1;
 		break;
 	}
 
@@ -1282,7 +1282,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
 	tty = tty_port_tty_get(&self->port);
 	if (tty) {
 		seq_printf(m, "Hardware: %s\n",
-			       tty->hw_stopped ? "Stopped" : "Running");
+			       tty->port->hw_stopped ? "Stopped" : "Running");
 		tty_kref_put(tty);
 	}
 }
diff --git a/net/irda/ircomm/ircomm_tty_attach.c b/net/irda/ircomm/ircomm_tty_attach.c
index 0a411019c098..36a3ec31bb71 100644
--- a/net/irda/ircomm/ircomm_tty_attach.c
+++ b/net/irda/ircomm/ircomm_tty_attach.c
@@ -140,7 +140,7 @@ int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
 	/* Make sure nobody tries to write before the link is up */
 	tty = tty_port_tty_get(&self->port);
 	if (tty) {
-		tty->hw_stopped = 1;
+		tty->port->hw_stopped = 1;
 		tty_kref_put(tty);
 	}
 
@@ -405,7 +405,7 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
 	self->flow = FLOW_STOP;
 
 	/* Stop data transfers */
-	tty->hw_stopped = 1;
+	tty->port->hw_stopped = 1;
 
 	ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL,
 			    NULL);
@@ -563,7 +563,7 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
 	} else {
 		pr_debug("%s(), starting hardware!\n", __func__);
 
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 
 		/* Wake up processes blocked on open */
 		wake_up_interruptible(&self->port.open_wait);
diff --git a/net/irda/ircomm/ircomm_tty_ioctl.c b/net/irda/ircomm/ircomm_tty_ioctl.c
index 78349fc346f3..25e143c95caa 100644
--- a/net/irda/ircomm/ircomm_tty_ioctl.c
+++ b/net/irda/ircomm/ircomm_tty_ioctl.c
@@ -170,7 +170,7 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
 	/* Handle turning off CRTSCTS */
 	if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(&tty->termios))
 	{
-		tty->hw_stopped = 0;
+		tty->port->hw_stopped = 0;
 		ircomm_tty_start(tty);
 	}
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (2 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 3/9] tty: move hw_stopped flag to tty_port Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-11 21:18   ` One Thousand Gnomes
  2016-09-09 22:37 ` [PATCH 5/9] tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup Rob Herring
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

TTY_IO_ERROR is a property of the tty port rather than the tty, so move
it to tty_port struct and remove another dependency on tty_struct from
drivers.

Partially converted with coccinelle:

@@
identifier t;
identifier func;
@@
- func(TTY_IO_ERROR, &t->flags)
+ func(TTY_PORT_IO_ERROR, &t->port->iflags)

@@
expression port;
identifier func;
@@
- func(TTY_IO_ERROR, &port.tty->flags)
+ func(TTY_PORT_IO_ERROR, &port.iflags)

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/char/pcmcia/synclink_cs.c   |  6 +++---
 drivers/isdn/i4l/isdn_tty.c         |  4 ++--
 drivers/mmc/card/sdio_uart.c        |  4 ++--
 drivers/staging/fwserial/fwserial.c |  4 ++--
 drivers/tty/amiserial.c             |  6 +++---
 drivers/tty/cyclades.c              | 12 ++++++------
 drivers/tty/mxser.c                 |  6 +++---
 drivers/tty/pty.c                   |  6 +++---
 drivers/tty/serial/crisv10.c        |  4 ++--
 drivers/tty/serial/ioc4_serial.c    |  2 +-
 drivers/tty/serial/serial_core.c    |  5 ++---
 drivers/tty/synclink.c              |  6 +++---
 drivers/tty/synclink_gt.c           |  4 ++--
 drivers/tty/synclinkmp.c            |  4 ++--
 drivers/tty/tty_port.c              |  6 +++---
 include/linux/tty.h                 |  5 +++--
 net/bluetooth/rfcomm/tty.c          |  2 +-
 net/irda/ircomm/ircomm_tty.c        |  2 +-
 18 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 39a3748ef6c9..86ff86712ee7 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -1300,7 +1300,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty)
 
 	if (retval) {
 		if (capable(CAP_SYS_ADMIN) && tty)
-			set_bit(TTY_IO_ERROR, &tty->flags);
+			set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		release_resources(info);
 		return retval;
 	}
@@ -1309,7 +1309,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty)
 	mgslpc_change_params(info, tty);
 
 	if (tty)
-		clear_bit(TTY_IO_ERROR, &tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	tty_port_set_initialized(&info->port, 1);
 
@@ -1359,7 +1359,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty)
 	release_resources(info);
 
 	if (tty)
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	tty_port_set_initialized(&info->port, 0);
 }
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index ca5ea73a3fc9..76bb852c3dc9 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1060,7 +1060,7 @@ isdn_tty_startup(modem_info *info)
 	 */
 	info->mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
 	if (info->port.tty)
-		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 	/*
 	 * and set the speed of the serial port
 	 */
@@ -1097,7 +1097,7 @@ isdn_tty_shutdown(modem_info *info)
 		}
 	}
 	if (info->port.tty)
-		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 0);
 }
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index d6d6a2e345ea..fa99cd32999f 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -607,7 +607,7 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty)
 	 * Set the TTY IO error marker - we will only clear this
 	 * once we have successfully opened the port.
 	 */
-	set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	kfifo_reset(&port->xmit_fifo);
 
@@ -655,7 +655,7 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty)
 		if (!(sdio_uart_get_mctrl(port) & TIOCM_CTS))
 			tty->port->hw_stopped = 1;
 
-	clear_bit(TTY_IO_ERROR, &tty->flags);
+	clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	/* Kick the IRQ handler once while we're still holding the host lock */
 	sdio_uart_irq(port->func);
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index 0dfdc9dc9672..aff79647fd0e 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -992,7 +992,7 @@ static int fwtty_port_activate(struct tty_port *tty_port,
 	unsigned int baud;
 	int err;
 
-	set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	err = dma_fifo_alloc(&port->tx_fifo, FWTTY_PORT_TXFIFO_LEN,
 			     cache_line_size(),
@@ -1019,7 +1019,7 @@ static int fwtty_port_activate(struct tty_port *tty_port,
 	__fwtty_write_port_status(port);
 	spin_unlock_bh(&port->lock);
 
-	clear_bit(TTY_IO_ERROR, &tty->flags);
+	clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	return 0;
 }
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index be6d59b910f8..7b2e44bb85f6 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -547,7 +547,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
 	retval = request_irq(IRQ_AMIGA_VERTB, ser_vbl_int, 0, "serial status", info);
 	if (retval) {
 	  if (serial_isroot()) {
-	      set_bit(TTY_IO_ERROR, &tty->flags);
+	      set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	    retval = 0;
 	  }
 	  goto errout;
@@ -566,7 +566,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
 	  info->MCR = SER_DTR | SER_RTS;
 	rtsdtr_ctrl(info->MCR);
 
-	clear_bit(TTY_IO_ERROR, &tty->flags);
+	clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	info->xmit.head = info->xmit.tail = 0;
 
 	/*
@@ -643,7 +643,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
 		info->MCR &= ~(SER_DTR|SER_RTS);
 	rtsdtr_ctrl(info->MCR);
 
-	set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 
 	tty_port_set_initialized(&info->tport, 0);
 	local_irq_restore(flags);
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 07f92c04cd6d..14370d97d199 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -1281,7 +1281,7 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
 		goto errout;
 
 	if (!info->type) {
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		goto errout;
 	}
 
@@ -1364,7 +1364,7 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
 
 	tty_port_set_initialized(&info->port, 1);
 
-	clear_bit(TTY_IO_ERROR, &tty->flags);
+	clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 	info->breakon = info->breakoff = 0;
 	memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -1445,7 +1445,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
 		/* it may be appropriate to clear _XMIT at
 		   some later date (after testing)!!! */
 
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		tty_port_set_initialized(&info->port, 0);
 		spin_unlock_irqrestore(&card->card_lock, flags);
 	} else {
@@ -1470,7 +1470,7 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
 		if (C_HUPCL(&tty->termios))
 			tty_port_lower_dtr_rts(&info->port);
 
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		tty_port_set_initialized(&info->port, 0);
 
 		spin_unlock_irqrestore(&card->card_lock, flags);
@@ -2147,7 +2147,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
 		else
 			cyy_change_rts_dtr(info, TIOCM_DTR, 0);
 
-		clear_bit(TTY_IO_ERROR, &tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		spin_unlock_irqrestore(&card->card_lock, flags);
 
 	} else {
@@ -2267,7 +2267,7 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
 				"was %x\n", info->line, retval);
 		}
 
-		clear_bit(TTY_IO_ERROR, &tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	}
 }				/* set_line_char */
 
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 72ae8a990a79..ec3a6ecc4b58 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -870,7 +870,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 	spin_lock_irqsave(&info->slock, flags);
 
 	if (!info->ioaddr || !info->type) {
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		free_page(page);
 		spin_unlock_irqrestore(&info->slock, flags);
 		return 0;
@@ -897,7 +897,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 	if (inb(info->ioaddr + UART_LSR) == 0xff) {
 		spin_unlock_irqrestore(&info->slock, flags);
 		if (capable(CAP_SYS_ADMIN)) {
-			set_bit(TTY_IO_ERROR, &tty->flags);
+			set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 			return 0;
 		} else
 			return -ENODEV;
@@ -935,7 +935,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 	(void) inb(info->ioaddr + UART_IIR);
 	(void) inb(info->ioaddr + UART_MSR);
 
-	clear_bit(TTY_IO_ERROR, &tty->flags);
+	clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 
 	/*
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 7c51ff7f9030..e77579e0e3c5 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -49,7 +49,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
 		if (tty->count > 2)
 			return;
 	}
-	set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	wake_up_interruptible(&tty->read_wait);
 	wake_up_interruptible(&tty->write_wait);
 	spin_lock_irq(&tty->ctrl_lock);
@@ -246,13 +246,13 @@ static int pty_open(struct tty_struct *tty, struct file *filp)
 	if (tty->driver->subtype == PTY_TYPE_SLAVE && tty->link->count != 1)
 		goto out;
 
-	clear_bit(TTY_IO_ERROR, &tty->flags);
+	clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
 	set_bit(TTY_THROTTLED, &tty->flags);
 	return 0;
 
 out:
-	set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	return -EIO;
 }
 
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index a45dc9d27b87..906ca2621f6a 100644
--- a/drivers/tty/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
@@ -2659,7 +2659,7 @@ startup(struct e100_serial * info)
 	}
 
 	if (info->port.tty)
-		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	info->xmit.head = info->xmit.tail = 0;
 	info->first_recv_buffer = info->last_recv_buffer = NULL;
@@ -2775,7 +2775,7 @@ shutdown(struct e100_serial * info)
 	}
 
 	if (info->port.tty)
-		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 0);
 	local_irq_restore(flags);
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index e5c42fef69d2..284639e2cea6 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -2442,7 +2442,7 @@ static void ic4_shutdown(struct uart_port *the_port)
 	wake_up_interruptible(&state->port.delta_msr_wait);
 
 	if (state->port.tty)
-		set_bit(TTY_IO_ERROR, &state->port.tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &state->port.iflags);
 
 	spin_lock_irqsave(&the_port->lock, port_flags);
 	set_notification(port, N_ALL, 0);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 73b7a7ae7862..70aea76dbfb7 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -237,7 +237,7 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state,
 
 	retval = uart_port_startup(tty, state, init_hw);
 	if (retval)
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &port->iflags);
 
 	return retval;
 }
@@ -257,8 +257,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 	/*
 	 * Set the TTY IO error marker
 	 */
-	if (tty)
-		set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &port->iflags);
 
 	if (tty_port_initialized(port)) {
 		tty_port_set_initialized(port, 0);
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index 57f678c6484e..48e63dd15595 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -1780,7 +1780,7 @@ static int startup(struct mgsl_struct * info)
 		
 	if ( retval ) {
   		if (capable(CAP_SYS_ADMIN) && info->port.tty)
-			set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+			set_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 		mgsl_release_resources(info);
   		return retval;
   	}
@@ -1789,7 +1789,7 @@ static int startup(struct mgsl_struct * info)
 	mgsl_change_params(info);
 
 	if (info->port.tty)
-		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 1);
 
@@ -1854,7 +1854,7 @@ static void shutdown(struct mgsl_struct * info)
 	mgsl_release_resources(info);
 
 	if (info->port.tty)
-		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 0);
 }	/* end of shutdown() */
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 7e56d62039e8..314a8cd897ff 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -2440,7 +2440,7 @@ static int startup(struct slgt_info *info)
 	change_params(info);
 
 	if (info->port.tty)
-		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 1);
 
@@ -2487,7 +2487,7 @@ static void shutdown(struct slgt_info *info)
 	spin_unlock_irqrestore(&info->lock,flags);
 
 	if (info->port.tty)
-		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 0);
 }
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index 46ab0c9808f7..1cfa66178487 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -2660,7 +2660,7 @@ static int startup(SLMP_INFO * info)
 	mod_timer(&info->status_timer, jiffies + msecs_to_jiffies(10));
 
 	if (info->port.tty)
-		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 1);
 
@@ -2703,7 +2703,7 @@ static void shutdown(SLMP_INFO * info)
 	spin_unlock_irqrestore(&info->lock,flags);
 
 	if (info->port.tty)
-		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &info->port.iflags);
 
 	tty_port_set_initialized(&info->port, 0);
 }
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 5ad4bda512e2..5f7a41547901 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -239,7 +239,7 @@ void tty_port_hangup(struct tty_port *port)
 	port->count = 0;
 	tty = port->tty;
 	if (tty)
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	port->tty = NULL;
 	spin_unlock_irqrestore(&port->lock, flags);
 	tty_port_set_active(port, 0);
@@ -531,7 +531,7 @@ void tty_port_close(struct tty_port *port, struct tty_struct *tty,
 	if (tty_port_close_start(port, tty, filp) == 0)
 		return;
 	tty_port_shutdown(port, tty);
-	set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	tty_port_close_end(port, tty);
 	tty_port_tty_set(port, NULL);
 }
@@ -580,7 +580,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
 	mutex_lock(&port->mutex);
 
 	if (!tty_port_initialized(port)) {
-		clear_bit(TTY_IO_ERROR, &tty->flags);
+		clear_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 		if (port->ops->activate) {
 			int retval = port->ops->activate(port, tty);
 			if (retval) {
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 3b0de8ac7ee4..524df94ed437 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -256,6 +256,8 @@ struct tty_port {
 #define TTY_PORT_CTS_FLOW	3	/* h/w flow control enabled */
 #define TTY_PORT_CHECK_CD	4	/* carrier detect enabled */
 
+#define TTY_PORT_IO_ERROR	3	/* device has I/O error */
+
 /*
  * Where all of the state associated with a tty is kept while the tty
  * is open.  Since the termios state should be kept even if the tty
@@ -347,7 +349,6 @@ struct tty_file_private {
  * clear_bit() to make things atomic.
  */
 #define TTY_THROTTLED 		0	/* Call unthrottle() at threshold min */
-#define TTY_IO_ERROR 		1	/* Cause an I/O error (may be no ldisc too) */
 #define TTY_OTHER_CLOSED 	2	/* Other side (if any) has closed */
 #define TTY_EXCLUSIVE 		3	/* Exclusive open mode */
 #define TTY_DO_WRITE_WAKEUP 	5	/* Call write_wakeup after queuing new */
@@ -374,7 +375,7 @@ static inline void tty_set_flow_change(struct tty_struct *tty, int val)
 
 static inline bool tty_io_error(struct tty_struct *tty)
 {
-	return test_bit(TTY_IO_ERROR, &tty->flags);
+	return test_bit(TTY_PORT_IO_ERROR, &tty->port->flags);
 }
 
 static inline bool tty_throttled(struct tty_struct *tty)
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 8e385a0ae60e..dfb177f1d5ae 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -115,7 +115,7 @@ static int rfcomm_dev_activate(struct tty_port *port, struct tty_struct *tty)
 
 	err = rfcomm_dlc_open(dev->dlc, &dev->src, &dev->dst, dev->channel);
 	if (err)
-		set_bit(TTY_IO_ERROR, &tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &tty->port->iflags);
 	return err;
 }
 
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index c55dd956d309..3ee3b75f6d22 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -927,7 +927,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
 
 	spin_lock_irqsave(&port->lock, flags);
 	if (port->tty) {
-		set_bit(TTY_IO_ERROR, &port->tty->flags);
+		set_bit(TTY_PORT_IO_ERROR, &port->iflags);
 		tty_kref_put(port->tty);
 	}
 	port->tty = NULL;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 5/9] tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (3 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-09 22:37 ` [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state Rob Herring
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

In preparation to use a tty_port without a tty, call the tty_port helper
tty_port_tty_wakeup instead of tty_wakeup directly.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/tty/serial/serial_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 70aea76dbfb7..d48ea0a98e92 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -111,7 +111,7 @@ void uart_write_wakeup(struct uart_port *port)
 	 * closed.  No cookie for you.
 	 */
 	BUG_ON(!state);
-	tty_wakeup(state->port.tty);
+	tty_port_tty_wakeup(&state->port);
 }
 
 static void uart_stop(struct tty_struct *tty)
@@ -631,7 +631,7 @@ static void uart_flush_buffer(struct tty_struct *tty)
 	if (port->ops->flush_buffer)
 		port->ops->flush_buffer(port);
 	uart_port_unlock(port, flags);
-	tty_wakeup(tty);
+	tty_port_tty_wakeup(&state->port);
 }
 
 /*
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (4 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 5/9] tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-09 22:37 ` [PATCH 7/9] tty: serial_core: convert private functions to use tty_port instead of tty_struct Rob Herring
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

The uart_state is a container of tty_port. Add an inline to convert
tty_port ptr to uart_state ptr and convert existing container_of users.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/tty/serial/serial_core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d48ea0a98e92..29eef4644e98 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -93,6 +93,11 @@ static inline void uart_port_deref(struct uart_port *uport)
 		uart_port_deref(__uport);				\
 	})
 
+static inline struct uart_state *tty_port_to_uart_state(struct tty_port *port)
+{
+	return container_of(port, struct uart_state, port);
+}
+
 static inline struct uart_port *uart_port_check(struct uart_state *state)
 {
 	lockdep_assert_held(&state->port.mutex);
@@ -720,7 +725,7 @@ static void uart_unthrottle(struct tty_struct *tty)
 
 static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 	int ret = -ENODEV;
 
@@ -1603,7 +1608,7 @@ static void uart_hangup(struct tty_struct *tty)
 /* uport == NULL if uart_port has already been removed */
 static void uart_port_shutdown(struct tty_port *port)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport = uart_port_check(state);
 
 	/*
@@ -1630,7 +1635,7 @@ static void uart_port_shutdown(struct tty_port *port)
 
 static int uart_carrier_raised(struct tty_port *port)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 	int mctrl;
 
@@ -1655,7 +1660,7 @@ static int uart_carrier_raised(struct tty_port *port)
 
 static void uart_dtr_rts(struct tty_port *port, int onoff)
 {
-	struct uart_state *state = container_of(port, struct uart_state, port);
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 
 	uport = uart_port_ref(state);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 7/9] tty: serial_core: convert private functions to use tty_port instead of tty_struct
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (5 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-09 22:37 ` [PATCH 8/9] tty: serial_core: remove dependence on tty->driver_data Rob Herring
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/tty/serial/serial_core.c | 72 +++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 38 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 29eef4644e98..8f2b52174263 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -51,8 +51,7 @@ static struct lock_class_key port_lock_key;
 
 #define HIGH_BITS_OFFSET	((sizeof(long)-sizeof(int))*8)
 
-static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
-					struct ktermios *old_termios);
+static void uart_change_speed(struct tty_port *port, struct ktermios *old_termios);
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
 static void uart_change_pm(struct uart_state *state,
 			   enum uart_pm_state pm_state);
@@ -131,11 +130,8 @@ static void uart_stop(struct tty_struct *tty)
 	uart_port_unlock(port, flags);
 }
 
-static void __uart_start(struct tty_struct *tty)
+static void __uart_start(struct uart_port *port)
 {
-	struct uart_state *state = tty->driver_data;
-	struct uart_port *port = state->uart_port;
-
 	if (port && !uart_tx_stopped(port))
 		port->ops->start_tx(port);
 }
@@ -147,7 +143,7 @@ static void uart_start(struct tty_struct *tty)
 	unsigned long flags;
 
 	port = uart_port_lock(state, flags);
-	__uart_start(tty);
+	__uart_start(port);
 	uart_port_unlock(port, flags);
 }
 
@@ -172,9 +168,10 @@ uart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear)
  * Startup the port.  This will be called once per open.  All calls
  * will be serialised by the per-port mutex.
  */
-static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
-		int init_hw)
+static int uart_port_startup(struct tty_port *port, int init_hw)
 {
+	struct tty_struct *tty = port->tty;
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport = uart_port_check(state);
 	unsigned long page;
 	int retval = 0;
@@ -210,7 +207,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
 		/*
 		 * Initialise the hardware port settings.
 		 */
-		uart_change_speed(tty, state, NULL);
+		uart_change_speed(port, NULL);
 
 		/*
 		 * Setup the RTS and DTR signals once the
@@ -231,16 +228,14 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
 	return retval;
 }
 
-static int uart_startup(struct tty_struct *tty, struct uart_state *state,
-		int init_hw)
+static int uart_startup(struct tty_port *port, int init_hw)
 {
-	struct tty_port *port = &state->port;
 	int retval;
 
 	if (tty_port_initialized(port))
 		return 0;
 
-	retval = uart_port_startup(tty, state, init_hw);
+	retval = uart_port_startup(port, init_hw);
 	if (retval)
 		set_bit(TTY_PORT_IO_ERROR, &port->iflags);
 
@@ -254,10 +249,11 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state,
  *
  * uport == NULL if uart_port has already been removed
  */
-static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
+static void uart_shutdown(struct tty_port *port)
 {
+	struct tty_struct *tty = port->tty;
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport = uart_port_check(state);
-	struct tty_port *port = &state->port;
 
 	/*
 	 * Set the TTY IO error marker
@@ -473,9 +469,10 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
 EXPORT_SYMBOL(uart_get_divisor);
 
 /* Caller holds port mutex */
-static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
-					struct ktermios *old_termios)
+static void uart_change_speed(struct tty_port *port, struct ktermios *old_termios)
 {
+	struct tty_struct *tty = port->tty;
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport = uart_port_check(state);
 	struct ktermios *termios;
 	int hw_stopped;
@@ -513,7 +510,7 @@ static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
 			uport->ops->stop_tx(uport);
 	} else {
 		if (hw_stopped)
-			__uart_start(tty);
+			__uart_start(uport);
 	}
 	spin_unlock_irq(&uport->lock);
 }
@@ -549,7 +546,7 @@ static int uart_write(struct tty_struct *tty,
 					const unsigned char *buf, int count)
 {
 	struct uart_state *state = tty->driver_data;
-	struct uart_port *port;
+	struct uart_port *uport;
 	struct circ_buf *circ;
 	unsigned long flags;
 	int c, ret = 0;
@@ -567,8 +564,8 @@ static int uart_write(struct tty_struct *tty,
 	if (!circ->buf)
 		return 0;
 
-	port = uart_port_lock(state, flags);
-	while (port) {
+	uport = uart_port_lock(state, flags);
+	while (uport) {
 		c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
 		if (count < c)
 			c = count;
@@ -581,8 +578,8 @@ static int uart_write(struct tty_struct *tty,
 		ret += c;
 	}
 
-	__uart_start(tty);
-	uart_port_unlock(port, flags);
+	__uart_start(uport);
+	uart_port_unlock(uport, flags);
 	return ret;
 }
 
@@ -778,7 +775,7 @@ static int uart_get_info_user(struct tty_port *port,
 	return 0;
 }
 
-static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
+static int uart_set_info(struct tty_port *port,
 			 struct uart_state *state,
 			 struct serial_struct *new_info)
 {
@@ -865,7 +862,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
 		 * We need to shutdown the serial port at the old
 		 * port/type/irq combination.
 		 */
-		uart_shutdown(tty, state);
+		uart_shutdown(port);
 	}
 
 	if (change_port) {
@@ -965,10 +962,10 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
 				      current->comm,
 				      tty_name(port->tty));
 			}
-			uart_change_speed(tty, state, NULL);
+			uart_change_speed(port, NULL);
 		}
 	} else {
-		retval = uart_startup(tty, state, 1);
+		retval = uart_startup(port, 1);
 		if (retval > 0)
 			retval = 0;
 	}
@@ -994,7 +991,7 @@ static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state,
 	 * under us.
 	 */
 	mutex_lock(&port->mutex);
-	retval = uart_set_info(tty, port, state, &new_serial);
+	retval = uart_set_info(port, state, &new_serial);
 	mutex_unlock(&port->mutex);
 	return retval;
 }
@@ -1117,7 +1114,7 @@ static int uart_do_autoconfig(struct tty_struct *tty,struct uart_state *state)
 
 	ret = -EBUSY;
 	if (tty_port_users(port) == 1) {
-		uart_shutdown(tty, state);
+		uart_shutdown(port);
 
 		/*
 		 * If we already have a port type configured,
@@ -1136,7 +1133,7 @@ static int uart_do_autoconfig(struct tty_struct *tty,struct uart_state *state)
 		 */
 		uport->ops->config_port(uport, flags);
 
-		ret = uart_startup(tty, state, 1);
+		ret = uart_startup(port, 1);
 		if (ret > 0)
 			ret = 0;
 	}
@@ -1402,6 +1399,7 @@ static void uart_set_ldisc(struct tty_struct *tty)
 static void uart_set_termios(struct tty_struct *tty,
 						struct ktermios *old_termios)
 {
+	struct tty_port *port = tty->port;
 	struct uart_state *state = tty->driver_data;
 	struct uart_port *uport;
 	unsigned int cflag = tty->termios.c_cflag;
@@ -1438,7 +1436,7 @@ static void uart_set_termios(struct tty_struct *tty,
 		goto out;
 	}
 
-	uart_change_speed(tty, state, old_termios);
+	uart_change_speed(port, old_termios);
 	/* reload cflag from termios; port driver may have overriden flags */
 	cflag = tty->termios.c_cflag;
 
@@ -1591,7 +1589,7 @@ static void uart_hangup(struct tty_struct *tty)
 
 	if (tty_port_active(port)) {
 		uart_flush_buffer(tty);
-		uart_shutdown(tty, state);
+		uart_shutdown(port);
 		spin_lock_irqsave(&port->lock, flags);
 		port->count = 0;
 		spin_unlock_irqrestore(&port->lock, flags);
@@ -1714,7 +1712,7 @@ static int uart_port_activate(struct tty_port *port, struct tty_struct *tty)
 	/*
 	 * Start up the serial port.
 	 */
-	return uart_startup(tty, state, 0);
+	return uart_startup(port, 0);
 }
 
 static const char *uart_type(struct uart_port *port)
@@ -2194,11 +2192,9 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
 		spin_unlock_irq(&uport->lock);
 		if (console_suspend_enabled || !uart_console(uport)) {
 			/* Protected by port mutex for now */
-			struct tty_struct *tty = port->tty;
 			ret = ops->startup(uport);
 			if (ret == 0) {
-				if (tty)
-					uart_change_speed(tty, state, NULL);
+				uart_change_speed(port, NULL);
 				spin_lock_irq(&uport->lock);
 				ops->set_mctrl(uport, uport->mctrl);
 				ops->start_tx(uport);
@@ -2210,7 +2206,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
 				 * Clear the "initialized" flag so we won't try
 				 * to call the low level drivers shutdown method.
 				 */
-				uart_shutdown(tty, state);
+				uart_shutdown(port);
 			}
 		}
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 8/9] tty: serial_core: remove dependence on tty->driver_data
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (6 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 7/9] tty: serial_core: convert private functions to use tty_port instead of tty_struct Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-09 22:37 ` [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup Rob Herring
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

As the uart_state contains tty_port, use that to get the uart_state ptr.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/tty/serial/serial_core.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 8f2b52174263..b9ec9fd688a2 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -120,7 +120,7 @@ void uart_write_wakeup(struct uart_port *port)
 
 static void uart_stop(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long flags;
 
@@ -138,7 +138,7 @@ static void __uart_start(struct uart_port *port)
 
 static void uart_start(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long flags;
 
@@ -517,7 +517,7 @@ static void uart_change_speed(struct tty_port *port, struct ktermios *old_termio
 
 static int uart_put_char(struct tty_struct *tty, unsigned char c)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	struct circ_buf *circ;
 	unsigned long flags;
@@ -545,7 +545,7 @@ static void uart_flush_chars(struct tty_struct *tty)
 static int uart_write(struct tty_struct *tty,
 					const unsigned char *buf, int count)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *uport;
 	struct circ_buf *circ;
 	unsigned long flags;
@@ -585,7 +585,7 @@ static int uart_write(struct tty_struct *tty,
 
 static int uart_write_room(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long flags;
 	int ret;
@@ -598,7 +598,7 @@ static int uart_write_room(struct tty_struct *tty)
 
 static int uart_chars_in_buffer(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long flags;
 	int ret;
@@ -611,7 +611,7 @@ static int uart_chars_in_buffer(struct tty_struct *tty)
 
 static void uart_flush_buffer(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long flags;
 
@@ -642,7 +642,7 @@ static void uart_flush_buffer(struct tty_struct *tty)
  */
 static void uart_send_xchar(struct tty_struct *tty, char ch)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long flags;
 
@@ -664,7 +664,7 @@ static void uart_send_xchar(struct tty_struct *tty, char ch)
 
 static void uart_throttle(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	upstat_t mask = 0;
 
@@ -693,7 +693,7 @@ static void uart_throttle(struct tty_struct *tty)
 
 static void uart_unthrottle(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	upstat_t mask = 0;
 
@@ -1026,7 +1026,7 @@ static int uart_get_lsr_info(struct tty_struct *tty,
 
 static int uart_tiocmget(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct tty_port *port = &state->port;
 	struct uart_port *uport;
 	int result = -EIO;
@@ -1050,7 +1050,7 @@ out:
 static int
 uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct tty_port *port = &state->port;
 	struct uart_port *uport;
 	int ret = -EIO;
@@ -1071,7 +1071,7 @@ out:
 
 static int uart_break_ctl(struct tty_struct *tty, int break_state)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct tty_port *port = &state->port;
 	struct uart_port *uport;
 	int ret = -EIO;
@@ -1221,7 +1221,7 @@ static int uart_wait_modem_status(struct uart_state *state, unsigned long arg)
 static int uart_get_icount(struct tty_struct *tty,
 			  struct serial_icounter_struct *icount)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_icount cnow;
 	struct uart_port *uport;
 
@@ -1295,7 +1295,7 @@ static int uart_set_rs485_config(struct uart_port *port,
 static int
 uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct tty_port *port = &state->port;
 	struct uart_port *uport;
 	void __user *uarg = (void __user *)arg;
@@ -1386,7 +1386,7 @@ out:
 
 static void uart_set_ldisc(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *uport;
 
 	mutex_lock(&state->port.mutex);
@@ -1400,7 +1400,7 @@ static void uart_set_termios(struct tty_struct *tty,
 						struct ktermios *old_termios)
 {
 	struct tty_port *port = tty->port;
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(port);
 	struct uart_port *uport;
 	unsigned int cflag = tty->termios.c_cflag;
 	unsigned int iflag_mask = IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK;
@@ -1461,7 +1461,7 @@ out:
  */
 static void uart_close(struct tty_struct *tty, struct file *filp)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct tty_port *port;
 
 	if (!state) {
@@ -1512,7 +1512,7 @@ static void uart_tty_port_shutdown(struct tty_port *port)
 
 static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct uart_port *port;
 	unsigned long char_time, expire;
 
@@ -1576,7 +1576,7 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
  */
 static void uart_hangup(struct tty_struct *tty)
 {
-	struct uart_state *state = tty->driver_data;
+	struct uart_state *state = tty_port_to_uart_state(tty->port);
 	struct tty_port *port = &state->port;
 	struct uart_port *uport;
 	unsigned long flags;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (7 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 8/9] tty: serial_core: remove dependence on tty->driver_data Rob Herring
@ 2016-09-09 22:37 ` Rob Herring
  2016-09-11 21:20   ` One Thousand Gnomes
  2016-09-11 21:14 ` [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes
  2016-09-15 10:43 ` Greg Kroah-Hartman
  10 siblings, 1 reply; 18+ messages in thread
From: Rob Herring @ 2016-09-09 22:37 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

If we don't have a tty when calling uart_port_startup, skip the baudrate
and modem control setup which depend on tty->termios struct. Either
tty_port clients will configure the line in a separate call or we'll
move termios into the tty_port.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/tty/serial/serial_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b9ec9fd688a2..2c3b187d517b 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -199,7 +199,7 @@ static int uart_port_startup(struct tty_port *port, int init_hw)
 	}
 
 	retval = uport->ops->startup(uport);
-	if (retval == 0) {
+	if (retval == 0 && tty) {
 		if (uart_console(uport) && uport->cons->cflag) {
 			tty->termios.c_cflag = uport->cons->cflag;
 			uport->cons->cflag = 0;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros
  2016-09-09 22:37 ` [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros Rob Herring
@ 2016-09-10  1:02   ` Rob Herring
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2016-09-10  1:02 UTC (permalink / raw)
  To: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley
  Cc: linux-kernel, linux-serial

On Fri, Sep 9, 2016 at 5:37 PM, Rob Herring <robh@kernel.org> wrote:
> In preparation to support tty drivers having only a tty_port and
> possibly not a tty_struct, convert all the termios flag macros to take a
> termios ptr instead of the tty_struct ptr. After this change drivers can
> be converted to support a termios struct other than tty->termios.

[...]

> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index 832cbd647145..e5d7e4db6bdc 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -560,7 +560,7 @@ static int at_xdmac_compute_chan_conf(struct dma_chan *chan,
>                         dev_err(chan2dev(chan), "invalid src maxburst value\n");
>                         return -EINVAL;
>                 }
> -               atchan->cfg |= AT_XDMAC_CC_CSIZE(csize);
> +               atchan->cfg |= AT_XDMAC_CC_CSIZE(&csize->termios);
>                 dwidth = ffs(atchan->sconfig.src_addr_width) - 1;
>                 if (dwidth < 0) {
>                         dev_err(chan2dev(chan), "invalid src addr width value\n");
> @@ -583,7 +583,7 @@ static int at_xdmac_compute_chan_conf(struct dma_chan *chan,
>                         dev_err(chan2dev(chan), "invalid src maxburst value\n");
>                         return -EINVAL;
>                 }
> -               atchan->cfg |= AT_XDMAC_CC_CSIZE(csize);
> +               atchan->cfg |= AT_XDMAC_CC_CSIZE(&csize->termios);
>                 dwidth = ffs(atchan->sconfig.dst_addr_width) - 1;
>                 if (dwidth < 0) {
>                         dev_err(chan2dev(chan), "invalid dst addr width value\n");

This file needs to be dropped. There were a few false matches and I
missed this one.

Rob

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/9] tty: tty_struct dependency clean-ups
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (8 preceding siblings ...)
  2016-09-09 22:37 ` [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup Rob Herring
@ 2016-09-11 21:14 ` One Thousand Gnomes
  2016-09-12  3:05   ` Rob Herring
  2016-09-15 10:43 ` Greg Kroah-Hartman
  10 siblings, 1 reply; 18+ messages in thread
From: One Thousand Gnomes @ 2016-09-11 21:14 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley,
	linux-kernel, linux-serial

On Fri,  9 Sep 2016 17:37:01 -0500
Rob Herring <robh@kernel.org> wrote:

> This patch series removes or prepares to remove some of the dependencies 
> on tty_struct within tty_port drivers. This will allow using tty_ports 
> directly for so called UART slave devices. 

You can create a tty_struct kernel side with the two tiny changes I
posted before. Why do you want to do invasive tree wide changes when you
can do simple ones ?

> Next up after this are moving some functions to the tty_port ops. I've 
> got some WIP patches for some of that, but nothing ready to send out 
> quite yet.

I think before this lot happens you need to decide where these structures
belong. Termios and termios_locked for example could live in the tty_port
as the physical tty is incapable of having multiple sets of terminal data
at once.

Really though this looks to me like *MASSIVE* churn for now purpose.
Create a tty_struct kernel side, and use that, the needed patch is then
tiny.

so IMHO NAK

Alan

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/9] tty: move hw_stopped flag to tty_port
  2016-09-09 22:37 ` [PATCH 3/9] tty: move hw_stopped flag to tty_port Rob Herring
@ 2016-09-11 21:15   ` One Thousand Gnomes
  0 siblings, 0 replies; 18+ messages in thread
From: One Thousand Gnomes @ 2016-09-11 21:15 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley,
	linux-kernel, linux-serial

On Fri,  9 Sep 2016 17:37:04 -0500
Rob Herring <robh@kernel.org> wrote:

> hw_stopped is a property of the tty port rather than the tty, so move it
> to tty_port struct and remove another dependency on tty_struct from
> drivers.
> 
> Converted with coccinelle:

This one makes sense. It's moving the object to the right place


Acked-by: Alan Cox <alan@linux.intel.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags
  2016-09-09 22:37 ` [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags Rob Herring
@ 2016-09-11 21:18   ` One Thousand Gnomes
  0 siblings, 0 replies; 18+ messages in thread
From: One Thousand Gnomes @ 2016-09-11 21:18 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley,
	linux-kernel, linux-serial

On Fri,  9 Sep 2016 17:37:05 -0500
Rob Herring <robh@kernel.org> wrote:

> TTY_IO_ERROR is a property of the tty port rather than the tty, so move
> it to tty_port struct and remove another dependency on tty_struct from
> drivers.
> 
> Partially converted with coccinelle:
> 
> @@
> identifier t;
> identifier func;
> @@
> - func(TTY_IO_ERROR, &t->flags)
> + func(TTY_PORT_IO_ERROR, &t->port->iflags)
> 
> @@
> expression port;
> identifier func;
> @@
> - func(TTY_IO_ERROR, &port.tty->flags)
> + func(TTY_PORT_IO_ERROR, &port.iflags)

Again this makes sense to move the object to the right structure.

I'm not convinced your recipe is a correct and reliable translation
because you don't capture the flag being cleared if the tty object is
freed and then a new one allocated. That needs further review IMHO

Alan

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup
  2016-09-09 22:37 ` [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup Rob Herring
@ 2016-09-11 21:20   ` One Thousand Gnomes
  0 siblings, 0 replies; 18+ messages in thread
From: One Thousand Gnomes @ 2016-09-11 21:20 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley,
	linux-kernel, linux-serial

On Fri,  9 Sep 2016 17:37:10 -0500
Rob Herring <robh@kernel.org> wrote:

> If we don't have a tty when calling uart_port_startup, skip the baudrate
> and modem control setup which depend on tty->termios struct. Either
> tty_port clients will configure the line in a separate call or we'll
> move termios into the tty_port.

I don't think getting rid of the tty object makes any sense whatsoever
just create a kernel one.

Either way the giant churny patch and this hack should be deferred in
favour of moving the termios structure into the tty port (and the locks
for it) and doing the right job once.

The termios does I agree belong in the tty_port so irrespective of final
direction fixing that is a right move.

Alan

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/9] tty: tty_struct dependency clean-ups
  2016-09-11 21:14 ` [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes
@ 2016-09-12  3:05   ` Rob Herring
  2016-09-12 11:46     ` One Thousand Gnomes
  0 siblings, 1 reply; 18+ messages in thread
From: Rob Herring @ 2016-09-12  3:05 UTC (permalink / raw)
  To: One Thousand Gnomes
  Cc: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley,
	linux-kernel, linux-serial

On Sun, Sep 11, 2016 at 4:14 PM, One Thousand Gnomes
<gnomes@lxorguk.ukuu.org.uk> wrote:
> On Fri,  9 Sep 2016 17:37:01 -0500
> Rob Herring <robh@kernel.org> wrote:
>
>> This patch series removes or prepares to remove some of the dependencies
>> on tty_struct within tty_port drivers. This will allow using tty_ports
>> directly for so called UART slave devices.
>
> You can create a tty_struct kernel side with the two tiny changes I
> posted before. Why do you want to do invasive tree wide changes when you
> can do simple ones ?

Well, I don't want to do invasive changes, but I thought the idea was
to use tty_port struct without a tty_struct.

>> Next up after this are moving some functions to the tty_port ops. I've
>> got some WIP patches for some of that, but nothing ready to send out
>> quite yet.
>
> I think before this lot happens you need to decide where these structures
> belong. Termios and termios_locked for example could live in the tty_port
> as the physical tty is incapable of having multiple sets of terminal data
> at once.

I was planning to keep termios out of tty_port and make clients of
tty_port carry it if for nothing else not quite understanding all the
details around the lifetime, init and locking of it. If there's always
a tty_struct then there's not much point moving it other than which
struct makes more sense. But that would cause some churn.

Rob

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/9] tty: tty_struct dependency clean-ups
  2016-09-12  3:05   ` Rob Herring
@ 2016-09-12 11:46     ` One Thousand Gnomes
  0 siblings, 0 replies; 18+ messages in thread
From: One Thousand Gnomes @ 2016-09-12 11:46 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alan Cox, Greg Kroah-Hartman, Jiri Slaby, Peter Hurley,
	linux-kernel, linux-serial

On Sun, 11 Sep 2016 22:05:07 -0500
Rob Herring <robh@kernel.org> wrote:

> On Sun, Sep 11, 2016 at 4:14 PM, One Thousand Gnomes
> <gnomes@lxorguk.ukuu.org.uk> wrote:
> > On Fri,  9 Sep 2016 17:37:01 -0500
> > Rob Herring <robh@kernel.org> wrote:
> >  
> >> This patch series removes or prepares to remove some of the dependencies
> >> on tty_struct within tty_port drivers. This will allow using tty_ports
> >> directly for so called UART slave devices.  
> >
> > You can create a tty_struct kernel side with the two tiny changes I
> > posted before. Why do you want to do invasive tree wide changes when you
> > can do simple ones ?  
> 
> Well, I don't want to do invasive changes, but I thought the idea was
> to use tty_port struct without a tty_struct.

I posted some tiny patches to break the file/tty requirement in the base
tty code for comment a while ago and they were very tiny for most ldiscs
(n_tty unsurprisingly wouldn't work this way but does anyone need kernel
mode n_tty ?)

Moving termios into the tty_port is IMHO a good thing to do whichever
approach is taken.

> I was planning to keep termios out of tty_port and make clients of
> tty_port carry it if for nothing else not quite understanding all the
> details around the lifetime, init and locking of it. If there's always
> a tty_struct then there's not much point moving it other than which
> struct makes more sense. But that would cause some churn.

The termios lifetime is the lifetime of the port, although it may get
reset at some times.

Alan

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/9] tty: tty_struct dependency clean-ups
  2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
                   ` (9 preceding siblings ...)
  2016-09-11 21:14 ` [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes
@ 2016-09-15 10:43 ` Greg Kroah-Hartman
  10 siblings, 0 replies; 18+ messages in thread
From: Greg Kroah-Hartman @ 2016-09-15 10:43 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alan Cox, Jiri Slaby, Peter Hurley, linux-kernel, linux-serial

On Fri, Sep 09, 2016 at 05:37:01PM -0500, Rob Herring wrote:
> This patch series removes or prepares to remove some of the dependencies 
> on tty_struct within tty_port drivers. This will allow using tty_ports 
> directly for so called UART slave devices. 
> 
> The first patch fixes a regression from the last round with tty 
> closing. Patches 2-4 are mechanical conversions generated with 
> coccinelle. This is my first adventure into coccinelle, so hopefully I 
> didn't screw things up. :) Only serial_core has some of its tty_struct 
> dependencies removed as those are the drivers we immediately care about 
> supporting slave devices with.
> 
> Next up after this are moving some functions to the tty_port ops. I've 
> got some WIP patches for some of that, but nothing ready to send out 
> quite yet.

I've applied the first patch here, and wanted to apply patch 3, but it
depended on #2, so I'll wait for your next round of patches.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-09-15 10:43 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-09 22:37 [PATCH 0/9] tty: tty_struct dependency clean-ups Rob Herring
2016-09-09 22:37 ` [PATCH 1/9] tty: serial_core: add tty NULL check to uart_tx_stopped Rob Herring
2016-09-09 22:37 ` [PATCH 2/9] tty: remove tty_struct dependency in tty flag macros Rob Herring
2016-09-10  1:02   ` Rob Herring
2016-09-09 22:37 ` [PATCH 3/9] tty: move hw_stopped flag to tty_port Rob Herring
2016-09-11 21:15   ` One Thousand Gnomes
2016-09-09 22:37 ` [PATCH 4/9] tty: move TTY_IO_ERROR flag to tty_port iflags Rob Herring
2016-09-11 21:18   ` One Thousand Gnomes
2016-09-09 22:37 ` [PATCH 5/9] tty: serial_core: use tty_port_tty_wakeup instead of tty_wakeup Rob Herring
2016-09-09 22:37 ` [PATCH 6/9] tty: serial_core: introduce tty_port_to_uart_state Rob Herring
2016-09-09 22:37 ` [PATCH 7/9] tty: serial_core: convert private functions to use tty_port instead of tty_struct Rob Herring
2016-09-09 22:37 ` [PATCH 8/9] tty: serial_core: remove dependence on tty->driver_data Rob Herring
2016-09-09 22:37 ` [PATCH 9/9] tty: serial_core: add tty NULL check in uart_port_startup Rob Herring
2016-09-11 21:20   ` One Thousand Gnomes
2016-09-11 21:14 ` [PATCH 0/9] tty: tty_struct dependency clean-ups One Thousand Gnomes
2016-09-12  3:05   ` Rob Herring
2016-09-12 11:46     ` One Thousand Gnomes
2016-09-15 10:43 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.