serial: add a new helper function
authorHuang Shijie <shijie8@gmail.com>
Thu, 23 Aug 2012 02:13:36 +0000 (22:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Sep 2012 20:28:35 +0000 (13:28 -0700)
In most of the time, the driver needs to check if the cts flow control
is enabled. But now, the driver checks the ASYNC_CTS_FLOW flag manually,
which is not a grace way. So add a new wraper function to make the code
tidy and clean.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 files changed:
drivers/char/pcmcia/synclink_cs.c
drivers/tty/amiserial.c
drivers/tty/cyclades.c
drivers/tty/isicom.c
drivers/tty/mxser.c
drivers/tty/serial/mxs-auart.c
drivers/tty/serial/serial_core.c
drivers/tty/synclink.c
drivers/tty/synclink_gt.c
drivers/tty/synclinkmp.c
include/linux/tty.h
net/irda/ircomm/ircomm_tty.c
net/irda/ircomm/ircomm_tty_attach.c

index 5db08c78beb5a1423902f6bd3ed62d690a7d5213..3f57d5de395723e03cf6b6c4148760d3ca043240 100644 (file)
@@ -1050,7 +1050,7 @@ static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty)
        wake_up_interruptible(&info->status_event_wait_q);
        wake_up_interruptible(&info->event_wait_q);
 
