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

serial: add a new helper function

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>

authored by

Huang Shijie and committed by
Greg Kroah-Hartman
f21ec3d2 e5b57c03

+20 -14
+1 -1
drivers/tty/amiserial.c
··· 420 420 tty_hangup(port->tty); 421 421 } 422 422 } 423 - if (port->flags & ASYNC_CTS_FLOW) { 423 + if (tty_port_cts_enabled(port)) { 424 424 if (port->tty->hw_stopped) { 425 425 if (!(status & SER_CTS)) { 426 426 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
+1 -1
drivers/tty/cyclades.c
··· 727 727 else 728 728 tty_hangup(tty); 729 729 } 730 - if ((mdm_change & CyCTS) && (info->port.flags & ASYNC_CTS_FLOW)) { 730 + if ((mdm_change & CyCTS) && tty_port_cts_enabled(&info->port)) { 731 731 if (tty->hw_stopped) { 732 732 if (mdm_status & CyCTS) { 733 733 /* cy_start isn't used
+1 -1
drivers/tty/isicom.c
··· 600 600 port->status &= ~ISI_DCD; 601 601 } 602 602 603 - if (port->port.flags & ASYNC_CTS_FLOW) { 603 + if (tty_port_cts_enabled(&port->port)) { 604 604 if (tty->hw_stopped) { 605 605 if (header & ISI_CTS) { 606 606 port->port.tty->hw_stopped = 0;
+1 -1
drivers/tty/mxser.c
··· 830 830 wake_up_interruptible(&port->port.open_wait); 831 831 } 832 832 833 - if (port->port.flags & ASYNC_CTS_FLOW) { 833 + if (tty_port_cts_enabled(&port->port)) { 834 834 if (tty->hw_stopped) { 835 835 if (status & UART_MSR_CTS) { 836 836 tty->hw_stopped = 0;
+1 -1
drivers/tty/serial/mxs-auart.c
··· 262 262 263 263 ctrl &= ~AUART_CTRL2_RTSEN; 264 264 if (mctrl & TIOCM_RTS) { 265 - if (u->state->port.flags & ASYNC_CTS_FLOW) 265 + if (tty_port_cts_enabled(&u->state->port)) 266 266 ctrl |= AUART_CTRL2_RTSEN; 267 267 } 268 268
+2 -2
drivers/tty/serial/serial_core.c
··· 176 176 uart_set_mctrl(uport, TIOCM_RTS | TIOCM_DTR); 177 177 } 178 178 179 - if (port->flags & ASYNC_CTS_FLOW) { 179 + if (tty_port_cts_enabled(port)) { 180 180 spin_lock_irq(&uport->lock); 181 181 if (!(uport->ops->get_mctrl(uport) & TIOCM_CTS)) 182 182 tty->hw_stopped = 1; ··· 2509 2509 2510 2510 uport->icount.cts++; 2511 2511 2512 - if (port->flags & ASYNC_CTS_FLOW) { 2512 + if (tty_port_cts_enabled(port)) { 2513 2513 if (tty->hw_stopped) { 2514 2514 if (status) { 2515 2515 tty->hw_stopped = 0;
+1 -1
drivers/tty/synclink.c
··· 1359 1359 } 1360 1360 } 1361 1361 1362 - if ( (info->port.flags & ASYNC_CTS_FLOW) && 1362 + if (tty_port_cts_enabled(&info->port) && 1363 1363 (status & MISCSTATUS_CTS_LATCHED) ) { 1364 1364 if (info->port.tty->hw_stopped) { 1365 1365 if (status & MISCSTATUS_CTS) {
+1 -1
drivers/tty/synclinkmp.c
··· 2500 2500 } 2501 2501 } 2502 2502 2503 - if ( (info->port.flags & ASYNC_CTS_FLOW) && 2503 + if (tty_port_cts_enabled(&info->port) && 2504 2504 (status & MISCSTATUS_CTS_LATCHED) ) { 2505 2505 if ( info->port.tty ) { 2506 2506 if (info->port.tty->hw_stopped) {
+6
include/linux/tty.h
··· 514 514 return port; 515 515 } 516 516 517 + /* If the cts flow control is enabled, return true. */ 518 + static inline bool tty_port_cts_enabled(struct tty_port *port) 519 + { 520 + return port->flags & ASYNC_CTS_FLOW; 521 + } 522 + 517 523 extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 518 524 extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 519 525 extern int tty_port_carrier_raised(struct tty_port *port);
+2 -2
net/irda/ircomm/ircomm_tty.c
··· 1070 1070 goto put; 1071 1071 } 1072 1072 } 1073 - if (tty && self->port.flags & ASYNC_CTS_FLOW) { 1073 + if (tty && tty_port_cts_enabled(&self->port)) { 1074 1074 if (tty->hw_stopped) { 1075 1075 if (status & IRCOMM_CTS) { 1076 1076 IRDA_DEBUG(2, ··· 1313 1313 1314 1314 seq_puts(m, "Flags:"); 1315 1315 sep = ' '; 1316 - if (self->port.flags & ASYNC_CTS_FLOW) { 1316 + if (tty_port_cts_enabled(&self->port)) { 1317 1317 seq_printf(m, "%cASYNC_CTS_FLOW", sep); 1318 1318 sep = '|'; 1319 1319 }
+1 -1
net/irda/ircomm/ircomm_tty_attach.c
··· 578 578 * will have to wait for the peer device (DCE) to raise the CTS 579 579 * line. 580 580 */ 581 - if ((self->port.flags & ASYNC_CTS_FLOW) && 581 + if (tty_port_cts_enabled(&self->port) && 582 582 ((self->settings.dce & IRCOMM_CTS) == 0)) { 583 583 IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __func__ ); 584 584 goto put;