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

Merge tag 'tty-3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial driver update from Greg Kroah-Hartman:
"Here's the big tty/serial driver merge request for 3.10-rc1

Once again, Jiri has a number of TTY driver fixes and cleanups, and
Peter Hurley came through with a bunch of ldisc fixes that resolve a
number of reported issues. There are some other serial driver
cleanups as well.

All of these have been in the linux-next tree for a while"

* tag 'tty-3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (117 commits)
tty/serial/sirf: fix MODULE_DEVICE_TABLE
serial: mxs: drop superfluous {get|put}_device
serial: mxs: fix buffer overflow
ARM: PL011: add support for extended FIFO-size of PL011-r1p5
serial_core.c: add put_device() after device_find_child()
tty: Fix unsafe bit ops in tty_throttle_safe/unthrottle_safe
serial: sccnxp: Replace pdata.init/exit with regulator API
serial: sccnxp: Do not override device name
TTY: pty, fix compilation warning
TTY: rocket, fix compilation warning
TTY: ircomm: fix DTR being raised on hang up
TTY: synclinkmp: fix DTR being raised on hang up
TTY: synclink_gt: fix DTR being raised on hang up
TTY: synclink: fix DTR being raised on hang up
serial: 8250_dw: Fix the stub for dw8250_probe_acpi()
serial: 8250_dw: Convert to devm_ioremap()
serial: 8250_dw: Set port capabilities based on CPR register
serial: 8250_dw: Let ACPI code extract the DMA client info
serial: 8250_dw: Support clk framework also with ACPI
serial: 8250_dw: Enable runtime PM
...