-       if (info->port.flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(&info->port)) {
                if (tty->hw_stopped) {
                        if (info->serial_signals & SerialSignal_CTS) {
                                if (debug_level >= DEBUG_LEVEL_ISR)
index 2b7535d42e05fc808d9f3eda9f176b365050c0e9..42d0a2581a87d9fae2968965f51d488330264c96 100644 (file)
@@ -420,7 +420,7 @@ static void check_modem_status(struct serial_state *info)
                                tty_hangup(port->tty);
                }
        }
-       if (port->flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(port)) {
                if (port->tty->hw_stopped) {
                        if (!(status & SER_CTS)) {
 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
index e3954dae50641026943b8497f7eae8a357a54350..0a6a0bc1b598caab2ca0019af8035428d5726cfd 100644 (file)
@@ -727,7 +727,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
                else
                        tty_hangup(tty);
        }
-       if ((mdm_change & CyCTS) && (info->port.flags & ASYNC_CTS_FLOW)) {
+       if ((mdm_change & CyCTS) && tty_port_cts_enabled(&info->port)) {
                if (tty->hw_stopped) {
                        if (mdm_status & CyCTS) {
                                /* cy_start isn't used
index 99cf22e5f2b6634bcf809ccecf37e463b4c620ab..d7492e18360768c683c86b4359c6173d8ae1310f 100644 (file)
@@ -600,7 +600,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
                                        port->status &= ~ISI_DCD;
                        }
 
-                       if (port->port.flags & ASYNC_CTS_FLOW) {
+                       if (tty_port_cts_enabled(&port->port)) {
                                if (tty->hw_stopped) {
                                        if (header & ISI_CTS) {
                                                port->port.tty->hw_stopped = 0;
index bb2da4ca82575bd307bc6452e278ad0e8121f9b0..cfda47dabd281a9704eb182f1b19cbe65eed15c1 100644 (file)
@@ -830,7 +830,7 @@ static void mxser_check_modem_status(struct tty_struct *tty,
                        wake_up_interruptible(&port->port.open_wait);
        }
 
-       if (port->port.flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(&port->port)) {
                if (tty->hw_stopped) {
                        if (status & UART_MSR_CTS) {
                                tty->hw_stopped = 0;
index 3a667eed63d6086c017c8abcc83a597850ec4966..dafeef2bfb49e736089e23910248fc30a1c59052 100644 (file)
@@ -262,7 +262,7 @@ static void mxs_auart_set_mctrl(struct uart_port *u, unsigned mctrl)
 
        ctrl &= ~AUART_CTRL2_RTSEN;
        if (mctrl & TIOCM_RTS) {
-               if (u->state->port.flags & ASYNC_CTS_FLOW)
+               if (tty_port_cts_enabled(&u->state->port))
                        ctrl |= AUART_CTRL2_RTSEN;
        }
 
index bb5f2360383686f1b3a70f0bc479a67e7da486b0..137b25ce39a73e3a74ff43ecbdfab3ef1779ba9e 100644 (file)
@@ -176,7 +176,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
                                uart_set_mctrl(uport, TIOCM_RTS | TIOCM_DTR);
                }
 
-               if (port->flags & ASYNC_CTS_FLOW) {
+               if (tty_port_cts_enabled(port)) {
                        spin_lock_irq(&uport->lock);
                        if (!(uport->ops->get_mctrl(uport) & TIOCM_CTS))
                                tty->hw_stopped = 1;
@@ -2509,7 +2509,7 @@ void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
 
        uport->icount.cts++;
 
-       if (port->flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(port)) {
                if (tty->hw_stopped) {
                        if (status) {
                                tty->hw_stopped = 0;
index 666aa1455fc76cdd9fa0bfd5e81c03aada348b3f..70e3a525bc82c4a438d9359a6cb45f07feb9572f 100644 (file)
@@ -1359,7 +1359,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
                        }
                }
        
-               if ( (info->port.flags & ASYNC_CTS_FLOW) && 
+               if (tty_port_cts_enabled(&info->port) &&
                     (status & MISCSTATUS_CTS_LATCHED) ) {
                        if (info->port.tty->hw_stopped) {
                                if (status & MISCSTATUS_CTS) {
index 45f6136f4e51eb58c91b91455c7292d78e39463d..b38e954eedd346130b388e2496d57b9d8995ccab 100644 (file)
@@ -2053,7 +2053,7 @@ static void cts_change(struct slgt_info *info, unsigned short status)
        wake_up_interruptible(&info->event_wait_q);
        info->pending_bh |= BH_STATUS;
 
-       if (info->port.flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(&info->port)) {
                if (info->port.tty) {
                        if (info->port.tty->hw_stopped) {
                                if (info->signals & SerialSignal_CTS) {
index 53429c890a899936b760d59819f011abbacad7d3..f17d9f3d84a2e80c512fbfac0e8cd634485b5fa4 100644 (file)
@@ -2500,7 +2500,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )
                        }
                }
 
-               if ( (info->port.flags & ASYNC_CTS_FLOW) &&
+               if (tty_port_cts_enabled(&info->port) &&
                     (status & MISCSTATUS_CTS_LATCHED) ) {
                        if ( info->port.tty ) {
                                if (info->port.tty->hw_stopped) {
index dbebd1e56bc13e4a24bd9707c33379b26a37a160..9892121354cd30e705cdc0ff7eaf597023d0fd68 100644 (file)
@@ -514,6 +514,12 @@ static inline struct tty_port *tty_port_get(struct tty_port *port)
        return port;
 }
 
+/* If the cts flow control is enabled, return true. */
+static inline bool tty_port_cts_enabled(struct tty_port *port)
+{
+       return port->flags & ASYNC_CTS_FLOW;
+}
+
 extern struct tty_struct *tty_port_tty_get(struct tty_port *port);
 extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
 extern int tty_port_carrier_raised(struct tty_port *port);
index 96689906b93c02022abbe097e866296a28beac0a..95a3a7a336ba86a0b8b3790a7ce8e722f17db1a2 100644 (file)
@@ -1070,7 +1070,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
                        goto put;
                }
        }
-       if (tty && self->port.flags & ASYNC_CTS_FLOW) {
+       if (tty && tty_port_cts_enabled(&self->port)) {
                if (tty->hw_stopped) {
                        if (status & IRCOMM_CTS) {
                                IRDA_DEBUG(2,
@@ -1313,7 +1313,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
 
        seq_puts(m, "Flags:");
        sep = ' ';
-       if (self->port.flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(&self->port)) {
                seq_printf(m, "%cASYNC_CTS_FLOW", sep);
                sep = '|';
        }
index 3ab70e7a07157821b3112578528ce63b99c4389c..edab393e0c82ec96bfd66dd662a888963761bab0 100644 (file)
@@ -578,7 +578,7 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
         * will have to wait for the peer device (DCE) to raise the CTS
         * line.
         */
-       if ((self->port.flags & ASYNC_CTS_FLOW) &&
+       if (tty_port_cts_enabled(&self->port) &&
                        ((self->settings.dce & IRCOMM_CTS) == 0)) {
                IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __func__ );
                goto put;