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

tty/serial: lay the foundations for the next set of reworks

- Stop drivers calling their own flush method indirectly, it obfuscates code
and it will change soon anyway

- A few more lock_kernel paths temporarily needed in some driver internal
waiting code

- Remove private put_char method that does a write call for one char - we
have that anyway

- Most but not yet all of the termios copy under lock fixing (some has other
dependencies to follow)

- Note a few locking bugs in drivers found in the process

- Kill remaining [ab]users of TIOCG/SSOFTCAR in the driver, these must go to
fix the termios locking

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
978e595f ac0e4b7d

+189 -234
+4 -2
drivers/char/amiserial.c
··· 1505 1505 rs_wait_until_sent(tty, info->timeout); 1506 1506 } 1507 1507 shutdown(info); 1508 - if (tty->driver->flush_buffer) 1509 - tty->driver->flush_buffer(tty); 1508 + rs_flush_buffer(tty); 1510 1509 1511 1510 tty_ldisc_flush(tty); 1512 1511 tty->closing = 0; ··· 1538 1539 return; /* Just in case.... */ 1539 1540 1540 1541 orig_jiffies = jiffies; 1542 + 1543 + lock_kernel(); 1541 1544 /* 1542 1545 * Set the check interval to be 1/5 of the estimated time to 1543 1546 * send a single character, and make it at least 1. The check ··· 1580 1579 break; 1581 1580 } 1582 1581 __set_current_state(TASK_RUNNING); 1582 + unlock_kernel(); 1583 1583 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1584 1584 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 1585 1585 #endif
+40 -36
drivers/char/cyclades.c
··· 2522 2522 return; /* Just in case.... */ 2523 2523 2524 2524 orig_jiffies = jiffies; 2525 + lock_kernel(); 2525 2526 /* 2526 2527 * Set the check interval to be 1/5 of the estimated time to 2527 2528 * send a single character, and make it at least 1. The check ··· 2574 2573 } 2575 2574 /* Run one more char cycle */ 2576 2575 msleep_interruptible(jiffies_to_msecs(char_time * 5)); 2576 + unlock_kernel(); 2577 2577 #ifdef CY_DEBUG_WAIT_UNTIL_SENT 2578 2578 printk(KERN_DEBUG "Clean (jiff=%lu)...done\n", jiffies); 2579 2579 #endif 2580 2580 } 2581 + 2582 + static void cy_flush_buffer(struct tty_struct *tty) 2583 + { 2584 + struct cyclades_port *info = tty->driver_data; 2585 + struct cyclades_card *card; 2586 + int channel, retval; 2587 + unsigned long flags; 2588 + 2589 + #ifdef CY_DEBUG_IO 2590 + printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line); 2591 + #endif 2592 + 2593 + if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) 2594 + return; 2595 + 2596 + card = info->card; 2597 + channel = info->line - card->first_line; 2598 + 2599 + spin_lock_irqsave(&card->card_lock, flags); 2600 + info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 2601 + spin_unlock_irqrestore(&card->card_lock, flags); 2602 + 2603 + if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board 2604 + buffers as well */ 2605 + spin_lock_irqsave(&card->card_lock, flags); 2606 + retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L); 2607 + if (retval != 0) { 2608 + printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d " 2609 + "was %x\n", info->line, retval); 2610 + } 2611 + spin_unlock_irqrestore(&card->card_lock, flags); 2612 + } 2613 + tty_wakeup(tty); 2614 + } /* cy_flush_buffer */ 2615 + 2581 2616 2582 2617 /* 2583 2618 * This routine is called when a particular tty device is closed. ··· 2726 2689 2727 2690 spin_unlock_irqrestore(&card->card_lock, flags); 2728 2691 shutdown(info); 2729 - if (tty->driver->flush_buffer) 2730 - tty->driver->flush_buffer(tty); 2692 + cy_flush_buffer(tty); 2731 2693 tty_ldisc_flush(tty); 2732 2694 spin_lock_irqsave(&card->card_lock, flags); 2733 2695 ··· 2917 2881 int char_count; 2918 2882 __u32 tx_put, tx_get, tx_bufsize; 2919 2883 2884 + lock_kernel(); 2920 2885 firm_id = card->base_addr + ID_ADDRESS; 2921 2886 zfw_ctrl = card->base_addr + 2922 2887 (readl(&firm_id->zfwctrl_addr) & 0xfffff); ··· 2935 2898 printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n", 2936 2899 info->line, info->xmit_cnt + char_count); 2937 2900 #endif 2901 + unlock_kernel(); 2938 2902 return info->xmit_cnt + char_count; 2939 2903 } 2940 2904 #endif /* Z_EXT_CHARS_IN_BUFFER */ ··· 4308 4270 spin_unlock_irqrestore(&cinfo->card_lock, flags); 4309 4271 } 4310 4272 } /* cy_start */ 4311 - 4312 - static void cy_flush_buffer(struct tty_struct *tty) 4313 - { 4314 - struct cyclades_port *info = tty->driver_data; 4315 - struct cyclades_card *card; 4316 - int channel, retval; 4317 - unsigned long flags; 4318 - 4319 - #ifdef CY_DEBUG_IO 4320 - printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line); 4321 - #endif 4322 - 4323 - if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) 4324 - return; 4325 - 4326 - card = info->card; 4327 - channel = info->line - card->first_line; 4328 - 4329 - spin_lock_irqsave(&card->card_lock, flags); 4330 - info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 4331 - spin_unlock_irqrestore(&card->card_lock, flags); 4332 - 4333 - if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board 4334 - buffers as well */ 4335 - spin_lock_irqsave(&card->card_lock, flags); 4336 - retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L); 4337 - if (retval != 0) { 4338 - printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d " 4339 - "was %x\n", info->line, retval); 4340 - } 4341 - spin_unlock_irqrestore(&card->card_lock, flags); 4342 - } 4343 - tty_wakeup(tty); 4344 - } /* cy_flush_buffer */ 4345 4273 4346 4274 /* 4347 4275 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
+2 -11
drivers/char/epca.c
··· 157 157 static void pc_close(struct tty_struct *, struct file *); 158 158 static void shutdown(struct channel *); 159 159 static void pc_hangup(struct tty_struct *); 160 - static void pc_put_char(struct tty_struct *, unsigned char); 161 160 static int pc_write_room(struct tty_struct *); 162 161 static int pc_chars_in_buffer(struct tty_struct *); 163 162 static void pc_flush_buffer(struct tty_struct *); ··· 458 459 setup_empty_event(tty, ch); 459 460 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 460 461 } 461 - if (tty->driver->flush_buffer) 462 - tty->driver->flush_buffer(tty); 462 + pc_flush_buffer(tty); 463 463 464 464 tty_ldisc_flush(tty); 465 465 shutdown(ch); ··· 530 532 if ((ch = verifyChannel(tty)) != NULL) { 531 533 unsigned long flags; 532 534 533 - if (tty->driver->flush_buffer) 534 - tty->driver->flush_buffer(tty); 535 + pc_flush_buffer(tty); 535 536 tty_ldisc_flush(tty); 536 537 shutdown(ch); 537 538 ··· 640 643 memoff(ch); 641 644 spin_unlock_irqrestore(&epca_lock, flags); 642 645 return amountCopied; 643 - } 644 - 645 - static void pc_put_char(struct tty_struct *tty, unsigned char c) 646 - { 647 - pc_write(tty, &c, 1); 648 646 } 649 647 650 648 static int pc_write_room(struct tty_struct *tty) ··· 1027 1035 .flush_buffer = pc_flush_buffer, 1028 1036 .chars_in_buffer = pc_chars_in_buffer, 1029 1037 .flush_chars = pc_flush_chars, 1030 - .put_char = pc_put_char, 1031 1038 .ioctl = pc_ioctl, 1032 1039 .set_termios = pc_set_termios, 1033 1040 .stop = pc_stop,
+1 -2
drivers/char/esp.c
··· 1994 1994 rs_wait_until_sent(tty, info->timeout); 1995 1995 } 1996 1996 shutdown(info); 1997 - if (tty->driver->flush_buffer) 1998 - tty->driver->flush_buffer(tty); 1997 + rs_flush_buffer(tty); 1999 1998 tty_ldisc_flush(tty); 2000 1999 tty->closing = 0; 2001 2000 info->tty = NULL;
+1 -2
drivers/char/generic_serial.c
··· 586 586 587 587 port->flags &= ~GS_ACTIVE; 588 588 589 - if (tty->driver->flush_buffer) 590 - tty->driver->flush_buffer(tty); 589 + gs_flush_buffer(tty); 591 590 592 591 tty_ldisc_flush(tty); 593 592 tty->closing = 0;
+17 -18
drivers/char/isicom.c
··· 1012 1012 } 1013 1013 } 1014 1014 1015 + static void isicom_flush_buffer(struct tty_struct *tty) 1016 + { 1017 + struct isi_port *port = tty->driver_data; 1018 + struct isi_board *card = port->card; 1019 + unsigned long flags; 1020 + 1021 + if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer")) 1022 + return; 1023 + 1024 + spin_lock_irqsave(&card->card_lock, flags); 1025 + port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1026 + spin_unlock_irqrestore(&card->card_lock, flags); 1027 + 1028 + tty_wakeup(tty); 1029 + } 1030 + 1015 1031 static void isicom_close(struct tty_struct *tty, struct file *filp) 1016 1032 { 1017 1033 struct isi_port *port = tty->driver_data; ··· 1081 1065 isicom_shutdown_port(port); 1082 1066 spin_unlock_irqrestore(&card->card_lock, flags); 1083 1067 1084 - if (tty->driver->flush_buffer) 1085 - tty->driver->flush_buffer(tty); 1068 + isicom_flush_buffer(tty); 1086 1069 tty_ldisc_flush(tty); 1087 1070 1088 1071 spin_lock_irqsave(&card->card_lock, flags); ··· 1462 1447 wake_up_interruptible(&port->open_wait); 1463 1448 } 1464 1449 1465 - /* flush_buffer et all */ 1466 - static void isicom_flush_buffer(struct tty_struct *tty) 1467 - { 1468 - struct isi_port *port = tty->driver_data; 1469 - struct isi_board *card = port->card; 1470 - unsigned long flags; 1471 - 1472 - if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer")) 1473 - return; 1474 - 1475 - spin_lock_irqsave(&card->card_lock, flags); 1476 - port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1477 - spin_unlock_irqrestore(&card->card_lock, flags); 1478 - 1479 - tty_wakeup(tty); 1480 - } 1481 1450 1482 1451 /* 1483 1452 * Driver init and deinit functions
+2
drivers/char/moxa.c
··· 1280 1280 */ 1281 1281 if (ch == NULL) 1282 1282 return 0; 1283 + lock_kernel(); 1283 1284 chars = MoxaPortTxQueue(ch); 1284 1285 if (chars) { 1285 1286 /* ··· 1290 1289 if (!(ch->statusflags & EMPTYWAIT)) 1291 1290 moxa_setup_empty_event(tty); 1292 1291 } 1292 + unlock_kernel(); 1293 1293 return chars; 1294 1294 } 1295 1295
+24 -23
drivers/char/mxser.c
··· 927 927 return 0; 928 928 } 929 929 930 + static void mxser_flush_buffer(struct tty_struct *tty) 931 + { 932 + struct mxser_port *info = tty->driver_data; 933 + char fcr; 934 + unsigned long flags; 935 + 936 + 937 + spin_lock_irqsave(&info->slock, flags); 938 + info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 939 + 940 + fcr = inb(info->ioaddr + UART_FCR); 941 + outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 942 + info->ioaddr + UART_FCR); 943 + outb(fcr, info->ioaddr + UART_FCR); 944 + 945 + spin_unlock_irqrestore(&info->slock, flags); 946 + 947 + tty_wakeup(tty); 948 + } 949 + 950 + 930 951 /* 931 952 * This routine is called when the serial port gets closed. First, we 932 953 * wait for the last remaining data to be sent. Then, we unlink its ··· 1034 1013 } 1035 1014 mxser_shutdown(info); 1036 1015 1037 - if (tty->driver->flush_buffer) 1038 - tty->driver->flush_buffer(tty); 1039 - 1016 + mxser_flush_buffer(tty); 1040 1017 tty_ldisc_flush(tty); 1041 1018 1042 1019 tty->closing = 0; ··· 1159 1140 { 1160 1141 struct mxser_port *info = tty->driver_data; 1161 1142 return info->xmit_cnt; 1162 - } 1163 - 1164 - static void mxser_flush_buffer(struct tty_struct *tty) 1165 - { 1166 - struct mxser_port *info = tty->driver_data; 1167 - char fcr; 1168 - unsigned long flags; 1169 - 1170 - 1171 - spin_lock_irqsave(&info->slock, flags); 1172 - info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1173 - 1174 - fcr = inb(info->ioaddr + UART_FCR); 1175 - outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 1176 - info->ioaddr + UART_FCR); 1177 - outb(fcr, info->ioaddr + UART_FCR); 1178 - 1179 - spin_unlock_irqrestore(&info->slock, flags); 1180 - 1181 - tty_wakeup(tty); 1182 1143 } 1183 1144 1184 1145 /* ··· 1991 1992 timeout, char_time); 1992 1993 printk("jiff=%lu...", jiffies); 1993 1994 #endif 1995 + lock_kernel(); 1994 1996 while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) { 1995 1997 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1996 1998 printk("lsr = %d (jiff=%lu)...", lsr, jiffies); ··· 2003 2003 break; 2004 2004 } 2005 2005 set_current_state(TASK_RUNNING); 2006 + unlock_kernel(); 2006 2007 2007 2008 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 2008 2009 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
+2 -11
drivers/char/nozomi.c
··· 1724 1724 const struct ctrl_dl *ctrl_dl = &port->ctrl_dl; 1725 1725 const struct ctrl_ul *ctrl_ul = &port->ctrl_ul; 1726 1726 1727 + /* Note: these could change under us but it is not clear this 1728 + matters if so */ 1727 1729 return (ctrl_ul->RTS ? TIOCM_RTS : 0) | 1728 1730 (ctrl_ul->DTR ? TIOCM_DTR : 0) | 1729 1731 (ctrl_dl->DCD ? TIOCM_CAR : 0) | ··· 1851 1849 spin_unlock_irqrestore(&dc->spin_mutex, flags); 1852 1850 } 1853 1851 1854 - /* just to discard single character writes */ 1855 - static void ntty_put_char(struct tty_struct *tty, unsigned char c) 1856 - { 1857 - /* 1858 - * card does not react correct when we write single chars 1859 - * to the card, so we discard them 1860 - */ 1861 - DBG2("PUT CHAR Function: %c", c); 1862 - } 1863 - 1864 1852 /* Returns number of chars in buffer, called by tty layer */ 1865 1853 static s32 ntty_chars_in_buffer(struct tty_struct *tty) 1866 1854 { ··· 1884 1892 .unthrottle = ntty_unthrottle, 1885 1893 .throttle = ntty_throttle, 1886 1894 .chars_in_buffer = ntty_chars_in_buffer, 1887 - .put_char = ntty_put_char, 1888 1895 .tiocmget = ntty_tiocmget, 1889 1896 .tiocmset = ntty_tiocmset, 1890 1897 };
+19 -19
drivers/char/riscom8.c
··· 1015 1015 return 0; 1016 1016 } 1017 1017 1018 + static void rc_flush_buffer(struct tty_struct *tty) 1019 + { 1020 + struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1021 + unsigned long flags; 1022 + 1023 + if (rc_paranoia_check(port, tty->name, "rc_flush_buffer")) 1024 + return; 1025 + 1026 + spin_lock_irqsave(&riscom_lock, flags); 1027 + 1028 + port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1029 + 1030 + spin_unlock_irqrestore(&riscom_lock, flags); 1031 + 1032 + tty_wakeup(tty); 1033 + } 1034 + 1035 + 1018 1036 static void rc_close(struct tty_struct * tty, struct file * filp) 1019 1037 { 1020 1038 struct riscom_port *port = (struct riscom_port *) tty->driver_data; ··· 1096 1078 } 1097 1079 } 1098 1080 rc_shutdown_port(bp, port); 1099 - if (tty->driver->flush_buffer) 1100 - tty->driver->flush_buffer(tty); 1081 + rc_flush_buffer(tty); 1101 1082 tty_ldisc_flush(tty); 1102 1083 1103 1084 tty->closing = 0; ··· 1228 1211 return 0; 1229 1212 1230 1213 return port->xmit_cnt; 1231 - } 1232 - 1233 - static void rc_flush_buffer(struct tty_struct *tty) 1234 - { 1235 - struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1236 - unsigned long flags; 1237 - 1238 - if (rc_paranoia_check(port, tty->name, "rc_flush_buffer")) 1239 - return; 1240 - 1241 - spin_lock_irqsave(&riscom_lock, flags); 1242 - 1243 - port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1244 - 1245 - spin_unlock_irqrestore(&riscom_lock, flags); 1246 - 1247 - tty_wakeup(tty); 1248 1214 } 1249 1215 1250 1216 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
+2
drivers/char/rocket.c
··· 1585 1585 jiffies); 1586 1586 printk(KERN_INFO "cps=%d...\n", info->cps); 1587 1587 #endif 1588 + lock_kernel(); 1588 1589 while (1) { 1589 1590 txcnt = sGetTxCnt(cp); 1590 1591 if (!txcnt) { ··· 1613 1612 break; 1614 1613 } 1615 1614 __set_current_state(TASK_RUNNING); 1615 + unlock_kernel(); 1616 1616 #ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT 1617 1617 printk(KERN_INFO "txcnt = %d (jiff=%lu)...done\n", txcnt, jiffies); 1618 1618 #endif
+1 -2
drivers/char/serial167.c
··· 1674 1674 if (info->flags & ASYNC_INITIALIZED) 1675 1675 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 1676 1676 shutdown(info); 1677 - if (tty->driver->flush_buffer) 1678 - tty->driver->flush_buffer(tty); 1677 + cy_flush_buffer(tty); 1679 1678 tty_ldisc_flush(tty); 1680 1679 info->tty = NULL; 1681 1680 if (info->blocked_open) {
+22 -24
drivers/char/specialix.c
··· 1504 1504 return 0; 1505 1505 } 1506 1506 1507 + static void sx_flush_buffer(struct tty_struct *tty) 1508 + { 1509 + struct specialix_port *port = (struct specialix_port *)tty->driver_data; 1510 + unsigned long flags; 1511 + struct specialix_board * bp; 1512 + 1513 + func_enter(); 1514 + 1515 + if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) { 1516 + func_exit(); 1517 + return; 1518 + } 1519 + 1520 + bp = port_Board(port); 1521 + spin_lock_irqsave(&port->lock, flags); 1522 + port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1523 + spin_unlock_irqrestore(&port->lock, flags); 1524 + tty_wakeup(tty); 1525 + 1526 + func_exit(); 1527 + } 1507 1528 1508 1529 static void sx_close(struct tty_struct * tty, struct file * filp) 1509 1530 { ··· 1618 1597 } 1619 1598 1620 1599 sx_shutdown_port(bp, port); 1621 - if (tty->driver->flush_buffer) 1622 - tty->driver->flush_buffer(tty); 1600 + sx_flush_buffer(tty); 1623 1601 tty_ldisc_flush(tty); 1624 1602 spin_lock_irqsave(&port->lock, flags); 1625 1603 tty->closing = 0; ··· 1789 1769 return port->xmit_cnt; 1790 1770 } 1791 1771 1792 - 1793 - static void sx_flush_buffer(struct tty_struct *tty) 1794 - { 1795 - struct specialix_port *port = (struct specialix_port *)tty->driver_data; 1796 - unsigned long flags; 1797 - struct specialix_board * bp; 1798 - 1799 - func_enter(); 1800 - 1801 - if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) { 1802 - func_exit(); 1803 - return; 1804 - } 1805 - 1806 - bp = port_Board(port); 1807 - spin_lock_irqsave(&port->lock, flags); 1808 - port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1809 - spin_unlock_irqrestore(&port->lock, flags); 1810 - tty_wakeup(tty); 1811 - 1812 - func_exit(); 1813 - } 1814 1772 1815 1773 1816 1774 static int sx_tiocmget(struct tty_struct *tty, struct file *file)
+2
drivers/char/stallion.c
··· 875 875 timeout = HZ; 876 876 tend = jiffies + timeout; 877 877 878 + lock_kernel(); 878 879 while (stl_datastate(portp)) { 879 880 if (signal_pending(current)) 880 881 break; ··· 883 882 if (time_after_eq(jiffies, tend)) 884 883 break; 885 884 } 885 + unlock_kernel(); 886 886 } 887 887 888 888 /*****************************************************************************/
+4 -3
drivers/char/synclink.c
··· 3157 3157 if (info->flags & ASYNC_INITIALIZED) 3158 3158 mgsl_wait_until_sent(tty, info->timeout); 3159 3159 3160 - if (tty->driver->flush_buffer) 3161 - tty->driver->flush_buffer(tty); 3160 + mgsl_flush_buffer(tty); 3162 3161 3163 3162 tty_ldisc_flush(tty); 3164 3163 ··· 3220 3221 * interval should also be less than the timeout. 3221 3222 * Note: use tight timings here to satisfy the NIST-PCTS. 3222 3223 */ 3223 - 3224 + 3225 + lock_kernel(); 3224 3226 if ( info->params.data_rate ) { 3225 3227 char_time = info->timeout/(32 * 5); 3226 3228 if (!char_time) ··· 3251 3251 break; 3252 3252 } 3253 3253 } 3254 + unlock_kernel(); 3254 3255 3255 3256 exit: 3256 3257 if (debug_level >= DEBUG_LEVEL_INFO)
+6 -2
drivers/char/synclinkmp.c
··· 862 862 if (info->flags & ASYNC_INITIALIZED) 863 863 wait_until_sent(tty, info->timeout); 864 864 865 - if (tty->driver->flush_buffer) 866 - tty->driver->flush_buffer(tty); 865 + flush_buffer(tty); 867 866 868 867 tty_ldisc_flush(tty); 869 868 ··· 1118 1119 if (sanity_check(info, tty->name, "wait_until_sent")) 1119 1120 return; 1120 1121 1122 + lock_kernel(); 1123 + 1121 1124 if (!(info->flags & ASYNC_INITIALIZED)) 1122 1125 goto exit; 1123 1126 ··· 1162 1161 } 1163 1162 1164 1163 exit: 1164 + unlock_kernel(); 1165 1165 if (debug_level >= DEBUG_LEVEL_INFO) 1166 1166 printk("%s(%d):%s wait_until_sent() exit\n", 1167 1167 __FILE__,__LINE__, info->device_name ); ··· 1178 1176 if (sanity_check(info, tty->name, "write_room")) 1179 1177 return 0; 1180 1178 1179 + lock_kernel(); 1181 1180 if (info->params.mode == MGSL_MODE_HDLC) { 1182 1181 ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE; 1183 1182 } else { ··· 1186 1183 if (ret < 0) 1187 1184 ret = 0; 1188 1185 } 1186 + unlock_kernel(); 1189 1187 1190 1188 if (debug_level >= DEBUG_LEVEL_INFO) 1191 1189 printk("%s(%d):%s write_room()=%d\n",
+1 -1
drivers/char/tty_io.c
··· 1204 1204 * not in the foreground, send a SIGTTOU. If the signal is blocked or 1205 1205 * ignored, go ahead and perform the operation. (POSIX 7.2) 1206 1206 * 1207 - * Locking: ctrl_lock - FIXME: review this 1207 + * Locking: ctrl_lock 1208 1208 */ 1209 1209 1210 1210 int tty_check_change(struct tty_struct *tty)
+12 -2
drivers/char/tty_ioctl.c
··· 396 396 static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) 397 397 { 398 398 int canon_change; 399 - struct ktermios old_termios = *tty->termios; 399 + struct ktermios old_termios; 400 400 struct tty_ldisc *ld; 401 401 unsigned long flags; 402 402 ··· 408 408 /* FIXME: we need to decide on some locking/ordering semantics 409 409 for the set_termios notification eventually */ 410 410 mutex_lock(&tty->termios_mutex); 411 - 411 + old_termios = *tty->termios; 412 412 *tty->termios = *new_termios; 413 413 unset_locked_termios(tty->termios, &old_termios, tty->termios_locked); 414 414 canon_change = (old_termios.c_lflag ^ tty->termios->c_lflag) & ICANON; ··· 480 480 if (retval) 481 481 return retval; 482 482 483 + mutex_lock(&tty->termios_mutex); 483 484 memcpy(&tmp_termios, tty->termios, sizeof(struct ktermios)); 485 + mutex_unlock(&tty->termios_mutex); 484 486 485 487 if (opt & TERMIOS_TERMIO) { 486 488 if (user_termio_to_kernel_termios(&tmp_termios, ··· 668 666 { 669 667 struct tchars tmp; 670 668 669 + mutex_lock(&tty->termios_mutex); 671 670 tmp.t_intrc = tty->termios->c_cc[VINTR]; 672 671 tmp.t_quitc = tty->termios->c_cc[VQUIT]; 673 672 tmp.t_startc = tty->termios->c_cc[VSTART]; 674 673 tmp.t_stopc = tty->termios->c_cc[VSTOP]; 675 674 tmp.t_eofc = tty->termios->c_cc[VEOF]; 676 675 tmp.t_brkc = tty->termios->c_cc[VEOL2]; /* what is brkc anyway? */ 676 + mutex_unlock(&tty->termios_mutex); 677 677 return copy_to_user(tchars, &tmp, sizeof(tmp)) ? -EFAULT : 0; 678 678 } 679 679 ··· 685 681 686 682 if (copy_from_user(&tmp, tchars, sizeof(tmp))) 687 683 return -EFAULT; 684 + mutex_lock(&tty->termios_mutex); 688 685 tty->termios->c_cc[VINTR] = tmp.t_intrc; 689 686 tty->termios->c_cc[VQUIT] = tmp.t_quitc; 690 687 tty->termios->c_cc[VSTART] = tmp.t_startc; 691 688 tty->termios->c_cc[VSTOP] = tmp.t_stopc; 692 689 tty->termios->c_cc[VEOF] = tmp.t_eofc; 693 690 tty->termios->c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */ 691 + mutex_unlock(&tty->termios_mutex); 694 692 return 0; 695 693 } 696 694 #endif ··· 702 696 { 703 697 struct ltchars tmp; 704 698 699 + mutex_lock(&tty->termios_mutex); 705 700 tmp.t_suspc = tty->termios->c_cc[VSUSP]; 706 701 /* what is dsuspc anyway? */ 707 702 tmp.t_dsuspc = tty->termios->c_cc[VSUSP]; ··· 711 704 tmp.t_flushc = tty->termios->c_cc[VEOL2]; 712 705 tmp.t_werasc = tty->termios->c_cc[VWERASE]; 713 706 tmp.t_lnextc = tty->termios->c_cc[VLNEXT]; 707 + mutex_unlock(&tty->termios_mutex); 714 708 return copy_to_user(ltchars, &tmp, sizeof(tmp)) ? -EFAULT : 0; 715 709 } 716 710 ··· 722 714 if (copy_from_user(&tmp, ltchars, sizeof(tmp))) 723 715 return -EFAULT; 724 716 717 + mutex_lock(&tty->termios_mutex); 725 718 tty->termios->c_cc[VSUSP] = tmp.t_suspc; 726 719 /* what is dsuspc anyway? */ 727 720 tty->termios->c_cc[VEOL2] = tmp.t_dsuspc; ··· 731 722 tty->termios->c_cc[VEOL2] = tmp.t_flushc; 732 723 tty->termios->c_cc[VWERASE] = tmp.t_werasc; 733 724 tty->termios->c_cc[VLNEXT] = tmp.t_lnextc; 725 + mutex_unlock(&tty->termios_mutex); 734 726 return 0; 735 727 } 736 728 #endif
+1 -3
drivers/isdn/i4l/isdn_tty.c
··· 1708 1708 } 1709 1709 dev->modempoll--; 1710 1710 isdn_tty_shutdown(info); 1711 - 1712 - if (tty->driver->flush_buffer) 1713 - tty->driver->flush_buffer(tty); 1711 + isdn_tty_flush_buffer(tty); 1714 1712 tty_ldisc_flush(tty); 1715 1713 info->tty = NULL; 1716 1714 info->ncarrier = 0;
+1 -17
drivers/serial/68328serial.c
··· 1017 1017 tty_wait_until_sent(tty, 0); 1018 1018 send_break(info, arg ? arg*(100) : 250); 1019 1019 return 0; 1020 - case TIOCGSOFTCAR: 1021 - error = put_user(C_CLOCAL(tty) ? 1 : 0, 1022 - (unsigned long *) arg); 1023 - if (error) 1024 - return error; 1025 - return 0; 1026 - case TIOCSSOFTCAR: 1027 - get_user(arg, (unsigned long *) arg); 1028 - tty->termios->c_cflag = 1029 - ((tty->termios->c_cflag & ~CLOCAL) | 1030 - (arg ? CLOCAL : 0)); 1031 - return 0; 1032 1020 case TIOCGSERIAL: 1033 1021 if (access_ok(VERIFY_WRITE, (void *) arg, 1034 1022 sizeof(struct serial_struct))) ··· 1048 1060 static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1049 1061 { 1050 1062 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; 1051 - 1052 - if (tty->termios->c_cflag == old_termios->c_cflag) 1053 - return; 1054 1063 1055 1064 change_speed(info); 1056 1065 ··· 1125 1140 uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); 1126 1141 1127 1142 shutdown(info); 1128 - if (tty->driver->flush_buffer) 1129 - tty->driver->flush_buffer(tty); 1143 + rs_flush_buffer(tty); 1130 1144 1131 1145 tty_ldisc_flush(tty); 1132 1146 tty->closing = 0;
+3 -14
drivers/serial/68360serial.c
··· 1436 1436 return retval; 1437 1437 end_break(info); 1438 1438 return 0; 1439 - case TIOCGSOFTCAR: 1440 - /* return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); */ 1441 - put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); 1442 - return 0; 1443 - case TIOCSSOFTCAR: 1444 - error = get_user(arg, (unsigned int *) arg); 1445 - if (error) 1446 - return error; 1447 - tty->termios->c_cflag = 1448 - ((tty->termios->c_cflag & ~CLOCAL) | 1449 - (arg ? CLOCAL : 0)); 1450 - return 0; 1451 1439 #ifdef maybe 1452 1440 case TIOCSERGETLSR: /* Get line status register */ 1453 1441 return get_lsr_info(info, (unsigned int *) arg); ··· 1653 1665 rs_360_wait_until_sent(tty, info->timeout); 1654 1666 } 1655 1667 shutdown(info); 1656 - if (tty->driver->flush_buffer) 1657 - tty->driver->flush_buffer(tty); 1668 + rs_360_flush_buffer(tty); 1658 1669 tty_ldisc_flush(tty); 1659 1670 tty->closing = 0; 1660 1671 info->event = 0; ··· 1704 1717 printk("jiff=%lu...", jiffies); 1705 1718 #endif 1706 1719 1720 + lock_kernel(); 1707 1721 /* We go through the loop at least once because we can't tell 1708 1722 * exactly when the last character exits the shifter. There can 1709 1723 * be at least two characters waiting to be sent after the buffers ··· 1733 1745 bdp--; 1734 1746 } while (bdp->status & BD_SC_READY); 1735 1747 current->state = TASK_RUNNING; 1748 + unlock_kernel(); 1736 1749 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1737 1750 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 1738 1751 #endif
+11 -12
drivers/serial/crisv10.c
··· 3581 3581 unsigned int set, unsigned int clear) 3582 3582 { 3583 3583 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3584 + unsigned long flags; 3584 3585 3585 - lock_kernel(); 3586 + local_irq_save(flags); 3586 3587 3587 3588 if (clear & TIOCM_RTS) 3588 3589 e100_rts(info, 0); ··· 3605 3604 if (set & TIOCM_CD) 3606 3605 e100_cd_out(info, 1); 3607 3606 3608 - unlock_kernel(); 3607 + local_irq_restore(flags); 3609 3608 return 0; 3610 3609 } 3611 3610 ··· 3614 3613 { 3615 3614 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3616 3615 unsigned int result; 3616 + unsigned long flags; 3617 3617 3618 - lock_kernel(); 3618 + local_irq_save(flags); 3619 + 3619 3620 result = 3620 3621 (!E100_RTS_GET(info) ? TIOCM_RTS : 0) 3621 3622 | (!E100_DTR_GET(info) ? TIOCM_DTR : 0) ··· 3626 3623 | (!E100_CD_GET(info) ? TIOCM_CAR : 0) 3627 3624 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0); 3628 3625 3629 - unlock_kernel(); 3626 + local_irq_restore(flags); 3630 3627 3631 3628 #ifdef SERIAL_DEBUG_IO 3632 3629 printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n", ··· 3704 3701 rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 3705 3702 { 3706 3703 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3707 - 3708 - if (tty->termios->c_cflag == old_termios->c_cflag && 3709 - tty->termios->c_iflag == old_termios->c_iflag) 3710 - return; 3711 3704 3712 3705 change_speed(info); 3713 3706 ··· 3807 3808 #endif 3808 3809 3809 3810 shutdown(info); 3810 - if (tty->driver->flush_buffer) 3811 - tty->driver->flush_buffer(tty); 3812 - if (tty->ldisc.flush_buffer) 3813 - tty->ldisc.flush_buffer(tty); 3811 + rs_flush_buffer(tty); 3812 + tty_ldisc_flush_buffer(tty); 3814 3813 tty->closing = 0; 3815 3814 info->event = 0; 3816 3815 info->tty = 0; ··· 3882 3885 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO 3883 3886 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k) 3884 3887 */ 3888 + lock_kernel(); 3885 3889 orig_jiffies = jiffies; 3886 3890 while (info->xmit.head != info->xmit.tail || /* More in send queue */ 3887 3891 (*info->ostatusadr & 0x007f) || /* more in FIFO */ ··· 3899 3901 curr_time_usec - info->last_tx_active_usec; 3900 3902 } 3901 3903 set_current_state(TASK_RUNNING); 3904 + unlock_kernel(); 3902 3905 } 3903 3906 3904 3907 /*
+4 -14
drivers/serial/mcfserial.c
··· 1072 1072 tty_wait_until_sent(tty, 0); 1073 1073 send_break(info, arg ? arg*(HZ/10) : HZ/4); 1074 1074 return 0; 1075 - case TIOCGSOFTCAR: 1076 - error = put_user(C_CLOCAL(tty) ? 1 : 0, 1077 - (unsigned long *) arg); 1078 - if (error) 1079 - return error; 1080 - return 0; 1081 - case TIOCSSOFTCAR: 1082 - get_user(arg, (unsigned long *) arg); 1083 - tty->termios->c_cflag = 1084 - ((tty->termios->c_cflag & ~CLOCAL) | 1085 - (arg ? CLOCAL : 0)); 1086 - return 0; 1087 1075 case TIOCGSERIAL: 1088 1076 if (access_ok(VERIFY_WRITE, (void *) arg, 1089 1077 sizeof(struct serial_struct))) ··· 1210 1222 } else 1211 1223 #endif 1212 1224 shutdown(info); 1213 - if (tty->driver->flush_buffer) 1214 - tty->driver->flush_buffer(tty); 1225 + mcfrs_flush_buffer(tty); 1215 1226 tty_ldisc_flush(tty); 1216 1227 1217 1228 tty->closing = 0; ··· 1263 1276 * Note: we have to use pretty tight timings here to satisfy 1264 1277 * the NIST-PCTS. 1265 1278 */ 1279 + lock_kernel(); 1280 + 1266 1281 fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud; 1267 1282 char_time = fifo_time / 5; 1268 1283 if (char_time == 0) ··· 1301 1312 if (timeout && time_after(jiffies, orig_jiffies + timeout)) 1302 1313 break; 1303 1314 } 1315 + unlock_kernel(); 1304 1316 #else 1305 1317 /* 1306 1318 * For the other coldfire models, assume all data has been sent
+1
drivers/serial/netx-serial.c
··· 287 287 { 288 288 unsigned int val; 289 289 290 + /* FIXME: Locking needed ? */ 290 291 if (mctrl & TIOCM_RTS) { 291 292 val = readl(port->membase + UART_RTS_CR); 292 293 writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR);