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

tty: Replace ASYNC_CHECK_CD and update atomically

Replace ASYNC_CHECK_CD bit in the tty_port::flags field with
TTY_PORT_CHECK_CD bit in the tty_port::iflags field. Introduce helpers
tty_port_set_check_carrier() and tty_port_check_carrier() to abstract
the atomic bit ops.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Hurley and committed by
Greg Kroah-Hartman
2d68655d 807c8d81

+39 -64
+2 -6
drivers/isdn/i4l/isdn_tty.c
··· 1043 1043 if (!(cflag & PARODD)) 1044 1044 cval |= UART_LCR_EPAR; 1045 1045 1046 - if (cflag & CLOCAL) 1047 - port->flags &= ~ASYNC_CHECK_CD; 1048 - else { 1049 - port->flags |= ASYNC_CHECK_CD; 1050 - } 1046 + tty_port_set_check_carrier(port, ~cflag & CLOCAL); 1051 1047 } 1052 1048 1053 1049 static int ··· 2522 2526 if (info->closing || (!info->port.tty)) 2523 2527 return; 2524 2528 2525 - if (info->port.flags & ASYNC_CHECK_CD) 2529 + if (tty_port_check_carrier(&info->port)) 2526 2530 tty_hangup(info->port.tty); 2527 2531 } 2528 2532 }
+3 -6
drivers/tty/amiserial.c
··· 398 398 wake_up_interruptible(&port->delta_msr_wait); 399 399 } 400 400 401 - if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) { 401 + if (tty_port_check_carrier(port) && (dstatus & SER_DCD)) { 402 402 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) 403 403 printk("ttyS%d CD now %s...", info->line, 404 404 (!(status & SER_DCD)) ? "on" : "off"); ··· 730 730 tty_port_set_cts_flow(port, cflag & CRTSCTS); 731 731 if (cflag & CRTSCTS) 732 732 info->IER |= UART_IER_MSI; 733 - if (cflag & CLOCAL) 734 - port->flags &= ~ASYNC_CHECK_CD; 735 - else { 736 - port->flags |= ASYNC_CHECK_CD; 733 + tty_port_set_check_carrier(port, ~cflag & CLOCAL); 734 + if (~cflag & CLOCAL) 737 735 info->IER |= UART_IER_MSI; 738 - } 739 736 /* TBD: 740 737 * Does clearing IER_MSI imply that we should disable the VBL interrupt ? 741 738 */
+4 -10
drivers/tty/cyclades.c
··· 714 714 wake_up_interruptible(&info->port.delta_msr_wait); 715 715 } 716 716 717 - if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) { 717 + if ((mdm_change & CyDCD) && tty_port_check_carrier(&info->port)) { 718 718 if (mdm_status & CyDCD) 719 719 wake_up_interruptible(&info->port.open_wait); 720 720 else ··· 1119 1119 case C_CM_MDCD: 1120 1120 info->icount.dcd++; 1121 1121 delta_count++; 1122 - if (info->port.flags & ASYNC_CHECK_CD) { 1122 + if (tty_port_check_carrier(&info->port)) { 1123 1123 u32 dcd = fw_ver > 241 ? param : 1124 1124 readl(&info->u.cyz.ch_ctrl->rs_status); 1125 1125 if (dcd & C_RS_DCD) ··· 2088 2088 info->cor2 |= CyCtsAE; 2089 2089 else 2090 2090 info->cor2 &= ~CyCtsAE; 2091 - if (cflag & CLOCAL) 2092 - info->port.flags &= ~ASYNC_CHECK_CD; 2093 - else 2094 - info->port.flags |= ASYNC_CHECK_CD; 2091 + tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); 2095 2092 2096 2093 /*********************************************** 2097 2094 The hardware option, CyRtsAO, presents RTS when ··· 2247 2250 } 2248 2251 2249 2252 /* CD sensitivity */ 2250 - if (cflag & CLOCAL) 2251 - info->port.flags &= ~ASYNC_CHECK_CD; 2252 - else 2253 - info->port.flags |= ASYNC_CHECK_CD; 2253 + tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); 2254 2254 2255 2255 if (baud == 0) { /* baud rate is zero, turn off line */ 2256 2256 cy_writel(&ch_ctrl->rs_control,
+2 -5
drivers/tty/isicom.c
··· 577 577 header = inw(base); 578 578 switch (header & 0xff) { 579 579 case 0: /* Change in EIA signals */ 580 - if (port->port.flags & ASYNC_CHECK_CD) { 580 + if (tty_port_check_carrier(&port->port)) { 581 581 if (port->status & ISI_DCD) { 582 582 if (!(header & ISI_DCD)) { 583 583 /* Carrier has been lost */ ··· 758 758 outw(channel_setup, base); 759 759 InterruptTheCard(base); 760 760 } 761 - if (C_CLOCAL(tty)) 762 - port->port.flags &= ~ASYNC_CHECK_CD; 763 - else 764 - port->port.flags |= ASYNC_CHECK_CD; 761 + tty_port_set_check_carrier(&port->port, !C_CLOCAL(tty)); 765 762 766 763 /* flow control settings ...*/ 767 764 flow_ctrl = 0;
+3 -6
drivers/tty/mxser.c
··· 746 746 } 747 747 } 748 748 outb(info->MCR, info->ioaddr + UART_MCR); 749 - if (cflag & CLOCAL) { 750 - info->port.flags &= ~ASYNC_CHECK_CD; 751 - } else { 752 - info->port.flags |= ASYNC_CHECK_CD; 749 + tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); 750 + if (~cflag & CLOCAL) 753 751 info->IER |= UART_IER_MSI; 754 - } 755 752 outb(info->IER, info->ioaddr + UART_IER); 756 753 757 754 /* ··· 821 824 port->mon_data.modem_status = status; 822 825 wake_up_interruptible(&port->port.delta_msr_wait); 823 826 824 - if ((port->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { 827 + if (tty_port_check_carrier(&port->port) && (status & UART_MSR_DDCD)) { 825 828 if (status & UART_MSR_DCD) 826 829 wake_up_interruptible(&port->port.open_wait); 827 830 }
+2 -6
drivers/tty/synclink.c
··· 1340 1340 wake_up_interruptible(&info->status_event_wait_q); 1341 1341 wake_up_interruptible(&info->event_wait_q); 1342 1342 1343 - if ( (info->port.flags & ASYNC_CHECK_CD) && 1343 + if (tty_port_check_carrier(&info->port) && 1344 1344 (status & MISCSTATUS_DCD_LATCHED) ) { 1345 1345 if ( debug_level >= DEBUG_LEVEL_ISR ) 1346 1346 printk("%s CD now %s...", info->device_name, ··· 1967 1967 info->timeout += HZ/50; /* Add .02 seconds of slop */ 1968 1968 1969 1969 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); 1970 - 1971 - if (cflag & CLOCAL) 1972 - info->port.flags &= ~ASYNC_CHECK_CD; 1973 - else 1974 - info->port.flags |= ASYNC_CHECK_CD; 1970 + tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); 1975 1971 1976 1972 /* process tty input control flags */ 1977 1973
+2 -6
drivers/tty/synclinkmp.c
··· 2463 2463 wake_up_interruptible(&info->status_event_wait_q); 2464 2464 wake_up_interruptible(&info->event_wait_q); 2465 2465 2466 - if ( (info->port.flags & ASYNC_CHECK_CD) && 2466 + if (tty_port_check_carrier(&info->port) && 2467 2467 (status & MISCSTATUS_DCD_LATCHED) ) { 2468 2468 if ( debug_level >= DEBUG_LEVEL_ISR ) 2469 2469 printk("%s CD now %s...", info->device_name, ··· 2814 2814 info->timeout += HZ/50; /* Add .02 seconds of slop */ 2815 2815 2816 2816 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); 2817 - 2818 - if (cflag & CLOCAL) 2819 - info->port.flags &= ~ASYNC_CHECK_CD; 2820 - else 2821 - info->port.flags |= ASYNC_CHECK_CD; 2817 + tty_port_set_check_carrier(&info->port, ~cflag & CLOCAL); 2822 2818 2823 2819 /* process tty input control flags */ 2824 2820
+13
include/linux/tty.h
··· 584 584 clear_bit(TTY_PORT_ACTIVE, &port->iflags); 585 585 } 586 586 587 + static inline bool tty_port_check_carrier(struct tty_port *port) 588 + { 589 + return test_bit(TTY_PORT_CHECK_CD, &port->iflags); 590 + } 591 + 592 + static inline void tty_port_set_check_carrier(struct tty_port *port, bool val) 593 + { 594 + if (val) 595 + set_bit(TTY_PORT_CHECK_CD, &port->iflags); 596 + else 597 + clear_bit(TTY_PORT_CHECK_CD, &port->iflags); 598 + } 599 + 587 600 extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 588 601 extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 589 602 extern int tty_port_carrier_raised(struct tty_port *port);
+2 -2
net/irda/ircomm/ircomm_tty.c
··· 999 999 if (status & IRCOMM_DCE_DELTA_ANY) { 1000 1000 /*wake_up_interruptible(&self->delta_msr_wait);*/ 1001 1001 } 1002 - if ((self->port.flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) { 1002 + if (tty_port_check_carrier(&self->port) && (status & IRCOMM_DELTA_CD)) { 1003 1003 pr_debug("%s(), ircomm%d CD now %s...\n", __func__ , self->line, 1004 1004 (status & IRCOMM_CD) ? "on" : "off"); 1005 1005 ··· 1255 1255 seq_printf(m, "%cASYNC_CTS_FLOW", sep); 1256 1256 sep = '|'; 1257 1257 } 1258 - if (self->port.flags & ASYNC_CHECK_CD) { 1258 + if (tty_port_check_carrier(&self->port)) { 1259 1259 seq_printf(m, "%cASYNC_CHECK_CD", sep); 1260 1260 sep = '|'; 1261 1261 }
+1 -1
net/irda/ircomm/ircomm_tty_attach.c
··· 968 968 ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); 969 969 ircomm_tty_start_watchdog_timer(self, 3*HZ); 970 970 971 - if (self->port.flags & ASYNC_CHECK_CD) { 971 + if (tty_port_check_carrier(&self->port)) { 972 972 /* Drop carrier */ 973 973 self->settings.dce = IRCOMM_DELTA_CD; 974 974 ircomm_tty_check_modem_status(self);
+1 -4
net/irda/ircomm/ircomm_tty_ioctl.c
··· 96 96 } else { 97 97 self->settings.flow_control &= ~IRCOMM_RTS_CTS_IN; 98 98 } 99 - if (cflag & CLOCAL) 100 - self->port.flags &= ~ASYNC_CHECK_CD; 101 - else 102 - self->port.flags |= ASYNC_CHECK_CD; 99 + tty_port_set_check_carrier(&self->port, ~cflag & CLOCAL); 103 100 #if 0 104 101 /* 105 102 * Set up parity check flag