+1678 -1619
+4
Documentation/devicetree/bindings/tty/serial/of-serial.txt
··· 33 33 RTAS and should not be registered. 34 34 - no-loopback-test: set to indicate that the port does not implements loopback 35 35 test mode 36 + - fifo-size: the fifo size of the UART. 37 + - auto-flow-control: one way to enable automatic flow control support. The 38 + driver is allowed to detect support for the capability even without this 39 + property. 36 40 37 41 Example: 38 42
+5
arch/arm/mach-s3c24xx/clock-s3c2440.c
··· 123 123 .ctrlbit = S3C2440_CLKCON_AC97, 124 124 }; 125 125 126 + #define S3C24XX_VA_UART0 (S3C_VA_UART) 127 + #define S3C24XX_VA_UART1 (S3C_VA_UART + 0x4000 ) 128 + #define S3C24XX_VA_UART2 (S3C_VA_UART + 0x8000 ) 129 + #define S3C24XX_VA_UART3 (S3C_VA_UART + 0xC000 ) 130 + 126 131 static unsigned long s3c2440_fclk_n_getrate(struct clk *clk) 127 132 { 128 133 unsigned long ucon0, ucon1, ucon2, divisor;
+5
arch/arm/mach-s3c24xx/common.c
··· 239 239 240 240 /* Serial port registrations */ 241 241 242 + #define S3C2410_PA_UART0 (S3C24XX_PA_UART) 243 + #define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 ) 244 + #define S3C2410_PA_UART2 (S3C24XX_PA_UART + 0x8000 ) 245 + #define S3C2443_PA_UART3 (S3C24XX_PA_UART + 0xC000 ) 246 + 242 247 static struct resource s3c2410_uart0_resource[] = { 243 248 [0] = DEFINE_RES_MEM(S3C2410_PA_UART0, SZ_16K), 244 249 [1] = DEFINE_RES_NAMED(IRQ_S3CUART_RX0, \
+1 -281
arch/arm/plat-samsung/include/plat/regs-serial.h
··· 1 - /* arch/arm/plat-samsung/include/plat/regs-serial.h 2 - * 3 - * From linux/include/asm-arm/hardware/serial_s3c2410.h 4 - * 5 - * Internal header file for Samsung S3C2410 serial ports (UART0-2) 6 - * 7 - * Copyright (C) 2002 Shane Nay (shane@minirl.com) 8 - * 9 - * Additional defines, Copyright 2003 Simtec Electronics (linux@simtec.co.uk) 10 - * 11 - * Adapted from: 12 - * 13 - * Internal header file for MX1ADS serial ports (UART1 & 2) 14 - * 15 - * Copyright (C) 2002 Shane Nay (shane@minirl.com) 16 - * 17 - * This program is free software; you can redistribute it and/or modify 18 - * it under the terms of the GNU General Public License as published by 19 - * the Free Software Foundation; either version 2 of the License, or 20 - * (at your option) any later version. 21 - * 22 - * This program is distributed in the hope that it will be useful, 23 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 - * GNU General Public License for more details. 26 - * 27 - * You should have received a copy of the GNU General Public License 28 - * along with this program; if not, write to the Free Software 29 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 - */ 31 - 32 - #ifndef __ASM_ARM_REGS_SERIAL_H 33 - #define __ASM_ARM_REGS_SERIAL_H 34 - 35 - #define S3C24XX_VA_UART0 (S3C_VA_UART) 36 - #define S3C24XX_VA_UART1 (S3C_VA_UART + 0x4000 ) 37 - #define S3C24XX_VA_UART2 (S3C_VA_UART + 0x8000 ) 38 - #define S3C24XX_VA_UART3 (S3C_VA_UART + 0xC000 ) 39 - 40 - #define S3C2410_PA_UART0 (S3C24XX_PA_UART) 41 - #define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 ) 42 - #define S3C2410_PA_UART2 (S3C24XX_PA_UART + 0x8000 ) 43 - #define S3C2443_PA_UART3 (S3C24XX_PA_UART + 0xC000 ) 44 - 45 - #define S3C2410_URXH (0x24) 46 - #define S3C2410_UTXH (0x20) 47 - #define S3C2410_ULCON (0x00) 48 - #define S3C2410_UCON (0x04) 49 - #define S3C2410_UFCON (0x08) 50 - #define S3C2410_UMCON (0x0C) 51 - #define S3C2410_UBRDIV (0x28) 52 - #define S3C2410_UTRSTAT (0x10) 53 - #define S3C2410_UERSTAT (0x14) 54 - #define S3C2410_UFSTAT (0x18) 55 - #define S3C2410_UMSTAT (0x1C) 56 - 57 - #define S3C2410_LCON_CFGMASK ((0xF<<3)|(0x3)) 58 - 59 - #define S3C2410_LCON_CS5 (0x0) 60 - #define S3C2410_LCON_CS6 (0x1) 61 - #define S3C2410_LCON_CS7 (0x2) 62 - #define S3C2410_LCON_CS8 (0x3) 63 - #define S3C2410_LCON_CSMASK (0x3) 64 - 65 - #define S3C2410_LCON_PNONE (0x0) 66 - #define S3C2410_LCON_PEVEN (0x5 << 3) 67 - #define S3C2410_LCON_PODD (0x4 << 3) 68 - #define S3C2410_LCON_PMASK (0x7 << 3) 69 - 70 - #define S3C2410_LCON_STOPB (1<<2) 71 - #define S3C2410_LCON_IRM (1<<6) 72 - 73 - #define S3C2440_UCON_CLKMASK (3<<10) 74 - #define S3C2440_UCON_CLKSHIFT (10) 75 - #define S3C2440_UCON_PCLK (0<<10) 76 - #define S3C2440_UCON_UCLK (1<<10) 77 - #define S3C2440_UCON_PCLK2 (2<<10) 78 - #define S3C2440_UCON_FCLK (3<<10) 79 - #define S3C2443_UCON_EPLL (3<<10) 80 - 81 - #define S3C6400_UCON_CLKMASK (3<<10) 82 - #define S3C6400_UCON_CLKSHIFT (10) 83 - #define S3C6400_UCON_PCLK (0<<10) 84 - #define S3C6400_UCON_PCLK2 (2<<10) 85 - #define S3C6400_UCON_UCLK0 (1<<10) 86 - #define S3C6400_UCON_UCLK1 (3<<10) 87 - 88 - #define S3C2440_UCON2_FCLK_EN (1<<15) 89 - #define S3C2440_UCON0_DIVMASK (15 << 12) 90 - #define S3C2440_UCON1_DIVMASK (15 << 12) 91 - #define S3C2440_UCON2_DIVMASK (7 << 12) 92 - #define S3C2440_UCON_DIVSHIFT (12) 93 - 94 - #define S3C2412_UCON_CLKMASK (3<<10) 95 - #define S3C2412_UCON_CLKSHIFT (10) 96 - #define S3C2412_UCON_UCLK (1<<10) 97 - #define S3C2412_UCON_USYSCLK (3<<10) 98 - #define S3C2412_UCON_PCLK (0<<10) 99 - #define S3C2412_UCON_PCLK2 (2<<10) 100 - 101 - #define S3C2410_UCON_CLKMASK (1 << 10) 102 - #define S3C2410_UCON_CLKSHIFT (10) 103 - #define S3C2410_UCON_UCLK (1<<10) 104 - #define S3C2410_UCON_SBREAK (1<<4) 105 - 106 - #define S3C2410_UCON_TXILEVEL (1<<9) 107 - #define S3C2410_UCON_RXILEVEL (1<<8) 108 - #define S3C2410_UCON_TXIRQMODE (1<<2) 109 - #define S3C2410_UCON_RXIRQMODE (1<<0) 110 - #define S3C2410_UCON_RXFIFO_TOI (1<<7) 111 - #define S3C2443_UCON_RXERR_IRQEN (1<<6) 112 - #define S3C2443_UCON_LOOPBACK (1<<5) 113 - 114 - #define S3C2410_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 115 - S3C2410_UCON_RXILEVEL | \ 116 - S3C2410_UCON_TXIRQMODE | \ 117 - S3C2410_UCON_RXIRQMODE | \ 118 - S3C2410_UCON_RXFIFO_TOI) 119 - 120 - #define S3C2410_UFCON_FIFOMODE (1<<0) 121 - #define S3C2410_UFCON_TXTRIG0 (0<<6) 122 - #define S3C2410_UFCON_RXTRIG8 (1<<4) 123 - #define S3C2410_UFCON_RXTRIG12 (2<<4) 124 - 125 - /* S3C2440 FIFO trigger levels */ 126 - #define S3C2440_UFCON_RXTRIG1 (0<<4) 127 - #define S3C2440_UFCON_RXTRIG8 (1<<4) 128 - #define S3C2440_UFCON_RXTRIG16 (2<<4) 129 - #define S3C2440_UFCON_RXTRIG32 (3<<4) 130 - 131 - #define S3C2440_UFCON_TXTRIG0 (0<<6) 132 - #define S3C2440_UFCON_TXTRIG16 (1<<6) 133 - #define S3C2440_UFCON_TXTRIG32 (2<<6) 134 - #define S3C2440_UFCON_TXTRIG48 (3<<6) 135 - 136 - #define S3C2410_UFCON_RESETBOTH (3<<1) 137 - #define S3C2410_UFCON_RESETTX (1<<2) 138 - #define S3C2410_UFCON_RESETRX (1<<1) 139 - 140 - #define S3C2410_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ 141 - S3C2410_UFCON_TXTRIG0 | \ 142 - S3C2410_UFCON_RXTRIG8 ) 143 - 144 - #define S3C2410_UMCOM_AFC (1<<4) 145 - #define S3C2410_UMCOM_RTS_LOW (1<<0) 146 - 147 - #define S3C2412_UMCON_AFC_63 (0<<5) /* same as s3c2443 */ 148 - #define S3C2412_UMCON_AFC_56 (1<<5) 149 - #define S3C2412_UMCON_AFC_48 (2<<5) 150 - #define S3C2412_UMCON_AFC_40 (3<<5) 151 - #define S3C2412_UMCON_AFC_32 (4<<5) 152 - #define S3C2412_UMCON_AFC_24 (5<<5) 153 - #define S3C2412_UMCON_AFC_16 (6<<5) 154 - #define S3C2412_UMCON_AFC_8 (7<<5) 155 - 156 - #define S3C2410_UFSTAT_TXFULL (1<<9) 157 - #define S3C2410_UFSTAT_RXFULL (1<<8) 158 - #define S3C2410_UFSTAT_TXMASK (15<<4) 159 - #define S3C2410_UFSTAT_TXSHIFT (4) 160 - #define S3C2410_UFSTAT_RXMASK (15<<0) 161 - #define S3C2410_UFSTAT_RXSHIFT (0) 162 - 163 - /* UFSTAT S3C2443 same as S3C2440 */ 164 - #define S3C2440_UFSTAT_TXFULL (1<<14) 165 - #define S3C2440_UFSTAT_RXFULL (1<<6) 166 - #define S3C2440_UFSTAT_TXSHIFT (8) 167 - #define S3C2440_UFSTAT_RXSHIFT (0) 168 - #define S3C2440_UFSTAT_TXMASK (63<<8) 169 - #define S3C2440_UFSTAT_RXMASK (63) 170 - 171 - #define S3C2410_UTRSTAT_TXE (1<<2) 172 - #define S3C2410_UTRSTAT_TXFE (1<<1) 173 - #define S3C2410_UTRSTAT_RXDR (1<<0) 174 - 175 - #define S3C2410_UERSTAT_OVERRUN (1<<0) 176 - #define S3C2410_UERSTAT_FRAME (1<<2) 177 - #define S3C2410_UERSTAT_BREAK (1<<3) 178 - #define S3C2443_UERSTAT_PARITY (1<<1) 179 - 180 - #define S3C2410_UERSTAT_ANY (S3C2410_UERSTAT_OVERRUN | \ 181 - S3C2410_UERSTAT_FRAME | \ 182 - S3C2410_UERSTAT_BREAK) 183 - 184 - #define S3C2410_UMSTAT_CTS (1<<0) 185 - #define S3C2410_UMSTAT_DeltaCTS (1<<2) 186 - 187 - #define S3C2443_DIVSLOT (0x2C) 188 - 189 - /* S3C64XX interrupt registers. */ 190 - #define S3C64XX_UINTP 0x30 191 - #define S3C64XX_UINTSP 0x34 192 - #define S3C64XX_UINTM 0x38 193 - 194 - #define S3C64XX_UINTM_RXD (0) 195 - #define S3C64XX_UINTM_TXD (2) 196 - #define S3C64XX_UINTM_RXD_MSK (1 << S3C64XX_UINTM_RXD) 197 - #define S3C64XX_UINTM_TXD_MSK (1 << S3C64XX_UINTM_TXD) 198 - 199 - /* Following are specific to S5PV210 */ 200 - #define S5PV210_UCON_CLKMASK (1<<10) 201 - #define S5PV210_UCON_CLKSHIFT (10) 202 - #define S5PV210_UCON_PCLK (0<<10) 203 - #define S5PV210_UCON_UCLK (1<<10) 204 - 205 - #define S5PV210_UFCON_TXTRIG0 (0<<8) 206 - #define S5PV210_UFCON_TXTRIG4 (1<<8) 207 - #define S5PV210_UFCON_TXTRIG8 (2<<8) 208 - #define S5PV210_UFCON_TXTRIG16 (3<<8) 209 - #define S5PV210_UFCON_TXTRIG32 (4<<8) 210 - #define S5PV210_UFCON_TXTRIG64 (5<<8) 211 - #define S5PV210_UFCON_TXTRIG128 (6<<8) 212 - #define S5PV210_UFCON_TXTRIG256 (7<<8) 213 - 214 - #define S5PV210_UFCON_RXTRIG1 (0<<4) 215 - #define S5PV210_UFCON_RXTRIG4 (1<<4) 216 - #define S5PV210_UFCON_RXTRIG8 (2<<4) 217 - #define S5PV210_UFCON_RXTRIG16 (3<<4) 218 - #define S5PV210_UFCON_RXTRIG32 (4<<4) 219 - #define S5PV210_UFCON_RXTRIG64 (5<<4) 220 - #define S5PV210_UFCON_RXTRIG128 (6<<4) 221 - #define S5PV210_UFCON_RXTRIG256 (7<<4) 222 - 223 - #define S5PV210_UFSTAT_TXFULL (1<<24) 224 - #define S5PV210_UFSTAT_RXFULL (1<<8) 225 - #define S5PV210_UFSTAT_TXMASK (255<<16) 226 - #define S5PV210_UFSTAT_TXSHIFT (16) 227 - #define S5PV210_UFSTAT_RXMASK (255<<0) 228 - #define S5PV210_UFSTAT_RXSHIFT (0) 229 - 230 - #define S3C2410_UCON_CLKSEL0 (1 << 0) 231 - #define S3C2410_UCON_CLKSEL1 (1 << 1) 232 - #define S3C2410_UCON_CLKSEL2 (1 << 2) 233 - #define S3C2410_UCON_CLKSEL3 (1 << 3) 234 - 235 - /* Default values for s5pv210 UCON and UFCON uart registers */ 236 - #define S5PV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 237 - S3C2410_UCON_RXILEVEL | \ 238 - S3C2410_UCON_TXIRQMODE | \ 239 - S3C2410_UCON_RXIRQMODE | \ 240 - S3C2410_UCON_RXFIFO_TOI | \ 241 - S3C2443_UCON_RXERR_IRQEN) 242 - 243 - #define S5PV210_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ 244 - S5PV210_UFCON_TXTRIG4 | \ 245 - S5PV210_UFCON_RXTRIG4) 246 - 247 - #ifndef __ASSEMBLY__ 248 - 249 - /* configuration structure for per-machine configurations for the 250 - * serial port 251 - * 252 - * the pointer is setup by the machine specific initialisation from the 253 - * arch/arm/mach-s3c2410/ directory. 254 - */ 255 - 256 - struct s3c2410_uartcfg { 257 - unsigned char hwport; /* hardware port number */ 258 - unsigned char unused; 259 - unsigned short flags; 260 - upf_t uart_flags; /* default uart flags */ 261 - unsigned int clk_sel; 262 - 263 - unsigned int has_fracval; 264 - 265 - unsigned long ucon; /* value of ucon for port */ 266 - unsigned long ulcon; /* value of ulcon for port */ 267 - unsigned long ufcon; /* value of ufcon for port */ 268 - }; 269 - 270 - /* s3c24xx_uart_devs 271 - * 272 - * this is exported from the core as we cannot use driver_register(), 273 - * or platform_add_device() before the console_initcall() 274 - */ 275 - 276 - extern struct platform_device *s3c24xx_uart_devs[4]; 277 - 278 - #endif /* __ASSEMBLY__ */ 279 - 280 - #endif /* __ASM_ARM_REGS_SERIAL_H */ 281 - 1 + #include <linux/serial_s3c.h>
+3 -13
arch/ia64/hp/sim/simserial.c
··· 142 142 goto out; 143 143 } 144 144 145 - if (info->xmit.head == info->xmit.tail || tty->stopped || 146 - tty->hw_stopped) { 145 + if (info->xmit.head == info->xmit.tail || tty->stopped) { 147 146 #ifdef SIMSERIAL_DEBUG 148 147 printk("transmit_chars: head=%d, tail=%d, stopped=%d\n", 149 148 info->xmit.head, info->xmit.tail, tty->stopped); ··· 180 181 struct serial_state *info = tty->driver_data; 181 182 182 183 if (info->xmit.head == info->xmit.tail || tty->stopped || 183 - tty->hw_stopped || !info->xmit.buf) 184 + !info->xmit.buf) 184 185 return; 185 186 186 187 transmit_chars(tty, info, NULL); ··· 216 217 * Hey, we transmit directly from here in our case 217 218 */ 218 219 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) && 219 - !tty->stopped && !tty->hw_stopped) 220 + !tty->stopped) 220 221 transmit_chars(tty, info, NULL); 221 222 222 223 return ret; ··· 324 325 325 326 #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 326 327 327 - static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 328 - { 329 - /* Handle turning off CRTSCTS */ 330 - if ((old_termios->c_cflag & CRTSCTS) && 331 - !(tty->termios.c_cflag & CRTSCTS)) { 332 - tty->hw_stopped = 0; 333 - } 334 - } 335 328 /* 336 329 * This routine will shutdown a serial port; interrupts are disabled, and 337 330 * DTR is dropped if the hangup on close termio flag is on. ··· 472 481 .throttle = rs_throttle, 473 482 .unthrottle = rs_unthrottle, 474 483 .send_xchar = rs_send_xchar, 475 - .set_termios = rs_set_termios, 476 484 .hangup = rs_hangup, 477 485 .proc_fops = &rs_proc_fops, 478 486 };
+1 -5
arch/um/drivers/chan_kern.c
··· 568 568 reactivate_fd(chan->fd, irq); 569 569 if (err == -EIO) { 570 570 if (chan->primary) { 571 - struct tty_struct *tty = tty_port_tty_get(&line->port); 572 - if (tty != NULL) { 573 - tty_hangup(tty); 574 - tty_kref_put(tty); 575 - } 571 + tty_port_tty_hangup(&line->port, false); 576 572 if (line->chan_out != chan) 577 573 close_one_chan(line->chan_out, 1); 578 574 }
+1 -7
arch/um/drivers/line.c
··· 248 248 { 249 249 struct chan *chan = data; 250 250 struct line *line = chan->line; 251 - struct tty_struct *tty; 252 251 int err; 253 252 254 253 /* ··· 266 267 } 267 268 spin_unlock(&line->lock); 268 269 269 - tty = tty_port_tty_get(&line->port); 270 - if (tty == NULL) 271 - return IRQ_NONE; 272 - 273 - tty_wakeup(tty); 274 - tty_kref_put(tty); 270 + tty_port_tty_wakeup(&line->port); 275 271 276 272 return IRQ_HANDLED; 277 273 }
+1 -6
drivers/isdn/capi/capi.c
··· 569 569 { 570 570 struct capidev *cdev = ap->private; 571 571 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 572 - struct tty_struct *tty; 573 572 struct capiminor *mp; 574 573 u16 datahandle; 575 574 struct capincci *np; ··· 626 627 CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 2)); 627 628 kfree_skb(skb); 628 629 capiminor_del_ack(mp, datahandle); 629 - tty = tty_port_tty_get(&mp->port); 630 - if (tty) { 631 - tty_wakeup(tty); 632 - tty_kref_put(tty); 633 - } 630 + tty_port_tty_wakeup(&mp->port); 634 631 handle_minor_send(mp); 635 632 636 633 } else {
+1 -5
drivers/isdn/gigaset/interface.c
··· 487 487 static void if_wake(unsigned long data) 488 488 { 489 489 struct cardstate *cs = (struct cardstate *)data; 490 - struct tty_struct *tty = tty_port_tty_get(&cs->port); 491 490 492 - if (tty) { 493 - tty_wakeup(tty); 494 - tty_kref_put(tty); 495 - } 491 + tty_port_tty_wakeup(&cs->port); 496 492 } 497 493 498 494 /*** interface to common ***/
-3
drivers/isdn/i4l/isdn_tty.c
··· 1472 1472 tty->termios.c_ospeed == old_termios->c_ospeed) 1473 1473 return; 1474 1474 isdn_tty_change_speed(info); 1475 - if ((old_termios->c_cflag & CRTSCTS) && 1476 - !(tty->termios.c_cflag & CRTSCTS)) 1477 - tty->hw_stopped = 0; 1478 1475 } 1479 1476 } 1480 1477
+2 -11
drivers/mmc/card/sdio_uart.c
··· 134 134 static void sdio_uart_port_remove(struct sdio_uart_port *port) 135 135 { 136 136 struct sdio_func *func; 137 - struct tty_struct *tty; 138 137 139 138 BUG_ON(sdio_uart_table[port->index] != port); 140 139 ··· 154 155 sdio_claim_host(func); 155 156 port->func = NULL; 156 157 mutex_unlock(&port->func_lock); 157 - tty = tty_port_tty_get(&port->port); 158 158 /* tty_hangup is async so is this safe as is ?? */ 159 - if (tty) { 160 - tty_hangup(tty); 161 - tty_kref_put(tty); 162 - } 159 + tty_port_tty_hangup(&port->port, false); 163 160 mutex_unlock(&port->port.mutex); 164 161 sdio_release_irq(func); 165 162 sdio_disable_func(func); ··· 487 492 wake_up_interruptible(&port->port.open_wait); 488 493 else { 489 494 /* DCD drop - hang up if tty attached */ 490 - tty = tty_port_tty_get(&port->port); 491 - if (tty) { 492 - tty_hangup(tty); 493 - tty_kref_put(tty); 494 - } 495 + tty_port_tty_hangup(&port->port, false); 495 496 } 496 497 } 497 498 if (status & UART_MSR_DCTS) {
+1 -3
drivers/net/caif/caif_serial.c
··· 88 88 { 89 89 ser->tty_status = 90 90 ser->tty->stopped << 5 | 91 - ser->tty->hw_stopped << 4 | 92 91 ser->tty->flow_stopped << 3 | 93 92 ser->tty->packet << 2 | 94 - ser->tty->port->low_latency << 1 | 95 - ser->tty->warned; 93 + ser->tty->port->low_latency << 1; 96 94 } 97 95 static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) 98 96 {
+1 -1
drivers/net/ppp/ppp_async.c
··· 314 314 /* flush our buffers and the serial port's buffer */ 315 315 if (arg == TCIOFLUSH || arg == TCOFLUSH) 316 316 ppp_async_flush_output(ap); 317 - err = tty_perform_flush(tty, arg); 317 + err = n_tty_ioctl_helper(tty, file, cmd, arg); 318 318 break; 319 319 320 320 case FIONREAD:
+1 -1
drivers/net/ppp/ppp_synctty.c
··· 355 355 /* flush our buffers and the serial port's buffer */ 356 356 if (arg == TCIOFLUSH || arg == TCOFLUSH) 357 357 ppp_sync_flush_output(ap); 358 - err = tty_perform_flush(tty, arg); 358 + err = n_tty_ioctl_helper(tty, file, cmd, arg); 359 359 break; 360 360 361 361 case FIONREAD:
+3 -17
drivers/net/usb/hso.c
··· 1925 1925 { 1926 1926 struct hso_serial *serial = urb->context; 1927 1927 int status = urb->status; 1928 - struct tty_struct *tty; 1929 1928 1930 1929 /* sanity check */ 1931 1930 if (!serial) { ··· 1940 1941 return; 1941 1942 } 1942 1943 hso_put_activity(serial->parent); 1943 - tty = tty_port_tty_get(&serial->port); 1944 - if (tty) { 1945 - tty_wakeup(tty); 1946 - tty_kref_put(tty); 1947 - } 1944 + tty_port_tty_wakeup(&serial->port); 1948 1945 hso_kick_transmit(serial); 1949 1946 1950 1947 D1(" "); ··· 2003 2008 put_rxbuf_data_and_resubmit_ctrl_urb(serial); 2004 2009 spin_unlock(&serial->serial_lock); 2005 2010 } else { 2006 - struct tty_struct *tty = tty_port_tty_get(&serial->port); 2007 2011 hso_put_activity(serial->parent); 2008 - if (tty) { 2009 - tty_wakeup(tty); 2010 - tty_kref_put(tty); 2011 - } 2012 + tty_port_tty_wakeup(&serial->port); 2012 2013 /* response to a write command */ 2013 2014 hso_kick_transmit(serial); 2014 2015 } ··· 3124 3133 static void hso_free_interface(struct usb_interface *interface) 3125 3134 { 3126 3135 struct hso_serial *hso_dev; 3127 - struct tty_struct *tty; 3128 3136 int i; 3129 3137 3130 3138 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { 3131 3139 if (serial_table[i] && 3132 3140 (serial_table[i]->interface == interface)) { 3133 3141 hso_dev = dev2ser(serial_table[i]); 3134 - tty = tty_port_tty_get(&hso_dev->port); 3135 - if (tty) { 3136 - tty_hangup(tty); 3137 - tty_kref_put(tty); 3138 - } 3142 + tty_port_tty_hangup(&hso_dev->port, false); 3139 3143 mutex_lock(&hso_dev->parent->mutex); 3140 3144 hso_dev->parent->usb_gone = 1; 3141 3145 mutex_unlock(&hso_dev->parent->mutex);
+2 -7
drivers/s390/char/sclp_tty.c
··· 107 107 static void 108 108 sclp_ttybuf_callback(struct sclp_buffer *buffer, int rc) 109 109 { 110 - struct tty_struct *tty; 111 110 unsigned long flags; 112 111 void *page; 113 112 ··· 124 125 struct sclp_buffer, list); 125 126 spin_unlock_irqrestore(&sclp_tty_lock, flags); 126 127 } while (buffer && sclp_emit_buffer(buffer, sclp_ttybuf_callback)); 127 - /* check if the tty needs a wake up call */ 128 - tty = tty_port_tty_get(&sclp_port); 129 - if (tty != NULL) { 130 - tty_wakeup(tty); 131 - tty_kref_put(tty); 132 - } 128 + 129 + tty_port_tty_wakeup(&sclp_port); 133 130 } 134 131 135 132 static inline void
+1 -7
drivers/s390/char/sclp_vt220.c
··· 114 114 static void 115 115 sclp_vt220_process_queue(struct sclp_vt220_request *request) 116 116 { 117 - struct tty_struct *tty; 118 117 unsigned long flags; 119 118 void *page; 120 119 ··· 138 139 } while (__sclp_vt220_emit(request)); 139 140 if (request == NULL && sclp_vt220_flush_later) 140 141 sclp_vt220_emit_current(); 141 - /* Check if the tty needs a wake up call */ 142 - tty = tty_port_tty_get(&sclp_vt220_port); 143 - if (tty) { 144 - tty_wakeup(tty); 145 - tty_kref_put(tty); 146 - } 142 + tty_port_tty_wakeup(&sclp_vt220_port); 147 143 } 148 144 149 145 #define SCLP_BUFFER_MAX_RETRY 1
+2 -8
drivers/staging/fwserial/fwserial.c
··· 744 744 struct fwtty_transaction *txn) 745 745 { 746 746 struct fwtty_port *port = txn->port; 747 - struct tty_struct *tty; 748 747 int len; 749 748 750 749 fwtty_dbg(port, "rcode: %d", rcode); ··· 768 769 port->stats.dropped += txn->dma_pended.len; 769 770 } 770 771 771 - if (len < WAKEUP_CHARS) { 772 - tty = tty_port_tty_get(&port->port); 773 - if (tty) { 774 - tty_wakeup(tty); 775 - tty_kref_put(tty); 776 - } 777 - } 772 + if (len < WAKEUP_CHARS) 773 + tty_port_tty_wakeup(&port->port); 778 774 } 779 775 780 776 static int fwtty_tx(struct fwtty_port *port, bool drain)
+1 -6
drivers/staging/serqt_usb2/serqt_usb2.c
··· 264 264 265 265 static void qt_write_bulk_callback(struct urb *urb) 266 266 { 267 - struct tty_struct *tty; 268 267 int status; 269 268 struct quatech_port *quatech_port; 270 269 ··· 277 278 278 279 quatech_port = urb->context; 279 280 280 - tty = tty_port_tty_get(&quatech_port->port->port); 281 - 282 - if (tty) 283 - tty_wakeup(tty); 284 - tty_kref_put(tty); 281 + tty_port_tty_wakeup(&quatech_port->port->port); 285 282 } 286 283 287 284 static void qt_interrupt_callback(struct urb *urb)
+1 -13
drivers/tty/amiserial.c
··· 1798 1798 }, 1799 1799 }; 1800 1800 1801 - static int __init amiga_serial_init(void) 1802 - { 1803 - return platform_driver_probe(&amiga_serial_driver, amiga_serial_probe); 1804 - } 1805 - 1806 - module_init(amiga_serial_init); 1807 - 1808 - static void __exit amiga_serial_exit(void) 1809 - { 1810 - platform_driver_unregister(&amiga_serial_driver); 1811 - } 1812 - 1813 - module_exit(amiga_serial_exit); 1801 + module_platform_driver_probe(amiga_serial_driver, amiga_serial_probe); 1814 1802 1815 1803 1816 1804 #if defined(CONFIG_SERIAL_CONSOLE) && !defined(MODULE)
+2 -8
drivers/tty/cyclades.c
··· 1124 1124 readl(&info->u.cyz.ch_ctrl->rs_status); 1125 1125 if (dcd & C_RS_DCD) 1126 1126 wake_up_interruptible(&info->port.open_wait); 1127 - else { 1128 - struct tty_struct *tty; 1129 - tty = tty_port_tty_get(&info->port); 1130 - if (tty) { 1131 - tty_hangup(tty); 1132 - tty_kref_put(tty); 1133 - } 1134 - } 1127 + else 1128 + tty_port_tty_hangup(&info->port, false); 1135 1129 } 1136 1130 break; 1137 1131 case C_CM_MCTS:
+1 -5
drivers/tty/ehv_bytechan.c
··· 472 472 static irqreturn_t ehv_bc_tty_tx_isr(int irq, void *data) 473 473 { 474 474 struct ehv_bc_data *bc = data; 475 - struct tty_struct *ttys = tty_port_tty_get(&bc->port); 476 475 477 476 ehv_bc_tx_dequeue(bc); 478 - if (ttys) { 479 - tty_wakeup(ttys); 480 - tty_kref_put(ttys); 481 - } 477 + tty_port_tty_wakeup(&bc->port); 482 478 483 479 return IRQ_HANDLED; 484 480 }
+1 -6
drivers/tty/hvc/hvsi.c
··· 861 861 { 862 862 struct hvsi_struct *hp = 863 863 container_of(work, struct hvsi_struct, writer.work); 864 - struct tty_struct *tty; 865 864 unsigned long flags; 866 865 #ifdef DEBUG 867 866 static long start_j = 0; ··· 894 895 start_j = 0; 895 896 #endif /* DEBUG */ 896 897 wake_up_all(&hp->emptyq); 897 - tty = tty_port_tty_get(&hp->port); 898 - if (tty) { 899 - tty_wakeup(tty); 900 - tty_kref_put(tty); 901 - } 898 + tty_port_tty_wakeup(&hp->port); 902 899 } 903 900 904 901 out:
+1 -2
drivers/tty/ipwireless/hardware.c
··· 1732 1732 flush_work(&hw->work_rx); 1733 1733 1734 1734 for (i = 0; i < NL_NUM_OF_ADDRESSES; i++) 1735 - if (hw->packet_assembler[i] != NULL) 1736 - kfree(hw->packet_assembler[i]); 1735 + kfree(hw->packet_assembler[i]); 1737 1736 1738 1737 for (i = 0; i < NL_NUM_OF_PRIORITIES; i++) 1739 1738 list_for_each_entry_safe(tp, tq, &hw->tx_queue[i], queue) {
+6 -13
drivers/tty/moxa.c
··· 913 913 914 914 /* pci hot-un-plug support */ 915 915 for (a = 0; a < brd->numPorts; a++) 916 - if (brd->ports[a].port.flags & ASYNC_INITIALIZED) { 917 - struct tty_struct *tty = tty_port_tty_get( 918 - &brd->ports[a].port); 919 - if (tty) { 920 - tty_hangup(tty); 921 - tty_kref_put(tty); 922 - } 923 - } 916 + if (brd->ports[a].port.flags & ASYNC_INITIALIZED) 917 + tty_port_tty_hangup(&brd->ports[a].port, false); 918 + 924 919 for (a = 0; a < MAX_PORTS_PER_BOARD; a++) 925 920 tty_port_destroy(&brd->ports[a].port); 921 + 926 922 while (1) { 927 923 opened = 0; 928 924 for (a = 0; a < brd->numPorts; a++) ··· 1361 1365 1362 1366 static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) 1363 1367 { 1364 - struct tty_struct *tty; 1365 1368 unsigned long flags; 1366 1369 dcd = !!dcd; 1367 1370 ··· 1368 1373 if (dcd != p->DCDState) { 1369 1374 p->DCDState = dcd; 1370 1375 spin_unlock_irqrestore(&p->port.lock, flags); 1371 - tty = tty_port_tty_get(&p->port); 1372 - if (tty && !C_CLOCAL(tty) && !dcd) 1373 - tty_hangup(tty); 1374 - tty_kref_put(tty); 1376 + if (!dcd) 1377 + tty_port_tty_hangup(&p->port, true); 1375 1378 } 1376 1379 else 1377 1380 spin_unlock_irqrestore(&p->port.lock, flags);
+4
drivers/tty/mxser.c
··· 1084 1084 mutex_lock(&port->mutex); 1085 1085 mxser_close_port(port); 1086 1086 mxser_flush_buffer(tty); 1087 + if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { 1088 + if (C_HUPCL(tty)) 1089 + tty_port_lower_dtr_rts(port); 1090 + } 1087 1091 mxser_shutdown_port(port); 1088 1092 clear_bit(ASYNCB_INITIALIZED, &port->flags); 1089 1093 mutex_unlock(&port->mutex);
+5 -5
drivers/tty/n_gsm.c
··· 1418 1418 pr_debug("DLCI %d goes closed.\n", dlci->addr); 1419 1419 dlci->state = DLCI_CLOSED; 1420 1420 if (dlci->addr != 0) { 1421 - struct tty_struct *tty = tty_port_tty_get(&dlci->port); 1422 - if (tty) { 1423 - tty_hangup(tty); 1424 - tty_kref_put(tty); 1425 - } 1421 + tty_port_tty_hangup(&dlci->port, false); 1426 1422 kfifo_reset(dlci->fifo); 1427 1423 } else 1428 1424 dlci->gsm->dead = 1; ··· 2964 2968 if (tty_port_close_start(&dlci->port, tty, filp) == 0) 2965 2969 goto out; 2966 2970 gsm_dlci_begin_close(dlci); 2971 + if (test_bit(ASYNCB_INITIALIZED, &dlci->port.flags)) { 2972 + if (C_HUPCL(tty)) 2973 + tty_port_lower_dtr_rts(&dlci->port); 2974 + } 2967 2975 tty_port_close_end(&dlci->port, tty); 2968 2976 tty_port_tty_set(&dlci->port, NULL); 2969 2977 out:
+87 -89
drivers/tty/n_tty.c
··· 153 153 if (left && !old_left) { 154 154 WARN_RATELIMIT(tty->port->itty == NULL, 155 155 "scheduling with invalid itty\n"); 156 + /* see if ldisc has been killed - if so, this means that 157 + * even though the ldisc has been halted and ->buf.work 158 + * cancelled, ->buf.work is about to be rescheduled 159 + */ 160 + WARN_RATELIMIT(test_bit(TTY_LDISC_HALTED, &tty->flags), 161 + "scheduling buffer work for halted ldisc\n"); 156 162 schedule_work(&tty->port->buf.work); 157 163 } 158 164 } ··· 195 189 } 196 190 197 191 /** 198 - * check_unthrottle - allow new receive data 199 - * @tty; tty device 200 - * 201 - * Check whether to call the driver unthrottle functions 202 - * 203 - * Can sleep, may be called under the atomic_read_lock mutex but 204 - * this is not guaranteed. 205 - */ 206 - static void check_unthrottle(struct tty_struct *tty) 207 - { 208 - if (tty->count) 209 - tty_unthrottle(tty); 210 - } 211 - 212 - /** 213 192 * reset_buffer_flags - reset buffer state 214 193 * @tty: terminal to reset 215 194 * 216 - * Reset the read buffer counters, clear the flags, 217 - * and make sure the driver is unthrottled. Called 218 - * from n_tty_open() and n_tty_flush_buffer(). 195 + * Reset the read buffer counters and clear the flags. 196 + * Called from n_tty_open() and n_tty_flush_buffer(). 219 197 * 220 198 * Locking: tty_read_lock for read fields. 221 199 */ 222 200 223 - static void reset_buffer_flags(struct tty_struct *tty) 201 + static void reset_buffer_flags(struct n_tty_data *ldata) 224 202 { 225 - struct n_tty_data *ldata = tty->disc_data; 226 203 unsigned long flags; 227 204 228 205 raw_spin_lock_irqsave(&ldata->read_lock, flags); ··· 218 229 219 230 ldata->canon_head = ldata->canon_data = ldata->erasing = 0; 220 231 bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); 221 - n_tty_set_room(tty); 222 232 } 223 233 224 - /** 225 - * n_tty_flush_buffer - clean input queue 226 - * @tty: terminal device 227 - * 228 - * Flush the input buffer. Called when the line discipline is 229 - * being closed, when the tty layer wants the buffer flushed (eg 230 - * at hangup) or when the N_TTY line discipline internally has to 231 - * clean the pending queue (for example some signals). 232 - * 233 - * Locking: ctrl_lock, read_lock. 234 - */ 235 - 236 - static void n_tty_flush_buffer(struct tty_struct *tty) 234 + static void n_tty_packet_mode_flush(struct tty_struct *tty) 237 235 { 238 236 unsigned long flags; 239 - /* clear everything and unthrottle the driver */ 240 - reset_buffer_flags(tty); 241 - 242 - if (!tty->link) 243 - return; 244 237 245 238 spin_lock_irqsave(&tty->ctrl_lock, flags); 246 239 if (tty->link->packet) { ··· 230 259 wake_up_interruptible(&tty->link->read_wait); 231 260 } 232 261 spin_unlock_irqrestore(&tty->ctrl_lock, flags); 262 + } 263 + 264 + /** 265 + * n_tty_flush_buffer - clean input queue 266 + * @tty: terminal device 267 + * 268 + * Flush the input buffer. Called when the tty layer wants the 269 + * buffer flushed (eg at hangup) or when the N_TTY line discipline 270 + * internally has to clean the pending queue (for example some signals). 271 + * 272 + * Locking: ctrl_lock, read_lock. 273 + */ 274 + 275 + static void n_tty_flush_buffer(struct tty_struct *tty) 276 + { 277 + reset_buffer_flags(tty->disc_data); 278 + n_tty_set_room(tty); 279 + 280 + if (tty->link) 281 + n_tty_packet_mode_flush(tty); 233 282 } 234 283 235 284 /** ··· 1023 1032 * isig - handle the ISIG optio 1024 1033 * @sig: signal 1025 1034 * @tty: terminal 1026 - * @flush: force flush 1027 1035 * 1028 - * Called when a signal is being sent due to terminal input. This 1029 - * may caus terminal flushing to take place according to the termios 1030 - * settings and character used. Called from the driver receive_buf 1031 - * path so serialized. 1036 + * Called when a signal is being sent due to terminal input. 1037 + * Called from the driver receive_buf path so serialized. 1032 1038 * 1033 - * Locking: ctrl_lock, read_lock (both via flush buffer) 1039 + * Locking: ctrl_lock 1034 1040 */ 1035 1041 1036 - static inline void isig(int sig, struct tty_struct *tty, int flush) 1042 + static inline void isig(int sig, struct tty_struct *tty) 1037 1043 { 1038 - if (tty->pgrp) 1039 - kill_pgrp(tty->pgrp, sig, 1); 1040 - if (flush || !L_NOFLSH(tty)) { 1041 - n_tty_flush_buffer(tty); 1042 - tty_driver_flush_buffer(tty); 1044 + struct pid *tty_pgrp = tty_get_pgrp(tty); 1045 + if (tty_pgrp) { 1046 + kill_pgrp(tty_pgrp, sig, 1); 1047 + put_pid(tty_pgrp); 1043 1048 } 1044 1049 } 1045 1050 ··· 1056 1069 if (I_IGNBRK(tty)) 1057 1070 return; 1058 1071 if (I_BRKINT(tty)) { 1059 - isig(SIGINT, tty, 1); 1072 + isig(SIGINT, tty); 1073 + if (!L_NOFLSH(tty)) { 1074 + n_tty_flush_buffer(tty); 1075 + tty_driver_flush_buffer(tty); 1076 + } 1060 1077 return; 1061 1078 } 1062 1079 if (I_PARMRK(tty)) { ··· 1227 1236 signal = SIGTSTP; 1228 1237 if (c == SUSP_CHAR(tty)) { 1229 1238 send_signal: 1230 - /* 1231 - * Note that we do not use isig() here because we want 1232 - * the order to be: 1233 - * 1) flush, 2) echo, 3) signal 1234 - */ 1235 1239 if (!L_NOFLSH(tty)) { 1236 1240 n_tty_flush_buffer(tty); 1237 1241 tty_driver_flush_buffer(tty); ··· 1237 1251 echo_char(c, tty); 1238 1252 process_echoes(tty); 1239 1253 } 1240 - if (tty->pgrp) 1241 - kill_pgrp(tty->pgrp, signal, 1); 1254 + isig(signal, tty); 1242 1255 return; 1243 1256 } 1244 1257 } ··· 1468 1483 * mode. We don't want to throttle the driver if we're in 1469 1484 * canonical mode and don't have a newline yet! 1470 1485 */ 1471 - if (tty->receive_room < TTY_THRESHOLD_THROTTLE) 1472 - tty_throttle(tty); 1473 - 1474 - /* FIXME: there is a tiny race here if the receive room check runs 1475 - before the other work executes and empties the buffer (upping 1476 - the receiving room and unthrottling. We then throttle and get 1477 - stuck. This has been observed and traced down by Vincent Pillet/ 1478 - We need to address this when we sort out out the rx path locking */ 1486 + while (1) { 1487 + tty_set_flow_change(tty, TTY_THROTTLE_SAFE); 1488 + if (tty->receive_room >= TTY_THRESHOLD_THROTTLE) 1489 + break; 1490 + if (!tty_throttle_safe(tty)) 1491 + break; 1492 + } 1493 + __tty_set_flow_change(tty, 0); 1479 1494 } 1480 1495 1481 1496 int is_ignored(int sig) ··· 1592 1607 { 1593 1608 struct n_tty_data *ldata = tty->disc_data; 1594 1609 1595 - n_tty_flush_buffer(tty); 1610 + if (tty->link) 1611 + n_tty_packet_mode_flush(tty); 1612 + 1596 1613 kfree(ldata->read_buf); 1597 1614 kfree(ldata->echo_buf); 1598 1615 kfree(ldata); ··· 1632 1645 goto err_free_bufs; 1633 1646 1634 1647 tty->disc_data = ldata; 1635 - reset_buffer_flags(tty); 1636 - tty_unthrottle(tty); 1648 + reset_buffer_flags(tty->disc_data); 1637 1649 ldata->column = 0; 1638 - n_tty_set_termios(tty, NULL); 1639 1650 tty->minimum_to_wake = 1; 1640 1651 tty->closing = 0; 1652 + /* indicate buffer work may resume */ 1653 + clear_bit(TTY_LDISC_HALTED, &tty->flags); 1654 + n_tty_set_termios(tty, NULL); 1655 + tty_unthrottle(tty); 1641 1656 1642 1657 return 0; 1643 1658 err_free_bufs: ··· 1729 1740 * and if appropriate send any needed signals and return a negative 1730 1741 * error code if action should be taken. 1731 1742 * 1732 - * FIXME: 1733 - * Locking: None - redirected write test is safe, testing 1734 - * current->signal should possibly lock current->sighand 1735 - * pgrp locking ? 1743 + * Locking: redirected write test is safe 1744 + * current->signal->tty check is safe 1745 + * ctrl_lock to safely reference tty->pgrp 1736 1746 */ 1737 1747 1738 1748 static int job_control(struct tty_struct *tty, struct file *file) ··· 1741 1753 /* NOTE: not yet done after every sleep pending a thorough 1742 1754 check of the logic of this change. -- jlc */ 1743 1755 /* don't stop on /dev/console */ 1744 - if (file->f_op->write != redirected_tty_write && 1745 - current->signal->tty == tty) { 1746 - if (!tty->pgrp) 1747 - printk(KERN_ERR "n_tty_read: no tty->pgrp!\n"); 1748 - else if (task_pgrp(current) != tty->pgrp) { 1749 - if (is_ignored(SIGTTIN) || 1750 - is_current_pgrp_orphaned()) 1751 - return -EIO; 1752 - kill_pgrp(task_pgrp(current), SIGTTIN, 1); 1753 - set_thread_flag(TIF_SIGPENDING); 1754 - return -ERESTARTSYS; 1755 - } 1756 + if (file->f_op->write == redirected_tty_write || 1757 + current->signal->tty != tty) 1758 + return 0; 1759 + 1760 + spin_lock_irq(&tty->ctrl_lock); 1761 + if (!tty->pgrp) 1762 + printk(KERN_ERR "n_tty_read: no tty->pgrp!\n"); 1763 + else if (task_pgrp(current) != tty->pgrp) { 1764 + spin_unlock_irq(&tty->ctrl_lock); 1765 + if (is_ignored(SIGTTIN) || is_current_pgrp_orphaned()) 1766 + return -EIO; 1767 + kill_pgrp(task_pgrp(current), SIGTTIN, 1); 1768 + set_thread_flag(TIF_SIGPENDING); 1769 + return -ERESTARTSYS; 1756 1770 } 1771 + spin_unlock_irq(&tty->ctrl_lock); 1757 1772 return 0; 1758 1773 } 1759 1774 ··· 1950 1959 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, 1951 1960 * we won't get any more characters. 1952 1961 */ 1953 - if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) { 1962 + while (1) { 1963 + tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); 1964 + if (n_tty_chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) 1965 + break; 1966 + if (!tty->count) 1967 + break; 1954 1968 n_tty_set_room(tty); 1955 - check_unthrottle(tty); 1969 + if (!tty_unthrottle_safe(tty)) 1970 + break; 1956 1971 } 1972 + __tty_set_flow_change(tty, 0); 1957 1973 1958 1974 if (b - buf >= minimum) 1959 1975 break;
+4 -11
drivers/tty/nozomi.c
··· 791 791 const u8 toggle = port->toggle_ul; 792 792 void __iomem *addr = port->ul_addr[toggle]; 793 793 const u32 ul_size = port->ul_size[toggle]; 794 - struct tty_struct *tty = tty_port_tty_get(&port->port); 795 794 796 795 /* Get data from tty and place in buf for now */ 797 796 size = kfifo_out(&port->fifo_ul, dc->send_buf, ··· 798 799 799 800 if (size == 0) { 800 801 DBG4("No more data to send, disable link:"); 801 - tty_kref_put(tty); 802 802 return 0; 803 803 } 804 804 ··· 807 809 write_mem32(addr, (u32 *) &size, 4); 808 810 write_mem32(addr + 4, (u32 *) dc->send_buf, size); 809 811 810 - if (tty) 811 - tty_wakeup(tty); 812 + tty_port_tty_wakeup(&port->port); 812 813 813 - tty_kref_put(tty); 814 814 return 1; 815 815 } 816 816 ··· 1501 1505 1502 1506 DBG1(" "); 1503 1507 1504 - for (i = 0; i < MAX_PORT; ++i) { 1505 - struct tty_struct *tty = tty_port_tty_get(&dc->port[i].port); 1506 - if (tty && list_empty(&tty->hangup_work.entry)) 1507 - tty_hangup(tty); 1508 - tty_kref_put(tty); 1509 - } 1508 + for (i = 0; i < MAX_PORT; ++i) 1509 + tty_port_tty_hangup(&dc->port[i].port, false); 1510 + 1510 1511 /* Racy below - surely should wait for scheduled work to be done or 1511 1512 complete off a hangup method ? */ 1512 1513 while (dc->open_ttys)
+6 -7
drivers/tty/pty.c
··· 405 405 return retval; 406 406 } 407 407 408 - /* this is called once with whichever end is closed last */ 409 - static void pty_unix98_shutdown(struct tty_struct *tty) 410 - { 411 - devpts_kill_index(tty->driver_data, tty->index); 412 - } 413 - 414 408 static void pty_cleanup(struct tty_struct *tty) 415 409 { 416 - tty->port->itty = NULL; 417 410 tty_port_put(tty->port); 418 411 } 419 412 ··· 618 625 619 626 static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) 620 627 { 628 + } 629 + 630 + /* this is called once with whichever end is closed last */ 631 + static void pty_unix98_shutdown(struct tty_struct *tty) 632 + { 633 + devpts_kill_index(tty->driver_data, tty->index); 621 634 } 622 635 623 636 static const struct tty_operations ptm_unix98_ops = {
+30 -36
drivers/tty/rocket.c
··· 449 449 450 450 /* Loop sending data to FIFO until done or FIFO full */ 451 451 while (1) { 452 - if (tty->stopped || tty->hw_stopped) 452 + if (tty->stopped) 453 453 break; 454 454 c = min(info->xmit_fifo_room, info->xmit_cnt); 455 455 c = min(c, XMIT_BUF_SIZE - info->xmit_tail); ··· 521 521 (ChanStatus & CD_ACT) ? "on" : "off"); 522 522 #endif 523 523 if (!(ChanStatus & CD_ACT) && info->cd_status) { 524 - struct tty_struct *tty; 525 524 #ifdef ROCKET_DEBUG_HANGUP 526 525 printk(KERN_INFO "CD drop, calling hangup.\n"); 527 526 #endif 528 - tty = tty_port_tty_get(&info->port); 529 - if (tty) { 530 - tty_hangup(tty); 531 - tty_kref_put(tty); 532 - } 527 + tty_port_tty_hangup(&info->port, false); 533 528 } 534 529 info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0; 535 530 wake_up_interruptible(&info->port.open_wait); ··· 1106 1111 1107 1112 /* Handle transition away from B0 status */ 1108 1113 if (!(old_termios->c_cflag & CBAUD) && (tty->termios.c_cflag & CBAUD)) { 1109 - if (!tty->hw_stopped || !(tty->termios.c_cflag & CRTSCTS)) 1110 - sSetRTS(cp); 1114 + sSetRTS(cp); 1111 1115 sSetDTR(cp); 1112 1116 } 1113 1117 1114 - if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios.c_cflag & CRTSCTS)) { 1115 - tty->hw_stopped = 0; 1118 + if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios.c_cflag & CRTSCTS)) 1116 1119 rp_start(tty); 1117 - } 1118 1120 } 1119 1121 1120 1122 static int rp_break(struct tty_struct *tty, int break_state) ··· 1567 1575 spin_lock_irqsave(&info->slock, flags); 1568 1576 cp = &info->channel; 1569 1577 1570 - if (!tty->stopped && !tty->hw_stopped && info->xmit_fifo_room == 0) 1578 + if (!tty->stopped && info->xmit_fifo_room == 0) 1571 1579 info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); 1572 1580 1573 - if (tty->stopped || tty->hw_stopped || info->xmit_fifo_room == 0 || info->xmit_cnt != 0) { 1581 + if (tty->stopped || info->xmit_fifo_room == 0 || info->xmit_cnt != 0) { 1574 1582 info->xmit_buf[info->xmit_head++] = ch; 1575 1583 info->xmit_head &= XMIT_BUF_SIZE - 1; 1576 1584 info->xmit_cnt++; ··· 1611 1619 #endif 1612 1620 cp = &info->channel; 1613 1621 1614 - if (!tty->stopped && !tty->hw_stopped && info->xmit_fifo_room < count) 1622 + if (!tty->stopped && info->xmit_fifo_room < count) 1615 1623 info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); 1616 1624 1617 1625 /* 1618 1626 * If the write queue for the port is empty, and there is FIFO space, stuff bytes 1619 1627 * into FIFO. Use the write queue for temp storage. 1620 1628 */ 1621 - if (!tty->stopped && !tty->hw_stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) { 1629 + if (!tty->stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) { 1622 1630 c = min(count, info->xmit_fifo_room); 1623 1631 b = buf; 1624 1632 ··· 1666 1674 retval += c; 1667 1675 } 1668 1676 1669 - if ((retval > 0) && !tty->stopped && !tty->hw_stopped) 1677 + if ((retval > 0) && !tty->stopped) 1670 1678 set_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); 1671 1679 1672 1680 end: ··· 2519 2527 return (CtlP->NumAiop); 2520 2528 } 2521 2529 2530 + #ifdef CONFIG_PCI 2522 2531 /*************************************************************************** 2523 2532 Function: sPCIInitController 2524 2533 Purpose: Initialization of controller global registers and controller ··· 2639 2646 else 2640 2647 return (CtlP->NumAiop); 2641 2648 } 2649 + 2650 + /* Resets the speaker controller on RocketModem II and III devices */ 2651 + static void rmSpeakerReset(CONTROLLER_T * CtlP, unsigned long model) 2652 + { 2653 + ByteIO_t addr; 2654 + 2655 + /* RocketModem II speaker control is at the 8th port location of offset 0x40 */ 2656 + if ((model == MODEL_RP4M) || (model == MODEL_RP6M)) { 2657 + addr = CtlP->AiopIO[0] + 0x4F; 2658 + sOutB(addr, 0); 2659 + } 2660 + 2661 + /* RocketModem III speaker control is at the 1st port location of offset 0x80 */ 2662 + if ((model == MODEL_UPCI_RM3_8PORT) 2663 + || (model == MODEL_UPCI_RM3_4PORT)) { 2664 + addr = CtlP->AiopIO[0] + 0x88; 2665 + sOutB(addr, 0); 2666 + } 2667 + } 2668 + #endif 2642 2669 2643 2670 /*************************************************************************** 2644 2671 Function: sReadAiopID ··· 3147 3134 if (!on) 3148 3135 addr += 8; 3149 3136 sOutB(addr + chan, 0); /* apply or remove reset */ 3150 - } 3151 - 3152 - /* Resets the speaker controller on RocketModem II and III devices */ 3153 - static void rmSpeakerReset(CONTROLLER_T * CtlP, unsigned long model) 3154 - { 3155 - ByteIO_t addr; 3156 - 3157 - /* RocketModem II speaker control is at the 8th port location of offset 0x40 */ 3158 - if ((model == MODEL_RP4M) || (model == MODEL_RP6M)) { 3159 - addr = CtlP->AiopIO[0] + 0x4F; 3160 - sOutB(addr, 0); 3161 - } 3162 - 3163 - /* RocketModem III speaker control is at the 1st port location of offset 0x80 */ 3164 - if ((model == MODEL_UPCI_RM3_8PORT) 3165 - || (model == MODEL_UPCI_RM3_4PORT)) { 3166 - addr = CtlP->AiopIO[0] + 0x88; 3167 - sOutB(addr, 0); 3168 - } 3169 3137 } 3170 3138 3171 3139 /* Returns the line number given the controller (board), aiop and channel number */
+3 -6
drivers/tty/serial/68328serial.c
··· 630 630 /* Enable transmitter */ 631 631 local_irq_save(flags); 632 632 633 - if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 634 - !info->xmit_buf) { 633 + if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) { 635 634 local_irq_restore(flags); 636 635 return; 637 636 } ··· 696 697 total += c; 697 698 } 698 699 699 - if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 700 + if (info->xmit_cnt && !tty->stopped) { 700 701 /* Enable transmitter */ 701 702 local_irq_disable(); 702 703 #ifndef USE_INTS ··· 977 978 change_speed(info, tty); 978 979 979 980 if ((old_termios->c_cflag & CRTSCTS) && 980 - !(tty->termios.c_cflag & CRTSCTS)) { 981 - tty->hw_stopped = 0; 981 + !(tty->termios.c_cflag & CRTSCTS)) 982 982 rs_start(tty); 983 - } 984 983 985 984 } 986 985
-7
drivers/tty/serial/8250/8250.h
··· 117 117 * is cleared, the machine locks up with endless interrupts. 118 118 */ 119 119 #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1) 120 - #elif defined(CONFIG_SBC8560) 121 - /* 122 - * WindRiver did something similarly broken on their SBC8560 board. The 123 - * UART tristates its IRQ output while OUT2 is clear, but they pulled 124 - * the interrupt line _up_ instead of down, so if we register the IRQ 125 - * while the UART is in that state, we die in an IRQ storm. */ 126 - #define ALPHA_KLUDGE_MCR (UART_MCR_OUT2) 127 120 #else 128 121 #define ALPHA_KLUDGE_MCR 0 129 122 #endif
+11 -7
drivers/tty/serial/8250/8250_core.c
··· 2755 2755 if (nr_uarts > UART_NR) 2756 2756 nr_uarts = UART_NR; 2757 2757 2758 - for (i = 0; i < nr_uarts; i++) { 2758 + for (i = 0; i < UART_NR; i++) { 2759 2759 struct uart_8250_port *up = &serial8250_ports[i]; 2760 2760 struct uart_port *port = &up->port; 2761 2761 ··· 2916 2916 * if so, search for the first available port that does have 2917 2917 * console support. 2918 2918 */ 2919 - if (co->index >= nr_uarts) 2919 + if (co->index >= UART_NR) 2920 2920 co->index = 0; 2921 2921 port = &serial8250_ports[co->index].port; 2922 2922 if (!port->iobase && !port->membase) ··· 2957 2957 int line; 2958 2958 struct uart_port *port; 2959 2959 2960 - for (line = 0; line < nr_uarts; line++) { 2960 + for (line = 0; line < UART_NR; line++) { 2961 2961 port = &serial8250_ports[line].port; 2962 2962 if (uart_match_port(p, port)) 2963 2963 return line; ··· 3110 3110 { 3111 3111 int i; 3112 3112 3113 - for (i = 0; i < nr_uarts; i++) { 3113 + for (i = 0; i < UART_NR; i++) { 3114 3114 struct uart_8250_port *up = &serial8250_ports[i]; 3115 3115 3116 3116 if (up->port.dev == &dev->dev) ··· 3178 3178 /* 3179 3179 * First, find a port entry which matches. 3180 3180 */ 3181 - for (i = 0; i < nr_uarts; i++) 3181 + for (i = 0; i < UART_NR; i++) 3182 3182 if (uart_match_port(&serial8250_ports[i].port, port)) 3183 3183 return &serial8250_ports[i]; 3184 3184 ··· 3187 3187 * free entry. We look for one which hasn't been previously 3188 3188 * used (indicated by zero iobase). 3189 3189 */ 3190 - for (i = 0; i < nr_uarts; i++) 3190 + for (i = 0; i < UART_NR; i++) 3191 3191 if (serial8250_ports[i].port.type == PORT_UNKNOWN && 3192 3192 serial8250_ports[i].port.iobase == 0) 3193 3193 return &serial8250_ports[i]; ··· 3196 3196 * That also failed. Last resort is to find any entry which 3197 3197 * doesn't have a real port associated with it. 3198 3198 */ 3199 - for (i = 0; i < nr_uarts; i++) 3199 + for (i = 0; i < UART_NR; i++) 3200 3200 if (serial8250_ports[i].port.type == PORT_UNKNOWN) 3201 3201 return &serial8250_ports[i]; 3202 3202 ··· 3246 3246 uart->port.fifosize = up->port.fifosize; 3247 3247 uart->tx_loadsz = up->tx_loadsz; 3248 3248 uart->capabilities = up->capabilities; 3249 + 3250 + /* Take tx_loadsz from fifosize if it wasn't set separately */ 3251 + if (uart->port.fifosize && !uart->tx_loadsz) 3252 + uart->tx_loadsz = uart->port.fifosize; 3249 3253 3250 3254 if (up->port.dev) 3251 3255 uart->port.dev = up->port.dev;
+34 -18
drivers/tty/serial/8250/8250_dma.c
··· 33 33 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 34 34 uart_write_wakeup(&p->port); 35 35 36 - if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) { 36 + if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) 37 37 serial8250_tx_dma(p); 38 - uart_write_wakeup(&p->port); 39 - } 40 38 } 41 39 42 40 static void __dma_rx_complete(void *param) ··· 65 67 struct circ_buf *xmit = &p->port.state->xmit; 66 68 struct dma_async_tx_descriptor *desc; 67 69 68 - if (dma->tx_running) 69 - return -EBUSY; 70 + if (uart_tx_stopped(&p->port) || dma->tx_running || 71 + uart_circ_empty(xmit)) 72 + return 0; 70 73 71 74 dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 72 - if (!dma->tx_size) 73 - return -EINVAL; 74 75 75 76 desc = dmaengine_prep_slave_single(dma->txchan, 76 77 dma->tx_addr + xmit->tail, ··· 101 104 struct dma_tx_state state; 102 105 int dma_status; 103 106 104 - /* 105 - * If RCVR FIFO trigger level was not reached, complete the transfer and 106 - * let 8250.c copy the remaining data. 107 - */ 108 - if ((iir & 0x3f) == UART_IIR_RX_TIMEOUT) { 109 - dma_status = dmaengine_tx_status(dma->rxchan, dma->rx_cookie, 110 - &state); 107 + dma_status = dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); 108 + 109 + switch (iir & 0x3f) { 110 + case UART_IIR_RLSI: 111 + /* 8250_core handles errors and break interrupts */ 112 + return -EIO; 113 + case UART_IIR_RX_TIMEOUT: 114 + /* 115 + * If RCVR FIFO trigger level was not reached, complete the 116 + * transfer and let 8250_core copy the remaining data. 117 + */ 111 118 if (dma_status == DMA_IN_PROGRESS) { 112 119 dmaengine_pause(dma->rxchan); 113 120 __dma_rx_complete(p); 114 121 } 115 122 return -ETIMEDOUT; 123 + default: 124 + break; 116 125 } 126 + 127 + if (dma_status) 128 + return 0; 117 129 118 130 desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, 119 131 dma->rx_size, DMA_DEV_TO_MEM, ··· 149 143 struct uart_8250_dma *dma = p->dma; 150 144 dma_cap_mask_t mask; 151 145 152 - dma->rxconf.src_addr = p->port.mapbase + UART_RX; 153 - dma->txconf.dst_addr = p->port.mapbase + UART_TX; 146 + /* Default slave configuration parameters */ 147 + dma->rxconf.direction = DMA_DEV_TO_MEM; 148 + dma->rxconf.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 149 + dma->rxconf.src_addr = p->port.mapbase + UART_RX; 150 + 151 + dma->txconf.direction = DMA_MEM_TO_DEV; 152 + dma->txconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 153 + dma->txconf.dst_addr = p->port.mapbase + UART_TX; 154 154 155 155 dma_cap_zero(mask); 156 156 dma_cap_set(DMA_SLAVE, mask); 157 157 158 158 /* Get a channel for RX */ 159 - dma->rxchan = dma_request_channel(mask, dma->fn, dma->rx_param); 159 + dma->rxchan = dma_request_slave_channel_compat(mask, 160 + dma->fn, dma->rx_param, 161 + p->port.dev, "rx"); 160 162 if (!dma->rxchan) 161 163 return -ENODEV; 162 164 163 165 dmaengine_slave_config(dma->rxchan, &dma->rxconf); 164 166 165 167 /* Get a channel for TX */ 166 - dma->txchan = dma_request_channel(mask, dma->fn, dma->tx_param); 168 + dma->txchan = dma_request_slave_channel_compat(mask, 169 + dma->fn, dma->tx_param, 170 + p->port.dev, "tx"); 167 171 if (!dma->txchan) { 168 172 dma_release_channel(dma->rxchan); 169 173 return -ENODEV;
+96 -98
drivers/tty/serial/8250/8250_dw.c
··· 26 26 #include <linux/platform_device.h> 27 27 #include <linux/slab.h> 28 28 #include <linux/acpi.h> 29 + #include <linux/clk.h> 30 + #include <linux/pm_runtime.h> 29 31 30 32 #include "8250.h" 31 33 ··· 35 33 #define DW_UART_USR 0x1f /* UART Status Register */ 36 34 #define DW_UART_CPR 0xf4 /* Component Parameter Register */ 37 35 #define DW_UART_UCV 0xf8 /* UART Component Version */ 38 - 39 - /* Intel Low Power Subsystem specific */ 40 - #define LPSS_PRV_CLOCK_PARAMS 0x800 41 36 42 37 /* Component Parameter Register bits */ 43 38 #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) ··· 54 55 55 56 56 57 struct dw8250_data { 57 - int last_lcr; 58 - int line; 58 + int last_lcr; 59 + int line; 60 + struct clk *clk; 59 61 }; 60 62 61 63 static void dw8250_serial_out(struct uart_port *p, int offset, int value) ··· 113 113 return 0; 114 114 } 115 115 116 + static void 117 + dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old) 118 + { 119 + if (!state) 120 + pm_runtime_get_sync(port->dev); 121 + 122 + serial8250_do_pm(port, state, old); 123 + 124 + if (state) 125 + pm_runtime_put_sync_suspend(port->dev); 126 + } 127 + 116 128 static int dw8250_probe_of(struct uart_port *p) 117 129 { 118 130 struct device_node *np = p->dev->of_node; ··· 148 136 if (!of_property_read_u32(np, "reg-shift", &val)) 149 137 p->regshift = val; 150 138 139 + /* clock got configured through clk api, all done */ 140 + if (p->uartclk) 141 + return 0; 142 + 143 + /* try to find out clock frequency from DT as fallback */ 151 144 if (of_property_read_u32(np, "clock-frequency", &val)) { 152 - dev_err(p->dev, "no clock-frequency property set\n"); 145 + dev_err(p->dev, "clk or clock-frequency not defined\n"); 153 146 return -EINVAL; 154 147 } 155 148 p->uartclk = val; ··· 163 146 } 164 147 165 148 #ifdef CONFIG_ACPI 166 - static bool dw8250_acpi_dma_filter(struct dma_chan *chan, void *parm) 167 - { 168 - return chan->chan_id == *(int *)parm; 169 - } 170 - 171 - static acpi_status 172 - dw8250_acpi_walk_resource(struct acpi_resource *res, void *data) 173 - { 174 - struct uart_port *p = data; 175 - struct uart_8250_port *port; 176 - struct uart_8250_dma *dma; 177 - struct acpi_resource_fixed_dma *fixed_dma; 178 - struct dma_slave_config *slave; 179 - 180 - port = container_of(p, struct uart_8250_port, port); 181 - 182 - switch (res->type) { 183 - case ACPI_RESOURCE_TYPE_FIXED_DMA: 184 - fixed_dma = &res->data.fixed_dma; 185 - 186 - /* TX comes first */ 187 - if (!port->dma) { 188 - dma = devm_kzalloc(p->dev, sizeof(*dma), GFP_KERNEL); 189 - if (!dma) 190 - return AE_NO_MEMORY; 191 - 192 - port->dma = dma; 193 - slave = &dma->txconf; 194 - 195 - slave->direction = DMA_MEM_TO_DEV; 196 - slave->dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 197 - slave->slave_id = fixed_dma->request_lines; 198 - slave->dst_maxburst = port->tx_loadsz / 4; 199 - 200 - dma->tx_chan_id = fixed_dma->channels; 201 - dma->tx_param = &dma->tx_chan_id; 202 - dma->fn = dw8250_acpi_dma_filter; 203 - } else { 204 - dma = port->dma; 205 - slave = &dma->rxconf; 206 - 207 - slave->direction = DMA_DEV_TO_MEM; 208 - slave->src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 209 - slave->slave_id = fixed_dma->request_lines; 210 - slave->src_maxburst = p->fifosize / 4; 211 - 212 - dma->rx_chan_id = fixed_dma->channels; 213 - dma->rx_param = &dma->rx_chan_id; 214 - } 215 - 216 - break; 217 - } 218 - 219 - return AE_OK; 220 - } 221 - 222 - static int dw8250_probe_acpi(struct uart_port *p) 149 + static int dw8250_probe_acpi(struct uart_8250_port *up) 223 150 { 224 151 const struct acpi_device_id *id; 225 - acpi_status status; 226 - u32 reg; 152 + struct uart_port *p = &up->port; 227 153 228 154 id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); 229 155 if (!id) ··· 176 216 p->serial_in = dw8250_serial_in32; 177 217 p->serial_out = dw8250_serial_out32; 178 218 p->regshift = 2; 179 - p->uartclk = (unsigned int)id->driver_data; 180 219 181 - status = acpi_walk_resources(ACPI_HANDLE(p->dev), METHOD_NAME__CRS, 182 - dw8250_acpi_walk_resource, p); 183 - if (ACPI_FAILURE(status)) { 184 - dev_err_ratelimited(p->dev, "%s failed \"%s\"\n", __func__, 185 - acpi_format_exception(status)); 186 - return -ENODEV; 187 - } 220 + if (!p->uartclk) 221 + p->uartclk = (unsigned int)id->driver_data; 188 222 189 - /* Fix Haswell issue where the clocks do not get enabled */ 190 - if (!strcmp(id->id, "INT33C4") || !strcmp(id->id, "INT33C5")) { 191 - reg = readl(p->membase + LPSS_PRV_CLOCK_PARAMS); 192 - writel(reg | 1, p->membase + LPSS_PRV_CLOCK_PARAMS); 193 - } 223 + up->dma = devm_kzalloc(p->dev, sizeof(*up->dma), GFP_KERNEL); 224 + if (!up->dma) 225 + return -ENOMEM; 226 + 227 + up->dma->rxconf.src_maxburst = p->fifosize / 4; 228 + up->dma->txconf.dst_maxburst = p->fifosize / 4; 194 229 195 230 return 0; 196 231 } 197 232 #else 198 - static inline int dw8250_probe_acpi(struct uart_port *p) 233 + static inline int dw8250_probe_acpi(struct uart_8250_port *up) 199 234 { 200 235 return -ENODEV; 201 236 } ··· 221 266 p->flags |= UPF_FIXED_TYPE; 222 267 p->fifosize = DW_UART_CPR_FIFO_SIZE(reg); 223 268 up->tx_loadsz = p->fifosize; 269 + up->capabilities = UART_CAP_FIFO; 224 270 } 271 + 272 + if (reg & DW_UART_CPR_AFCE_MODE) 273 + up->capabilities |= UART_CAP_AFE; 225 274 } 226 275 227 276 static int dw8250_probe(struct platform_device *pdev) ··· 245 286 uart.port.mapbase = regs->start; 246 287 uart.port.irq = irq->start; 247 288 uart.port.handle_irq = dw8250_handle_irq; 289 + uart.port.pm = dw8250_do_pm; 248 290 uart.port.type = PORT_8250; 249 291 uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT; 250 292 uart.port.dev = &pdev->dev; 251 293 252 - uart.port.membase = ioremap(regs->start, resource_size(regs)); 294 + uart.port.membase = devm_ioremap(&pdev->dev, regs->start, 295 + resource_size(regs)); 253 296 if (!uart.port.membase) 254 297 return -ENOMEM; 298 + 299 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 300 + if (!data) 301 + return -ENOMEM; 302 + 303 + data->clk = devm_clk_get(&pdev->dev, NULL); 304 + if (!IS_ERR(data->clk)) { 305 + clk_prepare_enable(data->clk); 306 + uart.port.uartclk = clk_get_rate(data->clk); 307 + } 255 308 256 309 uart.port.iotype = UPIO_MEM; 257 310 uart.port.serial_in = dw8250_serial_in; 258 311 uart.port.serial_out = dw8250_serial_out; 312 + uart.port.private_data = data; 259 313 260 314 dw8250_setup_port(&uart); 261 315 ··· 277 305 if (err) 278 306 return err; 279 307 } else if (ACPI_HANDLE(&pdev->dev)) { 280 - err = dw8250_probe_acpi(&uart.port); 308 + err = dw8250_probe_acpi(&uart); 281 309 if (err) 282 310 return err; 283 311 } else { 284 312 return -ENODEV; 285 313 } 286 314 287 - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 288 - if (!data) 289 - return -ENOMEM; 290 - 291 - uart.port.private_data = data; 292 - 293 315 data->line = serial8250_register_8250_port(&uart); 294 316 if (data->line < 0) 295 317 return data->line; 296 318 297 319 platform_set_drvdata(pdev, data); 320 + 321 + pm_runtime_set_active(&pdev->dev); 322 + pm_runtime_enable(&pdev->dev); 298 323 299 324 return 0; 300 325 } ··· 300 331 { 301 332 struct dw8250_data *data = platform_get_drvdata(pdev); 302 333 334 + pm_runtime_get_sync(&pdev->dev); 335 + 303 336 serial8250_unregister_port(data->line); 337 + 338 + if (!IS_ERR(data->clk)) 339 + clk_disable_unprepare(data->clk); 340 + 341 + pm_runtime_disable(&pdev->dev); 342 + pm_runtime_put_noidle(&pdev->dev); 304 343 305 344 return 0; 306 345 } 307 346 308 347 #ifdef CONFIG_PM 309 - static int dw8250_suspend(struct platform_device *pdev, pm_message_t state) 348 + static int dw8250_suspend(struct device *dev) 310 349 { 311 - struct dw8250_data *data = platform_get_drvdata(pdev); 350 + struct dw8250_data *data = dev_get_drvdata(dev); 312 351 313 352 serial8250_suspend_port(data->line); 314 353 315 354 return 0; 316 355 } 317 356 318 - static int dw8250_resume(struct platform_device *pdev) 357 + static int dw8250_resume(struct device *dev) 319 358 { 320 - struct dw8250_data *data = platform_get_drvdata(pdev); 359 + struct dw8250_data *data = dev_get_drvdata(dev); 321 360 322 361 serial8250_resume_port(data->line); 323 362 324 363 return 0; 325 364 } 326 - #else 327 - #define dw8250_suspend NULL 328 - #define dw8250_resume NULL 329 365 #endif /* CONFIG_PM */ 366 + 367 + #ifdef CONFIG_PM_RUNTIME 368 + static int dw8250_runtime_suspend(struct device *dev) 369 + { 370 + struct dw8250_data *data = dev_get_drvdata(dev); 371 + 372 + clk_disable_unprepare(data->clk); 373 + 374 + return 0; 375 + } 376 + 377 + static int dw8250_runtime_resume(struct device *dev) 378 + { 379 + struct dw8250_data *data = dev_get_drvdata(dev); 380 + 381 + clk_prepare_enable(data->clk); 382 + 383 + return 0; 384 + } 385 + #endif 386 + 387 + static const struct dev_pm_ops dw8250_pm_ops = { 388 + SET_SYSTEM_SLEEP_PM_OPS(dw8250_suspend, dw8250_resume) 389 + SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL) 390 + }; 330 391 331 392 static const struct of_device_id dw8250_of_match[] = { 332 393 { .compatible = "snps,dw-apb-uart" }, ··· 365 366 MODULE_DEVICE_TABLE(of, dw8250_of_match); 366 367 367 368 static const struct acpi_device_id dw8250_acpi_match[] = { 368 - { "INT33C4", 100000000 }, 369 - { "INT33C5", 100000000 }, 369 + { "INT33C4", 0 }, 370 + { "INT33C5", 0 }, 370 371 { }, 371 372 }; 372 373 MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match); ··· 375 376 .driver = { 376 377 .name = "dw-apb-uart", 377 378 .owner = THIS_MODULE, 379 + .pm = &dw8250_pm_ops, 378 380 .of_match_table = dw8250_of_match, 379 381 .acpi_match_table = ACPI_PTR(dw8250_acpi_match), 380 382 }, 381 383 .probe = dw8250_probe, 382 384 .remove = dw8250_remove, 383 - .suspend = dw8250_suspend, 384 - .resume = dw8250_resume, 385 385 }; 386 386 387 387 module_platform_driver(dw8250_platform_driver);
+158 -23
drivers/tty/serial/amba-pl011.c
··· 29 29 * and hooked into this driver. 30 30 */ 31 31 32 + 32 33 #if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 33 34 #define SUPPORT_SYSRQ 34 35 #endif ··· 73 72 /* There is by now at least one vendor with differing details, so handle it */ 74 73 struct vendor_data { 75 74 unsigned int ifls; 76 - unsigned int fifosize; 77 75 unsigned int lcrh_tx; 78 76 unsigned int lcrh_rx; 79 77 bool oversampling; 80 78 bool dma_threshold; 81 79 bool cts_event_workaround; 80 + 81 + unsigned int (*get_fifosize)(unsigned int periphid); 82 82 }; 83 + 84 + static unsigned int get_fifosize_arm(unsigned int periphid) 85 + { 86 + unsigned int rev = (periphid >> 20) & 0xf; 87 + return rev < 3 ? 16 : 32; 88 + } 83 89 84 90 static struct vendor_data vendor_arm = { 85 91 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, 86 - .fifosize = 16, 87 92 .lcrh_tx = UART011_LCRH, 88 93 .lcrh_rx = UART011_LCRH, 89 94 .oversampling = false, 90 95 .dma_threshold = false, 91 96 .cts_event_workaround = false, 97 + .get_fifosize = get_fifosize_arm, 92 98 }; 99 + 100 + static unsigned int get_fifosize_st(unsigned int periphid) 101 + { 102 + return 64; 103 + } 93 104 94 105 static struct vendor_data vendor_st = { 95 106 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF, 96 - .fifosize = 64, 97 107 .lcrh_tx = ST_UART011_LCRH_TX, 98 108 .lcrh_rx = ST_UART011_LCRH_RX, 99 109 .oversampling = true, 100 110 .dma_threshold = true, 101 111 .cts_event_workaround = true, 112 + .get_fifosize = get_fifosize_st, 102 113 }; 103 114 104 115 static struct uart_amba_port *amba_ports[UART_NR]; ··· 130 117 struct pl011_sgbuf sgbuf_b; 131 118 dma_cookie_t cookie; 132 119 bool running; 120 + struct timer_list timer; 121 + unsigned int last_residue; 122 + unsigned long last_jiffies; 123 + bool auto_poll_rate; 124 + unsigned int poll_rate; 125 + unsigned int poll_timeout; 133 126 }; 134 127 135 128 struct pl011_dmatx_data { ··· 242 223 static int pl011_sgbuf_init(struct dma_chan *chan, struct pl011_sgbuf *sg, 243 224 enum dma_data_direction dir) 244 225 { 245 - sg->buf = kmalloc(PL011_DMA_BUFFER_SIZE, GFP_KERNEL); 226 + dma_addr_t dma_addr; 227 + 228 + sg->buf = dma_alloc_coherent(chan->device->dev, 229 + PL011_DMA_BUFFER_SIZE, &dma_addr, GFP_KERNEL); 246 230 if (!sg->buf) 247 231 return -ENOMEM; 248 232 249 - sg_init_one(&sg->sg, sg->buf, PL011_DMA_BUFFER_SIZE); 233 + sg_init_table(&sg->sg, 1); 234 + sg_set_page(&sg->sg, phys_to_page(dma_addr), 235 + PL011_DMA_BUFFER_SIZE, offset_in_page(dma_addr)); 236 + sg_dma_address(&sg->sg) = dma_addr; 250 237 251 - if (dma_map_sg(chan->device->dev, &sg->sg, 1, dir) != 1) { 252 - kfree(sg->buf); 253 - return -EINVAL; 254 - } 255 238 return 0; 256 239 } 257 240 ··· 261 240 enum dma_data_direction dir) 262 241 { 263 242 if (sg->buf) { 264 - dma_unmap_sg(chan->device->dev, &sg->sg, 1, dir); 265 - kfree(sg->buf); 243 + dma_free_coherent(chan->device->dev, 244 + PL011_DMA_BUFFER_SIZE, sg->buf, 245 + sg_dma_address(&sg->sg)); 266 246 } 267 247 } 268 248 ··· 321 299 322 300 dmaengine_slave_config(chan, &rx_conf); 323 301 uap->dmarx.chan = chan; 302 + 303 + if (plat->dma_rx_poll_enable) { 304 + /* Set poll rate if specified. */ 305 + if (plat->dma_rx_poll_rate) { 306 + uap->dmarx.auto_poll_rate = false; 307 + uap->dmarx.poll_rate = plat->dma_rx_poll_rate; 308 + } else { 309 + /* 310 + * 100 ms defaults to poll rate if not 311 + * specified. This will be adjusted with 312 + * the baud rate at set_termios. 313 + */ 314 + uap->dmarx.auto_poll_rate = true; 315 + uap->dmarx.poll_rate = 100; 316 + } 317 + /* 3 secs defaults poll_timeout if not specified. */ 318 + if (plat->dma_rx_poll_timeout) 319 + uap->dmarx.poll_timeout = 320 + plat->dma_rx_poll_timeout; 321 + else 322 + uap->dmarx.poll_timeout = 3000; 323 + } else 324 + uap->dmarx.auto_poll_rate = false; 324 325 325 326 dev_info(uap->port.dev, "DMA channel RX %s\n", 326 327 dma_chan_name(uap->dmarx.chan)); ··· 746 701 struct tty_port *port = &uap->port.state->port; 747 702 struct pl011_sgbuf *sgbuf = use_buf_b ? 748 703 &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; 749 - struct device *dev = uap->dmarx.chan->device->dev; 750 704 int dma_count = 0; 751 705 u32 fifotaken = 0; /* only used for vdbg() */ 752 706 753 - /* Pick everything from the DMA first */ 707 + struct pl011_dmarx_data *dmarx = &uap->dmarx; 708 + int dmataken = 0; 709 + 710 + if (uap->dmarx.poll_rate) { 711 + /* The data can be taken by polling */ 712 + dmataken = sgbuf->sg.length - dmarx->last_residue; 713 + /* Recalculate the pending size */ 714 + if (pending >= dmataken) 715 + pending -= dmataken; 716 + } 717 + 718 + /* Pick the remain data from the DMA */ 754 719 if (pending) { 755 - /* Sync in buffer */ 756 - dma_sync_sg_for_cpu(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE); 757 720 758 721 /* 759 722 * First take all chars in the DMA pipe, then look in the FIFO. 760 723 * Note that tty_insert_flip_buf() tries to take as many chars 761 724 * as it can. 762 725 */ 763 - dma_count = tty_insert_flip_string(port, sgbuf->buf, pending); 764 - 765 - /* Return buffer to device */ 766 - dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE); 726 + dma_count = tty_insert_flip_string(port, sgbuf->buf + dmataken, 727 + pending); 767 728 768 729 uap->port.icount.rx += dma_count; 769 730 if (dma_count < pending) 770 731 dev_warn(uap->port.dev, 771 732 "couldn't insert all characters (TTY is full?)\n"); 772 733 } 734 + 735 + /* Reset the last_residue for Rx DMA poll */ 736 + if (uap->dmarx.poll_rate) 737 + dmarx->last_residue = sgbuf->sg.length; 773 738 774 739 /* 775 740 * Only continue with trying to read the FIFO if all DMA chars have ··· 920 865 writew(uap->dmacr, uap->port.membase + UART011_DMACR); 921 866 } 922 867 868 + /* 869 + * Timer handler for Rx DMA polling. 870 + * Every polling, It checks the residue in the dma buffer and transfer 871 + * data to the tty. Also, last_residue is updated for the next polling. 872 + */ 873 + static void pl011_dma_rx_poll(unsigned long args) 874 + { 875 + struct uart_amba_port *uap = (struct uart_amba_port *)args; 876 + struct tty_port *port = &uap->port.state->port; 877 + struct pl011_dmarx_data *dmarx = &uap->dmarx; 878 + struct dma_chan *rxchan = uap->dmarx.chan; 879 + unsigned long flags = 0; 880 + unsigned int dmataken = 0; 881 + unsigned int size = 0; 882 + struct pl011_sgbuf *sgbuf; 883 + int dma_count; 884 + struct dma_tx_state state; 885 + 886 + sgbuf = dmarx->use_buf_b ? &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a; 887 + rxchan->device->device_tx_status(rxchan, dmarx->cookie, &state); 888 + if (likely(state.residue < dmarx->last_residue)) { 889 + dmataken = sgbuf->sg.length - dmarx->last_residue; 890 + size = dmarx->last_residue - state.residue; 891 + dma_count = tty_insert_flip_string(port, sgbuf->buf + dmataken, 892 + size); 893 + if (dma_count == size) 894 + dmarx->last_residue = state.residue; 895 + dmarx->last_jiffies = jiffies; 896 + } 897 + tty_flip_buffer_push(port); 898 + 899 + /* 900 + * If no data is received in poll_timeout, the driver will fall back 901 + * to interrupt mode. We will retrigger DMA at the first interrupt. 902 + */ 903 + if (jiffies_to_msecs(jiffies - dmarx->last_jiffies) 904 + > uap->dmarx.poll_timeout) { 905 + 906 + spin_lock_irqsave(&uap->port.lock, flags); 907 + pl011_dma_rx_stop(uap); 908 + spin_unlock_irqrestore(&uap->port.lock, flags); 909 + 910 + uap->dmarx.running = false; 911 + dmaengine_terminate_all(rxchan); 912 + del_timer(&uap->dmarx.timer); 913 + } else { 914 + mod_timer(&uap->dmarx.timer, 915 + jiffies + msecs_to_jiffies(uap->dmarx.poll_rate)); 916 + } 917 + } 918 + 923 919 static void pl011_dma_startup(struct uart_amba_port *uap) 924 920 { 925 921 int ret; ··· 1033 927 if (pl011_dma_rx_trigger_dma(uap)) 1034 928 dev_dbg(uap->port.dev, "could not trigger initial " 1035 929 "RX DMA job, fall back to interrupt mode\n"); 930 + if (uap->dmarx.poll_rate) { 931 + init_timer(&(uap->dmarx.timer)); 932 + uap->dmarx.timer.function = pl011_dma_rx_poll; 933 + uap->dmarx.timer.data = (unsigned long)uap; 934 + mod_timer(&uap->dmarx.timer, 935 + jiffies + 936 + msecs_to_jiffies(uap->dmarx.poll_rate)); 937 + uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE; 938 + uap->dmarx.last_jiffies = jiffies; 939 + } 1036 940 } 1037 941 } 1038 942 ··· 1078 962 /* Clean up the RX DMA */ 1079 963 pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_a, DMA_FROM_DEVICE); 1080 964 pl011_sgbuf_free(uap->dmarx.chan, &uap->dmarx.sgbuf_b, DMA_FROM_DEVICE); 965 + if (uap->dmarx.poll_rate) 966 + del_timer_sync(&uap->dmarx.timer); 1081 967 uap->using_rx_dma = false; 1082 968 } 1083 969 } ··· 1093 975 { 1094 976 return uap->using_rx_dma && uap->dmarx.running; 1095 977 } 1096 - 1097 978 1098 979 #else 1099 980 /* Blank functions if the DMA engine is not available */ ··· 1205 1088 dev_dbg(uap->port.dev, "could not trigger RX DMA job " 1206 1089 "fall back to interrupt mode again\n"); 1207 1090 uap->im |= UART011_RXIM; 1208 - } else 1091 + } else { 1209 1092 uap->im &= ~UART011_RXIM; 1093 + #ifdef CONFIG_DMA_ENGINE 1094 + /* Start Rx DMA poll */ 1095 + if (uap->dmarx.poll_rate) { 1096 + uap->dmarx.last_jiffies = jiffies; 1097 + uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE; 1098 + mod_timer(&uap->dmarx.timer, 1099 + jiffies + 1100 + msecs_to_jiffies(uap->dmarx.poll_rate)); 1101 + } 1102 + #endif 1103 + } 1104 + 1210 1105 writew(uap->im, uap->port.membase + UART011_IMSC); 1211 1106 } 1212 1107 spin_lock(&uap->port.lock); ··· 1293 1164 unsigned int dummy_read; 1294 1165 1295 1166 spin_lock_irqsave(&uap->port.lock, flags); 1296 - 1297 1167 status = readw(uap->port.membase + UART011_MIS); 1298 1168 if (status) { 1299 1169 do { ··· 1679 1551 */ 1680 1552 baud = uart_get_baud_rate(port, termios, old, 0, 1681 1553 port->uartclk / clkdiv); 1554 + #ifdef CONFIG_DMA_ENGINE 1555 + /* 1556 + * Adjust RX DMA polling rate with baud rate if not specified. 1557 + */ 1558 + if (uap->dmarx.auto_poll_rate) 1559 + uap->dmarx.poll_rate = DIV_ROUND_UP(10000000, baud); 1560 + #endif 1682 1561 1683 1562 if (baud > port->uartclk/16) 1684 1563 quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud); ··· 2145 2010 uap->lcrh_rx = vendor->lcrh_rx; 2146 2011 uap->lcrh_tx = vendor->lcrh_tx; 2147 2012 uap->old_cr = 0; 2148 - uap->fifosize = vendor->fifosize; 2013 + uap->fifosize = vendor->get_fifosize(dev->periphid); 2149 2014 uap->port.dev = &dev->dev; 2150 2015 uap->port.mapbase = dev->res.start; 2151 2016 uap->port.membase = base;
+1 -1
drivers/tty/serial/arc_uart.c
··· 162 162 /* 163 163 * Driver internal routine, used by both tty(serial core) as well as tx-isr 164 164 * -Called under spinlock in either cases 165 - * -also tty->stopped / tty->hw_stopped has already been checked 165 + * -also tty->stopped has already been checked 166 166 * = by uart_start( ) before calling us 167 167 * = tx_ist checks that too before calling 168 168 */
-23
drivers/tty/serial/bfin_uart.c
··· 1011 1011 } 1012 1012 #endif 1013 1013 1014 - #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ 1015 - defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) 1016 - static void bfin_kgdboc_port_shutdown(struct uart_port *port) 1017 - { 1018 - if (kgdboc_break_enabled) { 1019 - kgdboc_break_enabled = 0; 1020 - bfin_serial_shutdown(port); 1021 - } 1022 - } 1023 - 1024 - static int bfin_kgdboc_port_startup(struct uart_port *port) 1025 - { 1026 - kgdboc_port_line = port->line; 1027 - kgdboc_break_enabled = !bfin_serial_startup(port); 1028 - return 0; 1029 - } 1030 - #endif 1031 - 1032 1014 static struct uart_ops bfin_serial_pops = { 1033 1015 .tx_empty = bfin_serial_tx_empty, 1034 1016 .set_mctrl = bfin_serial_set_mctrl, ··· 1029 1047 .request_port = bfin_serial_request_port, 1030 1048 .config_port = bfin_serial_config_port, 1031 1049 .verify_port = bfin_serial_verify_port, 1032 - #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ 1033 - defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) 1034 - .kgdboc_port_startup = bfin_kgdboc_port_startup, 1035 - .kgdboc_port_shutdown = bfin_kgdboc_port_shutdown, 1036 - #endif 1037 1050 #ifdef CONFIG_CONSOLE_POLL 1038 1051 .poll_put_char = bfin_serial_poll_put_char, 1039 1052 .poll_get_char = bfin_serial_poll_get_char,
+73 -95
drivers/tty/serial/crisv10.c
··· 169 169 170 170 171 171 #define DEF_BAUD 115200 /* 115.2 kbit/s */ 172 - #define STD_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) 173 172 #define DEF_RX 0x20 /* or SERIAL_CTRL_W >> 8 */ 174 173 /* Default value of tx_ctrl register: has txd(bit 7)=1 (idle) as default */ 175 174 #define DEF_TX 0x80 /* or SERIAL_CTRL_B */ ··· 245 246 .ifirstadr = R_DMA_CH7_FIRST, 246 247 .icmdadr = R_DMA_CH7_CMD, 247 248 .idescradr = R_DMA_CH7_DESCR, 248 - .flags = STD_FLAGS, 249 249 .rx_ctrl = DEF_RX, 250 250 .tx_ctrl = DEF_TX, 251 251 .iseteop = 2, ··· 298 300 .ifirstadr = R_DMA_CH9_FIRST, 299 301 .icmdadr = R_DMA_CH9_CMD, 300 302 .idescradr = R_DMA_CH9_DESCR, 301 - .flags = STD_FLAGS, 302 303 .rx_ctrl = DEF_RX, 303 304 .tx_ctrl = DEF_TX, 304 305 .iseteop = 3, ··· 353 356 .ifirstadr = R_DMA_CH3_FIRST, 354 357 .icmdadr = R_DMA_CH3_CMD, 355 358 .idescradr = R_DMA_CH3_DESCR, 356 - .flags = STD_FLAGS, 357 359 .rx_ctrl = DEF_RX, 358 360 .tx_ctrl = DEF_TX, 359 361 .iseteop = 0, ··· 406 410 .ifirstadr = R_DMA_CH5_FIRST, 407 411 .icmdadr = R_DMA_CH5_CMD, 408 412 .idescradr = R_DMA_CH5_DESCR, 409 - .flags = STD_FLAGS, 410 413 .rx_ctrl = DEF_RX, 411 414 .tx_ctrl = DEF_TX, 412 415 .iseteop = 1, ··· 2258 2263 2259 2264 */ 2260 2265 2261 - static 2262 - struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) 2266 + static void handle_ser_rx_interrupt_no_dma(struct e100_serial *info) 2263 2267 { 2264 2268 unsigned long data_read; 2265 2269 ··· 2364 2370 } 2365 2371 2366 2372 tty_flip_buffer_push(&info->port); 2367 - return info; 2368 2373 } 2369 2374 2370 - static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) 2375 + static void handle_ser_rx_interrupt(struct e100_serial *info) 2371 2376 { 2372 2377 unsigned char rstat; 2373 2378 ··· 2375 2382 #endif 2376 2383 /* DEBUG_LOG(info->line, "ser_interrupt stat %03X\n", rstat | (i << 8)); */ 2377 2384 if (!info->uses_dma_in) { 2378 - return handle_ser_rx_interrupt_no_dma(info); 2385 + handle_ser_rx_interrupt_no_dma(info); 2386 + return; 2379 2387 } 2380 2388 /* DMA is used */ 2381 2389 rstat = info->ioport[REG_STATUS]; ··· 2483 2489 /* Restarting the DMA never hurts */ 2484 2490 *info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart); 2485 2491 START_FLUSH_FAST_TIMER(info, "ser_int"); 2486 - return info; 2487 2492 } /* handle_ser_rx_interrupt */ 2488 2493 2489 2494 static void handle_ser_tx_interrupt(struct e100_serial *info) ··· 2527 2534 } 2528 2535 /* Normal char-by-char interrupt */ 2529 2536 if (info->xmit.head == info->xmit.tail 2530 - || info->port.tty->stopped 2531 - || info->port.tty->hw_stopped) { 2537 + || info->port.tty->stopped) { 2532 2538 DFLOW(DEBUG_LOG(info->line, "tx_int: stopped %i\n", 2533 2539 info->port.tty->stopped)); 2534 2540 e100_disable_serial_tx_ready_irq(info); ··· 2714 2722 2715 2723 /* if it was already initialized, skip this */ 2716 2724 2717 - if (info->flags & ASYNC_INITIALIZED) { 2725 + if (info->port.flags & ASYNC_INITIALIZED) { 2718 2726 local_irq_restore(flags); 2719 2727 free_page(xmit_page); 2720 2728 return 0; ··· 2839 2847 2840 2848 #endif /* CONFIG_SVINTO_SIM */ 2841 2849 2842 - info->flags |= ASYNC_INITIALIZED; 2850 + info->port.flags |= ASYNC_INITIALIZED; 2843 2851 2844 2852 local_irq_restore(flags); 2845 2853 return 0; ··· 2884 2892 2885 2893 #endif /* CONFIG_SVINTO_SIM */ 2886 2894 2887 - if (!(info->flags & ASYNC_INITIALIZED)) 2895 + if (!(info->port.flags & ASYNC_INITIALIZED)) 2888 2896 return; 2889 2897 2890 2898 #ifdef SERIAL_DEBUG_OPEN ··· 2915 2923 if (info->port.tty) 2916 2924 set_bit(TTY_IO_ERROR, &info->port.tty->flags); 2917 2925 2918 - info->flags &= ~ASYNC_INITIALIZED; 2926 + info->port.flags &= ~ASYNC_INITIALIZED; 2919 2927 local_irq_restore(flags); 2920 2928 } 2921 2929 ··· 2940 2948 /* possibly, the tx/rx should be disabled first to do this safely */ 2941 2949 2942 2950 /* change baud-rate and write it to the hardware */ 2943 - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) { 2951 + if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) { 2944 2952 /* Special baudrate */ 2945 2953 u32 mask = 0xFF << (info->line*8); /* Each port has 8 bits */ 2946 2954 unsigned long alt_source = ··· 3090 3098 if (info->tr_running || 3091 3099 info->xmit.head == info->xmit.tail || 3092 3100 tty->stopped || 3093 - tty->hw_stopped || 3094 3101 !info->xmit.buf) 3095 3102 return; 3096 3103 ··· 3167 3176 3168 3177 if (info->xmit.head != info->xmit.tail && 3169 3178 !tty->stopped && 3170 - !tty->hw_stopped && 3171 3179 !info->tr_running) { 3172 3180 start_transmit(info); 3173 3181 } ··· 3390 3400 tmp.line = info->line; 3391 3401 tmp.port = (int)info->ioport; 3392 3402 tmp.irq = info->irq; 3393 - tmp.flags = info->flags; 3403 + tmp.flags = info->port.flags; 3394 3404 tmp.baud_base = info->baud_base; 3395 - tmp.close_delay = info->close_delay; 3396 - tmp.closing_wait = info->closing_wait; 3405 + tmp.close_delay = info->port.close_delay; 3406 + tmp.closing_wait = info->port.closing_wait; 3397 3407 tmp.custom_divisor = info->custom_divisor; 3398 3408 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 3399 3409 return -EFAULT; ··· 3415 3425 3416 3426 if (!capable(CAP_SYS_ADMIN)) { 3417 3427 if ((new_serial.type != info->type) || 3418 - (new_serial.close_delay != info->close_delay) || 3428 + (new_serial.close_delay != info->port.close_delay) || 3419 3429 ((new_serial.flags & ~ASYNC_USR_MASK) != 3420 - (info->flags & ~ASYNC_USR_MASK))) 3430 + (info->port.flags & ~ASYNC_USR_MASK))) 3421 3431 return -EPERM; 3422 - info->flags = ((info->flags & ~ASYNC_USR_MASK) | 3432 + info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) | 3423 3433 (new_serial.flags & ASYNC_USR_MASK)); 3424 3434 goto check_and_exit; 3425 3435 } 3426 3436 3427 - if (info->count > 1) 3437 + if (info->port.count > 1) 3428 3438 return -EBUSY; 3429 3439 3430 3440 /* ··· 3433 3443 */ 3434 3444 3435 3445 info->baud_base = new_serial.baud_base; 3436 - info->flags = ((info->flags & ~ASYNC_FLAGS) | 3446 + info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) | 3437 3447 (new_serial.flags & ASYNC_FLAGS)); 3438 3448 info->custom_divisor = new_serial.custom_divisor; 3439 3449 info->type = new_serial.type; 3440 - info->close_delay = new_serial.close_delay; 3441 - info->closing_wait = new_serial.closing_wait; 3442 - info->port.low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3450 + info->port.close_delay = new_serial.close_delay; 3451 + info->port.closing_wait = new_serial.closing_wait; 3452 + info->port.low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3443 3453 3444 3454 check_and_exit: 3445 - if (info->flags & ASYNC_INITIALIZED) { 3455 + if (info->port.flags & ASYNC_INITIALIZED) { 3446 3456 change_speed(info); 3447 3457 } else 3448 3458 retval = startup(info); ··· 3723 3733 3724 3734 /* Handle turning off CRTSCTS */ 3725 3735 if ((old_termios->c_cflag & CRTSCTS) && 3726 - !(tty->termios.c_cflag & CRTSCTS)) { 3727 - tty->hw_stopped = 0; 3736 + !(tty->termios.c_cflag & CRTSCTS)) 3728 3737 rs_start(tty); 3729 - } 3730 3738 3731 3739 } 3732 3740 ··· 3760 3772 printk("[%d] rs_close ttyS%d, count = %d\n", current->pid, 3761 3773 info->line, info->count); 3762 3774 #endif 3763 - if ((tty->count == 1) && (info->count != 1)) { 3775 + if ((tty->count == 1) && (info->port.count != 1)) { 3764 3776 /* 3765 3777 * Uh, oh. tty->count is 1, which means that the tty 3766 3778 * structure will be freed. Info->count should always ··· 3770 3782 */ 3771 3783 printk(KERN_ERR 3772 3784 "rs_close: bad serial port count; tty->count is 1, " 3773 - "info->count is %d\n", info->count); 3774 - info->count = 1; 3785 + "info->count is %d\n", info->port.count); 3786 + info->port.count = 1; 3775 3787 } 3776 - if (--info->count < 0) { 3788 + if (--info->port.count < 0) { 3777 3789 printk(KERN_ERR "rs_close: bad serial port count for ttyS%d: %d\n", 3778 - info->line, info->count); 3779 - info->count = 0; 3790 + info->line, info->port.count); 3791 + info->port.count = 0; 3780 3792 } 3781 - if (info->count) { 3793 + if (info->port.count) { 3782 3794 local_irq_restore(flags); 3783 3795 return; 3784 3796 } 3785 - info->flags |= ASYNC_CLOSING; 3797 + info->port.flags |= ASYNC_CLOSING; 3786 3798 /* 3787 3799 * Save the termios structure, since this port may have 3788 3800 * separate termios for callout and dialin. 3789 3801 */ 3790 - if (info->flags & ASYNC_NORMAL_ACTIVE) 3802 + if (info->port.flags & ASYNC_NORMAL_ACTIVE) 3791 3803 info->normal_termios = tty->termios; 3792 3804 /* 3793 3805 * Now we wait for the transmit buffer to clear; and we notify 3794 3806 * the line discipline to only process XON/XOFF characters. 3795 3807 */ 3796 3808 tty->closing = 1; 3797 - if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) 3798 - tty_wait_until_sent(tty, info->closing_wait); 3809 + if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) 3810 + tty_wait_until_sent(tty, info->port.closing_wait); 3799 3811 /* 3800 3812 * At this point we stop accepting input. To do this, we 3801 3813 * disable the serial receiver and the DMA receive interrupt. ··· 3808 3820 e100_disable_rx(info); 3809 3821 e100_disable_rx_irq(info); 3810 3822 3811 - if (info->flags & ASYNC_INITIALIZED) { 3823 + if (info->port.flags & ASYNC_INITIALIZED) { 3812 3824 /* 3813 3825 * Before we drop DTR, make sure the UART transmitter 3814 3826 * has completely drained; this is especially ··· 3824 3836 tty->closing = 0; 3825 3837 info->event = 0; 3826 3838 info->port.tty = NULL; 3827 - if (info->blocked_open) { 3828 - if (info->close_delay) 3829 - schedule_timeout_interruptible(info->close_delay); 3830 - wake_up_interruptible(&info->open_wait); 3839 + if (info->port.blocked_open) { 3840 + if (info->port.close_delay) 3841 + schedule_timeout_interruptible(info->port.close_delay); 3842 + wake_up_interruptible(&info->port.open_wait); 3831 3843 } 3832 - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 3833 - wake_up_interruptible(&info->close_wait); 3844 + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 3845 + wake_up_interruptible(&info->port.close_wait); 3834 3846 local_irq_restore(flags); 3835 3847 3836 3848 /* port closed */ ··· 3923 3935 rs_flush_buffer(tty); 3924 3936 shutdown(info); 3925 3937 info->event = 0; 3926 - info->count = 0; 3927 - info->flags &= ~ASYNC_NORMAL_ACTIVE; 3938 + info->port.count = 0; 3939 + info->port.flags &= ~ASYNC_NORMAL_ACTIVE; 3928 3940 info->port.tty = NULL; 3929 - wake_up_interruptible(&info->open_wait); 3941 + wake_up_interruptible(&info->port.open_wait); 3930 3942 } 3931 3943 3932 3944 /* ··· 3948 3960 * until it's done, and then try again. 3949 3961 */ 3950 3962 if (tty_hung_up_p(filp) || 3951 - (info->flags & ASYNC_CLOSING)) { 3952 - wait_event_interruptible_tty(tty, info->close_wait, 3953 - !(info->flags & ASYNC_CLOSING)); 3963 + (info->port.flags & ASYNC_CLOSING)) { 3964 + wait_event_interruptible_tty(tty, info->port.close_wait, 3965 + !(info->port.flags & ASYNC_CLOSING)); 3954 3966 #ifdef SERIAL_DO_RESTART 3955 - if (info->flags & ASYNC_HUP_NOTIFY) 3967 + if (info->port.flags & ASYNC_HUP_NOTIFY) 3956 3968 return -EAGAIN; 3957 3969 else 3958 3970 return -ERESTARTSYS; ··· 3967 3979 */ 3968 3980 if ((filp->f_flags & O_NONBLOCK) || 3969 3981 (tty->flags & (1 << TTY_IO_ERROR))) { 3970 - info->flags |= ASYNC_NORMAL_ACTIVE; 3982 + info->port.flags |= ASYNC_NORMAL_ACTIVE; 3971 3983 return 0; 3972 3984 } 3973 3985 ··· 3978 3990 /* 3979 3991 * Block waiting for the carrier detect and the line to become 3980 3992 * free (i.e., not in use by the callout). While we are in 3981 - * this loop, info->count is dropped by one, so that 3993 + * this loop, info->port.count is dropped by one, so that 3982 3994 * rs_close() knows when to free things. We restore it upon 3983 3995 * exit, either normal or abnormal. 3984 3996 */ 3985 3997 retval = 0; 3986 - add_wait_queue(&info->open_wait, &wait); 3998 + add_wait_queue(&info->port.open_wait, &wait); 3987 3999 #ifdef SERIAL_DEBUG_OPEN 3988 4000 printk("block_til_ready before block: ttyS%d, count = %d\n", 3989 - info->line, info->count); 4001 + info->line, info->port.count); 3990 4002 #endif 3991 4003 local_irq_save(flags); 3992 4004 if (!tty_hung_up_p(filp)) { 3993 4005 extra_count++; 3994 - info->count--; 4006 + info->port.count--; 3995 4007 } 3996 4008 local_irq_restore(flags); 3997 - info->blocked_open++; 4009 + info->port.blocked_open++; 3998 4010 while (1) { 3999 4011 local_irq_save(flags); 4000 4012 /* assert RTS and DTR */ ··· 4003 4015 local_irq_restore(flags); 4004 4016 set_current_state(TASK_INTERRUPTIBLE); 4005 4017 if (tty_hung_up_p(filp) || 4006 - !(info->flags & ASYNC_INITIALIZED)) { 4018 + !(info->port.flags & ASYNC_INITIALIZED)) { 4007 4019 #ifdef SERIAL_DO_RESTART 4008 - if (info->flags & ASYNC_HUP_NOTIFY) 4020 + if (info->port.flags & ASYNC_HUP_NOTIFY) 4009 4021 retval = -EAGAIN; 4010 4022 else 4011 4023 retval = -ERESTARTSYS; ··· 4014 4026 #endif 4015 4027 break; 4016 4028 } 4017 - if (!(info->flags & ASYNC_CLOSING) && do_clocal) 4029 + if (!(info->port.flags & ASYNC_CLOSING) && do_clocal) 4018 4030 /* && (do_clocal || DCD_IS_ASSERTED) */ 4019 4031 break; 4020 4032 if (signal_pending(current)) { ··· 4023 4035 } 4024 4036 #ifdef SERIAL_DEBUG_OPEN 4025 4037 printk("block_til_ready blocking: ttyS%d, count = %d\n", 4026 - info->line, info->count); 4038 + info->line, info->port.count); 4027 4039 #endif 4028 4040 tty_unlock(tty); 4029 4041 schedule(); 4030 4042 tty_lock(tty); 4031 4043 } 4032 4044 set_current_state(TASK_RUNNING); 4033 - remove_wait_queue(&info->open_wait, &wait); 4045 + remove_wait_queue(&info->port.open_wait, &wait); 4034 4046 if (extra_count) 4035 - info->count++; 4036 - info->blocked_open--; 4047 + info->port.count++; 4048 + info->port.blocked_open--; 4037 4049 #ifdef SERIAL_DEBUG_OPEN 4038 4050 printk("block_til_ready after blocking: ttyS%d, count = %d\n", 4039 - info->line, info->count); 4051 + info->line, info->port.count); 4040 4052 #endif 4041 4053 if (retval) 4042 4054 return retval; 4043 - info->flags |= ASYNC_NORMAL_ACTIVE; 4055 + info->port.flags |= ASYNC_NORMAL_ACTIVE; 4044 4056 return 0; 4045 4057 } 4046 4058 ··· 4074 4086 4075 4087 #ifdef SERIAL_DEBUG_OPEN 4076 4088 printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name, 4077 - info->count); 4089 + info->port.count); 4078 4090 #endif 4079 4091 4080 - info->count++; 4092 + info->port.count++; 4081 4093 tty->driver_data = info; 4082 4094 info->port.tty = tty; 4083 4095 4084 - info->port.low_latency = !!(info->flags & ASYNC_LOW_LATENCY); 4096 + info->port.low_latency = !!(info->port.flags & ASYNC_LOW_LATENCY); 4085 4097 4086 4098 /* 4087 4099 * If the port is in the middle of closing, bail out now 4088 4100 */ 4089 4101 if (tty_hung_up_p(filp) || 4090 - (info->flags & ASYNC_CLOSING)) { 4091 - wait_event_interruptible_tty(tty, info->close_wait, 4092 - !(info->flags & ASYNC_CLOSING)); 4102 + (info->port.flags & ASYNC_CLOSING)) { 4103 + wait_event_interruptible_tty(tty, info->port.close_wait, 4104 + !(info->port.flags & ASYNC_CLOSING)); 4093 4105 #ifdef SERIAL_DO_RESTART 4094 - return ((info->flags & ASYNC_HUP_NOTIFY) ? 4106 + return ((info->port.flags & ASYNC_HUP_NOTIFY) ? 4095 4107 -EAGAIN : -ERESTARTSYS); 4096 4108 #else 4097 4109 return -EAGAIN; ··· 4101 4113 /* 4102 4114 * If DMA is enabled try to allocate the irq's. 4103 4115 */ 4104 - if (info->count == 1) { 4116 + if (info->port.count == 1) { 4105 4117 allocated_resources = 1; 4106 4118 if (info->dma_in_enabled) { 4107 4119 if (request_irq(info->dma_in_irq_nbr, ··· 4174 4186 if (allocated_resources) 4175 4187 deinit_port(info); 4176 4188 4177 - /* FIXME Decrease count info->count here too? */ 4189 + /* FIXME Decrease count info->port.count here too? */ 4178 4190 return retval; 4179 4191 } 4180 4192 ··· 4191 4203 return retval; 4192 4204 } 4193 4205 4194 - if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) { 4206 + if ((info->port.count == 1) && (info->port.flags & ASYNC_SPLIT_TERMIOS)) { 4195 4207 tty->termios = info->normal_termios; 4196 4208 change_speed(info); 4197 4209 } ··· 4244 4256 if (info->port.tty->stopped) 4245 4257 seq_printf(m, " stopped:%i", 4246 4258 (int)info->port.tty->stopped); 4247 - if (info->port.tty->hw_stopped) 4248 - seq_printf(m, " hw_stopped:%i", 4249 - (int)info->port.tty->hw_stopped); 4250 4259 } 4251 4260 4252 4261 { ··· 4440 4455 info->forced_eop = 0; 4441 4456 info->baud_base = DEF_BAUD_BASE; 4442 4457 info->custom_divisor = 0; 4443 - info->flags = 0; 4444 - info->close_delay = 5*HZ/10; 4445 - info->closing_wait = 30*HZ; 4446 4458 info->x_char = 0; 4447 4459 info->event = 0; 4448 - info->count = 0; 4449 - info->blocked_open = 0; 4450 4460 info->normal_termios = driver->init_termios; 4451 - init_waitqueue_head(&info->open_wait); 4452 - init_waitqueue_head(&info->close_wait); 4453 4461 info->xmit.buf = NULL; 4454 4462 info->xmit.tail = info->xmit.head = 0; 4455 4463 info->first_recv_buffer = info->last_recv_buffer = NULL;
-14
drivers/tty/serial/crisv10.h
··· 53 53 volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */ 54 54 volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */ 55 55 56 - int flags; /* defined in tty.h */ 57 - 58 56 u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */ 59 57 u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */ 60 58 u8 iseteop; /* bit number for R_SET_EOP for the input dma */ ··· 86 88 87 89 volatile int tr_running; /* 1 if output is running */ 88 90 89 - struct tty_struct *tty; 90 - int read_status_mask; 91 - int ignore_status_mask; 92 91 int x_char; /* xon/xoff character */ 93 - int close_delay; 94 - unsigned short closing_wait; 95 - unsigned short closing_wait2; 96 92 unsigned long event; 97 - unsigned long last_active; 98 93 int line; 99 94 int type; /* PORT_ETRAX */ 100 - int count; /* # of fd on device */ 101 - int blocked_open; /* # of blocked opens */ 102 95 struct circ_buf xmit; 103 96 struct etrax_recv_buffer *first_recv_buffer; 104 97 struct etrax_recv_buffer *last_recv_buffer; ··· 99 110 struct work_struct work; 100 111 struct async_icount icount; /* error-statistics etc.*/ 101 112 struct ktermios normal_termios; 102 - struct ktermios callout_termios; 103 - wait_queue_head_t open_wait; 104 - wait_queue_head_t close_wait; 105 113 106 114 unsigned long char_time_usec; /* The time for 1 char, in usecs */ 107 115 unsigned long flush_time_usec; /* How often we should flush */
+1 -2
drivers/tty/serial/icom.c
··· 1415 1415 struct icom_adapter *cur_adapter_entry; 1416 1416 struct list_head *tmp; 1417 1417 1418 - icom_adapter = (struct icom_adapter *) 1419 - kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); 1418 + icom_adapter = kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); 1420 1419 1421 1420 if (!icom_adapter) { 1422 1421 return -ENOMEM;
+4 -76
drivers/tty/serial/ifx6x60.c
··· 270 270 } 271 271 272 272 /** 273 - * ifx_spi_hangup - hang up an IFX device 274 - * @ifx_dev: our SPI device 275 - * 276 - * Hang up the tty attached to the IFX device if one is currently 277 - * open. If not take no action 278 - */ 279 - static void ifx_spi_ttyhangup(struct ifx_spi_device *ifx_dev) 280 - { 281 - struct tty_port *pport = &ifx_dev->tty_port; 282 - struct tty_struct *tty = tty_port_tty_get(pport); 283 - if (tty) { 284 - tty_hangup(tty); 285 - tty_kref_put(tty); 286 - } 287 - } 288 - 289 - /** 290 273 * ifx_spi_timeout - SPI timeout 291 274 * @arg: our SPI device 292 275 * ··· 281 298 struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg; 282 299 283 300 dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); 284 - ifx_spi_ttyhangup(ifx_dev); 301 + tty_port_tty_hangup(&ifx_dev->tty_port, false); 285 302 mrdy_set_low(ifx_dev); 286 303 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); 287 304 } ··· 426 443 } 427 444 428 445 /** 429 - * ifx_spi_wakeup_serial - SPI space made 430 - * @port_data: our SPI device 431 - * 432 - * We have emptied the FIFO enough that we want to get more data 433 - * queued into it. Poke the line discipline via tty_wakeup so that 434 - * it will feed us more bits 435 - */ 436 - static void ifx_spi_wakeup_serial(struct ifx_spi_device *ifx_dev) 437 - { 438 - struct tty_struct *tty; 439 - 440 - tty = tty_port_tty_get(&ifx_dev->tty_port); 441 - if (!tty) 442 - return; 443 - tty_wakeup(tty); 444 - tty_kref_put(tty); 445 - } 446 - 447 - /** 448 446 * ifx_spi_prepare_tx_buffer - prepare transmit frame 449 447 * @ifx_dev: our SPI device 450 448 * ··· 470 506 tx_count += temp_count; 471 507 if (temp_count == queue_length) 472 508 /* poke port to get more data */ 473 - ifx_spi_wakeup_serial(ifx_dev); 509 + tty_port_tty_wakeup(&ifx_dev->tty_port); 474 510 else /* more data in port, use next SPI message */ 475 511 ifx_dev->spi_more = 1; 476 512 } ··· 647 683 static void ifx_spi_complete(void *ctx) 648 684 { 649 685 struct ifx_spi_device *ifx_dev = ctx; 650 - struct tty_struct *tty; 651 - struct tty_ldisc *ldisc = NULL; 652 686 int length; 653 687 int actual_length; 654 688 unsigned char more; ··· 724 762 */ 725 763 ifx_spi_power_state_clear(ifx_dev, 726 764 IFX_SPI_POWER_DATA_PENDING); 727 - tty = tty_port_tty_get(&ifx_dev->tty_port); 728 - if (tty) { 729 - ldisc = tty_ldisc_ref(tty); 730 - if (ldisc) { 731 - ldisc->ops->write_wakeup(tty); 732 - tty_ldisc_deref(ldisc); 733 - } 734 - tty_kref_put(tty); 735 - } 765 + tty_port_tty_wakeup(&ifx_dev->tty_port); 736 766 } 737 767 } 738 768 } ··· 916 962 set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); 917 963 if (!solreset) { 918 964 /* unsolicited reset */ 919 - ifx_spi_ttyhangup(ifx_dev); 965 + tty_port_tty_hangup(&ifx_dev->tty_port, false); 920 966 } 921 967 } else { 922 968 /* exited reset */ ··· 1279 1325 */ 1280 1326 1281 1327 /** 1282 - * ifx_spi_spi_suspend - suspend SPI on system suspend 1283 - * @dev: device being suspended 1284 - * 1285 - * Suspend the SPI side. No action needed on Intel MID platforms, may 1286 - * need extending for other systems. 1287 - */ 1288 - static int ifx_spi_spi_suspend(struct spi_device *spi, pm_message_t msg) 1289 - { 1290 - return 0; 1291 - } 1292 - 1293 - /** 1294 - * ifx_spi_spi_resume - resume SPI side on system resume 1295 - * @dev: device being suspended 1296 - * 1297 - * Suspend the SPI side. No action needed on Intel MID platforms, may 1298 - * need extending for other systems. 1299 - */ 1300 - static int ifx_spi_spi_resume(struct spi_device *spi) 1301 - { 1302 - return 0; 1303 - } 1304 - 1305 - /** 1306 1328 * ifx_spi_pm_suspend - suspend modem on system suspend 1307 1329 * @dev: device being suspended 1308 1330 * ··· 1367 1437 .probe = ifx_spi_spi_probe, 1368 1438 .shutdown = ifx_spi_spi_shutdown, 1369 1439 .remove = ifx_spi_spi_remove, 1370 - .suspend = ifx_spi_spi_suspend, 1371 - .resume = ifx_spi_spi_resume, 1372 1440 .id_table = ifx_id_table 1373 1441 }; 1374 1442
-6
drivers/tty/serial/jsm/jsm_tty.c
··· 596 596 597 597 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start 2\n"); 598 598 599 - if (data_len <= 0) { 600 - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 601 - jsm_dbg(READ, &ch->ch_bd->pci_dev, "jsm_input 1\n"); 602 - return; 603 - } 604 - 605 599 len = tty_buffer_request_room(port, data_len); 606 600 n = len; 607 601
+12 -12
drivers/tty/serial/max3100.c
··· 778 778 max3100s[i]->spi = spi; 779 779 max3100s[i]->irq = spi->irq; 780 780 spin_lock_init(&max3100s[i]->conf_lock); 781 - dev_set_drvdata(&spi->dev, max3100s[i]); 781 + spi_set_drvdata(spi, max3100s[i]); 782 782 pdata = spi->dev.platform_data; 783 783 max3100s[i]->crystal = pdata->crystal; 784 784 max3100s[i]->loopback = pdata->loopback; ··· 819 819 820 820 static int max3100_remove(struct spi_device *spi) 821 821 { 822 - struct max3100_port *s = dev_get_drvdata(&spi->dev); 822 + struct max3100_port *s = spi_get_drvdata(spi); 823 823 int i; 824 824 825 825 mutex_lock(&max3100s_lock); ··· 849 849 return 0; 850 850 } 851 851 852 - #ifdef CONFIG_PM 852 + #ifdef CONFIG_PM_SLEEP 853 853 854 - static int max3100_suspend(struct spi_device *spi, pm_message_t state) 854 + static int max3100_suspend(struct device *dev) 855 855 { 856 - struct max3100_port *s = dev_get_drvdata(&spi->dev); 856 + struct max3100_port *s = dev_get_drvdata(dev); 857 857 858 858 dev_dbg(&s->spi->dev, "%s\n", __func__); 859 859 ··· 874 874 return 0; 875 875 } 876 876 877 - static int max3100_resume(struct spi_device *spi) 877 + static int max3100_resume(struct device *dev) 878 878 { 879 - struct max3100_port *s = dev_get_drvdata(&spi->dev); 879 + struct max3100_port *s = dev_get_drvdata(dev); 880 880 881 881 dev_dbg(&s->spi->dev, "%s\n", __func__); 882 882 ··· 894 894 return 0; 895 895 } 896 896 897 + static SIMPLE_DEV_PM_OPS(max3100_pm_ops, max3100_suspend, max3100_resume); 898 + #define MAX3100_PM_OPS (&max3100_pm_ops) 899 + 897 900 #else 898 - #define max3100_suspend NULL 899 - #define max3100_resume NULL 901 + #define MAX3100_PM_OPS NULL 900 902 #endif 901 903 902 904 static struct spi_driver max3100_driver = { 903 905 .driver = { 904 906 .name = "max3100", 905 907 .owner = THIS_MODULE, 908 + .pm = MAX3100_PM_OPS, 906 909 }, 907 - 908 910 .probe = max3100_probe, 909 911 .remove = max3100_remove, 910 - .suspend = max3100_suspend, 911 - .resume = max3100_resume, 912 912 }; 913 913 914 914 module_spi_driver(max3100_driver);
+16 -8
drivers/tty/serial/max310x.c
··· 881 881 .verify_port = max310x_verify_port, 882 882 }; 883 883 884 - static int max310x_suspend(struct spi_device *spi, pm_message_t state) 884 + #ifdef CONFIG_PM_SLEEP 885 + 886 + static int max310x_suspend(struct device *dev) 885 887 { 886 888 int ret; 887 - struct max310x_port *s = dev_get_drvdata(&spi->dev); 889 + struct max310x_port *s = dev_get_drvdata(dev); 888 890 889 - dev_dbg(&spi->dev, "Suspend\n"); 891 + dev_dbg(dev, "Suspend\n"); 890 892 891 893 ret = uart_suspend_port(&s->uart, &s->port); 892 894 ··· 907 905 return ret; 908 906 } 909 907 910 - static int max310x_resume(struct spi_device *spi) 908 + static int max310x_resume(struct device *dev) 911 909 { 912 - struct max310x_port *s = dev_get_drvdata(&spi->dev); 910 + struct max310x_port *s = dev_get_drvdata(dev); 913 911 914 - dev_dbg(&spi->dev, "Resume\n"); 912 + dev_dbg(dev, "Resume\n"); 915 913 916 914 if (s->pdata->suspend) 917 915 s->pdata->suspend(0); ··· 929 927 930 928 return uart_resume_port(&s->uart, &s->port); 931 929 } 930 + 931 + static SIMPLE_DEV_PM_OPS(max310x_pm_ops, max310x_suspend, max310x_resume); 932 + #define MAX310X_PM_OPS (&max310x_pm_ops) 933 + 934 + #else 935 + #define MAX310X_PM_OPS NULL 936 + #endif 932 937 933 938 #ifdef CONFIG_GPIOLIB 934 939 static int max310x_gpio_get(struct gpio_chip *chip, unsigned offset) ··· 1251 1242 .driver = { 1252 1243 .name = "max310x", 1253 1244 .owner = THIS_MODULE, 1245 + .pm = MAX310X_PM_OPS, 1254 1246 }, 1255 1247 .probe = max310x_probe, 1256 1248 .remove = max310x_remove, 1257 - .suspend = max310x_suspend, 1258 - .resume = max310x_resume, 1259 1249 .id_table = max310x_id_table, 1260 1250 }; 1261 1251 module_spi_driver(max310x_driver);
+12 -7
drivers/tty/serial/mrst_max3110.c
··· 743 743 .cons = &serial_m3110_console, 744 744 }; 745 745 746 - #ifdef CONFIG_PM 747 - static int serial_m3110_suspend(struct spi_device *spi, pm_message_t state) 746 + #ifdef CONFIG_PM_SLEEP 747 + static int serial_m3110_suspend(struct device *dev) 748 748 { 749 + struct spi_device *spi = to_spi_device(dev); 749 750 struct uart_max3110 *max = spi_get_drvdata(spi); 750 751 751 752 disable_irq(max->irq); ··· 755 754 return 0; 756 755 } 757 756 758 - static int serial_m3110_resume(struct spi_device *spi) 757 + static int serial_m3110_resume(struct device *dev) 759 758 { 759 + struct spi_device *spi = to_spi_device(dev); 760 760 struct uart_max3110 *max = spi_get_drvdata(spi); 761 761 762 762 max3110_out(max, max->cur_conf); ··· 765 763 enable_irq(max->irq); 766 764 return 0; 767 765 } 766 + 767 + static SIMPLE_DEV_PM_OPS(serial_m3110_pm_ops, serial_m3110_suspend, 768 + serial_m3110_resume); 769 + #define SERIAL_M3110_PM_OPS (&serial_m3110_pm_ops) 770 + 768 771 #else 769 - #define serial_m3110_suspend NULL 770 - #define serial_m3110_resume NULL 772 + #define SERIAL_M3110_PM_OPS NULL 771 773 #endif 772 774 773 775 static int serial_m3110_probe(struct spi_device *spi) ··· 878 872 .driver = { 879 873 .name = "spi_max3111", 880 874 .owner = THIS_MODULE, 875 + .pm = SERIAL_M3110_PM_OPS, 881 876 }, 882 877 .probe = serial_m3110_probe, 883 878 .remove = serial_m3110_remove, 884 - .suspend = serial_m3110_suspend, 885 - .resume = serial_m3110_resume, 886 879 }; 887 880 888 881 static int __init serial_m3110_init(void)
-2
drivers/tty/serial/msm_serial_hs.c
··· 907 907 unsigned int error_f = 0; 908 908 unsigned long flags; 909 909 unsigned int flush; 910 - struct tty_struct *tty; 911 910 struct tty_port *port; 912 911 struct uart_port *uport; 913 912 struct msm_hs_port *msm_uport; ··· 918 919 clk_enable(msm_uport->clk); 919 920 920 921 port = &uport->state->port; 921 - tty = port->tty; 922 922 923 923 msm_hs_write(uport, UARTDM_CR_ADDR, STALE_EVENT_DISABLE); 924 924
+5 -9
drivers/tty/serial/msm_smd_tty.c
··· 90 90 91 91 static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty) 92 92 { 93 + struct smd_tty_info *info = container_of(tport, struct smd_tty_info, 94 + port); 93 95 int i, res = 0; 94 - int n = tty->index; 95 96 const char *name = NULL; 96 - struct smd_tty_info *info = smd_tty + n; 97 97 98 98 for (i = 0; i < smd_tty_channels_len; i++) { 99 - if (smd_tty_channels[i].id == n) { 99 + if (smd_tty_channels[i].id == tty->index) { 100 100 name = smd_tty_channels[i].name; 101 101 break; 102 102 } ··· 117 117 118 118 static void smd_tty_port_shutdown(struct tty_port *tport) 119 119 { 120 - struct smd_tty_info *info; 121 - struct tty_struct *tty = tty_port_tty_get(tport); 120 + struct smd_tty_info *info = container_of(tport, struct smd_tty_info, 121 + port); 122 122 123 - info = tty->driver_data; 124 123 if (info->ch) { 125 124 smd_close(info->ch); 126 125 info->ch = 0; 127 126 } 128 - 129 - tty->driver_data = 0; 130 - tty_kref_put(tty); 131 127 } 132 128 133 129 static int smd_tty_open(struct tty_struct *tty, struct file *f)
+2 -4
drivers/tty/serial/mxs-auart.c
··· 883 883 unsigned int old_ctrl0, old_ctrl2; 884 884 unsigned int to = 1000; 885 885 886 - if (co->index > MXS_AUART_PORTS || co->index < 0) 886 + if (co->index >= MXS_AUART_PORTS || co->index < 0) 887 887 return; 888 888 889 889 s = auart_port[co->index]; ··· 1103 1103 s->port.fifosize = 16; 1104 1104 s->port.uartclk = clk_get_rate(s->clk); 1105 1105 s->port.type = PORT_IMX; 1106 - s->port.dev = s->dev = get_device(&pdev->dev); 1106 + s->port.dev = s->dev = &pdev->dev; 1107 1107 1108 1108 s->ctrl = 0; 1109 1109 ··· 1134 1134 auart_port[pdev->id] = NULL; 1135 1135 free_irq(s->irq, s); 1136 1136 out_free_clk: 1137 - put_device(s->dev); 1138 1137 clk_put(s->clk); 1139 1138 out_free: 1140 1139 kfree(s); ··· 1149 1150 1150 1151 auart_port[pdev->id] = NULL; 1151 1152 1152 - put_device(s->dev); 1153 1153 clk_put(s->clk); 1154 1154 free_irq(s->irq, s); 1155 1155 kfree(s);
+14 -3
drivers/tty/serial/of_serial.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/delay.h> 16 16 #include <linux/serial_core.h> 17 - #include <linux/serial_8250.h> 18 17 #include <linux/serial_reg.h> 19 18 #include <linux/of_address.h> 20 19 #include <linux/of_irq.h> 21 20 #include <linux/of_platform.h> 22 21 #include <linux/nwpserial.h> 23 22 #include <linux/clk.h> 23 + 24 + #include "8250/8250.h" 24 25 25 26 struct of_serial_info { 26 27 struct clk *clk; ··· 98 97 if (of_property_read_u32(np, "reg-shift", &prop) == 0) 99 98 port->regshift = prop; 100 99 100 + /* Check for fifo size */ 101 + if (of_property_read_u32(np, "fifo-size", &prop) == 0) 102 + port->fifosize = prop; 103 + 101 104 port->irq = irq_of_parse_and_map(np, 0); 102 105 port->iotype = UPIO_MEM; 103 106 if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { ··· 172 167 #ifdef CONFIG_SERIAL_8250 173 168 case PORT_8250 ... PORT_MAX_8250: 174 169 { 175 - /* For now the of bindings don't support the extra 176 - 8250 specific bits */ 177 170 struct uart_8250_port port8250; 178 171 memset(&port8250, 0, sizeof(port8250)); 179 172 port8250.port = port; 173 + 174 + if (port.fifosize) 175 + port8250.capabilities = UART_CAP_FIFO; 176 + 177 + if (of_property_read_bool(ofdev->dev.of_node, 178 + "auto-flow-control")) 179 + port8250.capabilities |= UART_CAP_AFE; 180 + 180 181 ret = serial8250_register_8250_port(&port8250); 181 182 break; 182 183 }
+79 -24
drivers/tty/serial/pch_uart.c
··· 1493 1493 return 0; 1494 1494 } 1495 1495 1496 - static struct uart_ops pch_uart_ops = { 1497 - .tx_empty = pch_uart_tx_empty, 1498 - .set_mctrl = pch_uart_set_mctrl, 1499 - .get_mctrl = pch_uart_get_mctrl, 1500 - .stop_tx = pch_uart_stop_tx, 1501 - .start_tx = pch_uart_start_tx, 1502 - .stop_rx = pch_uart_stop_rx, 1503 - .enable_ms = pch_uart_enable_ms, 1504 - .break_ctl = pch_uart_break_ctl, 1505 - .startup = pch_uart_startup, 1506 - .shutdown = pch_uart_shutdown, 1507 - .set_termios = pch_uart_set_termios, 1508 - /* .pm = pch_uart_pm, Not supported yet */ 1509 - /* .set_wake = pch_uart_set_wake, Not supported yet */ 1510 - .type = pch_uart_type, 1511 - .release_port = pch_uart_release_port, 1512 - .request_port = pch_uart_request_port, 1513 - .config_port = pch_uart_config_port, 1514 - .verify_port = pch_uart_verify_port 1515 - }; 1516 - 1517 - #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE 1518 - 1519 1496 /* 1520 1497 * Wait for transmitter & holding register to empty 1521 1498 */ ··· 1523 1546 } 1524 1547 } 1525 1548 } 1549 + 1550 + #ifdef CONFIG_CONSOLE_POLL 1551 + /* 1552 + * Console polling routines for communicate via uart while 1553 + * in an interrupt or debug context. 1554 + */ 1555 + static int pch_uart_get_poll_char(struct uart_port *port) 1556 + { 1557 + struct eg20t_port *priv = 1558 + container_of(port, struct eg20t_port, port); 1559 + u8 lsr = ioread8(priv->membase + UART_LSR); 1560 + 1561 + if (!(lsr & UART_LSR_DR)) 1562 + return NO_POLL_CHAR; 1563 + 1564 + return ioread8(priv->membase + PCH_UART_RBR); 1565 + } 1566 + 1567 + 1568 + static void pch_uart_put_poll_char(struct uart_port *port, 1569 + unsigned char c) 1570 + { 1571 + unsigned int ier; 1572 + struct eg20t_port *priv = 1573 + container_of(port, struct eg20t_port, port); 1574 + 1575 + /* 1576 + * First save the IER then disable the interrupts 1577 + */ 1578 + ier = ioread8(priv->membase + UART_IER); 1579 + pch_uart_hal_disable_interrupt(priv, PCH_UART_HAL_ALL_INT); 1580 + 1581 + wait_for_xmitr(priv, UART_LSR_THRE); 1582 + /* 1583 + * Send the character out. 1584 + * If a LF, also do CR... 1585 + */ 1586 + iowrite8(c, priv->membase + PCH_UART_THR); 1587 + if (c == 10) { 1588 + wait_for_xmitr(priv, UART_LSR_THRE); 1589 + iowrite8(13, priv->membase + PCH_UART_THR); 1590 + } 1591 + 1592 + /* 1593 + * Finally, wait for transmitter to become empty 1594 + * and restore the IER 1595 + */ 1596 + wait_for_xmitr(priv, BOTH_EMPTY); 1597 + iowrite8(ier, priv->membase + UART_IER); 1598 + } 1599 + #endif /* CONFIG_CONSOLE_POLL */ 1600 + 1601 + static struct uart_ops pch_uart_ops = { 1602 + .tx_empty = pch_uart_tx_empty, 1603 + .set_mctrl = pch_uart_set_mctrl, 1604 + .get_mctrl = pch_uart_get_mctrl, 1605 + .stop_tx = pch_uart_stop_tx, 1606 + .start_tx = pch_uart_start_tx, 1607 + .stop_rx = pch_uart_stop_rx, 1608 + .enable_ms = pch_uart_enable_ms, 1609 + .break_ctl = pch_uart_break_ctl, 1610 + .startup = pch_uart_startup, 1611 + .shutdown = pch_uart_shutdown, 1612 + .set_termios = pch_uart_set_termios, 1613 + /* .pm = pch_uart_pm, Not supported yet */ 1614 + /* .set_wake = pch_uart_set_wake, Not supported yet */ 1615 + .type = pch_uart_type, 1616 + .release_port = pch_uart_release_port, 1617 + .request_port = pch_uart_request_port, 1618 + .config_port = pch_uart_config_port, 1619 + .verify_port = pch_uart_verify_port, 1620 + #ifdef CONFIG_CONSOLE_POLL 1621 + .poll_get_char = pch_uart_get_poll_char, 1622 + .poll_put_char = pch_uart_put_poll_char, 1623 + #endif 1624 + }; 1625 + 1626 + #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE 1526 1627 1527 1628 static void pch_console_putchar(struct uart_port *port, int ch) 1528 1629 { ··· 1710 1655 #define PCH_CONSOLE (&pch_console) 1711 1656 #else 1712 1657 #define PCH_CONSOLE NULL 1713 - #endif 1658 + #endif /* CONFIG_SERIAL_PCH_UART_CONSOLE */ 1714 1659 1715 1660 static struct uart_driver pch_uart_driver = { 1716 1661 .owner = THIS_MODULE,
+54 -9
drivers/tty/serial/samsung.c
··· 39 39 #include <linux/tty_flip.h> 40 40 #include <linux/serial_core.h> 41 41 #include <linux/serial.h> 42 + #include <linux/serial_s3c.h> 42 43 #include <linux/delay.h> 43 44 #include <linux/clk.h> 44 45 #include <linux/cpufreq.h> ··· 47 46 48 47 #include <asm/irq.h> 49 48 50 - #include <mach/hardware.h> 51 - 52 - #include <plat/regs-serial.h> 49 + #ifdef CONFIG_SAMSUNG_CLOCK 53 50 #include <plat/clock.h> 51 + #endif 54 52 55 53 #include "samsung.h" 56 54 ··· 446 446 447 447 /* Clear pending interrupts and mask all interrupts */ 448 448 if (s3c24xx_serial_has_interrupt_mask(port)) { 449 + free_irq(port->irq, ourport); 450 + 449 451 wr_regl(port, S3C64XX_UINTP, 0xf); 450 452 wr_regl(port, S3C64XX_UINTM, 0xf); 451 453 } ··· 506 504 507 505 dbg("s3c64xx_serial_startup: port=%p (%08lx,%p)\n", 508 506 port->mapbase, port->membase); 507 + 508 + wr_regl(port, S3C64XX_UINTM, 0xf); 509 509 510 510 ret = request_irq(port->irq, s3c64xx_serial_handle_irq, IRQF_SHARED, 511 511 s3c24xx_serial_portname(port), ourport); ··· 898 894 #define S3C24XX_SERIAL_CONSOLE NULL 899 895 #endif 900 896 901 - #ifdef CONFIG_CONSOLE_POLL 897 + #if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_CONSOLE_POLL) 902 898 static int s3c24xx_serial_get_poll_char(struct uart_port *port); 903 899 static void s3c24xx_serial_put_poll_char(struct uart_port *port, 904 900 unsigned char c); ··· 922 918 .request_port = s3c24xx_serial_request_port, 923 919 .config_port = s3c24xx_serial_config_port, 924 920 .verify_port = s3c24xx_serial_verify_port, 925 - #ifdef CONFIG_CONSOLE_POLL 921 + #if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_CONSOLE_POLL) 926 922 .poll_get_char = s3c24xx_serial_get_poll_char, 927 923 .poll_put_char = s3c24xx_serial_put_poll_char, 928 924 #endif ··· 1183 1179 return 0; 1184 1180 } 1185 1181 1182 + #ifdef CONFIG_SAMSUNG_CLOCK 1186 1183 static ssize_t s3c24xx_serial_show_clksrc(struct device *dev, 1187 1184 struct device_attribute *attr, 1188 1185 char *buf) ··· 1199 1194 } 1200 1195 1201 1196 static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL); 1202 - 1197 + #endif 1203 1198 1204 1199 /* Device driver serial port probe */ 1205 1200 ··· 1257 1252 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); 1258 1253 platform_set_drvdata(pdev, &ourport->port); 1259 1254 1255 + #ifdef CONFIG_SAMSUNG_CLOCK 1260 1256 ret = device_create_file(&pdev->dev, &dev_attr_clock_source); 1261 1257 if (ret < 0) 1262 1258 dev_err(&pdev->dev, "failed to add clock source attr.\n"); 1259 + #endif 1263 1260 1264 1261 ret = s3c24xx_serial_cpufreq_register(ourport); 1265 1262 if (ret < 0) ··· 1279 1272 1280 1273 if (port) { 1281 1274 s3c24xx_serial_cpufreq_deregister(to_ourport(port)); 1275 + #ifdef CONFIG_SAMSUNG_CLOCK 1282 1276 device_remove_file(&dev->dev, &dev_attr_clock_source); 1277 + #endif 1283 1278 uart_remove_one_port(&s3c24xx_uart_drv, port); 1284 1279 } 1285 1280 ··· 1316 1307 return 0; 1317 1308 } 1318 1309 1310 + static int s3c24xx_serial_resume_noirq(struct device *dev) 1311 + { 1312 + struct uart_port *port = s3c24xx_dev_to_port(dev); 1313 + 1314 + if (port) { 1315 + /* restore IRQ mask */ 1316 + if (s3c24xx_serial_has_interrupt_mask(port)) { 1317 + unsigned int uintm = 0xf; 1318 + if (tx_enabled(port)) 1319 + uintm &= ~S3C64XX_UINTM_TXD_MSK; 1320 + if (rx_enabled(port)) 1321 + uintm &= ~S3C64XX_UINTM_RXD_MSK; 1322 + wr_regl(port, S3C64XX_UINTM, uintm); 1323 + } 1324 + } 1325 + 1326 + return 0; 1327 + } 1328 + 1319 1329 static const struct dev_pm_ops s3c24xx_serial_pm_ops = { 1320 1330 .suspend = s3c24xx_serial_suspend, 1321 1331 .resume = s3c24xx_serial_resume, 1332 + .resume_noirq = s3c24xx_serial_resume_noirq, 1322 1333 }; 1323 1334 #define SERIAL_SAMSUNG_PM_OPS (&s3c24xx_serial_pm_ops) 1324 1335 ··· 1372 1343 return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0; 1373 1344 } 1374 1345 1346 + static bool 1347 + s3c24xx_port_configured(unsigned int ucon) 1348 + { 1349 + /* consider the serial port configured if the tx/rx mode set */ 1350 + return (ucon & 0xf) != 0; 1351 + } 1352 + 1375 1353 #ifdef CONFIG_CONSOLE_POLL 1376 1354 /* 1377 1355 * Console polling routines for writing and reading from the uart while ··· 1401 1365 unsigned char c) 1402 1366 { 1403 1367 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1368 + unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); 1369 + 1370 + /* not possible to xmit on unconfigured port */ 1371 + if (!s3c24xx_port_configured(ucon)) 1372 + return; 1404 1373 1405 1374 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1406 1375 cpu_relax(); ··· 1418 1377 s3c24xx_serial_console_putchar(struct uart_port *port, int ch) 1419 1378 { 1420 1379 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1380 + unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); 1381 + 1382 + /* not possible to xmit on unconfigured port */ 1383 + if (!s3c24xx_port_configured(ucon)) 1384 + return; 1385 + 1421 1386 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1422 1387 barrier(); 1423 1388 wr_regb(cons_uart, S3C2410_UTXH, ch); ··· 1456 1409 "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n", 1457 1410 port, ulcon, ucon, ubrdiv); 1458 1411 1459 - if ((ucon & 0xf) != 0) { 1460 - /* consider the serial port configured if the tx/rx mode set */ 1461 - 1412 + if (s3c24xx_port_configured(ucon)) { 1462 1413 switch (ulcon & S3C2410_LCON_CSMASK) { 1463 1414 case S3C2410_LCON_CS5: 1464 1415 *bits = 5;
+3 -1
drivers/tty/serial/samsung.h
··· 76 76 #define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg)) 77 77 #define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg)) 78 78 79 - #ifdef CONFIG_SERIAL_SAMSUNG_DEBUG 79 + #if defined(CONFIG_SERIAL_SAMSUNG_DEBUG) && \ 80 + defined(CONFIG_DEBUG_LL) && \ 81 + !defined(MODULE) 80 82 81 83 extern void printascii(const char *); 82 84
+15 -8
drivers/tty/serial/sccnxp.c
··· 27 27 #include <linux/spinlock.h> 28 28 #include <linux/platform_device.h> 29 29 #include <linux/platform_data/serial-sccnxp.h> 30 + #include <linux/regulator/consumer.h> 30 31 31 32 #define SCCNXP_NAME "uart-sccnxp" 32 33 #define SCCNXP_MAJOR 204 ··· 132 131 struct timer_list timer; 133 132 134 133 struct sccnxp_pdata pdata; 134 + 135 + struct regulator *regulator; 135 136 }; 136 137 137 138 static inline u8 sccnxp_raw_read(void __iomem *base, u8 reg, u8 shift) ··· 792 789 return -EADDRNOTAVAIL; 793 790 } 794 791 795 - dev_set_name(&pdev->dev, SCCNXP_NAME); 796 - 797 792 s = devm_kzalloc(&pdev->dev, sizeof(struct sccnxp_port), GFP_KERNEL); 798 793 if (!s) { 799 794 dev_err(&pdev->dev, "Error allocating port structure\n"); ··· 919 918 goto err_out; 920 919 } 921 920 921 + s->regulator = devm_regulator_get(&pdev->dev, "VCC"); 922 + if (!IS_ERR(s->regulator)) { 923 + ret = regulator_enable(s->regulator); 924 + if (ret) { 925 + dev_err(&pdev->dev, 926 + "Failed to enable regulator: %i\n", ret); 927 + return ret; 928 + } 929 + } 930 + 922 931 membase = devm_ioremap_resource(&pdev->dev, res); 923 932 if (IS_ERR(membase)) { 924 933 ret = PTR_ERR(membase); ··· 978 967 s->imr = 0; 979 968 sccnxp_write(&s->port[0], SCCNXP_IMR_REG, 0); 980 969 981 - /* Board specific configure */ 982 - if (s->pdata.init) 983 - s->pdata.init(); 984 - 985 970 if (!s->poll) { 986 971 ret = devm_request_threaded_irq(&pdev->dev, s->irq, NULL, 987 972 sccnxp_ist, ··· 1018 1011 uart_unregister_driver(&s->uart); 1019 1012 platform_set_drvdata(pdev, NULL); 1020 1013 1021 - if (s->pdata.exit) 1022 - s->pdata.exit(); 1014 + if (!IS_ERR(s->regulator)) 1015 + return regulator_disable(s->regulator); 1023 1016 1024 1017 return 0; 1025 1018 }
+4 -5
drivers/tty/serial/serial-tegra.c
··· 26 26 #include <linux/dmaengine.h> 27 27 #include <linux/dma-mapping.h> 28 28 #include <linux/dmapool.h> 29 + #include <linux/err.h> 29 30 #include <linux/io.h> 30 31 #include <linux/irq.h> 31 32 #include <linux/module.h> ··· 1302 1301 } 1303 1302 1304 1303 u->mapbase = resource->start; 1305 - u->membase = devm_request_and_ioremap(&pdev->dev, resource); 1306 - if (!u->membase) { 1307 - dev_err(&pdev->dev, "memregion/iomap address req failed\n"); 1308 - return -EADDRNOTAVAIL; 1309 - } 1304 + u->membase = devm_ioremap_resource(&pdev->dev, resource); 1305 + if (IS_ERR(u->membase)) 1306 + return PTR_ERR(u->membase); 1310 1307 1311 1308 tup->uart_clk = devm_clk_get(&pdev->dev, NULL); 1312 1309 if (IS_ERR(tup->uart_clk)) {
+4
drivers/tty/serial/serial_core.c
··· 1941 1941 mutex_unlock(&port->mutex); 1942 1942 return 0; 1943 1943 } 1944 + put_device(tty_dev); 1945 + 1944 1946 if (console_suspend_enabled || !uart_console(uport)) 1945 1947 uport->suspended = 1; 1946 1948 ··· 2008 2006 disable_irq_wake(uport->irq); 2009 2007 uport->irq_wake = 0; 2010 2008 } 2009 + put_device(tty_dev); 2011 2010 mutex_unlock(&port->mutex); 2012 2011 return 0; 2013 2012 } 2013 + put_device(tty_dev); 2014 2014 uport->suspended = 0; 2015 2015 2016 2016 /*
-2
drivers/tty/serial/sh-sci.h
··· 15 15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 16 16 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 17 17 defined(CONFIG_ARCH_SH73A0) || \ 18 - defined(CONFIG_ARCH_SH7367) || \ 19 - defined(CONFIG_ARCH_SH7377) || \ 20 18 defined(CONFIG_ARCH_SH7372) || \ 21 19 defined(CONFIG_ARCH_R8A7740) 22 20
+1 -1
drivers/tty/serial/sirfsoc_uart.c
··· 758 758 { .compatible = "sirf,marco-uart", }, 759 759 {} 760 760 }; 761 - MODULE_DEVICE_TABLE(of, sirfsoc_serial_of_match); 761 + MODULE_DEVICE_TABLE(of, sirfsoc_uart_ids); 762 762 763 763 static struct platform_driver sirfsoc_uart_driver = { 764 764 .probe = sirfsoc_uart_probe,
+1 -1
drivers/tty/serial/sunsab.c
··· 203 203 flag = TTY_FRAME; 204 204 } 205 205 206 - if (uart_handle_sysrq_char(&up->port, ch)) 206 + if (uart_handle_sysrq_char(&up->port, ch) || !port) 207 207 continue; 208 208 209 209 if ((stat->sreg.isr0 & (up->port.ignore_status_mask & 0xff)) == 0 &&
+1 -1
drivers/tty/serial/sunzilog.c
··· 388 388 else if (r1 & CRC_ERR) 389 389 flag = TTY_FRAME; 390 390 } 391 - if (uart_handle_sysrq_char(&up->port, ch)) 391 + if (uart_handle_sysrq_char(&up->port, ch) || !port) 392 392 continue; 393 393 394 394 if (up->port.ignore_status_mask == 0xff ||
+4 -3
drivers/tty/serial/vt8500_serial.c
··· 35 35 #include <linux/clk.h> 36 36 #include <linux/platform_device.h> 37 37 #include <linux/of.h> 38 + #include <linux/err.h> 38 39 39 40 /* 40 41 * UART Register offsets ··· 586 585 if (!vt8500_port) 587 586 return -ENOMEM; 588 587 589 - vt8500_port->uart.membase = devm_request_and_ioremap(&pdev->dev, mmres); 590 - if (!vt8500_port->uart.membase) 591 - return -EADDRNOTAVAIL; 588 + vt8500_port->uart.membase = devm_ioremap_resource(&pdev->dev, mmres); 589 + if (IS_ERR(vt8500_port->uart.membase)) 590 + return PTR_ERR(vt8500_port->uart.membase); 592 591 593 592 vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); 594 593 if (IS_ERR(vt8500_port->clk)) {
-3
drivers/tty/serial/xilinx_uartps.c
··· 585 585 xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | 586 586 XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | 587 587 XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET); 588 - xuartps_writel(~(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | 589 - XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | 590 - XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT), XUARTPS_IDR_OFFSET); 591 588 592 589 return retval; 593 590 }
+1 -4
drivers/tty/synclink.c
··· 1058 1058 container_of(work, struct mgsl_struct, task); 1059 1059 int action; 1060 1060 1061 - if (!info) 1062 - return; 1063 - 1064 1061 if ( debug_level >= DEBUG_LEVEL_BH ) 1065 1062 printk( "%s(%d):mgsl_bh_handler(%s) entry\n", 1066 1063 __FILE__,__LINE__,info->device_name); ··· 3308 3311 port->blocked_open++; 3309 3312 3310 3313 while (1) { 3311 - if (tty->termios.c_cflag & CBAUD) 3314 + if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) 3312 3315 tty_port_raise_dtr_rts(port); 3313 3316 3314 3317 set_current_state(TASK_INTERRUPTIBLE);
+1 -1
drivers/tty/synclinkmp.c
··· 3329 3329 port->blocked_open++; 3330 3330 3331 3331 while (1) { 3332 - if (tty->termios.c_cflag & CBAUD) 3332 + if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) 3333 3333 tty_port_raise_dtr_rts(port); 3334 3334 3335 3335 set_current_state(TASK_INTERRUPTIBLE);
+19 -19
drivers/tty/sysrq.c
··· 101 101 } 102 102 static struct sysrq_key_op sysrq_SAK_op = { 103 103 .handler = sysrq_handle_SAK, 104 - .help_msg = "saK", 104 + .help_msg = "sak(k)", 105 105 .action_msg = "SAK", 106 106 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 107 107 }; ··· 117 117 118 118 static struct sysrq_key_op sysrq_unraw_op = { 119 119 .handler = sysrq_handle_unraw, 120 - .help_msg = "unRaw", 120 + .help_msg = "unraw(r)", 121 121 .action_msg = "Keyboard mode set to system default", 122 122 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 123 123 }; ··· 135 135 } 136 136 static struct sysrq_key_op sysrq_crash_op = { 137 137 .handler = sysrq_handle_crash, 138 - .help_msg = "Crash", 138 + .help_msg = "crash(c)", 139 139 .action_msg = "Trigger a crash", 140 140 .enable_mask = SYSRQ_ENABLE_DUMP, 141 141 }; ··· 148 148 } 149 149 static struct sysrq_key_op sysrq_reboot_op = { 150 150 .handler = sysrq_handle_reboot, 151 - .help_msg = "reBoot", 151 + .help_msg = "reboot(b)", 152 152 .action_msg = "Resetting", 153 153 .enable_mask = SYSRQ_ENABLE_BOOT, 154 154 }; ··· 159 159 } 160 160 static struct sysrq_key_op sysrq_sync_op = { 161 161 .handler = sysrq_handle_sync, 162 - .help_msg = "Sync", 162 + .help_msg = "sync(s)", 163 163 .action_msg = "Emergency Sync", 164 164 .enable_mask = SYSRQ_ENABLE_SYNC, 165 165 }; ··· 171 171 172 172 static struct sysrq_key_op sysrq_show_timers_op = { 173 173 .handler = sysrq_handle_show_timers, 174 - .help_msg = "show-all-timers(Q)", 174 + .help_msg = "show-all-timers(q)", 175 175 .action_msg = "Show clockevent devices & pending hrtimers (no others)", 176 176 }; 177 177 ··· 181 181 } 182 182 static struct sysrq_key_op sysrq_mountro_op = { 183 183 .handler = sysrq_handle_mountro, 184 - .help_msg = "Unmount", 184 + .help_msg = "unmount(u)", 185 185 .action_msg = "Emergency Remount R/O", 186 186 .enable_mask = SYSRQ_ENABLE_REMOUNT, 187 187 }; ··· 194 194 195 195 static struct sysrq_key_op sysrq_showlocks_op = { 196 196 .handler = sysrq_handle_showlocks, 197 - .help_msg = "show-all-locks(D)", 197 + .help_msg = "show-all-locks(d)", 198 198 .action_msg = "Show Locks Held", 199 199 }; 200 200 #else ··· 245 245 246 246 static struct sysrq_key_op sysrq_showallcpus_op = { 247 247 .handler = sysrq_handle_showallcpus, 248 - .help_msg = "show-backtrace-all-active-cpus(L)", 248 + .help_msg = "show-backtrace-all-active-cpus(l)", 249 249 .action_msg = "Show backtrace of all active CPUs", 250 250 .enable_mask = SYSRQ_ENABLE_DUMP, 251 251 }; ··· 260 260 } 261 261 static struct sysrq_key_op sysrq_showregs_op = { 262 262 .handler = sysrq_handle_showregs, 263 - .help_msg = "show-registers(P)", 263 + .help_msg = "show-registers(p)", 264 264 .action_msg = "Show Regs", 265 265 .enable_mask = SYSRQ_ENABLE_DUMP, 266 266 }; ··· 271 271 } 272 272 static struct sysrq_key_op sysrq_showstate_op = { 273 273 .handler = sysrq_handle_showstate, 274 - .help_msg = "show-task-states(T)", 274 + .help_msg = "show-task-states(t)", 275 275 .action_msg = "Show State", 276 276 .enable_mask = SYSRQ_ENABLE_DUMP, 277 277 }; ··· 282 282 } 283 283 static struct sysrq_key_op sysrq_showstate_blocked_op = { 284 284 .handler = sysrq_handle_showstate_blocked, 285 - .help_msg = "show-blocked-tasks(W)", 285 + .help_msg = "show-blocked-tasks(w)", 286 286 .action_msg = "Show Blocked State", 287 287 .enable_mask = SYSRQ_ENABLE_DUMP, 288 288 }; ··· 296 296 } 297 297 static struct sysrq_key_op sysrq_ftrace_dump_op = { 298 298 .handler = sysrq_ftrace_dump, 299 - .help_msg = "dump-ftrace-buffer(Z)", 299 + .help_msg = "dump-ftrace-buffer(z)", 300 300 .action_msg = "Dump ftrace buffer", 301 301 .enable_mask = SYSRQ_ENABLE_DUMP, 302 302 }; ··· 310 310 } 311 311 static struct sysrq_key_op sysrq_showmem_op = { 312 312 .handler = sysrq_handle_showmem, 313 - .help_msg = "show-memory-usage(M)", 313 + .help_msg = "show-memory-usage(m)", 314 314 .action_msg = "Show Memory", 315 315 .enable_mask = SYSRQ_ENABLE_DUMP, 316 316 }; ··· 341 341 } 342 342 static struct sysrq_key_op sysrq_term_op = { 343 343 .handler = sysrq_handle_term, 344 - .help_msg = "terminate-all-tasks(E)", 344 + .help_msg = "terminate-all-tasks(e)", 345 345 .action_msg = "Terminate All Tasks", 346 346 .enable_mask = SYSRQ_ENABLE_SIGNAL, 347 347 }; ··· 360 360 } 361 361 static struct sysrq_key_op sysrq_moom_op = { 362 362 .handler = sysrq_handle_moom, 363 - .help_msg = "memory-full-oom-kill(F)", 363 + .help_msg = "memory-full-oom-kill(f)", 364 364 .action_msg = "Manual OOM execution", 365 365 .enable_mask = SYSRQ_ENABLE_SIGNAL, 366 366 }; ··· 372 372 } 373 373 static struct sysrq_key_op sysrq_thaw_op = { 374 374 .handler = sysrq_handle_thaw, 375 - .help_msg = "thaw-filesystems(J)", 375 + .help_msg = "thaw-filesystems(j)", 376 376 .action_msg = "Emergency Thaw of all frozen filesystems", 377 377 .enable_mask = SYSRQ_ENABLE_SIGNAL, 378 378 }; ··· 385 385 } 386 386 static struct sysrq_key_op sysrq_kill_op = { 387 387 .handler = sysrq_handle_kill, 388 - .help_msg = "kill-all-tasks(I)", 388 + .help_msg = "kill-all-tasks(i)", 389 389 .action_msg = "Kill All Tasks", 390 390 .enable_mask = SYSRQ_ENABLE_SIGNAL, 391 391 }; ··· 396 396 } 397 397 static struct sysrq_key_op sysrq_unrt_op = { 398 398 .handler = sysrq_handle_unrt, 399 - .help_msg = "nice-all-RT-tasks(N)", 399 + .help_msg = "nice-all-RT-tasks(n)", 400 400 .action_msg = "Nice All RT Tasks", 401 401 .enable_mask = SYSRQ_ENABLE_RTNICE, 402 402 };
+10 -12
drivers/tty/tty_buffer.c
··· 449 449 tty_buffer_free(port, head); 450 450 continue; 451 451 } 452 - /* Ldisc or user is trying to flush the buffers 453 - we are feeding to the ldisc, stop feeding the 454 - line discipline as we want to empty the queue */ 455 - if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) 456 - break; 457 452 if (!tty->receive_room) 458 453 break; 459 454 if (count > tty->receive_room) ··· 460 465 disc->ops->receive_buf(tty, char_buf, 461 466 flag_buf, count); 462 467 spin_lock_irqsave(&buf->lock, flags); 468 + /* Ldisc or user is trying to flush the buffers. 469 + We may have a deferred request to flush the 470 + input buffer, if so pull the chain under the lock 471 + and empty the queue */ 472 + if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) { 473 + __tty_buffer_flush(port); 474 + clear_bit(TTYP_FLUSHPENDING, &port->iflags); 475 + wake_up(&tty->read_wait); 476 + break; 477 + } 463 478 } 464 479 clear_bit(TTYP_FLUSHING, &port->iflags); 465 480 } 466 481 467 - /* We may have a deferred request to flush the input buffer, 468 - if so pull the chain under the lock and empty the queue */ 469 - if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) { 470 - __tty_buffer_flush(port); 471 - clear_bit(TTYP_FLUSHPENDING, &port->iflags); 472 - wake_up(&tty->read_wait); 473 - } 474 482 spin_unlock_irqrestore(&buf->lock, flags); 475 483 476 484 tty_ldisc_deref(disc);
+118 -52
drivers/tty/tty_io.c
··· 533 533 EXPORT_SYMBOL_GPL(tty_wakeup); 534 534 535 535 /** 536 + * tty_signal_session_leader - sends SIGHUP to session leader 537 + * @tty controlling tty 538 + * @exit_session if non-zero, signal all foreground group processes 539 + * 540 + * Send SIGHUP and SIGCONT to the session leader and its process group. 541 + * Optionally, signal all processes in the foreground process group. 542 + * 543 + * Returns the number of processes in the session with this tty 544 + * as their controlling terminal. This value is used to drop 545 + * tty references for those processes. 546 + */ 547 + static int tty_signal_session_leader(struct tty_struct *tty, int exit_session) 548 + { 549 + struct task_struct *p; 550 + int refs = 0; 551 + struct pid *tty_pgrp = NULL; 552 + 553 + read_lock(&tasklist_lock); 554 + if (tty->session) { 555 + do_each_pid_task(tty->session, PIDTYPE_SID, p) { 556 + spin_lock_irq(&p->sighand->siglock); 557 + if (p->signal->tty == tty) { 558 + p->signal->tty = NULL; 559 + /* We defer the dereferences outside fo 560 + the tasklist lock */ 561 + refs++; 562 + } 563 + if (!p->signal->leader) { 564 + spin_unlock_irq(&p->sighand->siglock); 565 + continue; 566 + } 567 + __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p); 568 + __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p); 569 + put_pid(p->signal->tty_old_pgrp); /* A noop */ 570 + spin_lock(&tty->ctrl_lock); 571 + tty_pgrp = get_pid(tty->pgrp); 572 + if (tty->pgrp) 573 + p->signal->tty_old_pgrp = get_pid(tty->pgrp); 574 + spin_unlock(&tty->ctrl_lock); 575 + spin_unlock_irq(&p->sighand->siglock); 576 + } while_each_pid_task(tty->session, PIDTYPE_SID, p); 577 + } 578 + read_unlock(&tasklist_lock); 579 + 580 + if (tty_pgrp) { 581 + if (exit_session) 582 + kill_pgrp(tty_pgrp, SIGHUP, exit_session); 583 + put_pid(tty_pgrp); 584 + } 585 + 586 + return refs; 587 + } 588 + 589 + /** 536 590 * __tty_hangup - actual handler for hangup events 537 591 * @work: tty device 538 592 * ··· 608 554 * tasklist_lock to walk task list for hangup event 609 555 * ->siglock to protect ->signal/->sighand 610 556 */ 611 - static void __tty_hangup(struct tty_struct *tty) 557 + static void __tty_hangup(struct tty_struct *tty, int exit_session) 612 558 { 613 559 struct file *cons_filp = NULL; 614 560 struct file *filp, *f = NULL; 615 - struct task_struct *p; 616 561 struct tty_file_private *priv; 617 562 int closecount = 0, n; 618 - unsigned long flags; 619 - int refs = 0; 563 + int refs; 620 564 621 565 if (!tty) 622 566 return; ··· 651 599 } 652 600 spin_unlock(&tty_files_lock); 653 601 602 + refs = tty_signal_session_leader(tty, exit_session); 603 + /* Account for the p->signal references we killed */ 604 + while (refs--) 605 + tty_kref_put(tty); 606 + 654 607 /* 655 608 * it drops BTM and thus races with reopen 656 609 * we protect the race by TTY_HUPPING 657 610 */ 658 611 tty_ldisc_hangup(tty); 659 612 660 - read_lock(&tasklist_lock); 661 - if (tty->session) { 662 - do_each_pid_task(tty->session, PIDTYPE_SID, p) { 663 - spin_lock_irq(&p->sighand->siglock); 664 - if (p->signal->tty == tty) { 665 - p->signal->tty = NULL; 666 - /* We defer the dereferences outside fo 667 - the tasklist lock */ 668 - refs++; 669 - } 670 - if (!p->signal->leader) { 671 - spin_unlock_irq(&p->sighand->siglock); 672 - continue; 673 - } 674 - __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p); 675 - __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p); 676 - put_pid(p->signal->tty_old_pgrp); /* A noop */ 677 - spin_lock_irqsave(&tty->ctrl_lock, flags); 678 - if (tty->pgrp) 679 - p->signal->tty_old_pgrp = get_pid(tty->pgrp); 680 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 681 - spin_unlock_irq(&p->sighand->siglock); 682 - } while_each_pid_task(tty->session, PIDTYPE_SID, p); 683 - } 684 - read_unlock(&tasklist_lock); 685 - 686 - spin_lock_irqsave(&tty->ctrl_lock, flags); 613 + spin_lock_irq(&tty->ctrl_lock); 687 614 clear_bit(TTY_THROTTLED, &tty->flags); 688 615 clear_bit(TTY_PUSH, &tty->flags); 689 616 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ··· 671 640 tty->session = NULL; 672 641 tty->pgrp = NULL; 673 642 tty->ctrl_status = 0; 674 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 675 - 676 - /* Account for the p->signal references we killed */ 677 - while (refs--) 678 - tty_kref_put(tty); 643 + spin_unlock_irq(&tty->ctrl_lock); 679 644 680 645 /* 681 646 * If one of the devices matches a console pointer, we ··· 693 666 */ 694 667 set_bit(TTY_HUPPED, &tty->flags); 695 668 clear_bit(TTY_HUPPING, &tty->flags); 696 - tty_ldisc_enable(tty); 697 669 698 670 tty_unlock(tty); 699 671 ··· 705 679 struct tty_struct *tty = 706 680 container_of(work, struct tty_struct, hangup_work); 707 681 708 - __tty_hangup(tty); 682 + __tty_hangup(tty, 0); 709 683 } 710 684 711 685 /** ··· 743 717 744 718 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); 745 719 #endif 746 - __tty_hangup(tty); 720 + __tty_hangup(tty, 0); 747 721 } 748 722 749 723 EXPORT_SYMBOL(tty_vhangup); ··· 764 738 tty_vhangup(tty); 765 739 tty_kref_put(tty); 766 740 } 741 + } 742 + 743 + /** 744 + * tty_vhangup_session - hangup session leader exit 745 + * @tty: tty to hangup 746 + * 747 + * The session leader is exiting and hanging up its controlling terminal. 748 + * Every process in the foreground process group is signalled SIGHUP. 749 + * 750 + * We do this synchronously so that when the syscall returns the process 751 + * is complete. That guarantee is necessary for security reasons. 752 + */ 753 + 754 + static void tty_vhangup_session(struct tty_struct *tty) 755 + { 756 + #ifdef TTY_DEBUG_HANGUP 757 + char buf[64]; 758 + 759 + printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty, buf)); 760 + #endif 761 + __tty_hangup(tty, 1); 767 762 } 768 763 769 764 /** ··· 844 797 845 798 tty = get_current_tty(); 846 799 if (tty) { 847 - struct pid *tty_pgrp = get_pid(tty->pgrp); 848 - if (on_exit) { 849 - if (tty->driver->type != TTY_DRIVER_TYPE_PTY) 850 - tty_vhangup(tty); 800 + if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { 801 + tty_vhangup_session(tty); 802 + } else { 803 + struct pid *tty_pgrp = tty_get_pgrp(tty); 804 + if (tty_pgrp) { 805 + kill_pgrp(tty_pgrp, SIGHUP, on_exit); 806 + kill_pgrp(tty_pgrp, SIGCONT, on_exit); 807 + put_pid(tty_pgrp); 808 + } 851 809 } 852 810 tty_kref_put(tty); 853 - if (tty_pgrp) { 854 - kill_pgrp(tty_pgrp, SIGHUP, on_exit); 855 - if (!on_exit) 856 - kill_pgrp(tty_pgrp, SIGCONT, on_exit); 857 - put_pid(tty_pgrp); 858 - } 811 + 859 812 } else if (on_exit) { 860 813 struct pid *old_pgrp; 861 814 spin_lock_irq(&current->sighand->siglock); ··· 1405 1358 } 1406 1359 tty->count++; 1407 1360 1408 - mutex_lock(&tty->ldisc_mutex); 1409 1361 WARN_ON(!test_bit(TTY_LDISC, &tty->flags)); 1410 - mutex_unlock(&tty->ldisc_mutex); 1411 1362 1412 1363 return 0; 1413 1364 } ··· 1522 1477 } 1523 1478 EXPORT_SYMBOL(tty_free_termios); 1524 1479 1480 + /** 1481 + * tty_flush_works - flush all works of a tty 1482 + * @tty: tty device to flush works for 1483 + * 1484 + * Sync flush all works belonging to @tty. 1485 + */ 1486 + static void tty_flush_works(struct tty_struct *tty) 1487 + { 1488 + flush_work(&tty->SAK_work); 1489 + flush_work(&tty->hangup_work); 1490 + } 1525 1491 1526 1492 /** 1527 1493 * release_one_tty - release tty structure memory ··· 1618 1562 tty_free_termios(tty); 1619 1563 tty_driver_remove_tty(tty->driver, tty); 1620 1564 tty->port->itty = NULL; 1565 + cancel_work_sync(&tty->port->buf.work); 1621 1566 1622 1567 if (tty->link) 1623 1568 tty_kref_put(tty->link); ··· 1848 1791 return 0; 1849 1792 1850 1793 #ifdef TTY_DEBUG_HANGUP 1851 - printk(KERN_DEBUG "%s: freeing tty structure...\n", __func__); 1794 + printk(KERN_DEBUG "%s: %s: final close\n", __func__, tty_name(tty, buf)); 1852 1795 #endif 1853 1796 /* 1854 1797 * Ask the line discipline code to release its structures 1855 1798 */ 1856 1799 tty_ldisc_release(tty, o_tty); 1800 + 1801 + /* Wait for pending work before tty destruction commmences */ 1802 + tty_flush_works(tty); 1803 + if (o_tty) 1804 + tty_flush_works(o_tty); 1805 + 1806 + #ifdef TTY_DEBUG_HANGUP 1807 + printk(KERN_DEBUG "%s: %s: freeing structure...\n", __func__, tty_name(tty, buf)); 1808 + #endif 1857 1809 /* 1858 1810 * The release_tty function takes care of the details of clearing 1859 1811 * the slots and preserving the termios structure. The tty_unlock_pair
+84 -38
drivers/tty/tty_ioctl.c
··· 106 106 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && 107 107 tty->ops->throttle) 108 108 tty->ops->throttle(tty); 109 + tty->flow_change = 0; 109 110 mutex_unlock(&tty->termios_mutex); 110 111 } 111 112 EXPORT_SYMBOL(tty_throttle); ··· 130 129 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && 131 130 tty->ops->unthrottle) 132 131 tty->ops->unthrottle(tty); 132 + tty->flow_change = 0; 133 133 mutex_unlock(&tty->termios_mutex); 134 134 } 135 135 EXPORT_SYMBOL(tty_unthrottle); 136 + 137 + /** 138 + * tty_throttle_safe - flow control 139 + * @tty: terminal 140 + * 141 + * Similar to tty_throttle() but will only attempt throttle 142 + * if tty->flow_change is TTY_THROTTLE_SAFE. Prevents an accidental 143 + * throttle due to race conditions when throttling is conditional 144 + * on factors evaluated prior to throttling. 145 + * 146 + * Returns 0 if tty is throttled (or was already throttled) 147 + */ 148 + 149 + int tty_throttle_safe(struct tty_struct *tty) 150 + { 151 + int ret = 0; 152 + 153 + mutex_lock(&tty->termios_mutex); 154 + if (!test_bit(TTY_THROTTLED, &tty->flags)) { 155 + if (tty->flow_change != TTY_THROTTLE_SAFE) 156 + ret = 1; 157 + else { 158 + set_bit(TTY_THROTTLED, &tty->flags); 159 + if (tty->ops->throttle) 160 + tty->ops->throttle(tty); 161 + } 162 + } 163 + mutex_unlock(&tty->termios_mutex); 164 + 165 + return ret; 166 + } 167 + 168 + /** 169 + * tty_unthrottle_safe - flow control 170 + * @tty: terminal 171 + * 172 + * Similar to tty_unthrottle() but will only attempt unthrottle 173 + * if tty->flow_change is TTY_UNTHROTTLE_SAFE. Prevents an accidental 174 + * unthrottle due to race conditions when unthrottling is conditional 175 + * on factors evaluated prior to unthrottling. 176 + * 177 + * Returns 0 if tty is unthrottled (or was already unthrottled) 178 + */ 179 + 180 + int tty_unthrottle_safe(struct tty_struct *tty) 181 + { 182 + int ret = 0; 183 + 184 + mutex_lock(&tty->termios_mutex); 185 + if (test_bit(TTY_THROTTLED, &tty->flags)) { 186 + if (tty->flow_change != TTY_UNTHROTTLE_SAFE) 187 + ret = 1; 188 + else { 189 + clear_bit(TTY_THROTTLED, &tty->flags); 190 + if (tty->ops->unthrottle) 191 + tty->ops->unthrottle(tty); 192 + } 193 + } 194 + mutex_unlock(&tty->termios_mutex); 195 + 196 + return ret; 197 + } 136 198 137 199 /** 138 200 * tty_wait_until_sent - wait for I/O to finish ··· 477 413 tty_termios_encode_baud_rate(&tty->termios, ibaud, obaud); 478 414 } 479 415 EXPORT_SYMBOL_GPL(tty_encode_baud_rate); 480 - 481 - /** 482 - * tty_get_baud_rate - get tty bit rates 483 - * @tty: tty to query 484 - * 485 - * Returns the baud rate as an integer for this terminal. The 486 - * termios lock must be held by the caller and the terminal bit 487 - * flags may be updated. 488 - * 489 - * Locking: none 490 - */ 491 - 492 - speed_t tty_get_baud_rate(struct tty_struct *tty) 493 - { 494 - speed_t baud = tty_termios_baud_rate(&tty->termios); 495 - 496 - if (baud == 38400 && tty->alt_speed) { 497 - if (!tty->warned) { 498 - printk(KERN_WARNING "Use of setserial/setrocket to " 499 - "set SPD_* flags is deprecated\n"); 500 - tty->warned = 1; 501 - } 502 - baud = tty->alt_speed; 503 - } 504 - 505 - return baud; 506 - } 507 - EXPORT_SYMBOL(tty_get_baud_rate); 508 416 509 417 /** 510 418 * tty_termios_copy_hw - copy hardware settings ··· 1122 1086 } 1123 1087 EXPORT_SYMBOL_GPL(tty_mode_ioctl); 1124 1088 1125 - int tty_perform_flush(struct tty_struct *tty, unsigned long arg) 1126 - { 1127 - struct tty_ldisc *ld; 1128 - int retval = tty_check_change(tty); 1129 - if (retval) 1130 - return retval; 1131 1089 1132 - ld = tty_ldisc_ref_wait(tty); 1090 + /* Caller guarantees ldisc reference is held */ 1091 + static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg) 1092 + { 1093 + struct tty_ldisc *ld = tty->ldisc; 1094 + 1133 1095 switch (arg) { 1134 1096 case TCIFLUSH: 1135 1097 if (ld && ld->ops->flush_buffer) { ··· 1145 1111 tty_driver_flush_buffer(tty); 1146 1112 break; 1147 1113 default: 1148 - tty_ldisc_deref(ld); 1149 1114 return -EINVAL; 1150 1115 } 1151 - tty_ldisc_deref(ld); 1152 1116 return 0; 1117 + } 1118 + 1119 + int tty_perform_flush(struct tty_struct *tty, unsigned long arg) 1120 + { 1121 + struct tty_ldisc *ld; 1122 + int retval = tty_check_change(tty); 1123 + if (retval) 1124 + return retval; 1125 + 1126 + ld = tty_ldisc_ref_wait(tty); 1127 + retval = __tty_perform_flush(tty, arg); 1128 + if (ld) 1129 + tty_ldisc_deref(ld); 1130 + return retval; 1153 1131 } 1154 1132 EXPORT_SYMBOL_GPL(tty_perform_flush); 1155 1133 ··· 1201 1155 } 1202 1156 return 0; 1203 1157 case TCFLSH: 1204 - return tty_perform_flush(tty, arg); 1158 + return __tty_perform_flush(tty, arg); 1205 1159 default: 1206 1160 /* Try the mode commands */ 1207 1161 return tty_mode_ioctl(tty, file, cmd, arg);
+163 -173
drivers/tty/tty_ldisc.c
··· 20 20 #include <linux/uaccess.h> 21 21 #include <linux/ratelimit.h> 22 22 23 + #undef LDISC_DEBUG_HANGUP 24 + 25 + #ifdef LDISC_DEBUG_HANGUP 26 + #define tty_ldisc_debug(tty, f, args...) ({ \ 27 + char __b[64]; \ 28 + printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty, __b), ##args); \ 29 + }) 30 + #else 31 + #define tty_ldisc_debug(tty, f, args...) 32 + #endif 33 + 23 34 /* 24 35 * This guards the refcounted line discipline lists. The lock 25 36 * must be taken with irqs off because there are hangup path ··· 41 30 static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait); 42 31 /* Line disc dispatch table */ 43 32 static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; 44 - 45 - static inline struct tty_ldisc *get_ldisc(struct tty_ldisc *ld) 46 - { 47 - if (ld) 48 - atomic_inc(&ld->users); 49 - return ld; 50 - } 51 - 52 - static void put_ldisc(struct tty_ldisc *ld) 53 - { 54 - unsigned long flags; 55 - 56 - if (WARN_ON_ONCE(!ld)) 57 - return; 58 - 59 - /* 60 - * If this is the last user, free the ldisc, and 61 - * release the ldisc ops. 62 - * 63 - * We really want an "atomic_dec_and_raw_lock_irqsave()", 64 - * but we don't have it, so this does it by hand. 65 - */ 66 - raw_spin_lock_irqsave(&tty_ldisc_lock, flags); 67 - if (atomic_dec_and_test(&ld->users)) { 68 - struct tty_ldisc_ops *ldo = ld->ops; 69 - 70 - ldo->refcount--; 71 - module_put(ldo->owner); 72 - raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); 73 - 74 - kfree(ld); 75 - return; 76 - } 77 - raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); 78 - 79 - if (waitqueue_active(&ld->wq_idle)) 80 - wake_up(&ld->wq_idle); 81 - } 82 33 83 34 /** 84 35 * tty_register_ldisc - install a line discipline ··· 179 206 return ld; 180 207 } 181 208 209 + /** 210 + * tty_ldisc_put - release the ldisc 211 + * 212 + * Complement of tty_ldisc_get(). 213 + */ 214 + static inline void tty_ldisc_put(struct tty_ldisc *ld) 215 + { 216 + unsigned long flags; 217 + 218 + if (WARN_ON_ONCE(!ld)) 219 + return; 220 + 221 + raw_spin_lock_irqsave(&tty_ldisc_lock, flags); 222 + 223 + /* unreleased reader reference(s) will cause this WARN */ 224 + WARN_ON(!atomic_dec_and_test(&ld->users)); 225 + 226 + ld->ops->refcount--; 227 + module_put(ld->ops->owner); 228 + kfree(ld); 229 + raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); 230 + } 231 + 182 232 static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) 183 233 { 184 234 return (*pos < NR_LDISCS) ? pos : NULL; ··· 251 255 }; 252 256 253 257 /** 254 - * tty_ldisc_assign - set ldisc on a tty 255 - * @tty: tty to assign 256 - * @ld: line discipline 257 - * 258 - * Install an instance of a line discipline into a tty structure. The 259 - * ldisc must have a reference count above zero to ensure it remains. 260 - * The tty instance refcount starts at zero. 261 - * 262 - * Locking: 263 - * Caller must hold references 264 - */ 265 - 266 - static void tty_ldisc_assign(struct tty_struct *tty, struct tty_ldisc *ld) 267 - { 268 - tty->ldisc = ld; 269 - } 270 - 271 - /** 272 258 * tty_ldisc_try - internal helper 273 259 * @tty: the tty 274 260 * ··· 267 289 unsigned long flags; 268 290 struct tty_ldisc *ld; 269 291 292 + /* FIXME: this allows reference acquire after TTY_LDISC is cleared */ 270 293 raw_spin_lock_irqsave(&tty_ldisc_lock, flags); 271 294 ld = NULL; 272 - if (test_bit(TTY_LDISC, &tty->flags)) 273 - ld = get_ldisc(tty->ldisc); 295 + if (test_bit(TTY_LDISC, &tty->flags) && tty->ldisc) { 296 + ld = tty->ldisc; 297 + atomic_inc(&ld->users); 298 + } 274 299 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); 275 300 return ld; 276 301 } ··· 333 352 334 353 void tty_ldisc_deref(struct tty_ldisc *ld) 335 354 { 336 - put_ldisc(ld); 355 + unsigned long flags; 356 + 357 + if (WARN_ON_ONCE(!ld)) 358 + return; 359 + 360 + raw_spin_lock_irqsave(&tty_ldisc_lock, flags); 361 + /* 362 + * WARNs if one-too-many reader references were released 363 + * - the last reference must be released with tty_ldisc_put 364 + */ 365 + WARN_ON(atomic_dec_and_test(&ld->users)); 366 + raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); 367 + 368 + if (waitqueue_active(&ld->wq_idle)) 369 + wake_up(&ld->wq_idle); 337 370 } 338 371 EXPORT_SYMBOL_GPL(tty_ldisc_deref); 339 - 340 - static inline void tty_ldisc_put(struct tty_ldisc *ld) 341 - { 342 - put_ldisc(ld); 343 - } 344 372 345 373 /** 346 374 * tty_ldisc_enable - allow ldisc use ··· 363 373 * Clearing directly is allowed. 364 374 */ 365 375 366 - void tty_ldisc_enable(struct tty_struct *tty) 376 + static void tty_ldisc_enable(struct tty_struct *tty) 367 377 { 378 + clear_bit(TTY_LDISC_HALTED, &tty->flags); 368 379 set_bit(TTY_LDISC, &tty->flags); 369 380 clear_bit(TTY_LDISC_CHANGING, &tty->flags); 370 381 wake_up(&tty_ldisc_wait); ··· 470 479 /* There is an outstanding reference here so this is safe */ 471 480 old = tty_ldisc_get(old->ops->num); 472 481 WARN_ON(IS_ERR(old)); 473 - tty_ldisc_assign(tty, old); 482 + tty->ldisc = old; 474 483 tty_set_termios_ldisc(tty, old->ops->num); 475 484 if (tty_ldisc_open(tty, old) < 0) { 476 485 tty_ldisc_put(old); ··· 478 487 new_ldisc = tty_ldisc_get(N_TTY); 479 488 if (IS_ERR(new_ldisc)) 480 489 panic("n_tty: get"); 481 - tty_ldisc_assign(tty, new_ldisc); 490 + tty->ldisc = new_ldisc; 482 491 tty_set_termios_ldisc(tty, N_TTY); 483 492 r = tty_ldisc_open(tty, new_ldisc); 484 493 if (r < 0) ··· 486 495 "%s --- error %d.", 487 496 tty_name(tty, buf), r); 488 497 } 489 - } 490 - 491 - /** 492 - * tty_ldisc_halt - shut down the line discipline 493 - * @tty: tty device 494 - * 495 - * Shut down the line discipline and work queue for this tty device. 496 - * The TTY_LDISC flag being cleared ensures no further references can 497 - * be obtained while the delayed work queue halt ensures that no more 498 - * data is fed to the ldisc. 499 - * 500 - * You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex) 501 - * in order to make sure any currently executing ldisc work is also 502 - * flushed. 503 - */ 504 - 505 - static int tty_ldisc_halt(struct tty_struct *tty) 506 - { 507 - clear_bit(TTY_LDISC, &tty->flags); 508 - return cancel_work_sync(&tty->port->buf.work); 509 - } 510 - 511 - /** 512 - * tty_ldisc_flush_works - flush all works of a tty 513 - * @tty: tty device to flush works for 514 - * 515 - * Sync flush all works belonging to @tty. 516 - */ 517 - static void tty_ldisc_flush_works(struct tty_struct *tty) 518 - { 519 - flush_work(&tty->hangup_work); 520 - flush_work(&tty->SAK_work); 521 - flush_work(&tty->port->buf.work); 522 498 } 523 499 524 500 /** ··· 505 547 } 506 548 507 549 /** 550 + * tty_ldisc_halt - shut down the line discipline 551 + * @tty: tty device 552 + * @o_tty: paired pty device (can be NULL) 553 + * @timeout: # of jiffies to wait for ldisc refs to be released 554 + * 555 + * Shut down the line discipline and work queue for this tty device and 556 + * its paired pty (if exists). Clearing the TTY_LDISC flag ensures 557 + * no further references can be obtained, while waiting for existing 558 + * references to be released ensures no more data is fed to the ldisc. 559 + * 560 + * You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex) 561 + * in order to make sure any currently executing ldisc work is also 562 + * flushed. 563 + */ 564 + 565 + static int tty_ldisc_halt(struct tty_struct *tty, struct tty_struct *o_tty, 566 + long timeout) 567 + { 568 + int retval; 569 + 570 + clear_bit(TTY_LDISC, &tty->flags); 571 + if (o_tty) 572 + clear_bit(TTY_LDISC, &o_tty->flags); 573 + 574 + retval = tty_ldisc_wait_idle(tty, timeout); 575 + if (!retval && o_tty) 576 + retval = tty_ldisc_wait_idle(o_tty, timeout); 577 + if (retval) 578 + return retval; 579 + 580 + set_bit(TTY_LDISC_HALTED, &tty->flags); 581 + if (o_tty) 582 + set_bit(TTY_LDISC_HALTED, &o_tty->flags); 583 + 584 + return 0; 585 + } 586 + 587 + /** 588 + * tty_ldisc_hangup_halt - halt the line discipline for hangup 589 + * @tty: tty being hung up 590 + * 591 + * Shut down the line discipline and work queue for the tty device 592 + * being hungup. Clear the TTY_LDISC flag to ensure no further 593 + * references can be obtained and wait for remaining references to be 594 + * released to ensure no more data is fed to this ldisc. 595 + * Caller must hold legacy and ->ldisc_mutex. 596 + * 597 + * NB: tty_set_ldisc() is prevented from changing the ldisc concurrently 598 + * with this function by checking the TTY_HUPPING flag. 599 + */ 600 + static bool tty_ldisc_hangup_halt(struct tty_struct *tty) 601 + { 602 + char cur_n[TASK_COMM_LEN], tty_n[64]; 603 + long timeout = 3 * HZ; 604 + 605 + clear_bit(TTY_LDISC, &tty->flags); 606 + 607 + if (tty->ldisc) { /* Not yet closed */ 608 + tty_unlock(tty); 609 + 610 + while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) { 611 + timeout = MAX_SCHEDULE_TIMEOUT; 612 + printk_ratelimited(KERN_WARNING 613 + "%s: waiting (%s) for %s took too long, but we keep waiting...\n", 614 + __func__, get_task_comm(cur_n, current), 615 + tty_name(tty, tty_n)); 616 + } 617 + 618 + set_bit(TTY_LDISC_HALTED, &tty->flags); 619 + 620 + /* must reacquire both locks and preserve lock order */ 621 + mutex_unlock(&tty->ldisc_mutex); 622 + tty_lock(tty); 623 + mutex_lock(&tty->ldisc_mutex); 624 + } 625 + return !!tty->ldisc; 626 + } 627 + 628 + /** 508 629 * tty_set_ldisc - set line discipline 509 630 * @tty: the terminal to set 510 631 * @ldisc: the line discipline ··· 600 563 { 601 564 int retval; 602 565 struct tty_ldisc *o_ldisc, *new_ldisc; 603 - int work, o_work = 0; 604 566 struct tty_struct *o_tty; 605 567 606 568 new_ldisc = tty_ldisc_get(ldisc); ··· 625 589 return 0; 626 590 } 627 591 628 - tty_unlock(tty); 629 - /* 630 - * Problem: What do we do if this blocks ? 631 - * We could deadlock here 632 - */ 633 - 634 - tty_wait_until_sent(tty, 0); 635 - 636 - tty_lock(tty); 637 592 mutex_lock(&tty->ldisc_mutex); 638 593 639 594 /* ··· 664 637 * parallel to the change and re-referencing the tty. 665 638 */ 666 639 667 - work = tty_ldisc_halt(tty); 668 - if (o_tty) 669 - o_work = tty_ldisc_halt(o_tty); 640 + retval = tty_ldisc_halt(tty, o_tty, 5 * HZ); 670 641 671 642 /* 672 - * Wait for ->hangup_work and ->buf.work handlers to terminate. 643 + * Wait for hangup to complete, if pending. 673 644 * We must drop the mutex here in case a hangup is also in process. 674 645 */ 675 646 676 647 mutex_unlock(&tty->ldisc_mutex); 677 648 678 - tty_ldisc_flush_works(tty); 679 - 680 - retval = tty_ldisc_wait_idle(tty, 5 * HZ); 649 + flush_work(&tty->hangup_work); 681 650 682 651 tty_lock(tty); 683 652 mutex_lock(&tty->ldisc_mutex); ··· 698 675 tty_ldisc_close(tty, o_ldisc); 699 676 700 677 /* Now set up the new line discipline. */ 701 - tty_ldisc_assign(tty, new_ldisc); 678 + tty->ldisc = new_ldisc; 702 679 tty_set_termios_ldisc(tty, ldisc); 703 680 704 681 retval = tty_ldisc_open(tty, new_ldisc); ··· 728 705 729 706 /* Restart the work queue in case no characters kick it off. Safe if 730 707 already running */ 731 - if (work) 732 - schedule_work(&tty->port->buf.work); 733 - if (o_work) 708 + schedule_work(&tty->port->buf.work); 709 + if (o_tty) 734 710 schedule_work(&o_tty->port->buf.work); 711 + 735 712 mutex_unlock(&tty->ldisc_mutex); 736 713 tty_unlock(tty); 737 714 return retval; ··· 772 749 773 750 tty_ldisc_close(tty, tty->ldisc); 774 751 tty_ldisc_put(tty->ldisc); 775 - tty->ldisc = NULL; 776 752 /* 777 753 * Switch the line discipline back 778 754 */ 779 - tty_ldisc_assign(tty, ld); 755 + tty->ldisc = ld; 780 756 tty_set_termios_ldisc(tty, ldisc); 781 757 782 758 return 0; ··· 801 779 struct tty_ldisc *ld; 802 780 int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS; 803 781 int err = 0; 782 + 783 + tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc); 804 784 805 785 /* 806 786 * FIXME! What are the locking issues here? This may me overdoing ··· 836 812 */ 837 813 mutex_lock(&tty->ldisc_mutex); 838 814 839 - /* 840 - * this is like tty_ldisc_halt, but we need to give up 841 - * the BTM before calling cancel_work_sync, which may 842 - * need to wait for another function taking the BTM 843 - */ 844 - clear_bit(TTY_LDISC, &tty->flags); 845 - tty_unlock(tty); 846 - cancel_work_sync(&tty->port->buf.work); 847 - mutex_unlock(&tty->ldisc_mutex); 848 - retry: 849 - tty_lock(tty); 850 - mutex_lock(&tty->ldisc_mutex); 815 + if (tty_ldisc_hangup_halt(tty)) { 851 816 852 - /* At this point we have a closed ldisc and we want to 853 - reopen it. We could defer this to the next open but 854 - it means auditing a lot of other paths so this is 855 - a FIXME */ 856 - if (tty->ldisc) { /* Not yet closed */ 857 - if (atomic_read(&tty->ldisc->users) != 1) { 858 - char cur_n[TASK_COMM_LEN], tty_n[64]; 859 - long timeout = 3 * HZ; 860 - tty_unlock(tty); 861 - 862 - while (tty_ldisc_wait_idle(tty, timeout) == -EBUSY) { 863 - timeout = MAX_SCHEDULE_TIMEOUT; 864 - printk_ratelimited(KERN_WARNING 865 - "%s: waiting (%s) for %s took too long, but we keep waiting...\n", 866 - __func__, get_task_comm(cur_n, current), 867 - tty_name(tty, tty_n)); 868 - } 869 - mutex_unlock(&tty->ldisc_mutex); 870 - goto retry; 871 - } 872 - 817 + /* At this point we have a halted ldisc; we want to close it and 818 + reopen a new ldisc. We could defer the reopen to the next 819 + open but it means auditing a lot of other paths so this is 820 + a FIXME */ 873 821 if (reset == 0) { 874 822 875 823 if (!tty_ldisc_reinit(tty, tty->termios.c_line)) ··· 860 864 mutex_unlock(&tty->ldisc_mutex); 861 865 if (reset) 862 866 tty_reset_termios(tty); 867 + 868 + tty_ldisc_debug(tty, "re-opened ldisc: %p\n", tty->ldisc); 863 869 } 864 870 865 871 /** ··· 897 899 898 900 static void tty_ldisc_kill(struct tty_struct *tty) 899 901 { 900 - /* There cannot be users from userspace now. But there still might be 901 - * drivers holding a reference via tty_ldisc_ref. Do not steal them the 902 - * ldisc until they are done. */ 903 - tty_ldisc_wait_idle(tty, MAX_SCHEDULE_TIMEOUT); 904 - 905 902 mutex_lock(&tty->ldisc_mutex); 906 903 /* 907 904 * Now kill off the ldisc ··· 924 931 void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty) 925 932 { 926 933 /* 927 - * Prevent flush_to_ldisc() from rescheduling the work for later. Then 928 - * kill any delayed work. As this is the final close it does not 929 - * race with the set_ldisc code path. 934 + * Shutdown this line discipline. As this is the final close, 935 + * it does not race with the set_ldisc code path. 930 936 */ 931 937 932 - tty_ldisc_halt(tty); 933 - if (o_tty) 934 - tty_ldisc_halt(o_tty); 938 + tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc); 935 939 936 - tty_ldisc_flush_works(tty); 937 - if (o_tty) 938 - tty_ldisc_flush_works(o_tty); 940 + tty_ldisc_halt(tty, o_tty, MAX_SCHEDULE_TIMEOUT); 939 941 940 942 tty_lock_pair(tty, o_tty); 941 943 /* This will need doing differently if we need to lock */ ··· 941 953 tty_unlock_pair(tty, o_tty); 942 954 /* And the memory resources remaining (buffers, termios) will be 943 955 disposed of when the kref hits zero */ 956 + 957 + tty_ldisc_debug(tty, "ldisc closed\n"); 944 958 } 945 959 946 960 /** ··· 958 968 struct tty_ldisc *ld = tty_ldisc_get(N_TTY); 959 969 if (IS_ERR(ld)) 960 970 panic("n_tty: init_tty"); 961 - tty_ldisc_assign(tty, ld); 971 + tty->ldisc = ld; 962 972 } 963 973 964 974 /** ··· 970 980 */ 971 981 void tty_ldisc_deinit(struct tty_struct *tty) 972 982 { 973 - put_ldisc(tty->ldisc); 974 - tty_ldisc_assign(tty, NULL); 983 + tty_ldisc_put(tty->ldisc); 984 + tty->ldisc = NULL; 975 985 } 976 986 977 987 void tty_ldisc_begin(void)
+79 -30
drivers/tty/tty_port.c
··· 132 132 */ 133 133 void tty_port_destroy(struct tty_port *port) 134 134 { 135 + cancel_work_sync(&port->buf.work); 135 136 tty_buffer_free_all(port); 136 137 } 137 138 EXPORT_SYMBOL(tty_port_destroy); ··· 197 196 } 198 197 EXPORT_SYMBOL(tty_port_tty_set); 199 198 200 - static void tty_port_shutdown(struct tty_port *port) 199 + static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) 201 200 { 202 201 mutex_lock(&port->mutex); 203 - if (port->ops->shutdown && !port->console && 204 - test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) 202 + if (port->console) 203 + goto out; 204 + 205 + if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) { 206 + /* 207 + * Drop DTR/RTS if HUPCL is set. This causes any attached 208 + * modem to hang up the line. 209 + */ 210 + if (tty && C_HUPCL(tty)) 211 + tty_port_lower_dtr_rts(port); 212 + 213 + if (port->ops->shutdown) 205 214 port->ops->shutdown(port); 215 + } 216 + out: 206 217 mutex_unlock(&port->mutex); 207 218 } 208 219 ··· 228 215 229 216 void tty_port_hangup(struct tty_port *port) 230 217 { 218 + struct tty_struct *tty; 231 219 unsigned long flags; 232 220 233 221 spin_lock_irqsave(&port->lock, flags); 234 222 port->count = 0; 235 223 port->flags &= ~ASYNC_NORMAL_ACTIVE; 236 - if (port->tty) { 237 - set_bit(TTY_IO_ERROR, &port->tty->flags); 238 - tty_kref_put(port->tty); 239 - } 224 + tty = port->tty; 225 + if (tty) 226 + set_bit(TTY_IO_ERROR, &tty->flags); 240 227 port->tty = NULL; 241 228 spin_unlock_irqrestore(&port->lock, flags); 229 + tty_port_shutdown(port, tty); 230 + tty_kref_put(tty); 242 231 wake_up_interruptible(&port->open_wait); 243 232 wake_up_interruptible(&port->delta_msr_wait); 244 - tty_port_shutdown(port); 245 233 } 246 234 EXPORT_SYMBOL(tty_port_hangup); 235 + 236 + /** 237 + * tty_port_tty_hangup - helper to hang up a tty 238 + * 239 + * @port: tty port 240 + * @check_clocal: hang only ttys with CLOCAL unset? 241 + */ 242 + void tty_port_tty_hangup(struct tty_port *port, bool check_clocal) 243 + { 244 + struct tty_struct *tty = tty_port_tty_get(port); 245 + 246 + if (tty && (!check_clocal || !C_CLOCAL(tty))) { 247 + tty_hangup(tty); 248 + tty_kref_put(tty); 249 + } 250 + } 251 + EXPORT_SYMBOL_GPL(tty_port_tty_hangup); 252 + 253 + /** 254 + * tty_port_tty_wakeup - helper to wake up a tty 255 + * 256 + * @port: tty port 257 + */ 258 + void tty_port_tty_wakeup(struct tty_port *port) 259 + { 260 + struct tty_struct *tty = tty_port_tty_get(port); 261 + 262 + if (tty) { 263 + tty_wakeup(tty); 264 + tty_kref_put(tty); 265 + } 266 + } 267 + EXPORT_SYMBOL_GPL(tty_port_tty_wakeup); 247 268 248 269 /** 249 270 * tty_port_carrier_raised - carrier raised check ··· 397 350 398 351 while (1) { 399 352 /* Indicate we are open */ 400 - if (tty->termios.c_cflag & CBAUD) 353 + if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) 401 354 tty_port_raise_dtr_rts(port); 402 355 403 356 prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); ··· 442 395 } 443 396 EXPORT_SYMBOL(tty_port_block_til_ready); 444 397 398 + static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) 399 + { 400 + unsigned int bps = tty_get_baud_rate(tty); 401 + long timeout; 402 + 403 + if (bps > 1200) { 404 + timeout = (HZ * 10 * port->drain_delay) / bps; 405 + timeout = max_t(long, timeout, HZ / 10); 406 + } else { 407 + timeout = 2 * HZ; 408 + } 409 + schedule_timeout_interruptible(timeout); 410 + } 411 + 445 412 int tty_port_close_start(struct tty_port *port, 446 413 struct tty_struct *tty, struct file *filp) 447 414 { ··· 488 427 set_bit(ASYNCB_CLOSING, &port->flags); 489 428 tty->closing = 1; 490 429 spin_unlock_irqrestore(&port->lock, flags); 491 - /* Don't block on a stalled port, just pull the chain */ 492 - if (tty->flow_stopped) 493 - tty_driver_flush_buffer(tty); 494 - if (test_bit(ASYNCB_INITIALIZED, &port->flags) && 495 - port->closing_wait != ASYNC_CLOSING_WAIT_NONE) 496 - tty_wait_until_sent_from_close(tty, port->closing_wait); 497 - if (port->drain_delay) { 498 - unsigned int bps = tty_get_baud_rate(tty); 499 - long timeout; 500 430 501 - if (bps > 1200) 502 - timeout = max_t(long, 503 - (HZ * 10 * port->drain_delay) / bps, HZ / 10); 504 - else 505 - timeout = 2 * HZ; 506 - schedule_timeout_interruptible(timeout); 431 + if (test_bit(ASYNCB_INITIALIZED, &port->flags)) { 432 + /* Don't block on a stalled port, just pull the chain */ 433 + if (tty->flow_stopped) 434 + tty_driver_flush_buffer(tty); 435 + if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) 436 + tty_wait_until_sent_from_close(tty, port->closing_wait); 437 + if (port->drain_delay) 438 + tty_port_drain_delay(port, tty); 507 439 } 508 440 /* Flush the ldisc buffering */ 509 441 tty_ldisc_flush(tty); 510 - 511 - /* Drop DTR/RTS if HUPCL is set. This causes any attached modem to 512 - hang up the line */ 513 - if (tty->termios.c_cflag & HUPCL) 514 - tty_port_lower_dtr_rts(port); 515 442 516 443 /* Don't call port->drop for the last reference. Callers will want 517 444 to drop the last active reference in ->shutdown() or the tty ··· 535 486 { 536 487 if (tty_port_close_start(port, tty, filp) == 0) 537 488 return; 538 - tty_port_shutdown(port); 489 + tty_port_shutdown(port, tty); 539 490 set_bit(TTY_IO_ERROR, &tty->flags); 540 491 tty_port_close_end(port, tty); 541 492 tty_port_tty_set(port, NULL);
+1 -2
drivers/tty/vt/consolemap.c
··· 194 194 q = p->inverse_translations[i]; 195 195 196 196 if (!q) { 197 - q = p->inverse_translations[i] = (unsigned char *) 198 - kmalloc(MAX_GLYPH, GFP_KERNEL); 197 + q = p->inverse_translations[i] = kmalloc(MAX_GLYPH, GFP_KERNEL); 199 198 if (!q) return; 200 199 } 201 200 memset(q, 0, MAX_GLYPH);
+7 -24
drivers/usb/class/cdc-acm.c
··· 292 292 { 293 293 struct acm *acm = urb->context; 294 294 struct usb_cdc_notification *dr = urb->transfer_buffer; 295 - struct tty_struct *tty; 296 295 unsigned char *data; 297 296 int newctrl; 298 297 int retval; ··· 326 327 break; 327 328 328 329 case USB_CDC_NOTIFY_SERIAL_STATE: 329 - tty = tty_port_tty_get(&acm->port); 330 330 newctrl = get_unaligned_le16(data); 331 331 332 - if (tty) { 333 - if (!acm->clocal && 334 - (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { 335 - dev_dbg(&acm->control->dev, 336 - "%s - calling hangup\n", __func__); 337 - tty_hangup(tty); 338 - } 339 - tty_kref_put(tty); 332 + if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { 333 + dev_dbg(&acm->control->dev, "%s - calling hangup\n", 334 + __func__); 335 + tty_port_tty_hangup(&acm->port, false); 340 336 } 341 337 342 338 acm->ctrlin = newctrl; ··· 469 475 static void acm_softint(struct work_struct *work) 470 476 { 471 477 struct acm *acm = container_of(work, struct acm, work); 472 - struct tty_struct *tty; 473 478 474 479 dev_vdbg(&acm->data->dev, "%s\n", __func__); 475 480 476 - tty = tty_port_tty_get(&acm->port); 477 - if (!tty) 478 - return; 479 - tty_wakeup(tty); 480 - tty_kref_put(tty); 481 + tty_port_tty_wakeup(&acm->port); 481 482 } 482 483 483 484 /* ··· 1508 1519 static int acm_reset_resume(struct usb_interface *intf) 1509 1520 { 1510 1521 struct acm *acm = usb_get_intfdata(intf); 1511 - struct tty_struct *tty; 1512 1522 1513 - if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) { 1514 - tty = tty_port_tty_get(&acm->port); 1515 - if (tty) { 1516 - tty_hangup(tty); 1517 - tty_kref_put(tty); 1518 - } 1519 - } 1523 + if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) 1524 + tty_port_tty_hangup(&acm->port, false); 1520 1525 1521 1526 return acm_resume(intf); 1522 1527 }
+3 -14
drivers/usb/serial/digi_acceleport.c
··· 210 210 211 211 /* Local Function Declarations */ 212 212 213 - static void digi_wakeup_write(struct usb_serial_port *port); 214 213 static void digi_wakeup_write_lock(struct work_struct *work); 215 214 static int digi_write_oob_command(struct usb_serial_port *port, 216 215 unsigned char *buf, int count, int interruptible); ··· 373 374 unsigned long flags; 374 375 375 376 spin_lock_irqsave(&priv->dp_port_lock, flags); 376 - digi_wakeup_write(port); 377 + tty_port_tty_wakeup(&port->port); 377 378 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 378 379 } 379 - 380 - static void digi_wakeup_write(struct usb_serial_port *port) 381 - { 382 - struct tty_struct *tty = tty_port_tty_get(&port->port); 383 - if (tty) { 384 - tty_wakeup(tty); 385 - tty_kref_put(tty); 386 - } 387 - } 388 - 389 380 390 381 /* 391 382 * Digi Write OOB Command ··· 1033 1044 } 1034 1045 } 1035 1046 /* wake up processes sleeping on writes immediately */ 1036 - digi_wakeup_write(port); 1047 + tty_port_tty_wakeup(&port->port); 1037 1048 /* also queue up a wakeup at scheduler time, in case we */ 1038 1049 /* lost the race in write_chan(). */ 1039 1050 schedule_work(&priv->dp_wakeup_work); ··· 1511 1522 /* port must be open to use tty struct */ 1512 1523 if (rts) { 1513 1524 tty->hw_stopped = 0; 1514 - digi_wakeup_write(port); 1525 + tty_port_tty_wakeup(&port->port); 1515 1526 } 1516 1527 } else { 1517 1528 priv->dp_modem_signals &= ~TIOCM_CTS;
+5 -23
drivers/usb/serial/io_edgeport.c
··· 564 564 struct device *dev; 565 565 struct edgeport_port *edge_port; 566 566 struct usb_serial_port *port; 567 - struct tty_struct *tty; 568 567 unsigned char *data = urb->transfer_buffer; 569 568 int length = urb->actual_length; 570 569 int bytes_avail; ··· 642 643 643 644 /* tell the tty driver that something 644 645 has changed */ 645 - tty = tty_port_tty_get( 646 - &edge_port->port->port); 647 - if (tty) { 648 - tty_wakeup(tty); 649 - tty_kref_put(tty); 650 - } 646 + tty_port_tty_wakeup(&edge_port->port->port); 651 647 /* Since we have more credit, check 652 648 if more data can be sent */ 653 649 send_more_port_data(edge_serial, ··· 731 737 static void edge_bulk_out_data_callback(struct urb *urb) 732 738 { 733 739 struct edgeport_port *edge_port = urb->context; 734 - struct tty_struct *tty; 735 740 int status = urb->status; 736 741 737 742 if (status) { ··· 739 746 __func__, status); 740 747 } 741 748 742 - tty = tty_port_tty_get(&edge_port->port->port); 743 - 744 - if (tty && edge_port->open) { 745 - /* let the tty driver wakeup if it has a special 746 - write_wakeup function */ 747 - tty_wakeup(tty); 748 - } 749 - tty_kref_put(tty); 749 + if (edge_port->open) 750 + tty_port_tty_wakeup(&edge_port->port->port); 750 751 751 752 /* Release the Write URB */ 752 753 edge_port->write_in_progress = false; ··· 759 772 static void edge_bulk_out_cmd_callback(struct urb *urb) 760 773 { 761 774 struct edgeport_port *edge_port = urb->context; 762 - struct tty_struct *tty; 763 775 int status = urb->status; 764 776 765 777 atomic_dec(&CmdUrbs); ··· 779 793 return; 780 794 } 781 795 782 - /* Get pointer to tty */ 783 - tty = tty_port_tty_get(&edge_port->port->port); 784 - 785 796 /* tell the tty driver that something has changed */ 786 - if (tty && edge_port->open) 787 - tty_wakeup(tty); 788 - tty_kref_put(tty); 797 + if (edge_port->open) 798 + tty_port_tty_wakeup(&edge_port->port->port); 789 799 790 800 /* we have completed the command */ 791 801 edge_port->commandPending = false;
+10 -33
drivers/usb/serial/keyspan.c
··· 378 378 struct usb_serial *serial; 379 379 struct usb_serial_port *port; 380 380 struct keyspan_port_private *p_priv; 381 - struct tty_struct *tty; 382 381 int old_dcd_state, err; 383 382 int status = urb->status; 384 383 ··· 420 421 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 421 422 p_priv->ri_state = ((msg->ri) ? 1 : 0); 422 423 423 - if (old_dcd_state != p_priv->dcd_state) { 424 - tty = tty_port_tty_get(&port->port); 425 - if (tty && !C_CLOCAL(tty)) 426 - tty_hangup(tty); 427 - tty_kref_put(tty); 428 - } 424 + if (old_dcd_state != p_priv->dcd_state) 425 + tty_port_tty_hangup(&port->port, true); 429 426 430 427 /* Resubmit urb so we continue receiving */ 431 428 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 505 510 struct usb_serial *serial; 506 511 struct usb_serial_port *port; 507 512 struct keyspan_port_private *p_priv; 508 - struct tty_struct *tty; 509 513 int old_dcd_state; 510 514 int status = urb->status; 511 515 ··· 545 551 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 546 552 p_priv->ri_state = ((msg->ri) ? 1 : 0); 547 553 548 - if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 549 - tty = tty_port_tty_get(&port->port); 550 - if (tty && !C_CLOCAL(tty)) 551 - tty_hangup(tty); 552 - tty_kref_put(tty); 553 - } 554 + if (old_dcd_state != p_priv->dcd_state && old_dcd_state) 555 + tty_port_tty_hangup(&port->port, true); 554 556 555 557 /* Resubmit urb so we continue receiving */ 556 558 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 632 642 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 633 643 p_priv->ri_state = ((msg->ri) ? 1 : 0); 634 644 635 - if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 636 - struct tty_struct *tty = tty_port_tty_get(&port->port); 637 - if (tty && !C_CLOCAL(tty)) 638 - tty_hangup(tty); 639 - tty_kref_put(tty); 640 - } 645 + if (old_dcd_state != p_priv->dcd_state && old_dcd_state) 646 + tty_port_tty_hangup(&port->port, true); 641 647 642 648 /* Resubmit urb so we continue receiving */ 643 649 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 837 851 struct usb_serial *serial; 838 852 struct usb_serial_port *port; 839 853 struct keyspan_port_private *p_priv; 840 - struct tty_struct *tty; 841 854 int old_dcd_state, err; 842 855 int status = urb->status; 843 856 ··· 865 880 p_priv->dcd_state = ((msg->dcd) ? 1 : 0); 866 881 p_priv->ri_state = ((msg->ri) ? 1 : 0); 867 882 868 - if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 869 - tty = tty_port_tty_get(&port->port); 870 - if (tty && !C_CLOCAL(tty)) 871 - tty_hangup(tty); 872 - tty_kref_put(tty); 873 - } 883 + if (old_dcd_state != p_priv->dcd_state && old_dcd_state) 884 + tty_port_tty_hangup(&port->port, true); 874 885 875 886 /* Resubmit urb so we continue receiving */ 876 887 err = usb_submit_urb(urb, GFP_ATOMIC); ··· 934 953 p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0); 935 954 p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0); 936 955 937 - if (old_dcd_state != p_priv->dcd_state && old_dcd_state) { 938 - struct tty_struct *tty = tty_port_tty_get(&port->port); 939 - if (tty && !C_CLOCAL(tty)) 940 - tty_hangup(tty); 941 - tty_kref_put(tty); 942 - } 956 + if (old_dcd_state != p_priv->dcd_state && old_dcd_state) 957 + tty_port_tty_hangup(&port->port, true); 943 958 944 959 /* Resubmit urb so we continue receiving */ 945 960 err = usb_submit_urb(urb, GFP_ATOMIC);
+2 -4
drivers/usb/serial/keyspan_pda.c
··· 104 104 struct keyspan_pda_private *priv = 105 105 container_of(work, struct keyspan_pda_private, wakeup_work); 106 106 struct usb_serial_port *port = priv->port; 107 - struct tty_struct *tty = tty_port_tty_get(&port->port); 108 - if (tty) 109 - tty_wakeup(tty); 110 - tty_kref_put(tty); 107 + 108 + tty_port_tty_wakeup(&port->port); 111 109 } 112 110 113 111 static void keyspan_pda_request_unthrottle(struct work_struct *work)
+2 -6
drivers/usb/serial/mos7720.c
··· 932 932 static void mos7720_bulk_out_data_callback(struct urb *urb) 933 933 { 934 934 struct moschip_port *mos7720_port; 935 - struct tty_struct *tty; 936 935 int status = urb->status; 937 936 938 937 if (status) { ··· 945 946 return ; 946 947 } 947 948 948 - tty = tty_port_tty_get(&mos7720_port->port->port); 949 - 950 - if (tty && mos7720_port->open) 951 - tty_wakeup(tty); 952 - tty_kref_put(tty); 949 + if (mos7720_port->open) 950 + tty_port_tty_wakeup(&mos7720_port->port->port); 953 951 } 954 952 955 953 /*
+2 -5
drivers/usb/serial/mos7840.c
··· 816 816 { 817 817 struct moschip_port *mos7840_port; 818 818 struct usb_serial_port *port; 819 - struct tty_struct *tty; 820 819 int status = urb->status; 821 820 int i; 822 821 ··· 838 839 if (mos7840_port_paranoia_check(port, __func__)) 839 840 return; 840 841 841 - tty = tty_port_tty_get(&port->port); 842 - if (tty && mos7840_port->open) 843 - tty_wakeup(tty); 844 - tty_kref_put(tty); 842 + if (mos7840_port->open) 843 + tty_port_tty_wakeup(&port->port); 845 844 846 845 } 847 846
+2 -7
drivers/usb/serial/option.c
··· 1537 1537 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 1538 1538 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 1539 1539 1540 - if (old_dcd_state && !portdata->dcd_state) { 1541 - struct tty_struct *tty = 1542 - tty_port_tty_get(&port->port); 1543 - if (tty && !C_CLOCAL(tty)) 1544 - tty_hangup(tty); 1545 - tty_kref_put(tty); 1546 - } 1540 + if (old_dcd_state && !portdata->dcd_state) 1541 + tty_port_tty_hangup(&port->port, true); 1547 1542 } else { 1548 1543 dev_dbg(dev, "%s: type %x req %x\n", __func__, 1549 1544 req_pkt->bRequestType, req_pkt->bRequest);
+2 -15
drivers/usb/serial/quatech2.c
··· 116 116 }; 117 117 118 118 struct qt2_port_private { 119 - bool is_open; 120 119 u8 device_port; 121 120 122 121 spinlock_t urb_lock; ··· 396 397 return status; 397 398 } 398 399 399 - port_priv->is_open = true; 400 400 port_priv->device_port = (u8) device_port; 401 401 402 402 if (tty) ··· 414 416 415 417 serial = port->serial; 416 418 port_priv = usb_get_serial_port_data(port); 417 - 418 - port_priv->is_open = false; 419 419 420 420 spin_lock_irqsave(&port_priv->urb_lock, flags); 421 421 usb_kill_urb(port_priv->write_urb); ··· 660 664 __func__); 661 665 break; 662 666 } 663 - 664 - if (port_priv->is_open) 665 - tty_flip_buffer_push(&port->port); 667 + tty_flip_buffer_push(&port->port); 666 668 667 669 newport = *(ch + 3); 668 670 ··· 703 709 tty_insert_flip_string(&port->port, ch, 1); 704 710 } 705 711 706 - if (port_priv->is_open) 707 - tty_flip_buffer_push(&port->port); 712 + tty_flip_buffer_push(&port->port); 708 713 } 709 714 710 715 static void qt2_write_bulk_callback(struct urb *urb) ··· 902 909 u16 val; 903 910 904 911 port_priv = usb_get_serial_port_data(port); 905 - 906 - if (!port_priv->is_open) { 907 - dev_err(&port->dev, 908 - "%s - port is not open\n", __func__); 909 - return; 910 - } 911 912 912 913 val = (break_state == -1) ? 1 : 0; 913 914
+2 -6
drivers/usb/serial/sierra.c
··· 628 628 unsigned char signals = *((unsigned char *) 629 629 urb->transfer_buffer + 630 630 sizeof(struct usb_ctrlrequest)); 631 - struct tty_struct *tty; 632 631 633 632 dev_dbg(&port->dev, "%s: signal x%x\n", __func__, 634 633 signals); ··· 638 639 portdata->dsr_state = ((signals & 0x02) ? 1 : 0); 639 640 portdata->ri_state = ((signals & 0x08) ? 1 : 0); 640 641 641 - tty = tty_port_tty_get(&port->port); 642 - if (tty && !C_CLOCAL(tty) && 643 - old_dcd_state && !portdata->dcd_state) 644 - tty_hangup(tty); 645 - tty_kref_put(tty); 642 + if (old_dcd_state && !portdata->dcd_state) 643 + tty_port_tty_hangup(&port->port, true); 646 644 } else { 647 645 dev_dbg(&port->dev, "%s: type %x req %x\n", 648 646 __func__, req_pkt->bRequestType,
+2 -5
drivers/usb/serial/ti_usb_3410_5052.c
··· 1229 1229 { 1230 1230 int count, result; 1231 1231 struct usb_serial_port *port = tport->tp_port; 1232 - struct tty_struct *tty = tty_port_tty_get(&port->port); /* FIXME */ 1233 1232 unsigned long flags; 1234 1233 1235 1234 spin_lock_irqsave(&tport->tp_lock, flags); ··· 1269 1270 } 1270 1271 1271 1272 /* more room in the buffer for new writes, wakeup */ 1272 - if (tty) 1273 - tty_wakeup(tty); 1274 - tty_kref_put(tty); 1273 + tty_port_tty_wakeup(&port->port); 1274 + 1275 1275 wake_up_interruptible(&tport->tp_write_wait); 1276 1276 return; 1277 1277 unlock: 1278 1278 spin_unlock_irqrestore(&tport->tp_lock, flags); 1279 - tty_kref_put(tty); 1280 1279 return; 1281 1280 } 1282 1281
+1 -9
drivers/usb/serial/usb-serial.c
··· 542 542 { 543 543 struct usb_serial_port *port = 544 544 container_of(work, struct usb_serial_port, work); 545 - struct tty_struct *tty; 546 545 547 - tty = tty_port_tty_get(&port->port); 548 - if (!tty) 549 - return; 550 - 551 - dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number); 552 - 553 - tty_wakeup(tty); 554 - tty_kref_put(tty); 546 + tty_port_tty_wakeup(&port->port); 555 547 } 556 548 557 549 static void kill_traffic(struct usb_serial_port *port)
+3
include/linux/amba/serial.h
··· 203 203 bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 204 204 void *dma_rx_param; 205 205 void *dma_tx_param; 206 + bool dma_rx_poll_enable; 207 + unsigned int dma_rx_poll_rate; 208 + unsigned int dma_rx_poll_timeout; 206 209 void (*init) (void); 207 210 void (*exit) (void); 208 211 };
-4
include/linux/platform_data/serial-sccnxp.h
··· 86 86 const u32 mctrl_cfg[SCCNXP_MAX_UARTS]; 87 87 /* Timer value for polling mode (usecs) */ 88 88 const unsigned int poll_time_us; 89 - /* Called during startup */ 90 - void (*init)(void); 91 - /* Called before finish */ 92 - void (*exit)(void); 93 89 }; 94 90 95 91 #endif
+260
include/linux/serial_s3c.h
··· 1 + /* 2 + * Internal header file for Samsung S3C2410 serial ports (UART0-2) 3 + * 4 + * Copyright (C) 2002 Shane Nay (shane@minirl.com) 5 + * 6 + * Additional defines, Copyright 2003 Simtec Electronics (linux@simtec.co.uk) 7 + * 8 + * Adapted from: 9 + * 10 + * Internal header file for MX1ADS serial ports (UART1 & 2) 11 + * 12 + * Copyright (C) 2002 Shane Nay (shane@minirl.com) 13 + * 14 + * This program is free software; you can redistribute it and/or modify 15 + * it under the terms of the GNU General Public License as published by 16 + * the Free Software Foundation; either version 2 of the License, or 17 + * (at your option) any later version. 18 + * 19 + * This program is distributed in the hope that it will be useful, 20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 + * GNU General Public License for more details. 23 + * 24 + * You should have received a copy of the GNU General Public License 25 + * along with this program; if not, write to the Free Software 26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 + */ 28 + 29 + #ifndef __ASM_ARM_REGS_SERIAL_H 30 + #define __ASM_ARM_REGS_SERIAL_H 31 + 32 + #define S3C2410_URXH (0x24) 33 + #define S3C2410_UTXH (0x20) 34 + #define S3C2410_ULCON (0x00) 35 + #define S3C2410_UCON (0x04) 36 + #define S3C2410_UFCON (0x08) 37 + #define S3C2410_UMCON (0x0C) 38 + #define S3C2410_UBRDIV (0x28) 39 + #define S3C2410_UTRSTAT (0x10) 40 + #define S3C2410_UERSTAT (0x14) 41 + #define S3C2410_UFSTAT (0x18) 42 + #define S3C2410_UMSTAT (0x1C) 43 + 44 + #define S3C2410_LCON_CFGMASK ((0xF<<3)|(0x3)) 45 + 46 + #define S3C2410_LCON_CS5 (0x0) 47 + #define S3C2410_LCON_CS6 (0x1) 48 + #define S3C2410_LCON_CS7 (0x2) 49 + #define S3C2410_LCON_CS8 (0x3) 50 + #define S3C2410_LCON_CSMASK (0x3) 51 + 52 + #define S3C2410_LCON_PNONE (0x0) 53 + #define S3C2410_LCON_PEVEN (0x5 << 3) 54 + #define S3C2410_LCON_PODD (0x4 << 3) 55 + #define S3C2410_LCON_PMASK (0x7 << 3) 56 + 57 + #define S3C2410_LCON_STOPB (1<<2) 58 + #define S3C2410_LCON_IRM (1<<6) 59 + 60 + #define S3C2440_UCON_CLKMASK (3<<10) 61 + #define S3C2440_UCON_CLKSHIFT (10) 62 + #define S3C2440_UCON_PCLK (0<<10) 63 + #define S3C2440_UCON_UCLK (1<<10) 64 + #define S3C2440_UCON_PCLK2 (2<<10) 65 + #define S3C2440_UCON_FCLK (3<<10) 66 + #define S3C2443_UCON_EPLL (3<<10) 67 + 68 + #define S3C6400_UCON_CLKMASK (3<<10) 69 + #define S3C6400_UCON_CLKSHIFT (10) 70 + #define S3C6400_UCON_PCLK (0<<10) 71 + #define S3C6400_UCON_PCLK2 (2<<10) 72 + #define S3C6400_UCON_UCLK0 (1<<10) 73 + #define S3C6400_UCON_UCLK1 (3<<10) 74 + 75 + #define S3C2440_UCON2_FCLK_EN (1<<15) 76 + #define S3C2440_UCON0_DIVMASK (15 << 12) 77 + #define S3C2440_UCON1_DIVMASK (15 << 12) 78 + #define S3C2440_UCON2_DIVMASK (7 << 12) 79 + #define S3C2440_UCON_DIVSHIFT (12) 80 + 81 + #define S3C2412_UCON_CLKMASK (3<<10) 82 + #define S3C2412_UCON_CLKSHIFT (10) 83 + #define S3C2412_UCON_UCLK (1<<10) 84 + #define S3C2412_UCON_USYSCLK (3<<10) 85 + #define S3C2412_UCON_PCLK (0<<10) 86 + #define S3C2412_UCON_PCLK2 (2<<10) 87 + 88 + #define S3C2410_UCON_CLKMASK (1 << 10) 89 + #define S3C2410_UCON_CLKSHIFT (10) 90 + #define S3C2410_UCON_UCLK (1<<10) 91 + #define S3C2410_UCON_SBREAK (1<<4) 92 + 93 + #define S3C2410_UCON_TXILEVEL (1<<9) 94 + #define S3C2410_UCON_RXILEVEL (1<<8) 95 + #define S3C2410_UCON_TXIRQMODE (1<<2) 96 + #define S3C2410_UCON_RXIRQMODE (1<<0) 97 + #define S3C2410_UCON_RXFIFO_TOI (1<<7) 98 + #define S3C2443_UCON_RXERR_IRQEN (1<<6) 99 + #define S3C2443_UCON_LOOPBACK (1<<5) 100 + 101 + #define S3C2410_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 102 + S3C2410_UCON_RXILEVEL | \ 103 + S3C2410_UCON_TXIRQMODE | \ 104 + S3C2410_UCON_RXIRQMODE | \ 105 + S3C2410_UCON_RXFIFO_TOI) 106 + 107 + #define S3C2410_UFCON_FIFOMODE (1<<0) 108 + #define S3C2410_UFCON_TXTRIG0 (0<<6) 109 + #define S3C2410_UFCON_RXTRIG8 (1<<4) 110 + #define S3C2410_UFCON_RXTRIG12 (2<<4) 111 + 112 + /* S3C2440 FIFO trigger levels */ 113 + #define S3C2440_UFCON_RXTRIG1 (0<<4) 114 + #define S3C2440_UFCON_RXTRIG8 (1<<4) 115 + #define S3C2440_UFCON_RXTRIG16 (2<<4) 116 + #define S3C2440_UFCON_RXTRIG32 (3<<4) 117 + 118 + #define S3C2440_UFCON_TXTRIG0 (0<<6) 119 + #define S3C2440_UFCON_TXTRIG16 (1<<6) 120 + #define S3C2440_UFCON_TXTRIG32 (2<<6) 121 + #define S3C2440_UFCON_TXTRIG48 (3<<6) 122 + 123 + #define S3C2410_UFCON_RESETBOTH (3<<1) 124 + #define S3C2410_UFCON_RESETTX (1<<2) 125 + #define S3C2410_UFCON_RESETRX (1<<1) 126 + 127 + #define S3C2410_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ 128 + S3C2410_UFCON_TXTRIG0 | \ 129 + S3C2410_UFCON_RXTRIG8 ) 130 + 131 + #define S3C2410_UMCOM_AFC (1<<4) 132 + #define S3C2410_UMCOM_RTS_LOW (1<<0) 133 + 134 + #define S3C2412_UMCON_AFC_63 (0<<5) /* same as s3c2443 */ 135 + #define S3C2412_UMCON_AFC_56 (1<<5) 136 + #define S3C2412_UMCON_AFC_48 (2<<5) 137 + #define S3C2412_UMCON_AFC_40 (3<<5) 138 + #define S3C2412_UMCON_AFC_32 (4<<5) 139 + #define S3C2412_UMCON_AFC_24 (5<<5) 140 + #define S3C2412_UMCON_AFC_16 (6<<5) 141 + #define S3C2412_UMCON_AFC_8 (7<<5) 142 + 143 + #define S3C2410_UFSTAT_TXFULL (1<<9) 144 + #define S3C2410_UFSTAT_RXFULL (1<<8) 145 + #define S3C2410_UFSTAT_TXMASK (15<<4) 146 + #define S3C2410_UFSTAT_TXSHIFT (4) 147 + #define S3C2410_UFSTAT_RXMASK (15<<0) 148 + #define S3C2410_UFSTAT_RXSHIFT (0) 149 + 150 + /* UFSTAT S3C2443 same as S3C2440 */ 151 + #define S3C2440_UFSTAT_TXFULL (1<<14) 152 + #define S3C2440_UFSTAT_RXFULL (1<<6) 153 + #define S3C2440_UFSTAT_TXSHIFT (8) 154 + #define S3C2440_UFSTAT_RXSHIFT (0) 155 + #define S3C2440_UFSTAT_TXMASK (63<<8) 156 + #define S3C2440_UFSTAT_RXMASK (63) 157 + 158 + #define S3C2410_UTRSTAT_TXE (1<<2) 159 + #define S3C2410_UTRSTAT_TXFE (1<<1) 160 + #define S3C2410_UTRSTAT_RXDR (1<<0) 161 + 162 + #define S3C2410_UERSTAT_OVERRUN (1<<0) 163 + #define S3C2410_UERSTAT_FRAME (1<<2) 164 + #define S3C2410_UERSTAT_BREAK (1<<3) 165 + #define S3C2443_UERSTAT_PARITY (1<<1) 166 + 167 + #define S3C2410_UERSTAT_ANY (S3C2410_UERSTAT_OVERRUN | \ 168 + S3C2410_UERSTAT_FRAME | \ 169 + S3C2410_UERSTAT_BREAK) 170 + 171 + #define S3C2410_UMSTAT_CTS (1<<0) 172 + #define S3C2410_UMSTAT_DeltaCTS (1<<2) 173 + 174 + #define S3C2443_DIVSLOT (0x2C) 175 + 176 + /* S3C64XX interrupt registers. */ 177 + #define S3C64XX_UINTP 0x30 178 + #define S3C64XX_UINTSP 0x34 179 + #define S3C64XX_UINTM 0x38 180 + 181 + #define S3C64XX_UINTM_RXD (0) 182 + #define S3C64XX_UINTM_TXD (2) 183 + #define S3C64XX_UINTM_RXD_MSK (1 << S3C64XX_UINTM_RXD) 184 + #define S3C64XX_UINTM_TXD_MSK (1 << S3C64XX_UINTM_TXD) 185 + 186 + /* Following are specific to S5PV210 */ 187 + #define S5PV210_UCON_CLKMASK (1<<10) 188 + #define S5PV210_UCON_CLKSHIFT (10) 189 + #define S5PV210_UCON_PCLK (0<<10) 190 + #define S5PV210_UCON_UCLK (1<<10) 191 + 192 + #define S5PV210_UFCON_TXTRIG0 (0<<8) 193 + #define S5PV210_UFCON_TXTRIG4 (1<<8) 194 + #define S5PV210_UFCON_TXTRIG8 (2<<8) 195 + #define S5PV210_UFCON_TXTRIG16 (3<<8) 196 + #define S5PV210_UFCON_TXTRIG32 (4<<8) 197 + #define S5PV210_UFCON_TXTRIG64 (5<<8) 198 + #define S5PV210_UFCON_TXTRIG128 (6<<8) 199 + #define S5PV210_UFCON_TXTRIG256 (7<<8) 200 + 201 + #define S5PV210_UFCON_RXTRIG1 (0<<4) 202 + #define S5PV210_UFCON_RXTRIG4 (1<<4) 203 + #define S5PV210_UFCON_RXTRIG8 (2<<4) 204 + #define S5PV210_UFCON_RXTRIG16 (3<<4) 205 + #define S5PV210_UFCON_RXTRIG32 (4<<4) 206 + #define S5PV210_UFCON_RXTRIG64 (5<<4) 207 + #define S5PV210_UFCON_RXTRIG128 (6<<4) 208 + #define S5PV210_UFCON_RXTRIG256 (7<<4) 209 + 210 + #define S5PV210_UFSTAT_TXFULL (1<<24) 211 + #define S5PV210_UFSTAT_RXFULL (1<<8) 212 + #define S5PV210_UFSTAT_TXMASK (255<<16) 213 + #define S5PV210_UFSTAT_TXSHIFT (16) 214 + #define S5PV210_UFSTAT_RXMASK (255<<0) 215 + #define S5PV210_UFSTAT_RXSHIFT (0) 216 + 217 + #define S3C2410_UCON_CLKSEL0 (1 << 0) 218 + #define S3C2410_UCON_CLKSEL1 (1 << 1) 219 + #define S3C2410_UCON_CLKSEL2 (1 << 2) 220 + #define S3C2410_UCON_CLKSEL3 (1 << 3) 221 + 222 + /* Default values for s5pv210 UCON and UFCON uart registers */ 223 + #define S5PV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 224 + S3C2410_UCON_RXILEVEL | \ 225 + S3C2410_UCON_TXIRQMODE | \ 226 + S3C2410_UCON_RXIRQMODE | \ 227 + S3C2410_UCON_RXFIFO_TOI | \ 228 + S3C2443_UCON_RXERR_IRQEN) 229 + 230 + #define S5PV210_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ 231 + S5PV210_UFCON_TXTRIG4 | \ 232 + S5PV210_UFCON_RXTRIG4) 233 + 234 + #ifndef __ASSEMBLY__ 235 + 236 + /* configuration structure for per-machine configurations for the 237 + * serial port 238 + * 239 + * the pointer is setup by the machine specific initialisation from the 240 + * arch/arm/mach-s3c2410/ directory. 241 + */ 242 + 243 + struct s3c2410_uartcfg { 244 + unsigned char hwport; /* hardware port number */ 245 + unsigned char unused; 246 + unsigned short flags; 247 + upf_t uart_flags; /* default uart flags */ 248 + unsigned int clk_sel; 249 + 250 + unsigned int has_fracval; 251 + 252 + unsigned long ucon; /* value of ucon for port */ 253 + unsigned long ulcon; /* value of ulcon for port */ 254 + unsigned long ufcon; /* value of ufcon for port */ 255 + }; 256 + 257 + #endif /* __ASSEMBLY__ */ 258 + 259 + #endif /* __ASM_ARM_REGS_SERIAL_H */ 260 +
+37 -4
include/linux/tty.h
··· 255 255 int count; 256 256 struct winsize winsize; /* termios mutex */ 257 257 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; 258 - unsigned char warned:1; 259 258 unsigned char ctrl_status; /* ctrl_lock */ 260 259 unsigned int receive_room; /* Bytes free for queue */ 260 + int flow_change; 261 261 262 262 struct tty_struct *link; 263 263 struct fasync_struct *fasync; ··· 315 315 #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ 316 316 #define TTY_HUPPED 18 /* Post driver->hangup() */ 317 317 #define TTY_HUPPING 21 /* ->hangup() in progress */ 318 + #define TTY_LDISC_HALTED 22 /* Line discipline is halted */ 318 319 319 320 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) 321 + 322 + /* Values for tty->flow_change */ 323 + #define TTY_THROTTLE_SAFE 1 324 + #define TTY_UNTHROTTLE_SAFE 2 325 + 326 + static inline void __tty_set_flow_change(struct tty_struct *tty, int val) 327 + { 328 + tty->flow_change = val; 329 + } 330 + 331 + static inline void tty_set_flow_change(struct tty_struct *tty, int val) 332 + { 333 + tty->flow_change = val; 334 + smp_mb(); 335 + } 320 336 321 337 #ifdef CONFIG_TTY 322 338 extern void console_init(void); ··· 416 400 extern void tty_driver_flush_buffer(struct tty_struct *tty); 417 401 extern void tty_throttle(struct tty_struct *tty); 418 402 extern void tty_unthrottle(struct tty_struct *tty); 403 + extern int tty_throttle_safe(struct tty_struct *tty); 404 + extern int tty_unthrottle_safe(struct tty_struct *tty); 419 405 extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws); 420 406 extern void tty_driver_remove_tty(struct tty_driver *driver, 421 407 struct tty_struct *tty); ··· 437 419 extern void tty_buffer_free_all(struct tty_port *port); 438 420 extern void tty_buffer_flush(struct tty_struct *tty); 439 421 extern void tty_buffer_init(struct tty_port *port); 440 - extern speed_t tty_get_baud_rate(struct tty_struct *tty); 441 422 extern speed_t tty_termios_baud_rate(struct ktermios *termios); 442 423 extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); 443 424 extern void tty_termios_encode_baud_rate(struct ktermios *termios, 444 425 speed_t ibaud, speed_t obaud); 445 426 extern void tty_encode_baud_rate(struct tty_struct *tty, 446 427 speed_t ibaud, speed_t obaud); 428 + 429 + /** 430 + * tty_get_baud_rate - get tty bit rates 431 + * @tty: tty to query 432 + * 433 + * Returns the baud rate as an integer for this terminal. The 434 + * termios lock must be held by the caller and the terminal bit 435 + * flags may be updated. 436 + * 437 + * Locking: none 438 + */ 439 + static inline speed_t tty_get_baud_rate(struct tty_struct *tty) 440 + { 441 + return tty_termios_baud_rate(&tty->termios); 442 + } 443 + 447 444 extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 448 445 extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); 449 446 extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); ··· 535 502 extern void tty_port_raise_dtr_rts(struct tty_port *port); 536 503 extern void tty_port_lower_dtr_rts(struct tty_port *port); 537 504 extern void tty_port_hangup(struct tty_port *port); 505 + extern void tty_port_tty_hangup(struct tty_port *port, bool check_clocal); 506 + extern void tty_port_tty_wakeup(struct tty_port *port); 538 507 extern int tty_port_block_til_ready(struct tty_port *port, 539 508 struct tty_struct *tty, struct file *filp); 540 509 extern int tty_port_close_start(struct tty_port *port, ··· 561 526 extern void tty_ldisc_init(struct tty_struct *tty); 562 527 extern void tty_ldisc_deinit(struct tty_struct *tty); 563 528 extern void tty_ldisc_begin(void); 564 - /* This last one is just for the tty layer internals and shouldn't be used elsewhere */ 565 - extern void tty_ldisc_enable(struct tty_struct *tty); 566 529 567 530 568 531 /* n_tty.c */
+67 -67
include/linux/tty_ldisc.h
··· 9 9 * 10 10 * int (*open)(struct tty_struct *); 11 11 * 12 - * This function is called when the line discipline is associated 13 - * with the tty. The line discipline can use this as an 14 - * opportunity to initialize any state needed by the ldisc routines. 15 - * 12 + * This function is called when the line discipline is associated 13 + * with the tty. The line discipline can use this as an 14 + * opportunity to initialize any state needed by the ldisc routines. 15 + * 16 16 * void (*close)(struct tty_struct *); 17 17 * 18 18 * This function is called when the line discipline is being 19 - * shutdown, either because the tty is being closed or because 20 - * the tty is being changed to use a new line discipline 21 - * 19 + * shutdown, either because the tty is being closed or because 20 + * the tty is being changed to use a new line discipline 21 + * 22 22 * void (*flush_buffer)(struct tty_struct *tty); 23 23 * 24 - * This function instructs the line discipline to clear its 25 - * buffers of any input characters it may have queued to be 26 - * delivered to the user mode process. 27 - * 24 + * This function instructs the line discipline to clear its 25 + * buffers of any input characters it may have queued to be 26 + * delivered to the user mode process. 27 + * 28 28 * ssize_t (*chars_in_buffer)(struct tty_struct *tty); 29 29 * 30 - * This function returns the number of input characters the line 30 + * This function returns the number of input characters the line 31 31 * discipline may have queued up to be delivered to the user mode 32 32 * process. 33 - * 33 + * 34 34 * ssize_t (*read)(struct tty_struct * tty, struct file * file, 35 35 * unsigned char * buf, size_t nr); 36 36 * 37 - * This function is called when the user requests to read from 38 - * the tty. The line discipline will return whatever characters 39 - * it has buffered up for the user. If this function is not 40 - * defined, the user will receive an EIO error. 41 - * 42 - * ssize_t (*write)(struct tty_struct * tty, struct file * file, 43 - * const unsigned char * buf, size_t nr); 37 + * This function is called when the user requests to read from 38 + * the tty. The line discipline will return whatever characters 39 + * it has buffered up for the user. If this function is not 40 + * defined, the user will receive an EIO error. 44 41 * 45 - * This function is called when the user requests to write to the 46 - * tty. The line discipline will deliver the characters to the 47 - * low-level tty device for transmission, optionally performing 48 - * some processing on the characters first. If this function is 49 - * not defined, the user will receive an EIO error. 50 - * 42 + * ssize_t (*write)(struct tty_struct * tty, struct file * file, 43 + * const unsigned char * buf, size_t nr); 44 + * 45 + * This function is called when the user requests to write to the 46 + * tty. The line discipline will deliver the characters to the 47 + * low-level tty device for transmission, optionally performing 48 + * some processing on the characters first. If this function is 49 + * not defined, the user will receive an EIO error. 50 + * 51 51 * int (*ioctl)(struct tty_struct * tty, struct file * file, 52 - * unsigned int cmd, unsigned long arg); 52 + * unsigned int cmd, unsigned long arg); 53 53 * 54 54 * This function is called when the user requests an ioctl which 55 - * is not handled by the tty layer or the low-level tty driver. 56 - * It is intended for ioctls which affect line discpline 57 - * operation. Note that the search order for ioctls is (1) tty 58 - * layer, (2) tty low-level driver, (3) line discpline. So a 59 - * low-level driver can "grab" an ioctl request before the line 60 - * discpline has a chance to see it. 61 - * 62 - * long (*compat_ioctl)(struct tty_struct * tty, struct file * file, 63 - * unsigned int cmd, unsigned long arg); 55 + * is not handled by the tty layer or the low-level tty driver. 56 + * It is intended for ioctls which affect line discpline 57 + * operation. Note that the search order for ioctls is (1) tty 58 + * layer, (2) tty low-level driver, (3) line discpline. So a 59 + * low-level driver can "grab" an ioctl request before the line 60 + * discpline has a chance to see it. 64 61 * 65 - * Process ioctl calls from 32-bit process on 64-bit system 62 + * long (*compat_ioctl)(struct tty_struct * tty, struct file * file, 63 + * unsigned int cmd, unsigned long arg); 64 + * 65 + * Process ioctl calls from 32-bit process on 64-bit system 66 66 * 67 67 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 68 68 * 69 - * This function notifies the line discpline that a change has 70 - * been made to the termios structure. 71 - * 72 - * int (*poll)(struct tty_struct * tty, struct file * file, 73 - * poll_table *wait); 69 + * This function notifies the line discpline that a change has 70 + * been made to the termios structure. 74 71 * 75 - * This function is called when a user attempts to select/poll on a 76 - * tty device. It is solely the responsibility of the line 77 - * discipline to handle poll requests. 72 + * int (*poll)(struct tty_struct * tty, struct file * file, 73 + * poll_table *wait); 74 + * 75 + * This function is called when a user attempts to select/poll on a 76 + * tty device. It is solely the responsibility of the line 77 + * discipline to handle poll requests. 78 78 * 79 79 * void (*receive_buf)(struct tty_struct *, const unsigned char *cp, 80 - * char *fp, int count); 80 + * char *fp, int count); 81 81 * 82 - * This function is called by the low-level tty driver to send 83 - * characters received by the hardware to the line discpline for 84 - * processing. <cp> is a pointer to the buffer of input 85 - * character received by the device. <fp> is a pointer to a 86 - * pointer of flag bytes which indicate whether a character was 87 - * received with a parity error, etc. 88 - * 82 + * This function is called by the low-level tty driver to send 83 + * characters received by the hardware to the line discpline for 84 + * processing. <cp> is a pointer to the buffer of input 85 + * character received by the device. <fp> is a pointer to a 86 + * pointer of flag bytes which indicate whether a character was 87 + * received with a parity error, etc. 88 + * 89 89 * void (*write_wakeup)(struct tty_struct *); 90 90 * 91 - * This function is called by the low-level tty driver to signal 92 - * that line discpline should try to send more characters to the 93 - * low-level driver for transmission. If the line discpline does 94 - * not have any more data to send, it can just return. 91 + * This function is called by the low-level tty driver to signal 92 + * that line discpline should try to send more characters to the 93 + * low-level driver for transmission. If the line discpline does 94 + * not have any more data to send, it can just return. 95 95 * 96 96 * int (*hangup)(struct tty_struct *) 97 97 * ··· 115 115 char *name; 116 116 int num; 117 117 int flags; 118 - 118 + 119 119 /* 120 120 * The following routines are called from above. 121 121 */ ··· 123 123 void (*close)(struct tty_struct *); 124 124 void (*flush_buffer)(struct tty_struct *tty); 125 125 ssize_t (*chars_in_buffer)(struct tty_struct *tty); 126 - ssize_t (*read)(struct tty_struct * tty, struct file * file, 127 - unsigned char __user * buf, size_t nr); 128 - ssize_t (*write)(struct tty_struct * tty, struct file * file, 129 - const unsigned char * buf, size_t nr); 130 - int (*ioctl)(struct tty_struct * tty, struct file * file, 126 + ssize_t (*read)(struct tty_struct *tty, struct file *file, 127 + unsigned char __user *buf, size_t nr); 128 + ssize_t (*write)(struct tty_struct *tty, struct file *file, 129 + const unsigned char *buf, size_t nr); 130 + int (*ioctl)(struct tty_struct *tty, struct file *file, 131 131 unsigned int cmd, unsigned long arg); 132 - long (*compat_ioctl)(struct tty_struct * tty, struct file * file, 132 + long (*compat_ioctl)(struct tty_struct *tty, struct file *file, 133 133 unsigned int cmd, unsigned long arg); 134 - void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 134 + void (*set_termios)(struct tty_struct *tty, struct ktermios *old); 135 135 unsigned int (*poll)(struct tty_struct *, struct file *, 136 136 struct poll_table_struct *); 137 137 int (*hangup)(struct tty_struct *tty); 138 - 138 + 139 139 /* 140 140 * The following routines are called from below. 141 141 */ ··· 145 145 void (*dcd_change)(struct tty_struct *, unsigned int); 146 146 147 147 struct module *owner; 148 - 148 + 149 149 int refcount; 150 150 }; 151 151
+1 -1
net/irda/ircomm/ircomm_tty.c
··· 328 328 spin_unlock_irqrestore(&port->lock, flags); 329 329 330 330 while (1) { 331 - if (tty->termios.c_cflag & CBAUD) 331 + if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) 332 332 tty_port_raise_dtr_rts(port); 333 333 334 334 set_current_state(TASK_INTERRUPTIBLE);
+1 -5
net/irda/ircomm/ircomm_tty_attach.c
··· 997 997 self->settings.dce = IRCOMM_DELTA_CD; 998 998 ircomm_tty_check_modem_status(self); 999 999 } else { 1000 - struct tty_struct *tty = tty_port_tty_get(&self->port); 1001 1000 IRDA_DEBUG(0, "%s(), hanging up!\n", __func__ ); 1002 - if (tty) { 1003 - tty_hangup(tty); 1004 - tty_kref_put(tty); 1005 - } 1001 + tty_port_tty_hangup(&self->port, false); 1006 1002 } 1007 1003 break; 1008 1004 default: