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

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

Pull tty / serial updates from Greg KH:
"Here is the "big" set of tty/serial driver patches for 5.15-rc1

Nothing major in here at all, just some driver updates and more
cleanups on old tty apis and code that needed it that includes:

- tty.h cleanup of things that didn't belong in it

- other tty cleanups by Jiri

- driver cleanups

- rs485 support added to amba-pl011 driver

- dts updates

- stm32 serial driver updates

- other minor fixes and driver updates

All have been in linux-next for a while with no reported problems"

* tag 'tty-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (83 commits)
tty: serial: uartlite: Use read_poll_timeout for a polling loop
tty: serial: uartlite: Use constants in early_uartlite_putc
tty: Fix data race between tiocsti() and flush_to_ldisc()
serial: vt8500: Use of_device_get_match_data
serial: tegra: Use of_device_get_match_data
serial: 8250_ingenic: Use of_device_get_match_data
tty: serial: linflexuart: Remove redundant check to simplify the code
tty: serial: fsl_lpuart: do software reset for imx7ulp and imx8qxp
tty: serial: fsl_lpuart: enable two stop bits for lpuart32
tty: serial: fsl_lpuart: fix the wrong mapbase value
mxser: use semi-colons instead of commas
tty: moxa: use semi-colons instead of commas
tty: serial: fsl_lpuart: check dma_tx_in_progress in tx dma callback
tty: replace in_irq() with in_hardirq()
serial: sh-sci: fix break handling for sysrq
serial: stm32: use devm_platform_get_and_ioremap_resource()
serial: stm32: use the defined variable to simplify code
Revert "arm pl011 serial: support multi-irq request"
tty: serial: samsung: Add Exynos850 SoC data
tty: serial: samsung: Fix driver data macros style
...

+1409 -1035
+6
Documentation/devicetree/bindings/serial/8250.yaml
··· 66 66 - const: nxp,lpc3220-uart 67 67 - items: 68 68 - enum: 69 + - exar,xr16l2552 70 + - exar,xr16l2551 71 + - exar,xr16l2550 72 + - const: ns8250 73 + - items: 74 + - enum: 69 75 - altr,16550-FIFO32 70 76 - altr,16550-FIFO64 71 77 - altr,16550-FIFO128
+1
Documentation/devicetree/bindings/serial/8250_omap.yaml
··· 79 79 power-domains: true 80 80 clock-frequency: true 81 81 current-speed: true 82 + overrun-throttle-ms: true 82 83 83 84 required: 84 85 - compatible
-27
Documentation/devicetree/bindings/serial/cdns,uart.txt
··· 1 - Binding for Cadence UART Controller 2 - 3 - Required properties: 4 - - compatible : 5 - Use "xlnx,xuartps","cdns,uart-r1p8" for Zynq-7xxx SoC. 6 - Use "xlnx,zynqmp-uart","cdns,uart-r1p12" for Zynq Ultrascale+ MPSoC. 7 - - reg: Should contain UART controller registers location and length. 8 - - interrupts: Should contain UART controller interrupts. 9 - - clocks: Must contain phandles to the UART clocks 10 - See ../clocks/clock-bindings.txt for details. 11 - - clock-names: Tuple to identify input clocks, must contain "uart_clk" and "pclk" 12 - See ../clocks/clock-bindings.txt for details. 13 - 14 - 15 - Optional properties: 16 - - cts-override : Override the CTS modem status signal. This signal will 17 - always be reported as active instead of being obtained from the modem status 18 - register. Define this if your serial port does not use this pin 19 - 20 - Example: 21 - uart@e0000000 { 22 - compatible = "cdns,uart-r1p8"; 23 - clocks = <&clkc 23>, <&clkc 40>; 24 - clock-names = "uart_clk", "pclk"; 25 - reg = <0xE0000000 0x1000>; 26 - interrupts = <0 27 4>; 27 - };
+66
Documentation/devicetree/bindings/serial/cdns,uart.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/serial/cdns,uart.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Cadence UART Controller Device Tree Bindings 8 + 9 + maintainers: 10 + - Michal Simek <michal.simek@xilinx.com> 11 + 12 + allOf: 13 + - $ref: /schemas/serial.yaml# 14 + 15 + properties: 16 + compatible: 17 + oneOf: 18 + - description: UART controller for Zynq-7xxx SoC 19 + items: 20 + - const: xlnx,xuartps 21 + - const: cdns,uart-r1p8 22 + - description: UART controller for Zynq Ultrascale+ MPSoC 23 + items: 24 + - const: xlnx,zynqmp-uart 25 + - const: cdns,uart-r1p12 26 + 27 + reg: 28 + maxItems: 1 29 + 30 + interrupts: 31 + maxItems: 1 32 + 33 + clocks: 34 + maxItems: 2 35 + 36 + clock-names: 37 + items: 38 + - const: uart_clk 39 + - const: pclk 40 + 41 + cts-override: 42 + description: | 43 + Override the CTS modem status signal. This signal will 44 + always be reported as active instead of being obtained 45 + from the modem status register. Define this if your serial 46 + port does not use this pin. 47 + type: boolean 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - interrupts 53 + - clocks 54 + - clock-names 55 + 56 + unevaluatedProperties: false 57 + 58 + examples: 59 + - | 60 + uart0: serial@e0000000 { 61 + compatible = "xlnx,xuartps", "cdns,uart-r1p8"; 62 + clocks = <&clkc 23>, <&clkc 40>; 63 + clock-names = "uart_clk", "pclk"; 64 + reg = <0xE0000000 0x1000>; 65 + interrupts = <0 27 4>; 66 + };
+1
Documentation/devicetree/bindings/serial/mtk-uart.txt
··· 15 15 * "mediatek,mt7622-uart" for MT7622 compatible UARTS 16 16 * "mediatek,mt7623-uart" for MT7623 compatible UARTS 17 17 * "mediatek,mt7629-uart" for MT7629 compatible UARTS 18 + * "mediatek,mt7986-uart", "mediatek,mt6577-uart" for MT7986 compatible UARTS 18 19 * "mediatek,mt8127-uart" for MT8127 compatible UARTS 19 20 * "mediatek,mt8135-uart" for MT8135 compatible UARTS 20 21 * "mediatek,mt8173-uart" for MT8173 compatible UARTS
+4 -4
arch/alpha/kernel/srmcons.c
··· 204 204 struct tty_driver *driver; 205 205 int err; 206 206 207 - driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES); 208 - if (!driver) 209 - return -ENOMEM; 207 + driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0); 208 + if (IS_ERR(driver)) 209 + return PTR_ERR(driver); 210 210 211 211 tty_port_init(&srmcons_singleton.port); 212 212 ··· 221 221 tty_port_link_device(&srmcons_singleton.port, driver, 0); 222 222 err = tty_register_driver(driver); 223 223 if (err) { 224 - put_tty_driver(driver); 224 + tty_driver_kref_put(driver); 225 225 tty_port_destroy(&srmcons_singleton.port); 226 226 return err; 227 227 }
+16 -14
arch/m68k/emu/nfcon.c
··· 120 120 121 121 static int __init nfcon_init(void) 122 122 { 123 + struct tty_driver *driver; 123 124 int res; 124 125 125 126 stderr_id = nf_get_id("NF_STDERR"); 126 127 if (!stderr_id) 127 128 return -ENODEV; 128 129 129 - nfcon_tty_driver = alloc_tty_driver(1); 130 - if (!nfcon_tty_driver) 131 - return -ENOMEM; 130 + driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW); 131 + if (IS_ERR(driver)) 132 + return PTR_ERR(driver); 132 133 133 134 tty_port_init(&nfcon_tty_port); 134 135 135 - nfcon_tty_driver->driver_name = "nfcon"; 136 - nfcon_tty_driver->name = "nfcon"; 137 - nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; 138 - nfcon_tty_driver->subtype = SYSTEM_TYPE_TTY; 139 - nfcon_tty_driver->init_termios = tty_std_termios; 140 - nfcon_tty_driver->flags = TTY_DRIVER_REAL_RAW; 136 + driver->driver_name = "nfcon"; 137 + driver->name = "nfcon"; 138 + driver->type = TTY_DRIVER_TYPE_SYSTEM; 139 + driver->subtype = SYSTEM_TYPE_TTY; 140 + driver->init_termios = tty_std_termios; 141 141 142 - tty_set_operations(nfcon_tty_driver, &nfcon_tty_ops); 143 - tty_port_link_device(&nfcon_tty_port, nfcon_tty_driver, 0); 144 - res = tty_register_driver(nfcon_tty_driver); 142 + tty_set_operations(driver, &nfcon_tty_ops); 143 + tty_port_link_device(&nfcon_tty_port, driver, 0); 144 + res = tty_register_driver(driver); 145 145 if (res) { 146 146 pr_err("failed to register nfcon tty driver\n"); 147 - put_tty_driver(nfcon_tty_driver); 147 + tty_driver_kref_put(driver); 148 148 tty_port_destroy(&nfcon_tty_port); 149 149 return res; 150 150 } 151 + 152 + nfcon_tty_driver = driver; 151 153 152 154 if (!(nf_console.flags & CON_ENABLED)) 153 155 register_console(&nf_console); ··· 161 159 { 162 160 unregister_console(&nf_console); 163 161 tty_unregister_driver(nfcon_tty_driver); 164 - put_tty_driver(nfcon_tty_driver); 162 + tty_driver_kref_put(nfcon_tty_driver); 165 163 tty_port_destroy(&nfcon_tty_port); 166 164 } 167 165
+17 -15
arch/parisc/kernel/pdc_cons.c
··· 138 138 139 139 static int __init pdc_console_tty_driver_init(void) 140 140 { 141 + struct tty_driver *driver; 141 142 int err; 142 143 143 144 /* Check if the console driver is still registered. ··· 161 160 printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); 162 161 pdc_cons.flags &= ~CON_BOOT; 163 162 164 - pdc_console_tty_driver = alloc_tty_driver(1); 165 - 166 - if (!pdc_console_tty_driver) 167 - return -ENOMEM; 163 + driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW | 164 + TTY_DRIVER_RESET_TERMIOS); 165 + if (IS_ERR(driver)) 166 + return PTR_ERR(driver); 168 167 169 168 tty_port_init(&tty_port); 170 169 171 - pdc_console_tty_driver->driver_name = "pdc_cons"; 172 - pdc_console_tty_driver->name = "ttyB"; 173 - pdc_console_tty_driver->major = MUX_MAJOR; 174 - pdc_console_tty_driver->minor_start = 0; 175 - pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM; 176 - pdc_console_tty_driver->init_termios = tty_std_termios; 177 - pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW | 178 - TTY_DRIVER_RESET_TERMIOS; 179 - tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops); 180 - tty_port_link_device(&tty_port, pdc_console_tty_driver, 0); 170 + driver->driver_name = "pdc_cons"; 171 + driver->name = "ttyB"; 172 + driver->major = MUX_MAJOR; 173 + driver->minor_start = 0; 174 + driver->type = TTY_DRIVER_TYPE_SYSTEM; 175 + driver->init_termios = tty_std_termios; 176 + tty_set_operations(driver, &pdc_console_tty_ops); 177 + tty_port_link_device(&tty_port, driver, 0); 181 178 182 - err = tty_register_driver(pdc_console_tty_driver); 179 + err = tty_register_driver(driver); 183 180 if (err) { 184 181 printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); 185 182 tty_port_destroy(&tty_port); 183 + tty_driver_kref_put(driver); 186 184 return err; 187 185 } 186 + 187 + pdc_console_tty_driver = driver; 188 188 189 189 return 0; 190 190 }
+7 -6
arch/um/drivers/line.c
··· 538 538 const struct tty_operations *ops, 539 539 struct line *lines, int nlines) 540 540 { 541 - struct tty_driver *driver = alloc_tty_driver(nlines); 541 + struct tty_driver *driver; 542 542 int err; 543 543 int i; 544 544 545 - if (!driver) 546 - return -ENOMEM; 545 + driver = tty_alloc_driver(nlines, TTY_DRIVER_REAL_RAW | 546 + TTY_DRIVER_DYNAMIC_DEV); 547 + if (IS_ERR(driver)) 548 + return PTR_ERR(driver); 547 549 548 550 driver->driver_name = line_driver->name; 549 551 driver->name = line_driver->device_name; ··· 553 551 driver->minor_start = line_driver->minor_start; 554 552 driver->type = line_driver->type; 555 553 driver->subtype = line_driver->subtype; 556 - driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 557 554 driver->init_termios = tty_std_termios; 558 - 555 + 559 556 for (i = 0; i < nlines; i++) { 560 557 tty_port_init(&lines[i].port); 561 558 lines[i].port.ops = &line_port_ops; ··· 568 567 if (err) { 569 568 printk(KERN_ERR "register_lines : can't register %s driver\n", 570 569 line_driver->name); 571 - put_tty_driver(driver); 570 + tty_driver_kref_put(driver); 572 571 for (i = 0; i < nlines; i++) 573 572 tty_port_destroy(&lines[i].port); 574 573 return err;
+29 -16
arch/xtensa/platforms/iss/console.c
··· 136 136 137 137 static int __init rs_init(void) 138 138 { 139 - tty_port_init(&serial_port); 139 + struct tty_driver *driver; 140 + int ret; 140 141 141 - serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES); 142 + driver = tty_alloc_driver(SERIAL_MAX_NUM_LINES, TTY_DRIVER_REAL_RAW); 143 + if (IS_ERR(driver)) 144 + return PTR_ERR(driver); 145 + 146 + tty_port_init(&serial_port); 142 147 143 148 /* Initialize the tty_driver structure */ 144 149 145 - serial_driver->driver_name = "iss_serial"; 146 - serial_driver->name = "ttyS"; 147 - serial_driver->major = TTY_MAJOR; 148 - serial_driver->minor_start = 64; 149 - serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 150 - serial_driver->subtype = SERIAL_TYPE_NORMAL; 151 - serial_driver->init_termios = tty_std_termios; 152 - serial_driver->init_termios.c_cflag = 150 + driver->driver_name = "iss_serial"; 151 + driver->name = "ttyS"; 152 + driver->major = TTY_MAJOR; 153 + driver->minor_start = 64; 154 + driver->type = TTY_DRIVER_TYPE_SERIAL; 155 + driver->subtype = SERIAL_TYPE_NORMAL; 156 + driver->init_termios = tty_std_termios; 157 + driver->init_termios.c_cflag = 153 158 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 154 - serial_driver->flags = TTY_DRIVER_REAL_RAW; 155 159 156 - tty_set_operations(serial_driver, &serial_ops); 157 - tty_port_link_device(&serial_port, serial_driver, 0); 160 + tty_set_operations(driver, &serial_ops); 161 + tty_port_link_device(&serial_port, driver, 0); 158 162 159 - if (tty_register_driver(serial_driver)) 160 - panic("Couldn't register serial driver\n"); 163 + ret = tty_register_driver(driver); 164 + if (ret) { 165 + pr_err("Couldn't register serial driver\n"); 166 + tty_driver_kref_put(driver); 167 + tty_port_destroy(&serial_port); 168 + 169 + return ret; 170 + } 171 + 172 + serial_driver = driver; 173 + 161 174 return 0; 162 175 } 163 176 ··· 178 165 static __exit void rs_exit(void) 179 166 { 180 167 tty_unregister_driver(serial_driver); 181 - put_tty_driver(serial_driver); 168 + tty_driver_kref_put(serial_driver); 182 169 tty_port_destroy(&serial_port); 183 170 } 184 171
+2 -2
drivers/char/ttyprintk.c
··· 198 198 return 0; 199 199 200 200 error: 201 - put_tty_driver(ttyprintk_driver); 201 + tty_driver_kref_put(ttyprintk_driver); 202 202 tty_port_destroy(&tpk_port.port); 203 203 return ret; 204 204 } ··· 206 206 static void __exit ttyprintk_exit(void) 207 207 { 208 208 tty_unregister_driver(ttyprintk_driver); 209 - put_tty_driver(ttyprintk_driver); 209 + tty_driver_kref_put(ttyprintk_driver); 210 210 tty_port_destroy(&tpk_port.port); 211 211 } 212 212
+6 -7
drivers/ipack/devices/ipoctal.c
··· 347 347 /* Register the TTY device */ 348 348 349 349 /* Each IP-OCTAL channel is a TTY port */ 350 - tty = alloc_tty_driver(NR_CHANNELS); 351 - 352 - if (!tty) 353 - return -ENOMEM; 350 + tty = tty_alloc_driver(NR_CHANNELS, TTY_DRIVER_REAL_RAW | 351 + TTY_DRIVER_DYNAMIC_DEV); 352 + if (IS_ERR(tty)) 353 + return PTR_ERR(tty); 354 354 355 355 /* Fill struct tty_driver with ipoctal data */ 356 356 tty->owner = THIS_MODULE; ··· 362 362 tty->minor_start = 0; 363 363 tty->type = TTY_DRIVER_TYPE_SERIAL; 364 364 tty->subtype = SERIAL_TYPE_NORMAL; 365 - tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 366 365 tty->init_termios = tty_std_termios; 367 366 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 368 367 tty->init_termios.c_ispeed = 9600; ··· 371 372 res = tty_register_driver(tty); 372 373 if (res) { 373 374 dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n"); 374 - put_tty_driver(tty); 375 + tty_driver_kref_put(tty); 375 376 return res; 376 377 } 377 378 ··· 696 697 } 697 698 698 699 tty_unregister_driver(ipoctal->tty_drv); 699 - put_tty_driver(ipoctal->tty_drv); 700 + tty_driver_kref_put(ipoctal->tty_drv); 700 701 kfree(ipoctal); 701 702 } 702 703
+6 -8
drivers/isdn/capi/capi.c
··· 1269 1269 if (!capiminors) 1270 1270 return -ENOMEM; 1271 1271 1272 - drv = alloc_tty_driver(capi_ttyminors); 1273 - if (!drv) { 1272 + drv = tty_alloc_driver(capi_ttyminors, TTY_DRIVER_REAL_RAW | 1273 + TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_DYNAMIC_DEV); 1274 + if (IS_ERR(drv)) { 1274 1275 kfree(capiminors); 1275 - return -ENOMEM; 1276 + return PTR_ERR(drv); 1276 1277 } 1277 1278 drv->driver_name = "capi_nc"; 1278 1279 drv->name = "capi!"; ··· 1286 1285 drv->init_termios.c_oflag = OPOST | ONLCR; 1287 1286 drv->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1288 1287 drv->init_termios.c_lflag = 0; 1289 - drv->flags = 1290 - TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS | 1291 - TTY_DRIVER_DYNAMIC_DEV; 1292 1288 tty_set_operations(drv, &capinc_ops); 1293 1289 1294 1290 err = tty_register_driver(drv); 1295 1291 if (err) { 1296 - put_tty_driver(drv); 1292 + tty_driver_kref_put(drv); 1297 1293 kfree(capiminors); 1298 1294 printk(KERN_ERR "Couldn't register capi_nc driver\n"); 1299 1295 return err; ··· 1302 1304 static void __exit capinc_tty_exit(void) 1303 1305 { 1304 1306 tty_unregister_driver(capinc_tty_driver); 1305 - put_tty_driver(capinc_tty_driver); 1307 + tty_driver_kref_put(capinc_tty_driver); 1306 1308 kfree(capiminors); 1307 1309 } 1308 1310
+4 -4
drivers/misc/bcm-vk/bcm_vk_tty.c
··· 249 249 tty_drv->name = kstrdup(name, GFP_KERNEL); 250 250 if (!tty_drv->name) { 251 251 err = -ENOMEM; 252 - goto err_put_tty_driver; 252 + goto err_tty_driver_kref_put; 253 253 } 254 254 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; 255 255 tty_drv->subtype = SERIAL_TYPE_NORMAL; ··· 295 295 kfree(tty_drv->name); 296 296 tty_drv->name = NULL; 297 297 298 - err_put_tty_driver: 299 - put_tty_driver(tty_drv); 298 + err_tty_driver_kref_put: 299 + tty_driver_kref_put(tty_drv); 300 300 301 301 return err; 302 302 } ··· 317 317 kfree(vk->tty_drv->name); 318 318 vk->tty_drv->name = NULL; 319 319 320 - put_tty_driver(vk->tty_drv); 320 + tty_driver_kref_put(vk->tty_drv); 321 321 } 322 322 323 323 void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk)
+6 -6
drivers/mmc/core/sdio_uart.c
··· 1135 1135 int ret; 1136 1136 struct tty_driver *tty_drv; 1137 1137 1138 - sdio_uart_tty_driver = tty_drv = alloc_tty_driver(UART_NR); 1139 - if (!tty_drv) 1140 - return -ENOMEM; 1138 + sdio_uart_tty_driver = tty_drv = tty_alloc_driver(UART_NR, 1139 + TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); 1140 + if (IS_ERR(tty_drv)) 1141 + return PTR_ERR(tty_drv); 1141 1142 1142 1143 tty_drv->driver_name = "sdio_uart"; 1143 1144 tty_drv->name = "ttySDIO"; ··· 1146 1145 tty_drv->minor_start = 0; 1147 1146 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; 1148 1147 tty_drv->subtype = SERIAL_TYPE_NORMAL; 1149 - tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 1150 1148 tty_drv->init_termios = tty_std_termios; 1151 1149 tty_drv->init_termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL; 1152 1150 tty_drv->init_termios.c_ispeed = 4800; ··· 1165 1165 err2: 1166 1166 tty_unregister_driver(tty_drv); 1167 1167 err1: 1168 - put_tty_driver(tty_drv); 1168 + tty_driver_kref_put(tty_drv); 1169 1169 return ret; 1170 1170 } 1171 1171 ··· 1173 1173 { 1174 1174 sdio_unregister_driver(&sdio_uart_driver); 1175 1175 tty_unregister_driver(sdio_uart_tty_driver); 1176 - put_tty_driver(sdio_uart_tty_driver); 1176 + tty_driver_kref_put(sdio_uart_tty_driver); 1177 1177 } 1178 1178 1179 1179 module_init(sdio_uart_init);
+6 -6
drivers/net/usb/hso.c
··· 3241 3241 serial_table[i] = NULL; 3242 3242 3243 3243 /* allocate our driver using the proper amount of supported minors */ 3244 - tty_drv = alloc_tty_driver(HSO_SERIAL_TTY_MINORS); 3245 - if (!tty_drv) 3246 - return -ENOMEM; 3244 + tty_drv = tty_alloc_driver(HSO_SERIAL_TTY_MINORS, TTY_DRIVER_REAL_RAW | 3245 + TTY_DRIVER_DYNAMIC_DEV); 3246 + if (IS_ERR(tty_drv)) 3247 + return PTR_ERR(tty_drv); 3247 3248 3248 3249 /* fill in all needed values */ 3249 3250 tty_drv->driver_name = driver_name; ··· 3257 3256 tty_drv->minor_start = 0; 3258 3257 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; 3259 3258 tty_drv->subtype = SERIAL_TYPE_NORMAL; 3260 - tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 3261 3259 tty_drv->init_termios = tty_std_termios; 3262 3260 hso_init_termios(&tty_drv->init_termios); 3263 3261 tty_set_operations(tty_drv, &hso_serial_ops); ··· 3281 3281 err_unreg_tty: 3282 3282 tty_unregister_driver(tty_drv); 3283 3283 err_free_tty: 3284 - put_tty_driver(tty_drv); 3284 + tty_driver_kref_put(tty_drv); 3285 3285 return result; 3286 3286 } 3287 3287 ··· 3292 3292 tty_unregister_driver(tty_drv); 3293 3293 /* deregister the usb driver */ 3294 3294 usb_deregister(&hso_driver); 3295 - put_tty_driver(tty_drv); 3295 + tty_driver_kref_put(tty_drv); 3296 3296 } 3297 3297 3298 3298 /* Module definitions */
+1 -8
drivers/platform/surface/aggregator/core.c
··· 301 301 void *ctx) 302 302 { 303 303 struct serdev_device *serdev = ctx; 304 - struct acpi_resource_common_serialbus *serial; 305 304 struct acpi_resource_uart_serialbus *uart; 306 305 bool flow_control; 307 306 int status = 0; 308 307 309 - if (rsc->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) 308 + if (!serdev_acpi_get_uart_resource(rsc, &uart)) 310 309 return AE_OK; 311 - 312 - serial = &rsc->data.common_serial_bus; 313 - if (serial->type != ACPI_RESOURCE_SERIAL_TYPE_UART) 314 - return AE_OK; 315 - 316 - uart = &rsc->data.uart_serial_bus; 317 310 318 311 /* Set up serdev device. */ 319 312 serdev_device_set_baudrate(serdev, uart->default_baud_rate);
+5 -6
drivers/s390/char/con3215.c
··· 1076 1076 if (!CONSOLE_IS_3215) 1077 1077 return 0; 1078 1078 1079 - driver = alloc_tty_driver(NR_3215); 1080 - if (!driver) 1081 - return -ENOMEM; 1079 + driver = tty_alloc_driver(NR_3215, TTY_DRIVER_REAL_RAW); 1080 + if (IS_ERR(driver)) 1081 + return PTR_ERR(driver); 1082 1082 1083 1083 ret = ccw_driver_register(&raw3215_ccw_driver); 1084 1084 if (ret) { 1085 - put_tty_driver(driver); 1085 + tty_driver_kref_put(driver); 1086 1086 return ret; 1087 1087 } 1088 1088 /* ··· 1101 1101 driver->init_termios.c_iflag = IGNBRK | IGNPAR; 1102 1102 driver->init_termios.c_oflag = ONLCR; 1103 1103 driver->init_termios.c_lflag = ISIG; 1104 - driver->flags = TTY_DRIVER_REAL_RAW; 1105 1104 tty_set_operations(driver, &tty3215_ops); 1106 1105 ret = tty_register_driver(driver); 1107 1106 if (ret) { 1108 - put_tty_driver(driver); 1107 + tty_driver_kref_put(driver); 1109 1108 return ret; 1110 1109 } 1111 1110 tty3215_driver = driver;
+7 -8
drivers/s390/char/sclp_tty.c
··· 503 503 return 0; 504 504 if (!sclp.has_linemode) 505 505 return 0; 506 - driver = alloc_tty_driver(1); 507 - if (!driver) 508 - return -ENOMEM; 506 + driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW); 507 + if (IS_ERR(driver)) 508 + return PTR_ERR(driver); 509 509 510 510 rc = sclp_rw_init(); 511 511 if (rc) { 512 - put_tty_driver(driver); 512 + tty_driver_kref_put(driver); 513 513 return rc; 514 514 } 515 515 /* Allocate pages for output buffering */ 516 516 for (i = 0; i < MAX_KMEM_PAGES; i++) { 517 517 page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 518 518 if (page == NULL) { 519 - put_tty_driver(driver); 519 + tty_driver_kref_put(driver); 520 520 return -ENOMEM; 521 521 } 522 522 list_add_tail((struct list_head *) page, &sclp_tty_pages); ··· 532 532 533 533 rc = sclp_register(&sclp_input_event); 534 534 if (rc) { 535 - put_tty_driver(driver); 535 + tty_driver_kref_put(driver); 536 536 return rc; 537 537 } 538 538 ··· 548 548 driver->init_termios.c_iflag = IGNBRK | IGNPAR; 549 549 driver->init_termios.c_oflag = ONLCR; 550 550 driver->init_termios.c_lflag = ISIG | ECHO; 551 - driver->flags = TTY_DRIVER_REAL_RAW; 552 551 tty_set_operations(driver, &sclp_ops); 553 552 tty_port_link_device(&sclp_port, driver, 0); 554 553 rc = tty_register_driver(driver); 555 554 if (rc) { 556 - put_tty_driver(driver); 555 + tty_driver_kref_put(driver); 557 556 tty_port_destroy(&sclp_port); 558 557 return rc; 559 558 }
+4 -5
drivers/s390/char/sclp_vt220.c
··· 732 732 733 733 /* Note: we're not testing for CONSOLE_IS_SCLP here to preserve 734 734 * symmetry between VM and LPAR systems regarding ttyS1. */ 735 - driver = alloc_tty_driver(1); 736 - if (!driver) 737 - return -ENOMEM; 735 + driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW); 736 + if (IS_ERR(driver)) 737 + return PTR_ERR(driver); 738 738 rc = __sclp_vt220_init(MAX_KMEM_PAGES); 739 739 if (rc) 740 740 goto out_driver; ··· 746 746 driver->type = TTY_DRIVER_TYPE_SYSTEM; 747 747 driver->subtype = SYSTEM_TYPE_TTY; 748 748 driver->init_termios = tty_std_termios; 749 - driver->flags = TTY_DRIVER_REAL_RAW; 750 749 tty_set_operations(driver, &sclp_vt220_ops); 751 750 tty_port_link_device(&sclp_vt220_port, driver, 0); 752 751 ··· 763 764 out_init: 764 765 __sclp_vt220_cleanup(); 765 766 out_driver: 766 - put_tty_driver(driver); 767 + tty_driver_kref_put(driver); 767 768 return rc; 768 769 } 769 770 __initcall(sclp_vt220_tty_init);
+2 -2
drivers/s390/char/tty3270.c
··· 1935 1935 tty_set_operations(driver, &tty3270_ops); 1936 1936 ret = tty_register_driver(driver); 1937 1937 if (ret) { 1938 - put_tty_driver(driver); 1938 + tty_driver_kref_put(driver); 1939 1939 return ret; 1940 1940 } 1941 1941 tty3270_driver = driver; ··· 1952 1952 driver = tty3270_driver; 1953 1953 tty3270_driver = NULL; 1954 1954 tty_unregister_driver(driver); 1955 - put_tty_driver(driver); 1955 + tty_driver_kref_put(driver); 1956 1956 tty3270_del_views(); 1957 1957 } 1958 1958
+4 -4
drivers/staging/fwserial/fwserial.c
··· 2852 2852 tty_unregister_driver(fwloop_driver); 2853 2853 put_loop: 2854 2854 if (create_loop_dev) 2855 - put_tty_driver(fwloop_driver); 2855 + tty_driver_kref_put(fwloop_driver); 2856 2856 unregister_driver: 2857 2857 tty_unregister_driver(fwtty_driver); 2858 2858 put_tty: 2859 - put_tty_driver(fwtty_driver); 2859 + tty_driver_kref_put(fwtty_driver); 2860 2860 remove_debugfs: 2861 2861 debugfs_remove_recursive(fwserial_debugfs); 2862 2862 ··· 2871 2871 kmem_cache_destroy(fwtty_txn_cache); 2872 2872 if (create_loop_dev) { 2873 2873 tty_unregister_driver(fwloop_driver); 2874 - put_tty_driver(fwloop_driver); 2874 + tty_driver_kref_put(fwloop_driver); 2875 2875 } 2876 2876 tty_unregister_driver(fwtty_driver); 2877 - put_tty_driver(fwtty_driver); 2877 + tty_driver_kref_put(fwtty_driver); 2878 2878 debugfs_remove_recursive(fwserial_debugfs); 2879 2879 } 2880 2880
+6 -7
drivers/staging/gdm724x/gdm_tty.c
··· 281 281 int ret; 282 282 283 283 for (i = 0; i < TTY_MAX_COUNT; i++) { 284 - tty_driver = alloc_tty_driver(GDM_TTY_MINOR); 285 - if (!tty_driver) 286 - return -ENOMEM; 284 + tty_driver = tty_alloc_driver(GDM_TTY_MINOR, 285 + TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); 286 + if (IS_ERR(tty_driver)) 287 + return PTR_ERR(tty_driver); 287 288 288 289 tty_driver->owner = THIS_MODULE; 289 290 tty_driver->driver_name = DRIVER_STRING[i]; ··· 292 291 tty_driver->major = GDM_TTY_MAJOR; 293 292 tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 294 293 tty_driver->subtype = SERIAL_TYPE_NORMAL; 295 - tty_driver->flags = TTY_DRIVER_REAL_RAW | 296 - TTY_DRIVER_DYNAMIC_DEV; 297 294 tty_driver->init_termios = tty_std_termios; 298 295 tty_driver->init_termios.c_cflag = B9600 | CS8 | HUPCL | CLOCAL; 299 296 tty_driver->init_termios.c_lflag = ISIG | ICANON | IEXTEN; ··· 299 300 300 301 ret = tty_register_driver(tty_driver); 301 302 if (ret) { 302 - put_tty_driver(tty_driver); 303 + tty_driver_kref_put(tty_driver); 303 304 return ret; 304 305 } 305 306 ··· 318 319 tty_driver = gdm_driver[i]; 319 320 if (tty_driver) { 320 321 tty_unregister_driver(tty_driver); 321 - put_tty_driver(tty_driver); 322 + tty_driver_kref_put(tty_driver); 322 323 } 323 324 } 324 325 }
+2 -2
drivers/staging/greybus/uart.c
··· 973 973 return 0; 974 974 975 975 fail_put_gb_tty: 976 - put_tty_driver(gb_tty_driver); 976 + tty_driver_kref_put(gb_tty_driver); 977 977 fail_unregister_dev: 978 978 return retval; 979 979 } ··· 981 981 static void gb_tty_exit(void) 982 982 { 983 983 tty_unregister_driver(gb_tty_driver); 984 - put_tty_driver(gb_tty_driver); 984 + tty_driver_kref_put(gb_tty_driver); 985 985 idr_destroy(&tty_minors); 986 986 } 987 987
+109 -171
drivers/tty/amiserial.c
··· 22 22 * 23 23 */ 24 24 25 - #include <linux/delay.h> 26 - 27 25 /* Set of debugging defines */ 28 26 29 27 #undef SERIAL_DEBUG_INTR ··· 29 31 #undef SERIAL_DEBUG_FLOW 30 32 #undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 31 33 32 - /* Sanity checks */ 33 - 34 - #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) 35 - #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 36 - tty->name, (info->tport.flags), serial_driver->refcount,info->count,tty->count,s) 37 - #else 38 - #define DBG_CNT(s) 39 - #endif 40 - 41 34 /* 42 35 * End of serial driver configuration section. 43 36 */ 44 37 45 - #include <linux/module.h> 46 - 47 - #include <linux/types.h> 48 - #include <linux/serial.h> 49 - #include <linux/serial_reg.h> 50 - static char *serial_version = "4.30"; 51 - 52 - #include <linux/errno.h> 53 - #include <linux/signal.h> 54 - #include <linux/sched.h> 55 - #include <linux/kernel.h> 56 - #include <linux/timer.h> 57 - #include <linux/interrupt.h> 58 - #include <linux/tty.h> 59 - #include <linux/tty_flip.h> 38 + #include <linux/bitops.h> 60 39 #include <linux/circ_buf.h> 61 40 #include <linux/console.h> 62 - #include <linux/major.h> 63 - #include <linux/string.h> 41 + #include <linux/delay.h> 42 + #include <linux/errno.h> 64 43 #include <linux/fcntl.h> 65 - #include <linux/ptrace.h> 66 - #include <linux/ioport.h> 67 - #include <linux/mm.h> 68 - #include <linux/seq_file.h> 69 - #include <linux/slab.h> 70 44 #include <linux/init.h> 71 - #include <linux/bitops.h> 45 + #include <linux/interrupt.h> 46 + #include <linux/ioport.h> 47 + #include <linux/kernel.h> 48 + #include <linux/major.h> 49 + #include <linux/mm.h> 50 + #include <linux/module.h> 72 51 #include <linux/platform_device.h> 73 - 74 - #include <asm/setup.h> 75 - 76 - 77 - #include <asm/irq.h> 52 + #include <linux/ptrace.h> 53 + #include <linux/seq_file.h> 54 + #include <linux/serial.h> 55 + #include <linux/serial_reg.h> 56 + #include <linux/sched.h> 57 + #include <linux/signal.h> 58 + #include <linux/slab.h> 59 + #include <linux/string.h> 60 + #include <linux/timer.h> 61 + #include <linux/tty_flip.h> 62 + #include <linux/tty.h> 63 + #include <linux/types.h> 64 + #include <linux/uaccess.h> 78 65 79 66 #include <asm/amigahw.h> 80 67 #include <asm/amigaints.h> 68 + #include <asm/irq.h> 69 + #include <asm/setup.h> 81 70 82 71 struct serial_state { 83 72 struct tty_port tport; ··· 73 88 74 89 unsigned long port; 75 90 int baud_base; 76 - int xmit_fifo_size; 77 91 int custom_divisor; 78 92 int read_status_mask; 79 93 int ignore_status_mask; ··· 83 99 int x_char; /* xon/xoff character */ 84 100 }; 85 101 86 - #define custom amiga_custom 87 - static char *serial_name = "Amiga-builtin serial driver"; 88 - 89 102 static struct tty_driver *serial_driver; 90 103 91 104 /* number of characters left in xmit buffer before we ask for more */ 92 105 #define WAKEUP_CHARS 256 106 + 107 + #define XMIT_FIFO_SIZE 1 93 108 94 109 static unsigned char current_ctl_bits; 95 110 ··· 97 114 static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 98 115 99 116 100 - static struct serial_state rs_table[1]; 101 - 102 - #define NR_PORTS ARRAY_SIZE(rs_table) 103 - 104 - #include <linux/uaccess.h> 105 - 106 - #define serial_isroot() (capable(CAP_SYS_ADMIN)) 117 + static struct serial_state serial_state; 107 118 108 119 /* some serial hardware definitions */ 109 120 #define SDR_OVRUN (1<<15) ··· 138 161 if (info->IER & UART_IER_THRI) { 139 162 info->IER &= ~UART_IER_THRI; 140 163 /* disable Tx interrupt and remove any pending interrupts */ 141 - custom.intena = IF_TBE; 164 + amiga_custom.intena = IF_TBE; 142 165 mb(); 143 - custom.intreq = IF_TBE; 166 + amiga_custom.intreq = IF_TBE; 144 167 mb(); 145 168 } 146 169 local_irq_restore(flags); ··· 156 179 && info->xmit.buf 157 180 && !(info->IER & UART_IER_THRI)) { 158 181 info->IER |= UART_IER_THRI; 159 - custom.intena = IF_SETCLR | IF_TBE; 182 + amiga_custom.intena = IF_SETCLR | IF_TBE; 160 183 mb(); 161 184 /* set a pending Tx Interrupt, transmitter should restart now */ 162 - custom.intreq = IF_SETCLR | IF_TBE; 185 + amiga_custom.intreq = IF_SETCLR | IF_TBE; 163 186 mb(); 164 187 } 165 188 local_irq_restore(flags); ··· 168 191 /* 169 192 * ---------------------------------------------------------------------- 170 193 * 171 - * Here starts the interrupt handling routines. All of the following 172 - * subroutines are declared as inline and are folded into 173 - * rs_interrupt(). They were separated out for readability's sake. 194 + * Here start the interrupt handling routines. 174 195 * 175 - * Note: rs_interrupt() is a "fast" interrupt, which means that it 176 - * runs with interrupts turned off. People who may want to modify 177 - * rs_interrupt() should try to keep the interrupt handler as fast as 178 - * possible. After you are done making modifications, it is not a bad 179 - * idea to do: 180 - * 181 - * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c 182 - * 183 - * and look at the resulting assemble code in serial.s. 184 - * 185 - * - Ted Ts'o (tytso@mit.edu), 7-Mar-93 186 196 * ----------------------------------------------------------------------- 187 197 */ 188 198 ··· 184 220 icount = &info->icount; 185 221 186 222 status = UART_LSR_DR; /* We obviously have a character! */ 187 - serdatr = custom.serdatr; 223 + serdatr = amiga_custom.serdatr; 188 224 mb(); 189 - custom.intreq = IF_RBF; 225 + amiga_custom.intreq = IF_RBF; 190 226 mb(); 191 227 192 228 if((serdatr & 0x1ff) == 0) ··· 263 299 264 300 static void transmit_chars(struct serial_state *info) 265 301 { 266 - custom.intreq = IF_TBE; 302 + amiga_custom.intreq = IF_TBE; 267 303 mb(); 268 304 if (info->x_char) { 269 - custom.serdat = info->x_char | 0x100; 305 + amiga_custom.serdat = info->x_char | 0x100; 270 306 mb(); 271 307 info->icount.tx++; 272 308 info->x_char = 0; ··· 276 312 || info->tport.tty->flow.stopped 277 313 || info->tport.tty->hw_stopped) { 278 314 info->IER &= ~UART_IER_THRI; 279 - custom.intena = IF_TBE; 315 + amiga_custom.intena = IF_TBE; 280 316 mb(); 281 317 return; 282 318 } 283 319 284 - custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100; 320 + amiga_custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100; 285 321 mb(); 286 322 info->xmit.tail = info->xmit.tail & (SERIAL_XMIT_SIZE-1); 287 323 info->icount.tx++; ··· 295 331 printk("THRE..."); 296 332 #endif 297 333 if (info->xmit.head == info->xmit.tail) { 298 - custom.intena = IF_TBE; 334 + amiga_custom.intena = IF_TBE; 299 335 mb(); 300 336 info->IER &= ~UART_IER_THRI; 301 337 } ··· 348 384 #endif 349 385 port->tty->hw_stopped = 0; 350 386 info->IER |= UART_IER_THRI; 351 - custom.intena = IF_SETCLR | IF_TBE; 387 + amiga_custom.intena = IF_SETCLR | IF_TBE; 352 388 mb(); 353 389 /* set a pending Tx Interrupt, transmitter should restart now */ 354 - custom.intreq = IF_SETCLR | IF_TBE; 390 + amiga_custom.intreq = IF_SETCLR | IF_TBE; 355 391 mb(); 356 392 tty_wakeup(port->tty); 357 393 return; ··· 364 400 port->tty->hw_stopped = 1; 365 401 info->IER &= ~UART_IER_THRI; 366 402 /* disable Tx interrupt and remove any pending interrupts */ 367 - custom.intena = IF_TBE; 403 + amiga_custom.intena = IF_TBE; 368 404 mb(); 369 - custom.intreq = IF_TBE; 405 + amiga_custom.intreq = IF_TBE; 370 406 mb(); 371 407 } 372 408 } ··· 408 444 { 409 445 struct serial_state *info = dev_id; 410 446 411 - if (custom.serdatr & SDR_TBE) { 447 + if (amiga_custom.serdatr & SDR_TBE) { 412 448 #ifdef SERIAL_DEBUG_INTR 413 449 printk("ser_tx_int..."); 414 450 #endif ··· 468 504 469 505 /* Clear anything in the input buffer */ 470 506 471 - custom.intreq = IF_RBF; 507 + amiga_custom.intreq = IF_RBF; 472 508 mb(); 473 509 474 510 retval = request_irq(IRQ_AMIGA_VERTB, ser_vbl_int, 0, "serial status", info); 475 511 if (retval) { 476 - if (serial_isroot()) { 477 - set_bit(TTY_IO_ERROR, &tty->flags); 478 - retval = 0; 479 - } 480 - goto errout; 512 + if (capable(CAP_SYS_ADMIN)) { 513 + set_bit(TTY_IO_ERROR, &tty->flags); 514 + retval = 0; 515 + } 516 + goto errout; 481 517 } 482 518 483 519 /* enable both Rx and Tx interrupts */ 484 - custom.intena = IF_SETCLR | IF_RBF | IF_TBE; 520 + amiga_custom.intena = IF_SETCLR | IF_RBF | IF_TBE; 485 521 mb(); 486 522 info->IER = UART_IER_MSI; 487 523 ··· 517 553 static void shutdown(struct tty_struct *tty, struct serial_state *info) 518 554 { 519 555 unsigned long flags; 520 - struct serial_state *state; 521 556 522 557 if (!tty_port_initialized(&info->tport)) 523 558 return; 524 - 525 - state = info; 526 559 527 560 #ifdef SERIAL_DEBUG_OPEN 528 561 printk("Shutting down serial port %d ....\n", info->line); ··· 544 583 } 545 584 546 585 info->IER = 0; 547 - custom.intena = IF_RBF | IF_TBE; 586 + amiga_custom.intena = IF_RBF | IF_TBE; 548 587 mb(); 549 588 550 589 /* disable break condition */ 551 - custom.adkcon = AC_UARTBRK; 590 + amiga_custom.adkcon = AC_UARTBRK; 552 591 mb(); 553 592 554 593 if (C_HUPCL(tty)) ··· 632 671 if (!quot) 633 672 quot = baud_base / 9600; 634 673 info->quot = quot; 635 - info->timeout = ((info->xmit_fifo_size*HZ*bits*quot) / baud_base); 674 + info->timeout = (XMIT_FIFO_SIZE*HZ*bits*quot) / baud_base; 636 675 info->timeout += HZ/50; /* Add .02 seconds of slop */ 637 676 638 677 /* CTS flow control flag and modem status interrupts */ ··· 692 731 if(cval & UART_LCR_PARITY) 693 732 serper |= (SERPER_PARENB); 694 733 695 - custom.serper = serper; 734 + amiga_custom.serper = serper; 696 735 mb(); 697 736 } 698 737 ··· 736 775 737 776 local_irq_save(flags); 738 777 info->IER |= UART_IER_THRI; 739 - custom.intena = IF_SETCLR | IF_TBE; 778 + amiga_custom.intena = IF_SETCLR | IF_TBE; 740 779 mb(); 741 780 /* set a pending Tx Interrupt, transmitter should restart now */ 742 - custom.intreq = IF_SETCLR | IF_TBE; 781 + amiga_custom.intreq = IF_SETCLR | IF_TBE; 743 782 mb(); 744 783 local_irq_restore(flags); 745 784 } ··· 778 817 && !(info->IER & UART_IER_THRI)) { 779 818 info->IER |= UART_IER_THRI; 780 819 local_irq_disable(); 781 - custom.intena = IF_SETCLR | IF_TBE; 820 + amiga_custom.intena = IF_SETCLR | IF_TBE; 782 821 mb(); 783 822 /* set a pending Tx Interrupt, transmitter should restart now */ 784 - custom.intreq = IF_SETCLR | IF_TBE; 823 + amiga_custom.intreq = IF_SETCLR | IF_TBE; 785 824 mb(); 786 825 local_irq_restore(flags); 787 826 } ··· 828 867 829 868 /* Check this ! */ 830 869 local_irq_save(flags); 831 - if(!(custom.intenar & IF_TBE)) { 832 - custom.intena = IF_SETCLR | IF_TBE; 870 + if(!(amiga_custom.intenar & IF_TBE)) { 871 + amiga_custom.intena = IF_SETCLR | IF_TBE; 833 872 mb(); 834 873 /* set a pending Tx Interrupt, transmitter should restart now */ 835 - custom.intreq = IF_SETCLR | IF_TBE; 874 + amiga_custom.intreq = IF_SETCLR | IF_TBE; 836 875 mb(); 837 876 } 838 877 local_irq_restore(flags); ··· 909 948 ss->line = tty->index; 910 949 ss->port = state->port; 911 950 ss->flags = state->tport.flags; 912 - ss->xmit_fifo_size = state->xmit_fifo_size; 951 + ss->xmit_fifo_size = XMIT_FIFO_SIZE; 913 952 ss->baud_base = state->baud_base; 914 953 ss->close_delay = close_delay; 915 954 ss->closing_wait = closing_wait; ··· 930 969 change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) || 931 970 ss->custom_divisor != state->custom_divisor; 932 971 if (ss->irq || ss->port != state->port || 933 - ss->xmit_fifo_size != state->xmit_fifo_size) { 972 + ss->xmit_fifo_size != XMIT_FIFO_SIZE) { 934 973 tty_unlock(tty); 935 974 return -EINVAL; 936 975 } ··· 940 979 if (closing_wait != ASYNC_CLOSING_WAIT_NONE) 941 980 closing_wait = msecs_to_jiffies(closing_wait * 10); 942 981 943 - if (!serial_isroot()) { 982 + if (!capable(CAP_SYS_ADMIN)) { 944 983 if ((ss->baud_base != state->baud_base) || 945 984 (close_delay != port->close_delay) || 946 985 (closing_wait != port->closing_wait) || 947 - (ss->xmit_fifo_size != state->xmit_fifo_size) || 948 986 ((ss->flags & ~ASYNC_USR_MASK) != 949 987 (port->flags & ~ASYNC_USR_MASK))) { 950 988 tty_unlock(tty); ··· 1003 1043 unsigned long flags; 1004 1044 1005 1045 local_irq_save(flags); 1006 - status = custom.serdatr; 1046 + status = amiga_custom.serdatr; 1007 1047 mb(); 1008 1048 local_irq_restore(flags); 1009 1049 result = ((status & SDR_TSRE) ? TIOCSER_TEMT : 0); ··· 1065 1105 1066 1106 local_irq_save(flags); 1067 1107 if (break_state == -1) 1068 - custom.adkcon = AC_SETCLR | AC_UARTBRK; 1108 + amiga_custom.adkcon = AC_SETCLR | AC_UARTBRK; 1069 1109 else 1070 - custom.adkcon = AC_UARTBRK; 1110 + amiga_custom.adkcon = AC_UARTBRK; 1071 1111 mb(); 1072 1112 local_irq_restore(flags); 1073 1113 return 0; ··· 1244 1284 state->read_status_mask &= ~UART_LSR_DR; 1245 1285 if (tty_port_initialized(port)) { 1246 1286 /* disable receive interrupts */ 1247 - custom.intena = IF_RBF; 1287 + amiga_custom.intena = IF_RBF; 1248 1288 mb(); 1249 1289 /* clear any pending receive interrupt */ 1250 - custom.intreq = IF_RBF; 1290 + amiga_custom.intreq = IF_RBF; 1251 1291 mb(); 1252 1292 1253 1293 /* ··· 1275 1315 unsigned long orig_jiffies, char_time; 1276 1316 int lsr; 1277 1317 1278 - if (info->xmit_fifo_size == 0) 1279 - return; /* Just in case.... */ 1280 - 1281 1318 orig_jiffies = jiffies; 1282 1319 1283 1320 /* ··· 1285 1328 * Note: we have to use pretty tight timings here to satisfy 1286 1329 * the NIST-PCTS. 1287 1330 */ 1288 - char_time = (info->timeout - HZ/50) / info->xmit_fifo_size; 1331 + char_time = (info->timeout - HZ/50) / XMIT_FIFO_SIZE; 1289 1332 char_time = char_time / 5; 1290 1333 if (char_time == 0) 1291 1334 char_time = 1; ··· 1306 1349 printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time); 1307 1350 printk("jiff=%lu...", jiffies); 1308 1351 #endif 1309 - while(!((lsr = custom.serdatr) & SDR_TSRE)) { 1352 + while(!((lsr = amiga_custom.serdatr) & SDR_TSRE)) { 1310 1353 #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1311 1354 printk("serdatr = %d (jiff=%lu)...", lsr, jiffies); 1312 1355 #endif ··· 1346 1389 */ 1347 1390 static int rs_open(struct tty_struct *tty, struct file * filp) 1348 1391 { 1349 - struct serial_state *info = rs_table + tty->index; 1350 - struct tty_port *port = &info->tport; 1392 + struct tty_port *port = tty->port; 1393 + struct serial_state *info = container_of(port, struct serial_state, 1394 + tport); 1351 1395 int retval; 1352 1396 1353 1397 port->count++; 1354 1398 port->tty = tty; 1355 1399 tty->driver_data = info; 1356 - tty->port = port; 1357 1400 1358 1401 retval = startup(tty, info); 1359 1402 if (retval) { ··· 1418 1461 1419 1462 static int rs_proc_show(struct seq_file *m, void *v) 1420 1463 { 1421 - seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version); 1422 - line_info(m, 0, &rs_table[0]); 1464 + seq_printf(m, "serinfo:1.0 driver:4.30\n"); 1465 + line_info(m, 0, &serial_state); 1423 1466 return 0; 1424 1467 } 1425 1468 ··· 1430 1473 * rs_init() is called at boot-time to initialize the serial driver. 1431 1474 * --------------------------------------------------------------------- 1432 1475 */ 1433 - 1434 - /* 1435 - * This routine prints out the appropriate serial driver version 1436 - * number, and identifies which options were configured into this 1437 - * driver. 1438 - */ 1439 - static void show_serial_version(void) 1440 - { 1441 - printk(KERN_INFO "%s version %s\n", serial_name, serial_version); 1442 - } 1443 - 1444 1476 1445 1477 static const struct tty_operations serial_ops = { 1446 1478 .open = rs_open, ··· 1489 1543 */ 1490 1544 static int __init amiga_serial_probe(struct platform_device *pdev) 1491 1545 { 1546 + struct serial_state *state = &serial_state; 1547 + struct tty_driver *driver; 1492 1548 unsigned long flags; 1493 - struct serial_state * state; 1494 1549 int error; 1495 1550 1496 - serial_driver = alloc_tty_driver(NR_PORTS); 1497 - if (!serial_driver) 1498 - return -ENOMEM; 1499 - 1500 - show_serial_version(); 1551 + driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW); 1552 + if (IS_ERR(driver)) 1553 + return PTR_ERR(driver); 1501 1554 1502 1555 /* Initialize the tty_driver structure */ 1503 1556 1504 - serial_driver->driver_name = "amiserial"; 1505 - serial_driver->name = "ttyS"; 1506 - serial_driver->major = TTY_MAJOR; 1507 - serial_driver->minor_start = 64; 1508 - serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 1509 - serial_driver->subtype = SERIAL_TYPE_NORMAL; 1510 - serial_driver->init_termios = tty_std_termios; 1511 - serial_driver->init_termios.c_cflag = 1557 + driver->driver_name = "amiserial"; 1558 + driver->name = "ttyS"; 1559 + driver->major = TTY_MAJOR; 1560 + driver->minor_start = 64; 1561 + driver->type = TTY_DRIVER_TYPE_SERIAL; 1562 + driver->subtype = SERIAL_TYPE_NORMAL; 1563 + driver->init_termios = tty_std_termios; 1564 + driver->init_termios.c_cflag = 1512 1565 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1513 - serial_driver->flags = TTY_DRIVER_REAL_RAW; 1514 - tty_set_operations(serial_driver, &serial_ops); 1566 + tty_set_operations(driver, &serial_ops); 1515 1567 1516 - state = rs_table; 1517 - state->port = (int)&custom.serdatr; /* Just to give it a value */ 1518 - state->custom_divisor = 0; 1519 - state->icount.cts = state->icount.dsr = 1520 - state->icount.rng = state->icount.dcd = 0; 1521 - state->icount.rx = state->icount.tx = 0; 1522 - state->icount.frame = state->icount.parity = 0; 1523 - state->icount.overrun = state->icount.brk = 0; 1568 + memset(state, 0, sizeof(*state)); 1569 + state->port = (int)&amiga_custom.serdatr; /* Just to give it a value */ 1524 1570 tty_port_init(&state->tport); 1525 1571 state->tport.ops = &amiga_port_ops; 1526 - tty_port_link_device(&state->tport, serial_driver, 0); 1572 + tty_port_link_device(&state->tport, driver, 0); 1527 1573 1528 - error = tty_register_driver(serial_driver); 1574 + error = tty_register_driver(driver); 1529 1575 if (error) 1530 - goto fail_put_tty_driver; 1576 + goto fail_tty_driver_kref_put; 1531 1577 1532 1578 printk(KERN_INFO "ttyS0 is the amiga builtin serial port\n"); 1533 1579 1534 1580 /* Hardware set up */ 1535 1581 1536 1582 state->baud_base = amiga_colorclock; 1537 - state->xmit_fifo_size = 1; 1538 1583 1539 1584 /* set ISRs, and then disable the rx interrupts */ 1540 1585 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); ··· 1540 1603 local_irq_save(flags); 1541 1604 1542 1605 /* turn off Rx and Tx interrupts */ 1543 - custom.intena = IF_RBF | IF_TBE; 1606 + amiga_custom.intena = IF_RBF | IF_TBE; 1544 1607 mb(); 1545 1608 1546 1609 /* clear any pending interrupt */ 1547 - custom.intreq = IF_RBF | IF_TBE; 1610 + amiga_custom.intreq = IF_RBF | IF_TBE; 1548 1611 mb(); 1549 1612 1550 1613 local_irq_restore(flags); ··· 1558 1621 1559 1622 platform_set_drvdata(pdev, state); 1560 1623 1624 + serial_driver = driver; 1625 + 1561 1626 return 0; 1562 1627 1563 1628 fail_free_irq: 1564 1629 free_irq(IRQ_AMIGA_TBE, state); 1565 1630 fail_unregister: 1566 - tty_unregister_driver(serial_driver); 1567 - fail_put_tty_driver: 1631 + tty_unregister_driver(driver); 1632 + fail_tty_driver_kref_put: 1568 1633 tty_port_destroy(&state->tport); 1569 - put_tty_driver(serial_driver); 1634 + tty_driver_kref_put(driver); 1570 1635 return error; 1571 1636 } 1572 1637 ··· 1576 1637 { 1577 1638 struct serial_state *state = platform_get_drvdata(pdev); 1578 1639 1579 - /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ 1580 1640 tty_unregister_driver(serial_driver); 1581 - put_tty_driver(serial_driver); 1641 + tty_driver_kref_put(serial_driver); 1582 1642 tty_port_destroy(&state->tport); 1583 1643 1584 1644 free_irq(IRQ_AMIGA_TBE, state); ··· 1606 1668 1607 1669 static void amiga_serial_putc(char c) 1608 1670 { 1609 - custom.serdat = (unsigned char)c | 0x100; 1610 - while (!(custom.serdatr & 0x2000)) 1671 + amiga_custom.serdat = (unsigned char)c | 0x100; 1672 + while (!(amiga_custom.serdatr & 0x2000)) 1611 1673 barrier(); 1612 1674 } 1613 1675 ··· 1620 1682 static void serial_console_write(struct console *co, const char *s, 1621 1683 unsigned count) 1622 1684 { 1623 - unsigned short intena = custom.intenar; 1685 + unsigned short intena = amiga_custom.intenar; 1624 1686 1625 - custom.intena = IF_TBE; 1687 + amiga_custom.intena = IF_TBE; 1626 1688 1627 1689 while (count--) { 1628 1690 if (*s == '\n') ··· 1630 1692 amiga_serial_putc(*s++); 1631 1693 } 1632 1694 1633 - custom.intena = IF_SETCLR | (intena & IF_TBE); 1695 + amiga_custom.intena = IF_SETCLR | (intena & IF_TBE); 1634 1696 } 1635 1697 1636 1698 static struct tty_driver *serial_console_device(struct console *c, int *index)
+19 -15
drivers/tty/ehv_bytechan.c
··· 751 751 */ 752 752 static int __init ehv_bc_init(void) 753 753 { 754 + struct tty_driver *driver; 754 755 struct device_node *np; 755 756 unsigned int count = 0; /* Number of elements in bcs[] */ 756 757 int ret; ··· 774 773 if (!bcs) 775 774 return -ENOMEM; 776 775 777 - ehv_bc_driver = alloc_tty_driver(count); 778 - if (!ehv_bc_driver) { 779 - ret = -ENOMEM; 776 + driver = tty_alloc_driver(count, TTY_DRIVER_REAL_RAW | 777 + TTY_DRIVER_DYNAMIC_DEV); 778 + if (IS_ERR(driver)) { 779 + ret = PTR_ERR(driver); 780 780 goto err_free_bcs; 781 781 } 782 782 783 - ehv_bc_driver->driver_name = "ehv-bc"; 784 - ehv_bc_driver->name = ehv_bc_console.name; 785 - ehv_bc_driver->type = TTY_DRIVER_TYPE_CONSOLE; 786 - ehv_bc_driver->subtype = SYSTEM_TYPE_CONSOLE; 787 - ehv_bc_driver->init_termios = tty_std_termios; 788 - ehv_bc_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 789 - tty_set_operations(ehv_bc_driver, &ehv_bc_ops); 783 + driver->driver_name = "ehv-bc"; 784 + driver->name = ehv_bc_console.name; 785 + driver->type = TTY_DRIVER_TYPE_CONSOLE; 786 + driver->subtype = SYSTEM_TYPE_CONSOLE; 787 + driver->init_termios = tty_std_termios; 788 + tty_set_operations(driver, &ehv_bc_ops); 790 789 791 - ret = tty_register_driver(ehv_bc_driver); 790 + ret = tty_register_driver(driver); 792 791 if (ret) { 793 792 pr_err("ehv-bc: could not register tty driver (ret=%i)\n", ret); 794 - goto err_put_tty_driver; 793 + goto err_tty_driver_kref_put; 795 794 } 795 + 796 + ehv_bc_driver = driver; 796 797 797 798 ret = platform_driver_register(&ehv_bc_tty_driver); 798 799 if (ret) { ··· 806 803 return 0; 807 804 808 805 err_deregister_tty_driver: 809 - tty_unregister_driver(ehv_bc_driver); 810 - err_put_tty_driver: 811 - put_tty_driver(ehv_bc_driver); 806 + ehv_bc_driver = NULL; 807 + tty_unregister_driver(driver); 808 + err_tty_driver_kref_put: 809 + tty_driver_kref_put(driver); 812 810 err_free_bcs: 813 811 kfree(bcs); 814 812
+9 -9
drivers/tty/goldfish.c
··· 253 253 ret = -ENOMEM; 254 254 goto err_alloc_goldfish_ttys_failed; 255 255 } 256 - tty = alloc_tty_driver(goldfish_tty_line_count); 257 - if (tty == NULL) { 258 - ret = -ENOMEM; 259 - goto err_alloc_tty_driver_failed; 256 + tty = tty_alloc_driver(goldfish_tty_line_count, 257 + TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 258 + TTY_DRIVER_DYNAMIC_DEV); 259 + if (IS_ERR(tty)) { 260 + ret = PTR_ERR(tty); 261 + goto err_tty_alloc_driver_failed; 260 262 } 261 263 tty->driver_name = "goldfish"; 262 264 tty->name = "ttyGF"; 263 265 tty->type = TTY_DRIVER_TYPE_SERIAL; 264 266 tty->subtype = SERIAL_TYPE_NORMAL; 265 267 tty->init_termios = tty_std_termios; 266 - tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 267 - TTY_DRIVER_DYNAMIC_DEV; 268 268 tty_set_operations(tty, &goldfish_tty_ops); 269 269 ret = tty_register_driver(tty); 270 270 if (ret) ··· 274 274 return 0; 275 275 276 276 err_tty_register_driver_failed: 277 - put_tty_driver(tty); 278 - err_alloc_tty_driver_failed: 277 + tty_driver_kref_put(tty); 278 + err_tty_alloc_driver_failed: 279 279 kfree(goldfish_ttys); 280 280 goldfish_ttys = NULL; 281 281 err_alloc_goldfish_ttys_failed: ··· 285 285 static void goldfish_tty_delete_driver(void) 286 286 { 287 287 tty_unregister_driver(goldfish_tty_driver); 288 - put_tty_driver(goldfish_tty_driver); 288 + tty_driver_kref_put(goldfish_tty_driver); 289 289 goldfish_tty_driver = NULL; 290 290 kfree(goldfish_ttys); 291 291 goldfish_ttys = NULL;
+5 -5
drivers/tty/hvc/hvc_console.c
··· 1021 1021 int err; 1022 1022 1023 1023 /* We need more than hvc_count adapters due to hotplug additions. */ 1024 - drv = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS); 1025 - if (!drv) { 1026 - err = -ENOMEM; 1024 + drv = tty_alloc_driver(HVC_ALLOC_TTY_ADAPTERS, TTY_DRIVER_REAL_RAW | 1025 + TTY_DRIVER_RESET_TERMIOS); 1026 + if (IS_ERR(drv)) { 1027 + err = PTR_ERR(drv); 1027 1028 goto out; 1028 1029 } 1029 1030 ··· 1034 1033 drv->minor_start = HVC_MINOR; 1035 1034 drv->type = TTY_DRIVER_TYPE_SYSTEM; 1036 1035 drv->init_termios = tty_std_termios; 1037 - drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; 1038 1036 tty_set_operations(drv, &hvc_ops); 1039 1037 1040 1038 /* Always start the kthread because there can be hotplug vty adapters ··· 1063 1063 kthread_stop(hvc_task); 1064 1064 hvc_task = NULL; 1065 1065 put_tty: 1066 - put_tty_driver(drv); 1066 + tty_driver_kref_put(drv); 1067 1067 out: 1068 1068 return err; 1069 1069 }
+14 -3
drivers/tty/hvc/hvc_xen.c
··· 86 86 cons = intf->out_cons; 87 87 prod = intf->out_prod; 88 88 mb(); /* update queue values before going on */ 89 - BUG_ON((prod - cons) > sizeof(intf->out)); 89 + 90 + if ((prod - cons) > sizeof(intf->out)) { 91 + pr_err_once("xencons: Illegal ring page indices"); 92 + return -EINVAL; 93 + } 90 94 91 95 while ((sent < len) && ((prod - cons) < sizeof(intf->out))) 92 96 intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++]; ··· 118 114 */ 119 115 while (len) { 120 116 int sent = __write_console(cons, data, len); 121 - 117 + 118 + if (sent < 0) 119 + return sent; 120 + 122 121 data += sent; 123 122 len -= sent; 124 123 ··· 145 138 cons = intf->in_cons; 146 139 prod = intf->in_prod; 147 140 mb(); /* get pointers before reading ring */ 148 - BUG_ON((prod - cons) > sizeof(intf->in)); 141 + 142 + if ((prod - cons) > sizeof(intf->in)) { 143 + pr_err_once("xencons: Illegal ring page indices"); 144 + return -EINVAL; 145 + } 149 146 150 147 while (cons != prod && recv < len) 151 148 buf[recv++] = intf->in[MASK_XENCONS_IDX(cons++, intf->in)];
+6 -6
drivers/tty/hvc/hvcs.c
··· 1445 1445 } else 1446 1446 num_ttys_to_alloc = hvcs_parm_num_devs; 1447 1447 1448 - hvcs_tty_driver = alloc_tty_driver(num_ttys_to_alloc); 1449 - if (!hvcs_tty_driver) { 1448 + hvcs_tty_driver = tty_alloc_driver(num_ttys_to_alloc, 1449 + TTY_DRIVER_REAL_RAW); 1450 + if (IS_ERR(hvcs_tty_driver)) { 1450 1451 mutex_unlock(&hvcs_init_mutex); 1451 - return -ENOMEM; 1452 + return PTR_ERR(hvcs_tty_driver); 1452 1453 } 1453 1454 1454 1455 if (hvcs_alloc_index_list(num_ttys_to_alloc)) { ··· 1474 1473 * throw us into a horrible recursive echo-echo-echo loop. 1475 1474 */ 1476 1475 hvcs_tty_driver->init_termios = hvcs_tty_termios; 1477 - hvcs_tty_driver->flags = TTY_DRIVER_REAL_RAW; 1478 1476 1479 1477 tty_set_operations(hvcs_tty_driver, &hvcs_ops); 1480 1478 ··· 1509 1509 register_fail: 1510 1510 hvcs_free_index_list(); 1511 1511 index_fail: 1512 - put_tty_driver(hvcs_tty_driver); 1512 + tty_driver_kref_put(hvcs_tty_driver); 1513 1513 hvcs_tty_driver = NULL; 1514 1514 mutex_unlock(&hvcs_init_mutex); 1515 1515 return rc; ··· 1562 1562 1563 1563 hvcs_free_index_list(); 1564 1564 1565 - put_tty_driver(hvcs_tty_driver); 1565 + tty_driver_kref_put(hvcs_tty_driver); 1566 1566 1567 1567 printk(KERN_INFO "HVCS: driver module removed.\n"); 1568 1568 }
+33 -18
drivers/tty/hvc/hvsi.c
··· 1038 1038 1039 1039 static int __init hvsi_init(void) 1040 1040 { 1041 - int i; 1041 + struct tty_driver *driver; 1042 + int i, ret; 1042 1043 1043 - hvsi_driver = alloc_tty_driver(hvsi_count); 1044 - if (!hvsi_driver) 1045 - return -ENOMEM; 1044 + driver = tty_alloc_driver(hvsi_count, TTY_DRIVER_REAL_RAW); 1045 + if (IS_ERR(driver)) 1046 + return PTR_ERR(driver); 1046 1047 1047 - hvsi_driver->driver_name = "hvsi"; 1048 - hvsi_driver->name = "hvsi"; 1049 - hvsi_driver->major = HVSI_MAJOR; 1050 - hvsi_driver->minor_start = HVSI_MINOR; 1051 - hvsi_driver->type = TTY_DRIVER_TYPE_SYSTEM; 1052 - hvsi_driver->init_termios = tty_std_termios; 1053 - hvsi_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL; 1054 - hvsi_driver->init_termios.c_ispeed = 9600; 1055 - hvsi_driver->init_termios.c_ospeed = 9600; 1056 - hvsi_driver->flags = TTY_DRIVER_REAL_RAW; 1057 - tty_set_operations(hvsi_driver, &hvsi_ops); 1048 + driver->driver_name = "hvsi"; 1049 + driver->name = "hvsi"; 1050 + driver->major = HVSI_MAJOR; 1051 + driver->minor_start = HVSI_MINOR; 1052 + driver->type = TTY_DRIVER_TYPE_SYSTEM; 1053 + driver->init_termios = tty_std_termios; 1054 + driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL; 1055 + driver->init_termios.c_ispeed = 9600; 1056 + driver->init_termios.c_ospeed = 9600; 1057 + tty_set_operations(driver, &hvsi_ops); 1058 1058 1059 1059 for (i=0; i < hvsi_count; i++) { 1060 1060 struct hvsi_struct *hp = &hvsi_ports[i]; 1061 1061 int ret = 1; 1062 1062 1063 - tty_port_link_device(&hp->port, hvsi_driver, i); 1063 + tty_port_link_device(&hp->port, driver, i); 1064 1064 1065 1065 ret = request_irq(hp->virq, hvsi_interrupt, 0, "hvsi", hp); 1066 1066 if (ret) ··· 1069 1069 } 1070 1070 hvsi_wait = wait_for_state; /* irqs active now */ 1071 1071 1072 - if (tty_register_driver(hvsi_driver)) 1073 - panic("Couldn't register hvsi console driver\n"); 1072 + ret = tty_register_driver(driver); 1073 + if (ret) { 1074 + pr_err("Couldn't register hvsi console driver\n"); 1075 + goto err_free_irq; 1076 + } 1077 + 1078 + hvsi_driver = driver; 1074 1079 1075 1080 printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count); 1076 1081 1077 1082 return 0; 1083 + err_free_irq: 1084 + hvsi_wait = poll_for_state; 1085 + for (i = 0; i < hvsi_count; i++) { 1086 + struct hvsi_struct *hp = &hvsi_ports[i]; 1087 + 1088 + free_irq(hp->virq, hp); 1089 + } 1090 + tty_driver_kref_put(driver); 1091 + 1092 + return ret; 1078 1093 } 1079 1094 device_initcall(hvsi_init); 1080 1095
+6 -6
drivers/tty/ipwireless/tty.c
··· 564 564 { 565 565 int result; 566 566 567 - ipw_tty_driver = alloc_tty_driver(IPWIRELESS_PCMCIA_MINORS); 568 - if (!ipw_tty_driver) 569 - return -ENOMEM; 567 + ipw_tty_driver = tty_alloc_driver(IPWIRELESS_PCMCIA_MINORS, 568 + TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); 569 + if (IS_ERR(ipw_tty_driver)) 570 + return PTR_ERR(ipw_tty_driver); 570 571 571 572 ipw_tty_driver->driver_name = IPWIRELESS_PCCARD_NAME; 572 573 ipw_tty_driver->name = "ttyIPWp"; ··· 575 574 ipw_tty_driver->minor_start = IPWIRELESS_PCMCIA_START; 576 575 ipw_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 577 576 ipw_tty_driver->subtype = SERIAL_TYPE_NORMAL; 578 - ipw_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 579 577 ipw_tty_driver->init_termios = tty_std_termios; 580 578 ipw_tty_driver->init_termios.c_cflag = 581 579 B9600 | CS8 | CREAD | HUPCL | CLOCAL; ··· 585 585 if (result) { 586 586 printk(KERN_ERR IPWIRELESS_PCCARD_NAME 587 587 ": failed to register tty driver\n"); 588 - put_tty_driver(ipw_tty_driver); 588 + tty_driver_kref_put(ipw_tty_driver); 589 589 return result; 590 590 } 591 591 ··· 595 595 void ipwireless_tty_release(void) 596 596 { 597 597 tty_unregister_driver(ipw_tty_driver); 598 - put_tty_driver(ipw_tty_driver); 598 + tty_driver_kref_put(ipw_tty_driver); 599 599 } 600 600 601 601 int ipwireless_tty_is_modem(struct ipw_tty *tty)
+1 -1
drivers/tty/mips_ejtag_fdc.c
··· 1042 1042 dport = &priv->ports[nport]; 1043 1043 tty_port_destroy(&dport->port); 1044 1044 } 1045 - put_tty_driver(priv->driver); 1045 + tty_driver_kref_put(priv->driver); 1046 1046 return ret; 1047 1047 } 1048 1048
+6 -6
drivers/tty/moxa.c
··· 1053 1053 1054 1054 if (tty_register_driver(moxaDriver)) { 1055 1055 printk(KERN_ERR "can't register MOXA Smartio tty driver!\n"); 1056 - put_tty_driver(moxaDriver); 1056 + tty_driver_kref_put(moxaDriver); 1057 1057 return -1; 1058 1058 } 1059 1059 ··· 1119 1119 del_timer_sync(&moxaTimer); 1120 1120 1121 1121 tty_unregister_driver(moxaDriver); 1122 - put_tty_driver(moxaDriver); 1122 + tty_driver_kref_put(moxaDriver); 1123 1123 } 1124 1124 1125 1125 module_init(moxa_init); ··· 2034 2034 if (!info) 2035 2035 return -ENODEV; 2036 2036 mutex_lock(&info->port.mutex); 2037 - ss->type = info->type, 2038 - ss->line = info->port.tty->index, 2039 - ss->flags = info->port.flags, 2040 - ss->baud_base = 921600, 2037 + ss->type = info->type; 2038 + ss->line = info->port.tty->index; 2039 + ss->flags = info->port.flags; 2040 + ss->baud_base = 921600; 2041 2041 ss->close_delay = jiffies_to_msecs(info->port.close_delay) / 10; 2042 2042 mutex_unlock(&info->port.mutex); 2043 2043 return 0;
+12 -12
drivers/tty/mxser.c
··· 1039 1039 if (closing_wait != ASYNC_CLOSING_WAIT_NONE) 1040 1040 closing_wait = jiffies_to_msecs(closing_wait) / 10; 1041 1041 1042 - ss->type = info->type, 1043 - ss->line = tty->index, 1044 - ss->port = info->ioaddr, 1045 - ss->irq = info->board->irq, 1046 - ss->flags = info->port.flags, 1047 - ss->baud_base = MXSER_BAUD_BASE, 1042 + ss->type = info->type; 1043 + ss->line = tty->index; 1044 + ss->port = info->ioaddr; 1045 + ss->irq = info->board->irq; 1046 + ss->flags = info->port.flags; 1047 + ss->baud_base = MXSER_BAUD_BASE; 1048 1048 ss->close_delay = close_delay; 1049 1049 ss->closing_wait = closing_wait; 1050 1050 ss->custom_divisor = MXSER_CUSTOM_DIVISOR, ··· 1976 1976 { 1977 1977 int retval; 1978 1978 1979 - mxvar_sdriver = alloc_tty_driver(MXSER_PORTS); 1980 - if (!mxvar_sdriver) 1981 - return -ENOMEM; 1979 + mxvar_sdriver = tty_alloc_driver(MXSER_PORTS, TTY_DRIVER_REAL_RAW | 1980 + TTY_DRIVER_DYNAMIC_DEV); 1981 + if (IS_ERR(mxvar_sdriver)) 1982 + return PTR_ERR(mxvar_sdriver); 1982 1983 1983 1984 /* Initialize the tty_driver structure */ 1984 1985 mxvar_sdriver->name = "ttyMI"; ··· 1989 1988 mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL; 1990 1989 mxvar_sdriver->init_termios = tty_std_termios; 1991 1990 mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL; 1992 - mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW|TTY_DRIVER_DYNAMIC_DEV; 1993 1991 tty_set_operations(mxvar_sdriver, &mxser_ops); 1994 1992 1995 1993 retval = tty_register_driver(mxvar_sdriver); ··· 2008 2008 err_unr: 2009 2009 tty_unregister_driver(mxvar_sdriver); 2010 2010 err_put: 2011 - put_tty_driver(mxvar_sdriver); 2011 + tty_driver_kref_put(mxvar_sdriver); 2012 2012 return retval; 2013 2013 } 2014 2014 ··· 2016 2016 { 2017 2017 pci_unregister_driver(&mxser_driver); 2018 2018 tty_unregister_driver(mxvar_sdriver); 2019 - put_tty_driver(mxvar_sdriver); 2019 + tty_driver_kref_put(mxvar_sdriver); 2020 2020 } 2021 2021 2022 2022 module_init(mxser_module_init);
+6 -7
drivers/tty/n_gsm.c
··· 3252 3252 return status; 3253 3253 } 3254 3254 3255 - gsm_tty_driver = alloc_tty_driver(256); 3256 - if (!gsm_tty_driver) { 3255 + gsm_tty_driver = tty_alloc_driver(256, TTY_DRIVER_REAL_RAW | 3256 + TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); 3257 + if (IS_ERR(gsm_tty_driver)) { 3257 3258 pr_err("gsm_init: tty allocation failed.\n"); 3258 - status = -ENOMEM; 3259 + status = PTR_ERR(gsm_tty_driver); 3259 3260 goto err_unreg_ldisc; 3260 3261 } 3261 3262 gsm_tty_driver->driver_name = "gsmtty"; ··· 3265 3264 gsm_tty_driver->minor_start = 0; 3266 3265 gsm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 3267 3266 gsm_tty_driver->subtype = SERIAL_TYPE_NORMAL; 3268 - gsm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV 3269 - | TTY_DRIVER_HARDWARE_BREAK; 3270 3267 gsm_tty_driver->init_termios = tty_std_termios; 3271 3268 /* Fixme */ 3272 3269 gsm_tty_driver->init_termios.c_lflag &= ~ECHO; ··· 3279 3280 gsm_tty_driver->major, gsm_tty_driver->minor_start); 3280 3281 return 0; 3281 3282 err_put_driver: 3282 - put_tty_driver(gsm_tty_driver); 3283 + tty_driver_kref_put(gsm_tty_driver); 3283 3284 err_unreg_ldisc: 3284 3285 tty_unregister_ldisc(&tty_ldisc_packet); 3285 3286 return status; ··· 3289 3290 { 3290 3291 tty_unregister_ldisc(&tty_ldisc_packet); 3291 3292 tty_unregister_driver(gsm_tty_driver); 3292 - put_tty_driver(gsm_tty_driver); 3293 + tty_driver_kref_put(gsm_tty_driver); 3293 3294 } 3294 3295 3295 3296 module_init(gsm_init);
+6 -6
drivers/tty/nozomi.c
··· 1824 1824 { 1825 1825 int ret; 1826 1826 1827 - ntty_driver = alloc_tty_driver(NTTY_TTY_MAXMINORS); 1828 - if (!ntty_driver) 1829 - return -ENOMEM; 1827 + ntty_driver = tty_alloc_driver(NTTY_TTY_MAXMINORS, TTY_DRIVER_REAL_RAW | 1828 + TTY_DRIVER_DYNAMIC_DEV); 1829 + if (IS_ERR(ntty_driver)) 1830 + return PTR_ERR(ntty_driver); 1830 1831 1831 1832 ntty_driver->driver_name = NOZOMI_NAME_TTY; 1832 1833 ntty_driver->name = "noz"; 1833 1834 ntty_driver->major = 0; 1834 1835 ntty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1835 1836 ntty_driver->subtype = SERIAL_TYPE_NORMAL; 1836 - ntty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 1837 1837 ntty_driver->init_termios = tty_std_termios; 1838 1838 ntty_driver->init_termios.c_cflag = B115200 | CS8 | CREAD | \ 1839 1839 HUPCL | CLOCAL; ··· 1857 1857 unr_tty: 1858 1858 tty_unregister_driver(ntty_driver); 1859 1859 free_tty: 1860 - put_tty_driver(ntty_driver); 1860 + tty_driver_kref_put(ntty_driver); 1861 1861 return ret; 1862 1862 } 1863 1863 ··· 1865 1865 { 1866 1866 pci_unregister_driver(&nozomi_driver); 1867 1867 tty_unregister_driver(ntty_driver); 1868 - put_tty_driver(ntty_driver); 1868 + tty_driver_kref_put(ntty_driver); 1869 1869 } 1870 1870 1871 1871 module_init(nozomi_init);
+29 -7
drivers/tty/serdev/core.c
··· 562 562 int index; 563 563 }; 564 564 565 + /** 566 + * serdev_acpi_get_uart_resource - Gets UARTSerialBus resource if type matches 567 + * @ares: ACPI resource 568 + * @uart: Pointer to UARTSerialBus resource will be returned here 569 + * 570 + * Checks if the given ACPI resource is of type UARTSerialBus. 571 + * In this case, returns a pointer to it to the caller. 572 + * 573 + * Return: True if resource type is of UARTSerialBus, otherwise false. 574 + */ 575 + bool serdev_acpi_get_uart_resource(struct acpi_resource *ares, 576 + struct acpi_resource_uart_serialbus **uart) 577 + { 578 + struct acpi_resource_uart_serialbus *sb; 579 + 580 + if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) 581 + return false; 582 + 583 + sb = &ares->data.uart_serial_bus; 584 + if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_UART) 585 + return false; 586 + 587 + *uart = sb; 588 + return true; 589 + } 590 + EXPORT_SYMBOL_GPL(serdev_acpi_get_uart_resource); 591 + 565 592 static int acpi_serdev_parse_resource(struct acpi_resource *ares, void *data) 566 593 { 567 594 struct acpi_serdev_lookup *lookup = data; 568 595 struct acpi_resource_uart_serialbus *sb; 569 596 acpi_status status; 570 597 571 - if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) 572 - return 1; 573 - 574 - if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART) 598 + if (!serdev_acpi_get_uart_resource(ares, &sb)) 575 599 return 1; 576 600 577 601 if (lookup->index != -1 && lookup->n++ != lookup->index) 578 602 return 1; 579 - 580 - sb = &ares->data.uart_serial_bus; 581 603 582 604 status = acpi_get_handle(lookup->device_handle, 583 605 sb->resource_source.string_ptr, ··· 608 586 return 1; 609 587 610 588 /* 611 - * NOTE: Ideally, we would also want to retreive other properties here, 589 + * NOTE: Ideally, we would also want to retrieve other properties here, 612 590 * once setting them before opening the device is supported by serdev. 613 591 */ 614 592
+1 -1
drivers/tty/serial/8250/8250_bcm7271.c
··· 941 941 struct clk *baud_mux_clk; 942 942 struct uart_8250_port up; 943 943 struct resource *irq; 944 - void __iomem *membase = 0; 944 + void __iomem *membase = NULL; 945 945 resource_size_t mapbase = 0; 946 946 u32 clk_rate = 0; 947 947 int ret;
+23 -13
drivers/tty/serial/8250/8250_exar.c
··· 114 114 struct exar8250_platform { 115 115 int (*rs485_config)(struct uart_port *, struct serial_rs485 *); 116 116 int (*register_gpio)(struct pci_dev *, struct uart_8250_port *); 117 + void (*unregister_gpio)(struct uart_8250_port *); 117 118 }; 118 119 119 120 /** ··· 353 352 writeb(0x00, p + UART_EXAR_MPIOOD_15_8); 354 353 } 355 354 356 - static void * 357 - __xr17v35x_register_gpio(struct pci_dev *pcidev, 358 - const struct software_node *node) 355 + static struct platform_device *__xr17v35x_register_gpio(struct pci_dev *pcidev, 356 + const struct software_node *node) 359 357 { 360 358 struct platform_device *pdev; 361 359 ··· 374 374 return pdev; 375 375 } 376 376 377 + static void __xr17v35x_unregister_gpio(struct platform_device *pdev) 378 + { 379 + device_remove_software_node(&pdev->dev); 380 + platform_device_unregister(pdev); 381 + } 382 + 377 383 static const struct property_entry exar_gpio_properties[] = { 378 384 PROPERTY_ENTRY_U32("exar,first-pin", 0), 379 385 PROPERTY_ENTRY_U32("ngpios", 16), ··· 390 384 .properties = exar_gpio_properties, 391 385 }; 392 386 393 - static int xr17v35x_register_gpio(struct pci_dev *pcidev, 394 - struct uart_8250_port *port) 387 + static int xr17v35x_register_gpio(struct pci_dev *pcidev, struct uart_8250_port *port) 395 388 { 396 389 if (pcidev->vendor == PCI_VENDOR_ID_EXAR) 397 390 port->port.private_data = 398 391 __xr17v35x_register_gpio(pcidev, &exar_gpio_node); 399 392 400 393 return 0; 394 + } 395 + 396 + static void xr17v35x_unregister_gpio(struct uart_8250_port *port) 397 + { 398 + if (!port->port.private_data) 399 + return; 400 + 401 + __xr17v35x_unregister_gpio(port->port.private_data); 402 + port->port.private_data = NULL; 401 403 } 402 404 403 405 static int generic_rs485_config(struct uart_port *port, ··· 433 419 434 420 static const struct exar8250_platform exar8250_default_platform = { 435 421 .register_gpio = xr17v35x_register_gpio, 422 + .unregister_gpio = xr17v35x_unregister_gpio, 436 423 .rs485_config = generic_rs485_config, 437 424 }; 438 425 ··· 499 484 static const struct exar8250_platform iot2040_platform = { 500 485 .rs485_config = iot2040_rs485_config, 501 486 .register_gpio = iot2040_register_gpio, 487 + .unregister_gpio = xr17v35x_unregister_gpio, 502 488 }; 503 489 504 490 /* ··· 571 555 572 556 static void pci_xr17v35x_exit(struct pci_dev *pcidev) 573 557 { 558 + const struct exar8250_platform *platform = exar_get_platform(); 574 559 struct exar8250 *priv = pci_get_drvdata(pcidev); 575 560 struct uart_8250_port *port = serial8250_get_port(priv->line[0]); 576 - struct platform_device *pdev; 577 561 578 - pdev = port->port.private_data; 579 - if (!pdev) 580 - return; 581 - 582 - device_remove_software_node(&pdev->dev); 583 - platform_device_unregister(pdev); 584 - port->port.private_data = NULL; 562 + platform->unregister_gpio(port); 585 563 } 586 564 587 565 static inline void exar_misc_clear(struct exar8250 *priv)
+2 -4
drivers/tty/serial/8250/8250_ingenic.c
··· 209 209 struct uart_8250_port uart = {}; 210 210 struct ingenic_uart_data *data; 211 211 const struct ingenic_uart_config *cdata; 212 - const struct of_device_id *match; 213 212 struct resource *regs; 214 213 int irq, err, line; 215 214 216 - match = of_match_device(of_match, &pdev->dev); 217 - if (!match) { 215 + cdata = of_device_get_match_data(&pdev->dev); 216 + if (!cdata) { 218 217 dev_err(&pdev->dev, "Error: No device match found\n"); 219 218 return -ENODEV; 220 219 } 221 - cdata = match->data; 222 220 223 221 irq = platform_get_irq(pdev, 0); 224 222 if (irq < 0)
+10
drivers/tty/serial/8250/8250_lpss.c
··· 158 158 159 159 static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port) 160 160 { 161 + struct uart_8250_dma *dma = &lpss->data.dma; 162 + struct uart_8250_port *up = up_to_u8250p(port); 163 + 164 + /* 165 + * This simply makes the checks in the 8250_port to try the DMA 166 + * channel request which in turn uses the magic of ACPI tables 167 + * parsing (see drivers/dma/acpi-dma.c for the details) and 168 + * matching with the registered General Purpose DMA controllers. 169 + */ 170 + up->dma = dma; 161 171 return 0; 162 172 } 163 173
+25 -2
drivers/tty/serial/8250/8250_omap.c
··· 538 538 static void omap_serial_fill_features_erratas(struct uart_8250_port *up, 539 539 struct omap8250_priv *priv) 540 540 { 541 - const struct soc_device_attribute k3_soc_devices[] = { 541 + static const struct soc_device_attribute k3_soc_devices[] = { 542 542 { .family = "AM65X", }, 543 543 { .family = "J721E", .revision = "SR1.0" }, 544 544 { /* sentinel */ } ··· 617 617 struct uart_port *port = dev_id; 618 618 struct omap8250_priv *priv = port->private_data; 619 619 struct uart_8250_port *up = up_to_u8250p(port); 620 - unsigned int iir; 620 + unsigned int iir, lsr; 621 621 int ret; 622 622 623 623 #ifdef CONFIG_SERIAL_8250_DMA ··· 628 628 #endif 629 629 630 630 serial8250_rpm_get(up); 631 + lsr = serial_port_in(port, UART_LSR); 631 632 iir = serial_port_in(port, UART_IIR); 632 633 ret = serial8250_handle_irq(port, iir); 633 634 ··· 641 640 (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT && 642 641 serial_port_in(port, UART_OMAP_RX_LVL) == 0) { 643 642 serial_port_in(port, UART_RX); 643 + } 644 + 645 + /* Stop processing interrupts on input overrun */ 646 + if ((lsr & UART_LSR_OE) && up->overrun_backoff_time_ms > 0) { 647 + unsigned long delay; 648 + 649 + up->ier = port->serial_in(port, UART_IER); 650 + if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { 651 + port->ops->stop_rx(port); 652 + } else { 653 + /* Keep restarting the timer until 654 + * the input overrun subsides. 655 + */ 656 + cancel_delayed_work(&up->overrun_backoff); 657 + } 658 + 659 + delay = msecs_to_jiffies(up->overrun_backoff_time_ms); 660 + schedule_delayed_work(&up->overrun_backoff, delay); 644 661 } 645 662 646 663 serial8250_rpm_put(up); ··· 1371 1352 up.port.uartclk = clk_get_rate(clk); 1372 1353 } 1373 1354 } 1355 + 1356 + if (of_property_read_u32(np, "overrun-throttle-ms", 1357 + &up.overrun_backoff_time_ms) != 0) 1358 + up.overrun_backoff_time_ms = 0; 1374 1359 1375 1360 priv->wakeirq = irq_of_parse_and_map(np, 1); 1376 1361
+1 -1
drivers/tty/serial/8250/8250_pci.c
··· 87 87 88 88 static int 89 89 setup_port(struct serial_private *priv, struct uart_8250_port *port, 90 - int bar, int offset, int regshift) 90 + u8 bar, unsigned int offset, int regshift) 91 91 { 92 92 struct pci_dev *dev = priv->dev; 93 93
+2
drivers/tty/serial/8250/8250_pnp.c
··· 13 13 #include <linux/pnp.h> 14 14 #include <linux/string.h> 15 15 #include <linux/kernel.h> 16 + #include <linux/property.h> 16 17 #include <linux/serial_core.h> 17 18 #include <linux/bitops.h> 18 19 ··· 476 475 if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE) 477 476 uart.port.flags |= UPF_SHARE_IRQ; 478 477 uart.port.uartclk = 1843200; 478 + device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk); 479 479 uart.port.dev = &dev->dev; 480 480 481 481 line = serial8250_register_8250_port(&uart);
+2 -1
drivers/tty/serial/8250/8250_port.c
··· 122 122 .name = "16C950/954", 123 123 .fifo_size = 128, 124 124 .tx_loadsz = 128, 125 - .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 125 + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01, 126 + .rxtrig_bytes = {16, 32, 112, 120}, 126 127 /* UART_CAP_EFR breaks billionon CF bluetooth card. */ 127 128 .flags = UART_CAP_FIFO | UART_CAP_SLEEP, 128 129 },
+6 -4
drivers/tty/serial/8250/Kconfig
··· 363 363 config SERIAL_8250_FSL 364 364 bool 365 365 depends on SERIAL_8250_CONSOLE 366 - default PPC || ARM || ARM64 366 + default PPC || ARM || ARM64 || COMPILE_TEST 367 367 368 368 config SERIAL_8250_DW 369 369 tristate "Support for Synopsys DesignWare 8250 quirks" ··· 375 375 376 376 config SERIAL_8250_EM 377 377 tristate "Support for Emma Mobile integrated serial port" 378 - depends on SERIAL_8250 && ARM && HAVE_CLK 378 + depends on SERIAL_8250 && HAVE_CLK 379 + depends on ARM || COMPILE_TEST 379 380 help 380 381 Selecting this option will add support for the integrated serial 381 382 port hardware found on the Emma Mobile line of processors. ··· 384 383 385 384 config SERIAL_8250_IOC3 386 385 tristate "SGI IOC3 8250 UART support" 387 - depends on SGI_MFD_IOC3 && SERIAL_8250 386 + depends on SERIAL_8250 387 + depends on SGI_MFD_IOC3 || COMPILE_TEST 388 388 select SERIAL_8250_EXTENDED 389 389 select SERIAL_8250_SHARE_IRQ 390 390 help ··· 497 495 config SERIAL_8250_PXA 498 496 tristate "PXA serial port support" 499 497 depends on SERIAL_8250 500 - depends on ARCH_PXA || ARCH_MMP 498 + depends on ARCH_PXA || ARCH_MMP || COMPILE_TEST 501 499 help 502 500 If you have a machine based on an Intel XScale PXA2xx CPU you can 503 501 enable its onboard serial ports by enabling this option. The option is
+2 -2
drivers/tty/serial/Kconfig
··· 959 959 960 960 config SERIAL_OMAP 961 961 tristate "OMAP serial port support" 962 - depends on ARCH_OMAP2PLUS || COMPILE_TEST 962 + depends on (ARCH_OMAP2PLUS && !SERIAL_8250_OMAP) || COMPILE_TEST 963 963 select SERIAL_CORE 964 964 help 965 965 If you have a machine based on an Texas Instruments OMAP CPU you ··· 1382 1382 select SERIAL_CORE 1383 1383 depends on ARM || COMPILE_TEST 1384 1384 help 1385 - This driver is for the on-chip Asychronous Serial Controller on 1385 + This driver is for the on-chip Asynchronous Serial Controller on 1386 1386 STMicroelectronics STi SoCs. 1387 1387 ASC is embedded in ST COMMS IP block. It supports Rx & Tx functionality. 1388 1388 It support all industry standard baud rates.
+161 -2
drivers/tty/serial/amba-pl011.c
··· 265 265 unsigned int old_cr; /* state during shutdown */ 266 266 unsigned int fixed_baud; /* vendor-set fixed baud rate */ 267 267 char type[12]; 268 + bool rs485_tx_started; 269 + unsigned int rs485_tx_drain_interval; /* usecs */ 268 270 #ifdef CONFIG_DMA_ENGINE 269 271 /* DMA stuff */ 270 272 bool using_tx_dma; ··· 276 274 bool dma_probed; 277 275 #endif 278 276 }; 277 + 278 + static unsigned int pl011_tx_empty(struct uart_port *port); 279 279 280 280 static unsigned int pl011_reg_to_offset(const struct uart_amba_port *uap, 281 281 unsigned int reg) ··· 1286 1282 #define pl011_dma_flush_buffer NULL 1287 1283 #endif 1288 1284 1285 + static void pl011_rs485_tx_stop(struct uart_amba_port *uap) 1286 + { 1287 + struct uart_port *port = &uap->port; 1288 + int i = 0; 1289 + u32 cr; 1290 + 1291 + /* Wait until hardware tx queue is empty */ 1292 + while (!pl011_tx_empty(port)) { 1293 + if (i == port->fifosize) { 1294 + dev_warn(port->dev, 1295 + "timeout while draining hardware tx queue\n"); 1296 + break; 1297 + } 1298 + 1299 + udelay(uap->rs485_tx_drain_interval); 1300 + i++; 1301 + } 1302 + 1303 + if (port->rs485.delay_rts_after_send) 1304 + mdelay(port->rs485.delay_rts_after_send); 1305 + 1306 + cr = pl011_read(uap, REG_CR); 1307 + 1308 + if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) 1309 + cr &= ~UART011_CR_RTS; 1310 + else 1311 + cr |= UART011_CR_RTS; 1312 + 1313 + /* Disable the transmitter and reenable the transceiver */ 1314 + cr &= ~UART011_CR_TXE; 1315 + cr |= UART011_CR_RXE; 1316 + pl011_write(cr, uap, REG_CR); 1317 + 1318 + uap->rs485_tx_started = false; 1319 + } 1320 + 1289 1321 static void pl011_stop_tx(struct uart_port *port) 1290 1322 { 1291 1323 struct uart_amba_port *uap = ··· 1330 1290 uap->im &= ~UART011_TXIM; 1331 1291 pl011_write(uap->im, uap, REG_IMSC); 1332 1292 pl011_dma_tx_stop(uap); 1293 + 1294 + if ((port->rs485.flags & SER_RS485_ENABLED) && uap->rs485_tx_started) 1295 + pl011_rs485_tx_stop(uap); 1333 1296 } 1334 1297 1335 1298 static bool pl011_tx_chars(struct uart_amba_port *uap, bool from_irq); ··· 1423 1380 return true; 1424 1381 } 1425 1382 1383 + static void pl011_rs485_tx_start(struct uart_amba_port *uap) 1384 + { 1385 + struct uart_port *port = &uap->port; 1386 + u32 cr; 1387 + 1388 + /* Enable transmitter */ 1389 + cr = pl011_read(uap, REG_CR); 1390 + cr |= UART011_CR_TXE; 1391 + 1392 + /* Disable receiver if half-duplex */ 1393 + if (!(port->rs485.flags & SER_RS485_RX_DURING_TX)) 1394 + cr &= ~UART011_CR_RXE; 1395 + 1396 + if (port->rs485.flags & SER_RS485_RTS_ON_SEND) 1397 + cr &= ~UART011_CR_RTS; 1398 + else 1399 + cr |= UART011_CR_RTS; 1400 + 1401 + pl011_write(cr, uap, REG_CR); 1402 + 1403 + if (port->rs485.delay_rts_before_send) 1404 + mdelay(port->rs485.delay_rts_before_send); 1405 + 1406 + uap->rs485_tx_started = true; 1407 + } 1408 + 1426 1409 /* Returns true if tx interrupts have to be (kept) enabled */ 1427 1410 static bool pl011_tx_chars(struct uart_amba_port *uap, bool from_irq) 1428 1411 { ··· 1465 1396 pl011_stop_tx(&uap->port); 1466 1397 return false; 1467 1398 } 1399 + 1400 + if ((uap->port.rs485.flags & SER_RS485_ENABLED) && 1401 + !uap->rs485_tx_started) 1402 + pl011_rs485_tx_start(uap); 1468 1403 1469 1404 /* If we are using DMA mode, try to send some characters. */ 1470 1405 if (pl011_dma_tx_irq(uap)) ··· 1614 1541 struct uart_amba_port *uap = 1615 1542 container_of(port, struct uart_amba_port, port); 1616 1543 unsigned int cr; 1544 + 1545 + if (port->rs485.flags & SER_RS485_ENABLED) 1546 + mctrl &= ~TIOCM_RTS; 1617 1547 1618 1548 cr = pl011_read(uap, REG_CR); 1619 1549 ··· 1839 1763 1840 1764 /* restore RTS and DTR */ 1841 1765 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR); 1842 - cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; 1766 + cr |= UART01x_CR_UARTEN | UART011_CR_RXE; 1767 + 1768 + if (port->rs485.flags & SER_RS485_ENABLED) { 1769 + if (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) 1770 + cr &= ~UART011_CR_RTS; 1771 + else 1772 + cr |= UART011_CR_RTS; 1773 + } else { 1774 + cr |= UART011_CR_TXE; 1775 + } 1776 + 1843 1777 pl011_write(cr, uap, REG_CR); 1844 1778 1845 1779 spin_unlock_irq(&uap->port.lock); ··· 1950 1864 1951 1865 pl011_dma_shutdown(uap); 1952 1866 1867 + if ((port->rs485.flags & SER_RS485_ENABLED) && uap->rs485_tx_started) 1868 + pl011_rs485_tx_stop(uap); 1869 + 1953 1870 free_irq(uap->port.irq, uap); 1954 1871 1955 1872 pl011_disable_uart(uap); ··· 2030 1941 unsigned int lcr_h, old_cr; 2031 1942 unsigned long flags; 2032 1943 unsigned int baud, quot, clkdiv; 1944 + unsigned int bits; 2033 1945 2034 1946 if (uap->vendor->oversampling) 2035 1947 clkdiv = 8; ··· 2081 1991 if (uap->fifosize > 1) 2082 1992 lcr_h |= UART01x_LCRH_FEN; 2083 1993 1994 + bits = tty_get_frame_size(termios->c_cflag); 1995 + 2084 1996 spin_lock_irqsave(&port->lock, flags); 2085 1997 2086 1998 /* ··· 2090 1998 */ 2091 1999 uart_update_timeout(port, termios->c_cflag, baud); 2092 2000 2001 + /* 2002 + * Calculate the approximated time it takes to transmit one character 2003 + * with the given baud rate. We use this as the poll interval when we 2004 + * wait for the tx queue to empty. 2005 + */ 2006 + uap->rs485_tx_drain_interval = (bits * 1000 * 1000) / baud; 2007 + 2093 2008 pl011_setup_status_masks(port, termios); 2094 2009 2095 2010 if (UART_ENABLE_MS(port, termios->c_cflag)) 2096 2011 pl011_enable_ms(port); 2012 + 2013 + if (port->rs485.flags & SER_RS485_ENABLED) 2014 + termios->c_cflag &= ~CRTSCTS; 2097 2015 2098 2016 /* first, disable everything */ 2099 2017 old_cr = pl011_read(uap, REG_CR); ··· 2224 2122 if (ser->baud_base < 9600) 2225 2123 ret = -EINVAL; 2226 2124 return ret; 2125 + } 2126 + 2127 + static int pl011_rs485_config(struct uart_port *port, 2128 + struct serial_rs485 *rs485) 2129 + { 2130 + struct uart_amba_port *uap = 2131 + container_of(port, struct uart_amba_port, port); 2132 + 2133 + /* pick sane settings if the user hasn't */ 2134 + if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == 2135 + !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { 2136 + rs485->flags |= SER_RS485_RTS_ON_SEND; 2137 + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; 2138 + } 2139 + /* clamp the delays to [0, 100ms] */ 2140 + rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); 2141 + rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); 2142 + memset(rs485->padding, 0, sizeof(rs485->padding)); 2143 + 2144 + if (port->rs485.flags & SER_RS485_ENABLED) 2145 + pl011_rs485_tx_stop(uap); 2146 + 2147 + /* Set new configuration */ 2148 + port->rs485 = *rs485; 2149 + 2150 + /* Make sure auto RTS is disabled */ 2151 + if (port->rs485.flags & SER_RS485_ENABLED) { 2152 + u32 cr = pl011_read(uap, REG_CR); 2153 + 2154 + cr &= ~UART011_CR_RTSEN; 2155 + pl011_write(cr, uap, REG_CR); 2156 + port->status &= ~UPSTAT_AUTORTS; 2157 + } 2158 + 2159 + return 0; 2227 2160 } 2228 2161 2229 2162 static const struct uart_ops amba_pl011_pops = { ··· 2725 2588 return -EBUSY; 2726 2589 } 2727 2590 2591 + static int pl011_get_rs485_mode(struct uart_amba_port *uap) 2592 + { 2593 + struct uart_port *port = &uap->port; 2594 + struct serial_rs485 *rs485 = &port->rs485; 2595 + int ret; 2596 + 2597 + ret = uart_get_rs485_mode(port); 2598 + if (ret) 2599 + return ret; 2600 + 2601 + /* clamp the delays to [0, 100ms] */ 2602 + rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); 2603 + rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); 2604 + 2605 + return 0; 2606 + } 2607 + 2728 2608 static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap, 2729 2609 struct resource *mmiobase, int index) 2730 2610 { 2731 2611 void __iomem *base; 2612 + int ret; 2732 2613 2733 2614 base = devm_ioremap_resource(dev, mmiobase); 2734 2615 if (IS_ERR(base)) ··· 2762 2607 uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_AMBA_PL011_CONSOLE); 2763 2608 uap->port.flags = UPF_BOOT_AUTOCONF; 2764 2609 uap->port.line = index; 2610 + 2611 + ret = pl011_get_rs485_mode(uap); 2612 + if (ret) 2613 + return ret; 2765 2614 2766 2615 amba_ports[index] = uap; 2767 2616 ··· 2824 2665 uap->port.iotype = vendor->access_32b ? UPIO_MEM32 : UPIO_MEM; 2825 2666 uap->port.irq = dev->irq[0]; 2826 2667 uap->port.ops = &amba_pl011_pops; 2827 - 2668 + uap->port.rs485_config = pl011_rs485_config; 2828 2669 snprintf(uap->type, sizeof(uap->type), "PL011 rev%u", amba_rev(dev)); 2829 2670 2830 2671 ret = pl011_setup_port(&dev->dev, uap, &dev->res, portnr);
+1 -5
drivers/tty/serial/fsl_linflexuart.c
··· 861 861 862 862 platform_set_drvdata(pdev, sport); 863 863 864 - ret = uart_add_one_port(&linflex_reg, sport); 865 - if (ret) 866 - return ret; 867 - 868 - return 0; 864 + return uart_add_one_port(&linflex_reg, sport); 869 865 } 870 866 871 867 static int linflex_remove(struct platform_device *pdev)
+59 -3
drivers/tty/serial/fsl_lpuart.c
··· 7 7 8 8 #include <linux/clk.h> 9 9 #include <linux/console.h> 10 + #include <linux/delay.h> 10 11 #include <linux/dma-mapping.h> 11 12 #include <linux/dmaengine.h> 12 13 #include <linux/dmapool.h> ··· 109 108 #define UARTSFIFO_RXOF 0x04 110 109 #define UARTSFIFO_TXOF 0x02 111 110 #define UARTSFIFO_RXUF 0x01 111 + 112 + /* 32-bit global registers only for i.MX7ULP/i.MX8x 113 + * Used to reset all internal logic and registers, except the Global Register. 114 + */ 115 + #define UART_GLOBAL 0x8 112 116 113 117 /* 32-bit register definition */ 114 118 #define UARTBAUD 0x00 ··· 225 219 #define UARTWATER_TXWATER_OFF 0 226 220 #define UARTWATER_RXWATER_OFF 16 227 221 222 + #define UART_GLOBAL_RST 0x2 223 + #define GLOBAL_RST_MIN_US 20 224 + #define GLOBAL_RST_MAX_US 40 225 + 228 226 /* Rx DMA timeout in ms, which is used to calculate Rx ring buffer size */ 229 227 #define DMA_RX_TIMEOUT (10) 230 228 ··· 330 320 sport->devtype == LS1028A_LPUART); 331 321 } 332 322 323 + static inline bool is_imx7ulp_lpuart(struct lpuart_port *sport) 324 + { 325 + return sport->devtype == IMX7ULP_LPUART; 326 + } 327 + 333 328 static inline bool is_imx8qxp_lpuart(struct lpuart_port *sport) 334 329 { 335 330 return sport->devtype == IMX8QXP_LPUART; ··· 397 382 398 383 #define lpuart_enable_clks(x) __lpuart_enable_clks(x, true) 399 384 #define lpuart_disable_clks(x) __lpuart_enable_clks(x, false) 385 + 386 + static int lpuart_global_reset(struct lpuart_port *sport) 387 + { 388 + struct uart_port *port = &sport->port; 389 + void __iomem *global_addr; 390 + int ret; 391 + 392 + if (uart_console(port)) 393 + return 0; 394 + 395 + ret = clk_prepare_enable(sport->ipg_clk); 396 + if (ret) { 397 + dev_err(sport->port.dev, "failed to enable uart ipg clk: %d\n", ret); 398 + return ret; 399 + } 400 + 401 + if (is_imx7ulp_lpuart(sport) || is_imx8qxp_lpuart(sport)) { 402 + global_addr = port->membase + UART_GLOBAL - IMX_REG_OFF; 403 + writel(UART_GLOBAL_RST, global_addr); 404 + usleep_range(GLOBAL_RST_MIN_US, GLOBAL_RST_MAX_US); 405 + writel(0, global_addr); 406 + usleep_range(GLOBAL_RST_MIN_US, GLOBAL_RST_MAX_US); 407 + } 408 + 409 + clk_disable_unprepare(sport->ipg_clk); 410 + return 0; 411 + } 400 412 401 413 static void lpuart_stop_tx(struct uart_port *port) 402 414 { ··· 521 479 unsigned long flags; 522 480 523 481 spin_lock_irqsave(&sport->port.lock, flags); 482 + if (!sport->dma_tx_in_progress) { 483 + spin_unlock_irqrestore(&sport->port.lock, flags); 484 + return; 485 + } 524 486 525 487 dma_unmap_sg(chan->device->dev, sgl, sport->dma_tx_nents, 526 488 DMA_TO_DEVICE); ··· 2091 2045 { 2092 2046 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 2093 2047 unsigned long flags; 2094 - unsigned long ctrl, old_ctrl, modem; 2048 + unsigned long ctrl, old_ctrl, bd, modem; 2095 2049 unsigned int baud; 2096 2050 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; 2097 2051 2098 2052 ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL); 2053 + bd = lpuart32_read(&sport->port, UARTBAUD); 2099 2054 modem = lpuart32_read(&sport->port, UARTMODIR); 2100 2055 /* 2101 2056 * only support CS8 and CS7, and for CS7 must enable PE. ··· 2140 2093 } 2141 2094 2142 2095 if (termios->c_cflag & CSTOPB) 2143 - termios->c_cflag &= ~CSTOPB; 2096 + bd |= UARTBAUD_SBNS; 2097 + else 2098 + bd &= ~UARTBAUD_SBNS; 2144 2099 2145 2100 /* parity must be enabled when CS7 to match 8-bits format */ 2146 2101 if ((termios->c_cflag & CSIZE) == CS7) ··· 2212 2163 lpuart32_write(&sport->port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE), 2213 2164 UARTCTRL); 2214 2165 2166 + lpuart32_write(&sport->port, bd, UARTBAUD); 2215 2167 lpuart32_serial_setbrg(sport, baud); 2216 2168 lpuart32_write(&sport->port, modem, UARTMODIR); 2217 2169 lpuart32_write(&sport->port, ctrl, UARTCTRL); ··· 2661 2611 return PTR_ERR(sport->port.membase); 2662 2612 2663 2613 sport->port.membase += sdata->reg_off; 2664 - sport->port.mapbase = res->start; 2614 + sport->port.mapbase = res->start + sdata->reg_off; 2665 2615 sport->port.dev = &pdev->dev; 2666 2616 sport->port.type = PORT_LPUART; 2667 2617 sport->devtype = sdata->devtype; ··· 2741 2691 if (ret) 2742 2692 goto failed_attach_port; 2743 2693 2694 + ret = lpuart_global_reset(sport); 2695 + if (ret) 2696 + goto failed_reset; 2697 + 2744 2698 ret = uart_get_rs485_mode(&sport->port); 2745 2699 if (ret) 2746 2700 goto failed_get_rs485; ··· 2761 2707 return 0; 2762 2708 2763 2709 failed_get_rs485: 2710 + failed_reset: 2711 + uart_remove_one_port(&lpuart_reg, &sport->port); 2764 2712 failed_attach_port: 2765 2713 failed_irq_request: 2766 2714 lpuart_disable_clks(sport);
+2
drivers/tty/serial/jsm/jsm_neo.c
··· 815 815 /* Parse any modem signal changes */ 816 816 jsm_dbg(INTR, &ch->ch_bd->pci_dev, 817 817 "MOD_STAT: sending to parse_modem_sigs\n"); 818 + spin_lock_irqsave(&ch->uart_port.lock, lock_flags); 818 819 neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr)); 820 + spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags); 819 821 } 820 822 } 821 823
+3
drivers/tty/serial/jsm/jsm_tty.c
··· 187 187 188 188 static int jsm_tty_open(struct uart_port *port) 189 189 { 190 + unsigned long lock_flags; 190 191 struct jsm_board *brd; 191 192 struct jsm_channel *channel = 192 193 container_of(port, struct jsm_channel, uart_port); ··· 241 240 channel->ch_cached_lsr = 0; 242 241 channel->ch_stops_sent = 0; 243 242 243 + spin_lock_irqsave(&port->lock, lock_flags); 244 244 termios = &port->state->port.tty->termios; 245 245 channel->ch_c_cflag = termios->c_cflag; 246 246 channel->ch_c_iflag = termios->c_iflag; ··· 261 259 jsm_carrier(channel); 262 260 263 261 channel->ch_open_count++; 262 + spin_unlock_irqrestore(&port->lock, lock_flags); 264 263 265 264 jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n"); 266 265 return 0;
+5 -6
drivers/tty/serial/kgdb_nmi.c
··· 330 330 if (!arch_kgdb_ops.enable_nmi) 331 331 return 0; 332 332 333 - kgdb_nmi_tty_driver = alloc_tty_driver(1); 334 - if (!kgdb_nmi_tty_driver) { 333 + kgdb_nmi_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW); 334 + if (IS_ERR(kgdb_nmi_tty_driver)) { 335 335 pr_err("%s: cannot allocate tty\n", __func__); 336 - return -ENOMEM; 336 + return PTR_ERR(kgdb_nmi_tty_driver); 337 337 } 338 338 kgdb_nmi_tty_driver->driver_name = "ttyNMI"; 339 339 kgdb_nmi_tty_driver->name = "ttyNMI"; 340 340 kgdb_nmi_tty_driver->num = 1; 341 341 kgdb_nmi_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 342 342 kgdb_nmi_tty_driver->subtype = SERIAL_TYPE_NORMAL; 343 - kgdb_nmi_tty_driver->flags = TTY_DRIVER_REAL_RAW; 344 343 kgdb_nmi_tty_driver->init_termios = tty_std_termios; 345 344 tty_termios_encode_baud_rate(&kgdb_nmi_tty_driver->init_termios, 346 345 KGDB_NMI_BAUD, KGDB_NMI_BAUD); ··· 355 356 356 357 return 0; 357 358 err_drv_reg: 358 - put_tty_driver(kgdb_nmi_tty_driver); 359 + tty_driver_kref_put(kgdb_nmi_tty_driver); 359 360 return ret; 360 361 } 361 362 EXPORT_SYMBOL_GPL(kgdb_register_nmi_console); ··· 373 374 return ret; 374 375 375 376 tty_unregister_driver(kgdb_nmi_tty_driver); 376 - put_tty_driver(kgdb_nmi_tty_driver); 377 + tty_driver_kref_put(kgdb_nmi_tty_driver); 377 378 378 379 return 0; 379 380 }
+5 -10
drivers/tty/serial/max310x.c
··· 1271 1271 /* Always ask for fixed clock rate from a property. */ 1272 1272 device_property_read_u32(dev, "clock-frequency", &uartclk); 1273 1273 1274 - s->clk = devm_clk_get_optional(dev, "osc"); 1274 + xtal = device_property_match_string(dev, "clock-names", "osc") < 0; 1275 + if (xtal) 1276 + s->clk = devm_clk_get_optional(dev, "xtal"); 1277 + else 1278 + s->clk = devm_clk_get_optional(dev, "osc"); 1275 1279 if (IS_ERR(s->clk)) 1276 1280 return PTR_ERR(s->clk); 1277 - if (s->clk) { 1278 - xtal = false; 1279 - } else { 1280 - s->clk = devm_clk_get_optional(dev, "xtal"); 1281 - if (IS_ERR(s->clk)) 1282 - return PTR_ERR(s->clk); 1283 - 1284 - xtal = true; 1285 - } 1286 1281 1287 1282 ret = clk_prepare_enable(s->clk); 1288 1283 if (ret)
+2 -73
drivers/tty/serial/omap-serial.c
··· 276 276 277 277 dev_dbg(up->port.dev, "serial_omap_enable_ms+%d\n", up->port.line); 278 278 279 - pm_runtime_get_sync(up->dev); 280 279 up->ier |= UART_IER_MSI; 281 280 serial_out(up, UART_IER, up->ier); 282 - pm_runtime_mark_last_busy(up->dev); 283 - pm_runtime_put_autosuspend(up->dev); 284 281 } 285 282 286 283 static void serial_omap_stop_tx(struct uart_port *port) 287 284 { 288 285 struct uart_omap_port *up = to_uart_omap_port(port); 289 286 int res; 290 - 291 - pm_runtime_get_sync(up->dev); 292 287 293 288 /* Handle RS-485 */ 294 289 if (port->rs485.flags & SER_RS485_ENABLED) { ··· 325 330 up->ier &= ~UART_IER_THRI; 326 331 serial_out(up, UART_IER, up->ier); 327 332 } 328 - 329 - pm_runtime_mark_last_busy(up->dev); 330 - pm_runtime_put_autosuspend(up->dev); 331 333 } 332 334 333 335 static void serial_omap_stop_rx(struct uart_port *port) 334 336 { 335 337 struct uart_omap_port *up = to_uart_omap_port(port); 336 338 337 - pm_runtime_get_sync(up->dev); 338 339 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); 339 340 up->port.read_status_mask &= ~UART_LSR_DR; 340 341 serial_out(up, UART_IER, up->ier); 341 - pm_runtime_mark_last_busy(up->dev); 342 - pm_runtime_put_autosuspend(up->dev); 343 342 } 344 343 345 344 static void transmit_chars(struct uart_omap_port *up, unsigned int lsr) ··· 388 399 struct uart_omap_port *up = to_uart_omap_port(port); 389 400 int res; 390 401 391 - pm_runtime_get_sync(up->dev); 392 - 393 402 /* Handle RS-485 */ 394 403 if (port->rs485.flags & SER_RS485_ENABLED) { 395 404 /* Fire THR interrupts when FIFO is below trigger level */ ··· 408 421 up->rs485_tx_filter_count = 0; 409 422 410 423 serial_omap_enable_ier_thri(up); 411 - pm_runtime_mark_last_busy(up->dev); 412 - pm_runtime_put_autosuspend(up->dev); 413 424 } 414 425 415 426 static void serial_omap_throttle(struct uart_port *port) ··· 415 430 struct uart_omap_port *up = to_uart_omap_port(port); 416 431 unsigned long flags; 417 432 418 - pm_runtime_get_sync(up->dev); 419 433 spin_lock_irqsave(&up->port.lock, flags); 420 434 up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); 421 435 serial_out(up, UART_IER, up->ier); 422 436 spin_unlock_irqrestore(&up->port.lock, flags); 423 - pm_runtime_mark_last_busy(up->dev); 424 - pm_runtime_put_autosuspend(up->dev); 425 437 } 426 438 427 439 static void serial_omap_unthrottle(struct uart_port *port) ··· 426 444 struct uart_omap_port *up = to_uart_omap_port(port); 427 445 unsigned long flags; 428 446 429 - pm_runtime_get_sync(up->dev); 430 447 spin_lock_irqsave(&up->port.lock, flags); 431 448 up->ier |= UART_IER_RLSI | UART_IER_RDI; 432 449 serial_out(up, UART_IER, up->ier); 433 450 spin_unlock_irqrestore(&up->port.lock, flags); 434 - pm_runtime_mark_last_busy(up->dev); 435 - pm_runtime_put_autosuspend(up->dev); 436 451 } 437 452 438 453 static unsigned int check_modem_status(struct uart_omap_port *up) ··· 555 576 int max_count = 256; 556 577 557 578 spin_lock(&up->port.lock); 558 - pm_runtime_get_sync(up->dev); 559 579 560 580 do { 561 581 iir = serial_in(up, UART_IIR); ··· 594 616 595 617 tty_flip_buffer_push(&up->port.state->port); 596 618 597 - pm_runtime_mark_last_busy(up->dev); 598 - pm_runtime_put_autosuspend(up->dev); 599 619 up->port_activity = jiffies; 600 620 601 621 return ret; ··· 605 629 unsigned long flags; 606 630 unsigned int ret = 0; 607 631 608 - pm_runtime_get_sync(up->dev); 609 632 dev_dbg(up->port.dev, "serial_omap_tx_empty+%d\n", up->port.line); 610 633 spin_lock_irqsave(&up->port.lock, flags); 611 634 ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0; 612 635 spin_unlock_irqrestore(&up->port.lock, flags); 613 - pm_runtime_mark_last_busy(up->dev); 614 - pm_runtime_put_autosuspend(up->dev); 636 + 615 637 return ret; 616 638 } 617 639 ··· 619 645 unsigned int status; 620 646 unsigned int ret = 0; 621 647 622 - pm_runtime_get_sync(up->dev); 623 648 status = check_modem_status(up); 624 - pm_runtime_mark_last_busy(up->dev); 625 - pm_runtime_put_autosuspend(up->dev); 626 649 627 650 dev_dbg(up->port.dev, "serial_omap_get_mctrl+%d\n", up->port.line); 628 651 ··· 651 680 if (mctrl & TIOCM_LOOP) 652 681 mcr |= UART_MCR_LOOP; 653 682 654 - pm_runtime_get_sync(up->dev); 655 683 old_mcr = serial_in(up, UART_MCR); 656 684 old_mcr &= ~(UART_MCR_LOOP | UART_MCR_OUT2 | UART_MCR_OUT1 | 657 685 UART_MCR_DTR | UART_MCR_RTS); ··· 666 696 up->efr &= ~UART_EFR_RTS; 667 697 serial_out(up, UART_EFR, up->efr); 668 698 serial_out(up, UART_LCR, lcr); 669 - 670 - pm_runtime_mark_last_busy(up->dev); 671 - pm_runtime_put_autosuspend(up->dev); 672 699 } 673 700 674 701 static void serial_omap_break_ctl(struct uart_port *port, int break_state) ··· 674 707 unsigned long flags; 675 708 676 709 dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line); 677 - pm_runtime_get_sync(up->dev); 678 710 spin_lock_irqsave(&up->port.lock, flags); 679 711 if (break_state == -1) 680 712 up->lcr |= UART_LCR_SBC; ··· 681 715 up->lcr &= ~UART_LCR_SBC; 682 716 serial_out(up, UART_LCR, up->lcr); 683 717 spin_unlock_irqrestore(&up->port.lock, flags); 684 - pm_runtime_mark_last_busy(up->dev); 685 - pm_runtime_put_autosuspend(up->dev); 686 718 } 687 719 688 720 static int serial_omap_startup(struct uart_port *port) ··· 752 788 753 789 serial_out(up, UART_OMAP_WER, up->wer); 754 790 755 - pm_runtime_mark_last_busy(up->dev); 756 - pm_runtime_put_autosuspend(up->dev); 757 791 up->port_activity = jiffies; 758 792 return 0; 759 793 } ··· 763 801 764 802 dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line); 765 803 766 - pm_runtime_get_sync(up->dev); 767 804 /* 768 805 * Disable interrupts from this port 769 806 */ ··· 786 825 if (serial_in(up, UART_LSR) & UART_LSR_DR) 787 826 (void) serial_in(up, UART_RX); 788 827 789 - pm_runtime_mark_last_busy(up->dev); 790 - pm_runtime_put_autosuspend(up->dev); 828 + pm_runtime_put_sync(up->dev); 791 829 free_irq(up->port.irq, up); 792 830 dev_pm_clear_wake_irq(up->dev); 793 831 } ··· 856 896 * Ok, we're now changing the port state. Do it with 857 897 * interrupts disabled. 858 898 */ 859 - pm_runtime_get_sync(up->dev); 860 899 spin_lock_irqsave(&up->port.lock, flags); 861 900 862 901 /* ··· 1055 1096 serial_omap_set_mctrl(&up->port, up->port.mctrl); 1056 1097 1057 1098 spin_unlock_irqrestore(&up->port.lock, flags); 1058 - pm_runtime_mark_last_busy(up->dev); 1059 - pm_runtime_put_autosuspend(up->dev); 1060 1099 dev_dbg(up->port.dev, "serial_omap_set_termios+%d\n", up->port.line); 1061 1100 } 1062 1101 ··· 1067 1110 1068 1111 dev_dbg(up->port.dev, "serial_omap_pm+%d\n", up->port.line); 1069 1112 1070 - pm_runtime_get_sync(up->dev); 1071 1113 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 1072 1114 efr = serial_in(up, UART_EFR); 1073 1115 serial_out(up, UART_EFR, efr | UART_EFR_ECB); ··· 1076 1120 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 1077 1121 serial_out(up, UART_EFR, efr); 1078 1122 serial_out(up, UART_LCR, 0); 1079 - 1080 - pm_runtime_mark_last_busy(up->dev); 1081 - pm_runtime_put_autosuspend(up->dev); 1082 1123 } 1083 1124 1084 1125 static void serial_omap_release_port(struct uart_port *port) ··· 1155 1202 { 1156 1203 struct uart_omap_port *up = to_uart_omap_port(port); 1157 1204 1158 - pm_runtime_get_sync(up->dev); 1159 1205 wait_for_xmitr(up); 1160 1206 serial_out(up, UART_TX, ch); 1161 - pm_runtime_mark_last_busy(up->dev); 1162 - pm_runtime_put_autosuspend(up->dev); 1163 1207 } 1164 1208 1165 1209 static int serial_omap_poll_get_char(struct uart_port *port) ··· 1164 1214 struct uart_omap_port *up = to_uart_omap_port(port); 1165 1215 unsigned int status; 1166 1216 1167 - pm_runtime_get_sync(up->dev); 1168 1217 status = serial_in(up, UART_LSR); 1169 1218 if (!(status & UART_LSR_DR)) { 1170 1219 status = NO_POLL_CHAR; ··· 1173 1224 status = serial_in(up, UART_RX); 1174 1225 1175 1226 out: 1176 - pm_runtime_mark_last_busy(up->dev); 1177 - pm_runtime_put_autosuspend(up->dev); 1178 - 1179 1227 return status; 1180 1228 } 1181 1229 ··· 1255 1309 unsigned int ier; 1256 1310 int locked = 1; 1257 1311 1258 - pm_runtime_get_sync(up->dev); 1259 - 1260 1312 local_irq_save(flags); 1261 1313 if (up->port.sysrq) 1262 1314 locked = 0; ··· 1287 1343 if (up->msr_saved_flags) 1288 1344 check_modem_status(up); 1289 1345 1290 - pm_runtime_mark_last_busy(up->dev); 1291 - pm_runtime_put_autosuspend(up->dev); 1292 1346 if (locked) 1293 1347 spin_unlock(&up->port.lock); 1294 1348 local_irq_restore(flags); ··· 1345 1403 unsigned int mode; 1346 1404 int val; 1347 1405 1348 - pm_runtime_get_sync(up->dev); 1349 - 1350 1406 /* Disable interrupts from this port */ 1351 1407 mode = up->ier; 1352 1408 up->ier = 0; ··· 1377 1437 up->scr &= ~OMAP_UART_SCR_TX_EMPTY; 1378 1438 serial_out(up, UART_OMAP_SCR, up->scr); 1379 1439 } 1380 - 1381 - pm_runtime_mark_last_busy(up->dev); 1382 - pm_runtime_put_autosuspend(up->dev); 1383 1440 1384 1441 return 0; 1385 1442 } ··· 1674 1737 omap_up_info->autosuspend_timeout = -1; 1675 1738 1676 1739 device_init_wakeup(up->dev, true); 1677 - pm_runtime_use_autosuspend(&pdev->dev); 1678 - pm_runtime_set_autosuspend_delay(&pdev->dev, 1679 - omap_up_info->autosuspend_timeout); 1680 1740 1681 - pm_runtime_irq_safe(&pdev->dev); 1682 1741 pm_runtime_enable(&pdev->dev); 1683 1742 1684 1743 pm_runtime_get_sync(&pdev->dev); ··· 1688 1755 if (ret != 0) 1689 1756 goto err_add_port; 1690 1757 1691 - pm_runtime_mark_last_busy(up->dev); 1692 - pm_runtime_put_autosuspend(up->dev); 1693 1758 return 0; 1694 1759 1695 1760 err_add_port: 1696 - pm_runtime_dont_use_autosuspend(&pdev->dev); 1697 1761 pm_runtime_put_sync(&pdev->dev); 1698 1762 pm_runtime_disable(&pdev->dev); 1699 1763 cpu_latency_qos_remove_request(&up->pm_qos_request); ··· 1708 1778 1709 1779 uart_remove_one_port(&serial_omap_reg, &up->port); 1710 1780 1711 - pm_runtime_dont_use_autosuspend(up->dev); 1712 1781 pm_runtime_put_sync(up->dev); 1713 1782 pm_runtime_disable(up->dev); 1714 1783 cpu_latency_qos_remove_request(&up->pm_qos_request);
+71 -24
drivers/tty/serial/samsung_tty.c
··· 65 65 struct s3c24xx_uart_info { 66 66 char *name; 67 67 enum s3c24xx_port_type type; 68 + unsigned int has_usi; 68 69 unsigned int port_type; 69 70 unsigned int fifosize; 70 71 unsigned long rx_fifomask; ··· 306 305 dmaengine_pause(dma->tx_chan); 307 306 dmaengine_tx_status(dma->tx_chan, dma->tx_cookie, &state); 308 307 dmaengine_terminate_all(dma->tx_chan); 309 - dma_sync_single_for_cpu(ourport->port.dev, 310 - dma->tx_transfer_addr, dma->tx_size, DMA_TO_DEVICE); 308 + dma_sync_single_for_cpu(dma->tx_chan->device->dev, 309 + dma->tx_transfer_addr, dma->tx_size, 310 + DMA_TO_DEVICE); 311 311 async_tx_ack(dma->tx_desc); 312 312 count = dma->tx_bytes_requested - state.residue; 313 313 xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); ··· 340 338 count = dma->tx_bytes_requested - state.residue; 341 339 async_tx_ack(dma->tx_desc); 342 340 343 - dma_sync_single_for_cpu(ourport->port.dev, dma->tx_transfer_addr, 344 - dma->tx_size, DMA_TO_DEVICE); 341 + dma_sync_single_for_cpu(dma->tx_chan->device->dev, 342 + dma->tx_transfer_addr, dma->tx_size, 343 + DMA_TO_DEVICE); 345 344 346 345 spin_lock_irqsave(&port->lock, flags); 347 346 ··· 446 443 dma->tx_size = count & ~(dma_get_cache_alignment() - 1); 447 444 dma->tx_transfer_addr = dma->tx_addr + xmit->tail; 448 445 449 - dma_sync_single_for_device(ourport->port.dev, dma->tx_transfer_addr, 450 - dma->tx_size, DMA_TO_DEVICE); 446 + dma_sync_single_for_device(dma->tx_chan->device->dev, 447 + dma->tx_transfer_addr, dma->tx_size, 448 + DMA_TO_DEVICE); 451 449 452 450 dma->tx_desc = dmaengine_prep_slave_single(dma->tx_chan, 453 451 dma->tx_transfer_addr, dma->tx_size, ··· 519 515 if (!count) 520 516 return; 521 517 522 - dma_sync_single_for_cpu(ourport->port.dev, dma->rx_addr, 518 + dma_sync_single_for_cpu(dma->rx_chan->device->dev, dma->rx_addr, 523 519 dma->rx_size, DMA_FROM_DEVICE); 524 520 525 521 ourport->port.icount.rx += count; ··· 640 636 { 641 637 struct s3c24xx_uart_dma *dma = ourport->dma; 642 638 643 - dma_sync_single_for_device(ourport->port.dev, dma->rx_addr, 644 - dma->rx_size, DMA_FROM_DEVICE); 639 + dma_sync_single_for_device(dma->rx_chan->device->dev, dma->rx_addr, 640 + dma->rx_size, DMA_FROM_DEVICE); 645 641 646 642 dma->rx_desc = dmaengine_prep_slave_single(dma->rx_chan, 647 643 dma->rx_addr, dma->rx_size, DMA_DEV_TO_MEM, ··· 1106 1102 goto err_release_tx; 1107 1103 } 1108 1104 1109 - dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf, 1110 - dma->rx_size, DMA_FROM_DEVICE); 1111 - if (dma_mapping_error(p->port.dev, dma->rx_addr)) { 1105 + dma->rx_addr = dma_map_single(dma->rx_chan->device->dev, dma->rx_buf, 1106 + dma->rx_size, DMA_FROM_DEVICE); 1107 + if (dma_mapping_error(dma->rx_chan->device->dev, dma->rx_addr)) { 1112 1108 reason = "DMA mapping error for RX buffer"; 1113 1109 ret = -EIO; 1114 1110 goto err_free_rx; 1115 1111 } 1116 1112 1117 1113 /* TX buffer */ 1118 - dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf, 1119 - UART_XMIT_SIZE, DMA_TO_DEVICE); 1120 - if (dma_mapping_error(p->port.dev, dma->tx_addr)) { 1114 + dma->tx_addr = dma_map_single(dma->tx_chan->device->dev, 1115 + p->port.state->xmit.buf, UART_XMIT_SIZE, 1116 + DMA_TO_DEVICE); 1117 + if (dma_mapping_error(dma->tx_chan->device->dev, dma->tx_addr)) { 1121 1118 reason = "DMA mapping error for TX buffer"; 1122 1119 ret = -EIO; 1123 1120 goto err_unmap_rx; ··· 1127 1122 return 0; 1128 1123 1129 1124 err_unmap_rx: 1130 - dma_unmap_single(p->port.dev, dma->rx_addr, dma->rx_size, 1131 - DMA_FROM_DEVICE); 1125 + dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, 1126 + dma->rx_size, DMA_FROM_DEVICE); 1132 1127 err_free_rx: 1133 1128 kfree(dma->rx_buf); 1134 1129 err_release_tx: ··· 1147 1142 1148 1143 if (dma->rx_chan) { 1149 1144 dmaengine_terminate_all(dma->rx_chan); 1150 - dma_unmap_single(p->port.dev, dma->rx_addr, 1151 - dma->rx_size, DMA_FROM_DEVICE); 1145 + dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, 1146 + dma->rx_size, DMA_FROM_DEVICE); 1152 1147 kfree(dma->rx_buf); 1153 1148 dma_release_channel(dma->rx_chan); 1154 1149 dma->rx_chan = NULL; ··· 1156 1151 1157 1152 if (dma->tx_chan) { 1158 1153 dmaengine_terminate_all(dma->tx_chan); 1159 - dma_unmap_single(p->port.dev, dma->tx_addr, 1160 - UART_XMIT_SIZE, DMA_TO_DEVICE); 1154 + dma_unmap_single(dma->tx_chan->device->dev, dma->tx_addr, 1155 + UART_XMIT_SIZE, DMA_TO_DEVICE); 1161 1156 dma_release_channel(dma->tx_chan); 1162 1157 dma->tx_chan = NULL; 1163 1158 } ··· 1357 1352 return ret; 1358 1353 } 1359 1354 1355 + static void exynos_usi_init(struct uart_port *port) 1356 + { 1357 + struct s3c24xx_uart_port *ourport = to_ourport(port); 1358 + struct s3c24xx_uart_info *info = ourport->info; 1359 + unsigned int val; 1360 + 1361 + if (!info->has_usi) 1362 + return; 1363 + 1364 + /* Clear the software reset of USI block (it's set at startup) */ 1365 + val = rd_regl(port, USI_CON); 1366 + val &= ~USI_CON_RESET_MASK; 1367 + wr_regl(port, USI_CON, val); 1368 + udelay(1); 1369 + 1370 + /* Continuously provide the clock to USI IP w/o gating (for Rx mode) */ 1371 + val = rd_regl(port, USI_OPTION); 1372 + val &= ~USI_OPTION_HWACG_MASK; 1373 + val |= USI_OPTION_HWACG_CLKREQ_ON; 1374 + wr_regl(port, USI_OPTION, val); 1375 + } 1376 + 1360 1377 /* power power management control */ 1361 1378 1362 1379 static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level, ··· 1406 1379 if (!IS_ERR(ourport->baudclk)) 1407 1380 clk_prepare_enable(ourport->baudclk); 1408 1381 1382 + exynos_usi_init(port); 1409 1383 break; 1410 1384 default: 1411 1385 dev_err(port->dev, "s3c24xx_serial: unknown pm %d\n", level); ··· 2130 2102 if (ret) 2131 2103 pr_warn("uart: failed to enable baudclk\n"); 2132 2104 2105 + exynos_usi_init(port); 2106 + 2133 2107 /* Keep all interrupts masked and cleared */ 2134 2108 switch (ourport->info->type) { 2135 2109 case TYPE_S3C6400: ··· 2780 2750 #endif 2781 2751 2782 2752 #if defined(CONFIG_ARCH_EXYNOS) 2783 - #define EXYNOS_COMMON_SERIAL_DRV_DATA \ 2753 + #define EXYNOS_COMMON_SERIAL_DRV_DATA_USI(_has_usi) \ 2784 2754 .info = &(struct s3c24xx_uart_info) { \ 2785 2755 .name = "Samsung Exynos UART", \ 2786 2756 .type = TYPE_S3C6400, \ 2757 + .has_usi = _has_usi, \ 2787 2758 .port_type = PORT_S3C6400, \ 2788 2759 .has_divslot = 1, \ 2789 2760 .rx_fifomask = S5PV210_UFSTAT_RXMASK, \ ··· 2804 2773 .has_fracval = 1, \ 2805 2774 } \ 2806 2775 2776 + #define EXYNOS_COMMON_SERIAL_DRV_DATA \ 2777 + EXYNOS_COMMON_SERIAL_DRV_DATA_USI(0) 2778 + 2807 2779 static struct s3c24xx_serial_drv_data exynos4210_serial_drv_data = { 2808 2780 EXYNOS_COMMON_SERIAL_DRV_DATA, 2809 2781 .fifosize = { 256, 64, 16, 16 }, ··· 2817 2783 .fifosize = { 64, 256, 16, 256 }, 2818 2784 }; 2819 2785 2786 + static struct s3c24xx_serial_drv_data exynos850_serial_drv_data = { 2787 + EXYNOS_COMMON_SERIAL_DRV_DATA_USI(1), 2788 + .fifosize = { 256, 64, 64, 64 }, 2789 + }; 2790 + 2820 2791 #define EXYNOS4210_SERIAL_DRV_DATA ((kernel_ulong_t)&exynos4210_serial_drv_data) 2821 2792 #define EXYNOS5433_SERIAL_DRV_DATA ((kernel_ulong_t)&exynos5433_serial_drv_data) 2793 + #define EXYNOS850_SERIAL_DRV_DATA ((kernel_ulong_t)&exynos850_serial_drv_data) 2794 + 2822 2795 #else 2823 - #define EXYNOS4210_SERIAL_DRV_DATA (kernel_ulong_t)NULL 2824 - #define EXYNOS5433_SERIAL_DRV_DATA (kernel_ulong_t)NULL 2796 + #define EXYNOS4210_SERIAL_DRV_DATA ((kernel_ulong_t)NULL) 2797 + #define EXYNOS5433_SERIAL_DRV_DATA ((kernel_ulong_t)NULL) 2798 + #define EXYNOS850_SERIAL_DRV_DATA ((kernel_ulong_t)NULL) 2825 2799 #endif 2826 2800 2827 2801 #ifdef CONFIG_ARCH_APPLE ··· 2885 2843 }, { 2886 2844 .name = "s5l-uart", 2887 2845 .driver_data = S5L_SERIAL_DRV_DATA, 2846 + }, { 2847 + .name = "exynos850-uart", 2848 + .driver_data = EXYNOS850_SERIAL_DRV_DATA, 2888 2849 }, 2889 2850 { }, 2890 2851 }; ··· 2911 2866 .data = (void *)EXYNOS5433_SERIAL_DRV_DATA }, 2912 2867 { .compatible = "apple,s5l-uart", 2913 2868 .data = (void *)S5L_SERIAL_DRV_DATA }, 2869 + { .compatible = "samsung,exynos850-uart", 2870 + .data = (void *)EXYNOS850_SERIAL_DRV_DATA }, 2914 2871 {}, 2915 2872 }; 2916 2873 MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match);
+2 -4
drivers/tty/serial/serial-tegra.c
··· 1568 1568 struct resource *resource; 1569 1569 int ret; 1570 1570 const struct tegra_uart_chip_data *cdata; 1571 - const struct of_device_id *match; 1572 1571 1573 - match = of_match_device(tegra_uart_of_match, &pdev->dev); 1574 - if (!match) { 1572 + cdata = of_device_get_match_data(&pdev->dev); 1573 + if (!cdata) { 1575 1574 dev_err(&pdev->dev, "Error: No device match found\n"); 1576 1575 return -ENODEV; 1577 1576 } 1578 - cdata = match->data; 1579 1577 1580 1578 tup = devm_kzalloc(&pdev->dev, sizeof(*tup), GFP_KERNEL); 1581 1579 if (!tup) {
+15 -5
drivers/tty/serial/serial_core.c
··· 2314 2314 port->dev ? ": " : "", 2315 2315 port->name, 2316 2316 address, port->irq, port->uartclk / 16, uart_type(port)); 2317 + 2318 + /* The magic multiplier feature is a bit obscure, so report it too. */ 2319 + if (port->flags & UPF_MAGIC_MULTIPLIER) 2320 + pr_info("%s%s%s extra baud rates supported: %d, %d", 2321 + port->dev ? dev_name(port->dev) : "", 2322 + port->dev ? ": " : "", 2323 + port->name, 2324 + port->uartclk / 8, port->uartclk / 4); 2317 2325 } 2318 2326 2319 2327 static void ··· 2530 2522 if (!drv->state) 2531 2523 goto out; 2532 2524 2533 - normal = alloc_tty_driver(drv->nr); 2534 - if (!normal) 2525 + normal = tty_alloc_driver(drv->nr, TTY_DRIVER_REAL_RAW | 2526 + TTY_DRIVER_DYNAMIC_DEV); 2527 + if (IS_ERR(normal)) { 2528 + retval = PTR_ERR(normal); 2535 2529 goto out_kfree; 2530 + } 2536 2531 2537 2532 drv->tty_driver = normal; 2538 2533 ··· 2548 2537 normal->init_termios = tty_std_termios; 2549 2538 normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2550 2539 normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 9600; 2551 - normal->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 2552 2540 normal->driver_state = drv; 2553 2541 tty_set_operations(normal, &uart_ops); 2554 2542 ··· 2568 2558 2569 2559 for (i = 0; i < drv->nr; i++) 2570 2560 tty_port_destroy(&drv->state[i].port); 2571 - put_tty_driver(normal); 2561 + tty_driver_kref_put(normal); 2572 2562 out_kfree: 2573 2563 kfree(drv->state); 2574 2564 out: ··· 2590 2580 unsigned int i; 2591 2581 2592 2582 tty_unregister_driver(p); 2593 - put_tty_driver(p); 2583 + tty_driver_kref_put(p); 2594 2584 for (i = 0; i < drv->nr; i++) 2595 2585 tty_port_destroy(&drv->state[i].port); 2596 2586 kfree(drv->state);
+6 -1
drivers/tty/serial/sh-sci.c
··· 1758 1758 1759 1759 /* Handle BREAKs */ 1760 1760 sci_handle_breaks(port); 1761 + 1762 + /* drop invalid character received before break was detected */ 1763 + serial_port_in(port, SCxRDR); 1764 + 1761 1765 sci_clear_SCxSR(port, SCxSR_BREAK_CLEAR(port)); 1762 1766 1763 1767 return IRQ_HANDLED; ··· 1841 1837 ret = sci_er_interrupt(irq, ptr); 1842 1838 1843 1839 /* Break Interrupt */ 1844 - if ((ssr_status & SCxSR_BRK(port)) && err_enabled) 1840 + if (s->irqs[SCIx_ERI_IRQ] != s->irqs[SCIx_BRI_IRQ] && 1841 + (ssr_status & SCxSR_BRK(port)) && err_enabled) 1845 1842 ret = sci_br_interrupt(irq, ptr); 1846 1843 1847 1844 /* Overrun Interrupt */
+5 -6
drivers/tty/serial/stm32-usart.c
··· 1034 1034 int ret, irq; 1035 1035 1036 1036 irq = platform_get_irq(pdev, 0); 1037 - if (irq <= 0) 1038 - return irq ? : -ENODEV; 1037 + if (irq < 0) 1038 + return irq; 1039 1039 1040 1040 port->iotype = UPIO_MEM; 1041 1041 port->flags = UPF_BOOT_AUTOCONF; ··· 1064 1064 &stm32port->txftcfg); 1065 1065 } 1066 1066 1067 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1068 - port->membase = devm_ioremap_resource(&pdev->dev, res); 1067 + port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1069 1068 if (IS_ERR(port->membase)) 1070 1069 return PTR_ERR(port->membase); 1071 1070 port->mapbase = res->start; ··· 1176 1177 if (uart_console(port)) 1177 1178 return -ENODEV; 1178 1179 1179 - stm32port->rx_buf = dma_alloc_coherent(&pdev->dev, RX_BUF_L, 1180 + stm32port->rx_buf = dma_alloc_coherent(dev, RX_BUF_L, 1180 1181 &stm32port->rx_dma_buf, 1181 1182 GFP_KERNEL); 1182 1183 if (!stm32port->rx_buf) ··· 1242 1243 1243 1244 stm32port->tx_dma_busy = false; 1244 1245 1245 - stm32port->tx_buf = dma_alloc_coherent(&pdev->dev, TX_BUF_L, 1246 + stm32port->tx_buf = dma_alloc_coherent(dev, TX_BUF_L, 1246 1247 &stm32port->tx_dma_buf, 1247 1248 GFP_KERNEL); 1248 1249 if (!stm32port->tx_buf)
+62 -26
drivers/tty/serial/uartlite.c
··· 17 17 #include <linux/interrupt.h> 18 18 #include <linux/init.h> 19 19 #include <linux/io.h> 20 + #include <linux/iopoll.h> 20 21 #include <linux/of.h> 21 22 #include <linux/of_address.h> 22 23 #include <linux/of_device.h> 23 24 #include <linux/of_platform.h> 24 25 #include <linux/clk.h> 26 + #include <linux/pm_runtime.h> 25 27 26 28 #define ULITE_NAME "ttyUL" 27 29 #define ULITE_MAJOR 204 ··· 56 54 #define ULITE_CONTROL_RST_TX 0x01 57 55 #define ULITE_CONTROL_RST_RX 0x02 58 56 #define ULITE_CONTROL_IE 0x10 57 + #define UART_AUTOSUSPEND_TIMEOUT 3000 /* ms */ 59 58 60 59 /* Static pointer to console port */ 61 60 #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE ··· 393 390 static void ulite_pm(struct uart_port *port, unsigned int state, 394 391 unsigned int oldstate) 395 392 { 396 - struct uartlite_data *pdata = port->private_data; 393 + int ret; 397 394 398 - if (!state) 399 - clk_enable(pdata->clk); 400 - else 401 - clk_disable(pdata->clk); 395 + if (!state) { 396 + ret = pm_runtime_get_sync(port->dev); 397 + if (ret < 0) 398 + dev_err(port->dev, "Failed to enable clocks\n"); 399 + } else { 400 + pm_runtime_mark_last_busy(port->dev); 401 + pm_runtime_put_autosuspend(port->dev); 402 + } 402 403 } 403 404 404 405 #ifdef CONFIG_CONSOLE_POLL ··· 455 448 static void ulite_console_wait_tx(struct uart_port *port) 456 449 { 457 450 u8 val; 458 - unsigned long timeout; 459 451 460 452 /* 461 453 * Spin waiting for TX fifo to have space available. 462 454 * When using the Microblaze Debug Module this can take up to 1s 463 455 */ 464 - timeout = jiffies + msecs_to_jiffies(1000); 465 - while (1) { 466 - val = uart_in32(ULITE_STATUS, port); 467 - if ((val & ULITE_STATUS_TXFULL) == 0) 468 - break; 469 - if (time_after(jiffies, timeout)) { 470 - dev_warn(port->dev, 471 - "timeout waiting for TX buffer empty\n"); 472 - break; 473 - } 474 - cpu_relax(); 475 - } 456 + if (read_poll_timeout_atomic(uart_in32, val, !(val & ULITE_STATUS_TXFULL), 457 + 0, 1000000, false, ULITE_STATUS, port)) 458 + dev_warn(port->dev, 459 + "timeout waiting for TX buffer empty\n"); 476 460 } 477 461 478 462 static void ulite_console_putchar(struct uart_port *port, int ch) ··· 553 555 * This limit is pretty arbitrary, unless we are at about 10 baud 554 556 * we'll never timeout on a working UART. 555 557 */ 556 - 557 558 unsigned retries = 1000000; 558 - /* read status bit - 0x8 offset */ 559 - while (--retries && (readl(port->membase + 8) & (1 << 3))) 559 + 560 + while (--retries && 561 + (readl(port->membase + ULITE_STATUS) & ULITE_STATUS_TXFULL)) 560 562 ; 561 563 562 564 /* Only attempt the iowrite if we didn't timeout */ 563 - /* write to TX_FIFO - 0x4 offset */ 564 565 if (retries) 565 - writel(c & 0xff, port->membase + 4); 566 + writel(c & 0xff, port->membase + ULITE_TX); 566 567 } 567 568 568 569 static void early_uartlite_write(struct console *console, ··· 716 719 return 0; 717 720 } 718 721 722 + static int __maybe_unused ulite_runtime_suspend(struct device *dev) 723 + { 724 + struct uart_port *port = dev_get_drvdata(dev); 725 + struct uartlite_data *pdata = port->private_data; 726 + 727 + clk_disable(pdata->clk); 728 + return 0; 729 + }; 730 + 731 + static int __maybe_unused ulite_runtime_resume(struct device *dev) 732 + { 733 + struct uart_port *port = dev_get_drvdata(dev); 734 + struct uartlite_data *pdata = port->private_data; 735 + int ret; 736 + 737 + ret = clk_enable(pdata->clk); 738 + if (ret) { 739 + dev_err(dev, "Cannot enable clock.\n"); 740 + return ret; 741 + } 742 + return 0; 743 + } 744 + 719 745 /* --------------------------------------------------------------------- 720 746 * Platform bus binding 721 747 */ 722 748 723 - static SIMPLE_DEV_PM_OPS(ulite_pm_ops, ulite_suspend, ulite_resume); 749 + static const struct dev_pm_ops ulite_pm_ops = { 750 + SET_SYSTEM_SLEEP_PM_OPS(ulite_suspend, ulite_resume) 751 + SET_RUNTIME_PM_OPS(ulite_runtime_suspend, 752 + ulite_runtime_resume, NULL) 753 + }; 724 754 725 755 #if defined(CONFIG_OF) 726 756 /* Match table for of_platform binding */ ··· 803 779 return ret; 804 780 } 805 781 782 + pm_runtime_use_autosuspend(&pdev->dev); 783 + pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT); 784 + pm_runtime_set_active(&pdev->dev); 785 + pm_runtime_enable(&pdev->dev); 786 + 806 787 if (!ulite_uart_driver.state) { 807 788 dev_dbg(&pdev->dev, "uartlite: calling uart_register_driver()\n"); 808 789 ret = uart_register_driver(&ulite_uart_driver); 809 790 if (ret < 0) { 810 791 dev_err(&pdev->dev, "Failed to register driver\n"); 792 + clk_disable_unprepare(pdata->clk); 811 793 return ret; 812 794 } 813 795 } 814 796 815 797 ret = ulite_assign(&pdev->dev, id, res->start, irq, pdata); 816 798 817 - clk_disable(pdata->clk); 799 + pm_runtime_mark_last_busy(&pdev->dev); 800 + pm_runtime_put_autosuspend(&pdev->dev); 818 801 819 802 return ret; 820 803 } ··· 830 799 { 831 800 struct uart_port *port = dev_get_drvdata(&pdev->dev); 832 801 struct uartlite_data *pdata = port->private_data; 802 + int rc; 833 803 834 804 clk_disable_unprepare(pdata->clk); 835 - return ulite_release(&pdev->dev); 805 + rc = ulite_release(&pdev->dev); 806 + pm_runtime_disable(&pdev->dev); 807 + pm_runtime_set_suspended(&pdev->dev); 808 + pm_runtime_dont_use_autosuspend(&pdev->dev); 809 + return rc; 836 810 } 837 811 838 812 /* work with hotplug and coldplug */
+2 -5
drivers/tty/serial/vt8500_serial.c
··· 623 623 struct vt8500_port *vt8500_port; 624 624 struct resource *mmres, *irqres; 625 625 struct device_node *np = pdev->dev.of_node; 626 - const struct of_device_id *match; 627 626 const unsigned int *flags; 628 627 int ret; 629 628 int port; 630 629 631 - match = of_match_device(wmt_dt_ids, &pdev->dev); 632 - if (!match) 630 + flags = of_device_get_match_data(&pdev->dev); 631 + if (!flags) 633 632 return -EINVAL; 634 - 635 - flags = match->data; 636 633 637 634 mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 638 635 irqres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+2 -2
drivers/tty/sysrq.c
··· 258 258 if (!trigger_all_cpu_backtrace()) { 259 259 struct pt_regs *regs = NULL; 260 260 261 - if (in_irq()) 261 + if (in_hardirq()) 262 262 regs = get_irq_regs(); 263 263 if (regs) { 264 264 pr_info("CPU%d:\n", smp_processor_id()); ··· 280 280 { 281 281 struct pt_regs *regs = NULL; 282 282 283 - if (in_irq()) 283 + if (in_hardirq()) 284 284 regs = get_irq_regs(); 285 285 if (regs) 286 286 show_regs(regs);
+2 -15
drivers/tty/tty_io.c
··· 2290 2290 * Locking: 2291 2291 * Called functions take tty_ldiscs_lock 2292 2292 * current->signal->tty check is safe without locks 2293 - * 2294 - * FIXME: may race normal receive processing 2295 2293 */ 2296 2294 2297 2295 static int tiocsti(struct tty_struct *tty, char __user *p) ··· 2305 2307 ld = tty_ldisc_ref_wait(tty); 2306 2308 if (!ld) 2307 2309 return -EIO; 2310 + tty_buffer_lock_exclusive(tty->port); 2308 2311 if (ld->ops->receive_buf) 2309 2312 ld->ops->receive_buf(tty, &ch, &mbz, 1); 2313 + tty_buffer_unlock_exclusive(tty->port); 2310 2314 tty_ldisc_deref(ld); 2311 2315 return 0; 2312 2316 } ··· 3437 3437 kref_put(&driver->kref, destruct_tty_driver); 3438 3438 } 3439 3439 EXPORT_SYMBOL(tty_driver_kref_put); 3440 - 3441 - void tty_set_operations(struct tty_driver *driver, 3442 - const struct tty_operations *op) 3443 - { 3444 - driver->ops = op; 3445 - }; 3446 - EXPORT_SYMBOL(tty_set_operations); 3447 - 3448 - void put_tty_driver(struct tty_driver *d) 3449 - { 3450 - tty_driver_kref_put(d); 3451 - } 3452 - EXPORT_SYMBOL(put_tty_driver); 3453 3440 3454 3441 /* 3455 3442 * Called by a tty driver to register itself.
+2 -2
drivers/tty/ttynull.c
··· 84 84 85 85 ret = tty_register_driver(driver); 86 86 if (ret < 0) { 87 - put_tty_driver(driver); 87 + tty_driver_kref_put(driver); 88 88 tty_port_destroy(&ttynull_port); 89 89 return ret; 90 90 } ··· 99 99 { 100 100 unregister_console(&ttynull_console); 101 101 tty_unregister_driver(ttynull_driver); 102 - put_tty_driver(ttynull_driver); 102 + tty_driver_kref_put(ttynull_driver); 103 103 tty_port_destroy(&ttynull_port); 104 104 } 105 105
+2 -2
drivers/tty/vcc.c
··· 1028 1028 rv = tty_register_driver(vcc_tty_driver); 1029 1029 if (rv) { 1030 1030 pr_err("VCC: TTY driver registration failed\n"); 1031 - put_tty_driver(vcc_tty_driver); 1031 + tty_driver_kref_put(vcc_tty_driver); 1032 1032 vcc_tty_driver = NULL; 1033 1033 return rv; 1034 1034 } ··· 1041 1041 static void vcc_tty_exit(void) 1042 1042 { 1043 1043 tty_unregister_driver(vcc_tty_driver); 1044 - put_tty_driver(vcc_tty_driver); 1044 + tty_driver_kref_put(vcc_tty_driver); 1045 1045 vccdbg("VCC: TTY driver unregistered\n"); 1046 1046 1047 1047 vcc_tty_driver = NULL;
+31 -31
drivers/tty/vt/keyboard.c
··· 1171 1171 * 1172 1172 * Check the status of a keyboard led flag and report it back 1173 1173 */ 1174 - int vt_get_leds(int console, int flag) 1174 + int vt_get_leds(unsigned int console, int flag) 1175 1175 { 1176 - struct kbd_struct *kb = kbd_table + console; 1176 + struct kbd_struct *kb = &kbd_table[console]; 1177 1177 int ret; 1178 1178 unsigned long flags; 1179 1179 ··· 1193 1193 * Set the LEDs on a console. This is a wrapper for the VT layer 1194 1194 * so that we can keep kbd knowledge internal 1195 1195 */ 1196 - void vt_set_led_state(int console, int leds) 1196 + void vt_set_led_state(unsigned int console, int leds) 1197 1197 { 1198 - struct kbd_struct *kb = kbd_table + console; 1198 + struct kbd_struct *kb = &kbd_table[console]; 1199 1199 setledstate(kb, leds); 1200 1200 } 1201 1201 ··· 1212 1212 * don't hold the lock. We probably need to split out an LED lock 1213 1213 * but not during an -rc release! 1214 1214 */ 1215 - void vt_kbd_con_start(int console) 1215 + void vt_kbd_con_start(unsigned int console) 1216 1216 { 1217 - struct kbd_struct *kb = kbd_table + console; 1217 + struct kbd_struct *kb = &kbd_table[console]; 1218 1218 unsigned long flags; 1219 1219 spin_lock_irqsave(&led_lock, flags); 1220 1220 clr_vc_kbd_led(kb, VC_SCROLLOCK); ··· 1229 1229 * Handle console stop. This is a wrapper for the VT layer 1230 1230 * so that we can keep kbd knowledge internal 1231 1231 */ 1232 - void vt_kbd_con_stop(int console) 1232 + void vt_kbd_con_stop(unsigned int console) 1233 1233 { 1234 - struct kbd_struct *kb = kbd_table + console; 1234 + struct kbd_struct *kb = &kbd_table[console]; 1235 1235 unsigned long flags; 1236 1236 spin_lock_irqsave(&led_lock, flags); 1237 1237 set_vc_kbd_led(kb, VC_SCROLLOCK); ··· 1377 1377 { 1378 1378 struct vc_data *vc = vc_cons[fg_console].d; 1379 1379 1380 - kbd = kbd_table + vc->vc_num; 1380 + kbd = &kbd_table[vc->vc_num]; 1381 1381 if (kbd->kbdmode == VC_RAW) 1382 1382 put_queue(vc, data); 1383 1383 } ··· 1400 1400 tty->driver_data = vc; 1401 1401 } 1402 1402 1403 - kbd = kbd_table + vc->vc_num; 1403 + kbd = &kbd_table[vc->vc_num]; 1404 1404 1405 1405 #ifdef CONFIG_SPARC 1406 1406 if (keycode == KEY_STOP) ··· 1825 1825 * Update the keyboard mode bits while holding the correct locks. 1826 1826 * Return 0 for success or an error code. 1827 1827 */ 1828 - int vt_do_kdskbmode(int console, unsigned int arg) 1828 + int vt_do_kdskbmode(unsigned int console, unsigned int arg) 1829 1829 { 1830 - struct kbd_struct *kb = kbd_table + console; 1830 + struct kbd_struct *kb = &kbd_table[console]; 1831 1831 int ret = 0; 1832 1832 unsigned long flags; 1833 1833 ··· 1865 1865 * Update the keyboard meta bits while holding the correct locks. 1866 1866 * Return 0 for success or an error code. 1867 1867 */ 1868 - int vt_do_kdskbmeta(int console, unsigned int arg) 1868 + int vt_do_kdskbmeta(unsigned int console, unsigned int arg) 1869 1869 { 1870 - struct kbd_struct *kb = kbd_table + console; 1870 + struct kbd_struct *kb = &kbd_table[console]; 1871 1871 int ret = 0; 1872 1872 unsigned long flags; 1873 1873 ··· 2008 2008 } 2009 2009 2010 2010 int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, 2011 - int console) 2011 + unsigned int console) 2012 2012 { 2013 - struct kbd_struct *kb = kbd_table + console; 2013 + struct kbd_struct *kb = &kbd_table[console]; 2014 2014 struct kbentry kbe; 2015 2015 2016 2016 if (copy_from_user(&kbe, user_kbe, sizeof(struct kbentry))) ··· 2097 2097 return ret; 2098 2098 } 2099 2099 2100 - int vt_do_kdskled(int console, int cmd, unsigned long arg, int perm) 2100 + int vt_do_kdskled(unsigned int console, int cmd, unsigned long arg, int perm) 2101 2101 { 2102 - struct kbd_struct *kb = kbd_table + console; 2102 + struct kbd_struct *kb = &kbd_table[console]; 2103 2103 unsigned long flags; 2104 2104 unsigned char ucval; 2105 2105 ··· 2139 2139 return -ENOIOCTLCMD; 2140 2140 } 2141 2141 2142 - int vt_do_kdgkbmode(int console) 2142 + int vt_do_kdgkbmode(unsigned int console) 2143 2143 { 2144 - struct kbd_struct *kb = kbd_table + console; 2144 + struct kbd_struct *kb = &kbd_table[console]; 2145 2145 /* This is a spot read so needs no locking */ 2146 2146 switch (kb->kbdmode) { 2147 2147 case VC_RAW: ··· 2163 2163 * 2164 2164 * Report the meta flag status of this console 2165 2165 */ 2166 - int vt_do_kdgkbmeta(int console) 2166 + int vt_do_kdgkbmeta(unsigned int console) 2167 2167 { 2168 - struct kbd_struct *kb = kbd_table + console; 2168 + struct kbd_struct *kb = &kbd_table[console]; 2169 2169 /* Again a spot read so no locking */ 2170 2170 return vc_kbd_mode(kb, VC_META) ? K_ESCPREFIX : K_METABIT; 2171 2171 } ··· 2176 2176 * 2177 2177 * Restore the unicode console state to its default 2178 2178 */ 2179 - void vt_reset_unicode(int console) 2179 + void vt_reset_unicode(unsigned int console) 2180 2180 { 2181 2181 unsigned long flags; 2182 2182 ··· 2204 2204 * Reset the keyboard bits for a console as part of a general console 2205 2205 * reset event 2206 2206 */ 2207 - void vt_reset_keyboard(int console) 2207 + void vt_reset_keyboard(unsigned int console) 2208 2208 { 2209 - struct kbd_struct *kb = kbd_table + console; 2209 + struct kbd_struct *kb = &kbd_table[console]; 2210 2210 unsigned long flags; 2211 2211 2212 2212 spin_lock_irqsave(&kbd_event_lock, flags); ··· 2234 2234 * caller must be sure that there are no synchronization needs 2235 2235 */ 2236 2236 2237 - int vt_get_kbd_mode_bit(int console, int bit) 2237 + int vt_get_kbd_mode_bit(unsigned int console, int bit) 2238 2238 { 2239 - struct kbd_struct *kb = kbd_table + console; 2239 + struct kbd_struct *kb = &kbd_table[console]; 2240 2240 return vc_kbd_mode(kb, bit); 2241 2241 } 2242 2242 ··· 2249 2249 * caller must be sure that there are no synchronization needs 2250 2250 */ 2251 2251 2252 - void vt_set_kbd_mode_bit(int console, int bit) 2252 + void vt_set_kbd_mode_bit(unsigned int console, int bit) 2253 2253 { 2254 - struct kbd_struct *kb = kbd_table + console; 2254 + struct kbd_struct *kb = &kbd_table[console]; 2255 2255 unsigned long flags; 2256 2256 2257 2257 spin_lock_irqsave(&kbd_event_lock, flags); ··· 2268 2268 * caller must be sure that there are no synchronization needs 2269 2269 */ 2270 2270 2271 - void vt_clr_kbd_mode_bit(int console, int bit) 2271 + void vt_clr_kbd_mode_bit(unsigned int console, int bit) 2272 2272 { 2273 - struct kbd_struct *kb = kbd_table + console; 2273 + struct kbd_struct *kb = &kbd_table[console]; 2274 2274 unsigned long flags; 2275 2275 2276 2276 spin_lock_irqsave(&kbd_event_lock, flags);
+22 -5
drivers/tty/vt/vt.c
··· 1219 1219 new_row_size = new_cols << 1; 1220 1220 new_screen_size = new_row_size * new_rows; 1221 1221 1222 - if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) 1223 - return 0; 1222 + if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) { 1223 + /* 1224 + * This function is being called here to cover the case 1225 + * where the userspace calls the FBIOPUT_VSCREENINFO twice, 1226 + * passing the same fb_var_screeninfo containing the fields 1227 + * yres/xres equal to a number non-multiple of vc_font.height 1228 + * and yres_virtual/xres_virtual equal to number lesser than the 1229 + * vc_font.height and yres/xres. 1230 + * In the second call, the struct fb_var_screeninfo isn't 1231 + * being modified by the underlying driver because of the 1232 + * if above, and this causes the fbcon_display->vrows to become 1233 + * negative and it eventually leads to out-of-bound 1234 + * access by the imageblit function. 1235 + * To give the correct values to the struct and to not have 1236 + * to deal with possible errors from the code below, we call 1237 + * the resize_screen here as well. 1238 + */ 1239 + return resize_screen(vc, new_cols, new_rows, user); 1240 + } 1224 1241 1225 1242 if (new_screen_size > KMALLOC_MAX_SIZE || !new_screen_size) 1226 1243 return -EINVAL; ··· 3599 3582 3600 3583 vcs_init(); 3601 3584 3602 - console_driver = alloc_tty_driver(MAX_NR_CONSOLES); 3603 - if (!console_driver) 3585 + console_driver = tty_alloc_driver(MAX_NR_CONSOLES, TTY_DRIVER_REAL_RAW | 3586 + TTY_DRIVER_RESET_TERMIOS); 3587 + if (IS_ERR(console_driver)) 3604 3588 panic("Couldn't allocate console driver\n"); 3605 3589 3606 3590 console_driver->name = "tty"; ··· 3612 3594 console_driver->init_termios = tty_std_termios; 3613 3595 if (default_utf8) 3614 3596 console_driver->init_termios.c_iflag |= IUTF8; 3615 - console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; 3616 3597 tty_set_operations(console_driver, &con_ops); 3617 3598 if (tty_register_driver(console_driver)) 3618 3599 panic("Couldn't register console driver\n");
+7 -7
drivers/usb/class/cdc-acm.c
··· 2027 2027 static int __init acm_init(void) 2028 2028 { 2029 2029 int retval; 2030 - acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS); 2031 - if (!acm_tty_driver) 2032 - return -ENOMEM; 2030 + acm_tty_driver = tty_alloc_driver(ACM_TTY_MINORS, TTY_DRIVER_REAL_RAW | 2031 + TTY_DRIVER_DYNAMIC_DEV); 2032 + if (IS_ERR(acm_tty_driver)) 2033 + return PTR_ERR(acm_tty_driver); 2033 2034 acm_tty_driver->driver_name = "acm", 2034 2035 acm_tty_driver->name = "ttyACM", 2035 2036 acm_tty_driver->major = ACM_TTY_MAJOR, 2036 2037 acm_tty_driver->minor_start = 0, 2037 2038 acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL, 2038 2039 acm_tty_driver->subtype = SERIAL_TYPE_NORMAL, 2039 - acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 2040 2040 acm_tty_driver->init_termios = tty_std_termios; 2041 2041 acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | 2042 2042 HUPCL | CLOCAL; ··· 2044 2044 2045 2045 retval = tty_register_driver(acm_tty_driver); 2046 2046 if (retval) { 2047 - put_tty_driver(acm_tty_driver); 2047 + tty_driver_kref_put(acm_tty_driver); 2048 2048 return retval; 2049 2049 } 2050 2050 2051 2051 retval = usb_register(&acm_driver); 2052 2052 if (retval) { 2053 2053 tty_unregister_driver(acm_tty_driver); 2054 - put_tty_driver(acm_tty_driver); 2054 + tty_driver_kref_put(acm_tty_driver); 2055 2055 return retval; 2056 2056 } 2057 2057 ··· 2064 2064 { 2065 2065 usb_deregister(&acm_driver); 2066 2066 tty_unregister_driver(acm_tty_driver); 2067 - put_tty_driver(acm_tty_driver); 2067 + tty_driver_kref_put(acm_tty_driver); 2068 2068 idr_destroy(&acm_minors); 2069 2069 } 2070 2070
+19 -17
drivers/usb/gadget/function/u_serial.c
··· 1445 1445 1446 1446 static int userial_init(void) 1447 1447 { 1448 + struct tty_driver *driver; 1448 1449 unsigned i; 1449 1450 int status; 1450 1451 1451 - gs_tty_driver = alloc_tty_driver(MAX_U_SERIAL_PORTS); 1452 - if (!gs_tty_driver) 1453 - return -ENOMEM; 1452 + driver = tty_alloc_driver(MAX_U_SERIAL_PORTS, TTY_DRIVER_REAL_RAW | 1453 + TTY_DRIVER_DYNAMIC_DEV); 1454 + if (IS_ERR(driver)) 1455 + return PTR_ERR(driver); 1454 1456 1455 - gs_tty_driver->driver_name = "g_serial"; 1456 - gs_tty_driver->name = "ttyGS"; 1457 + driver->driver_name = "g_serial"; 1458 + driver->name = "ttyGS"; 1457 1459 /* uses dynamically assigned dev_t values */ 1458 1460 1459 - gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1460 - gs_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1461 - gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 1462 - gs_tty_driver->init_termios = tty_std_termios; 1461 + driver->type = TTY_DRIVER_TYPE_SERIAL; 1462 + driver->subtype = SERIAL_TYPE_NORMAL; 1463 + driver->init_termios = tty_std_termios; 1463 1464 1464 1465 /* 9600-8-N-1 ... matches defaults expected by "usbser.sys" on 1465 1466 * MS-Windows. Otherwise, most of these flags shouldn't affect 1466 1467 * anything unless we were to actually hook up to a serial line. 1467 1468 */ 1468 - gs_tty_driver->init_termios.c_cflag = 1469 + driver->init_termios.c_cflag = 1469 1470 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1470 - gs_tty_driver->init_termios.c_ispeed = 9600; 1471 - gs_tty_driver->init_termios.c_ospeed = 9600; 1471 + driver->init_termios.c_ispeed = 9600; 1472 + driver->init_termios.c_ospeed = 9600; 1472 1473 1473 - tty_set_operations(gs_tty_driver, &gs_tty_ops); 1474 + tty_set_operations(driver, &gs_tty_ops); 1474 1475 for (i = 0; i < MAX_U_SERIAL_PORTS; i++) 1475 1476 mutex_init(&ports[i].lock); 1476 1477 1477 1478 /* export the driver ... */ 1478 - status = tty_register_driver(gs_tty_driver); 1479 + status = tty_register_driver(driver); 1479 1480 if (status) { 1480 1481 pr_err("%s: cannot register, err %d\n", 1481 1482 __func__, status); 1482 1483 goto fail; 1483 1484 } 1485 + 1486 + gs_tty_driver = driver; 1484 1487 1485 1488 pr_debug("%s: registered %d ttyGS* device%s\n", __func__, 1486 1489 MAX_U_SERIAL_PORTS, ··· 1491 1488 1492 1489 return status; 1493 1490 fail: 1494 - put_tty_driver(gs_tty_driver); 1495 - gs_tty_driver = NULL; 1491 + tty_driver_kref_put(driver); 1496 1492 return status; 1497 1493 } 1498 1494 module_init(userial_init); ··· 1499 1497 static void userial_cleanup(void) 1500 1498 { 1501 1499 tty_unregister_driver(gs_tty_driver); 1502 - put_tty_driver(gs_tty_driver); 1500 + tty_driver_kref_put(gs_tty_driver); 1503 1501 gs_tty_driver = NULL; 1504 1502 } 1505 1503 module_exit(userial_cleanup);
+2 -2
drivers/usb/host/xhci-dbgtty.c
··· 541 541 ret = tty_register_driver(dbc_tty_driver); 542 542 if (ret) { 543 543 pr_err("Can't register dbc tty driver\n"); 544 - put_tty_driver(dbc_tty_driver); 544 + tty_driver_kref_put(dbc_tty_driver); 545 545 } 546 546 return ret; 547 547 } ··· 550 550 { 551 551 if (dbc_tty_driver) { 552 552 tty_unregister_driver(dbc_tty_driver); 553 - put_tty_driver(dbc_tty_driver); 553 + tty_driver_kref_put(dbc_tty_driver); 554 554 dbc_tty_driver = NULL; 555 555 } 556 556 }
+6 -7
drivers/usb/serial/usb-serial.c
··· 1319 1319 { 1320 1320 int result; 1321 1321 1322 - usb_serial_tty_driver = alloc_tty_driver(USB_SERIAL_TTY_MINORS); 1323 - if (!usb_serial_tty_driver) 1324 - return -ENOMEM; 1322 + usb_serial_tty_driver = tty_alloc_driver(USB_SERIAL_TTY_MINORS, 1323 + TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); 1324 + if (IS_ERR(usb_serial_tty_driver)) 1325 + return PTR_ERR(usb_serial_tty_driver); 1325 1326 1326 1327 /* Initialize our global data */ 1327 1328 result = bus_register(&usb_serial_bus_type); ··· 1337 1336 usb_serial_tty_driver->minor_start = 0; 1338 1337 usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1339 1338 usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1340 - usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | 1341 - TTY_DRIVER_DYNAMIC_DEV; 1342 1339 usb_serial_tty_driver->init_termios = tty_std_termios; 1343 1340 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD 1344 1341 | HUPCL | CLOCAL; ··· 1366 1367 1367 1368 exit_bus: 1368 1369 pr_err("%s - returning with error %d\n", __func__, result); 1369 - put_tty_driver(usb_serial_tty_driver); 1370 + tty_driver_kref_put(usb_serial_tty_driver); 1370 1371 return result; 1371 1372 } 1372 1373 ··· 1378 1379 usb_serial_generic_deregister(); 1379 1380 1380 1381 tty_unregister_driver(usb_serial_tty_driver); 1381 - put_tty_driver(usb_serial_tty_driver); 1382 + tty_driver_kref_put(usb_serial_tty_driver); 1382 1383 bus_unregister(&usb_serial_bus_type); 1383 1384 idr_destroy(&serial_minors); 1384 1385 }
+14
include/linux/serdev.h
··· 327 327 } 328 328 #endif /* CONFIG_SERIAL_DEV_CTRL_TTYPORT */ 329 329 330 + struct acpi_resource; 331 + struct acpi_resource_uart_serialbus; 332 + 333 + #ifdef CONFIG_ACPI 334 + bool serdev_acpi_get_uart_resource(struct acpi_resource *ares, 335 + struct acpi_resource_uart_serialbus **uart); 336 + #else 337 + static inline bool serdev_acpi_get_uart_resource(struct acpi_resource *ares, 338 + struct acpi_resource_uart_serialbus **uart) 339 + { 340 + return false; 341 + } 342 + #endif /* CONFIG_ACPI */ 343 + 330 344 #endif /*_LINUX_SERDEV_H */
+9
include/linux/serial_s3c.h
··· 27 27 #define S3C2410_UERSTAT (0x14) 28 28 #define S3C2410_UFSTAT (0x18) 29 29 #define S3C2410_UMSTAT (0x1C) 30 + #define USI_CON (0xC4) 31 + #define USI_OPTION (0xC8) 32 + 33 + #define USI_CON_RESET (1<<0) 34 + #define USI_CON_RESET_MASK (1<<0) 35 + 36 + #define USI_OPTION_HWACG_CLKREQ_ON (1<<1) 37 + #define USI_OPTION_HWACG_CLKSTOP_ON (1<<2) 38 + #define USI_OPTION_HWACG_MASK (3<<1) 30 39 31 40 #define S3C2410_LCON_CFGMASK ((0xF<<3)|(0x3)) 32 41
+2 -273
include/linux/tty.h
··· 6 6 #include <linux/major.h> 7 7 #include <linux/termios.h> 8 8 #include <linux/workqueue.h> 9 + #include <linux/tty_buffer.h> 9 10 #include <linux/tty_driver.h> 10 11 #include <linux/tty_ldisc.h> 12 + #include <linux/tty_port.h> 11 13 #include <linux/mutex.h> 12 14 #include <linux/tty_flags.h> 13 - #include <linux/seq_file.h> 14 15 #include <uapi/linux/tty.h> 15 16 #include <linux/rwsem.h> 16 17 #include <linux/llist.h> ··· 31 30 * isn't in use (eg VINTR has no character etc) 32 31 */ 33 32 #define __DISABLED_CHAR '\0' 34 - 35 - struct tty_buffer { 36 - union { 37 - struct tty_buffer *next; 38 - struct llist_node free; 39 - }; 40 - int used; 41 - int size; 42 - int commit; 43 - int read; 44 - int flags; 45 - /* Data points here */ 46 - unsigned long data[]; 47 - }; 48 - 49 - /* Values for .flags field of tty_buffer */ 50 - #define TTYB_NORMAL 1 /* buffer has no flags buffer */ 51 - 52 - static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs) 53 - { 54 - return ((unsigned char *)b->data) + ofs; 55 - } 56 - 57 - static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs) 58 - { 59 - return (char *)char_buf_ptr(b, ofs) + b->size; 60 - } 61 - 62 - struct tty_bufhead { 63 - struct tty_buffer *head; /* Queue head */ 64 - struct work_struct work; 65 - struct mutex lock; 66 - atomic_t priority; 67 - struct tty_buffer sentinel; 68 - struct llist_head free; /* Free queue head */ 69 - atomic_t mem_used; /* In-use buffers excluding free list */ 70 - int mem_limit; 71 - struct tty_buffer *tail; /* Active buffer */ 72 - }; 73 - /* 74 - * When a break, frame error, or parity error happens, these codes are 75 - * stuffed into the flags buffer. 76 - */ 77 - #define TTY_NORMAL 0 78 - #define TTY_BREAK 1 79 - #define TTY_FRAME 2 80 - #define TTY_PARITY 3 81 - #define TTY_OVERRUN 4 82 33 83 34 #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR]) 84 35 #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT]) ··· 117 164 118 165 struct device; 119 166 struct signal_struct; 120 - 121 - /* 122 - * Port level information. Each device keeps its own port level information 123 - * so provide a common structure for those ports wanting to use common support 124 - * routines. 125 - * 126 - * The tty port has a different lifetime to the tty so must be kept apart. 127 - * In addition be careful as tty -> port mappings are valid for the life 128 - * of the tty object but in many cases port -> tty mappings are valid only 129 - * until a hangup so don't use the wrong path. 130 - */ 131 - 132 - struct tty_port; 133 - 134 - struct tty_port_operations { 135 - /* Return 1 if the carrier is raised */ 136 - int (*carrier_raised)(struct tty_port *port); 137 - /* Control the DTR line */ 138 - void (*dtr_rts)(struct tty_port *port, int raise); 139 - /* Called when the last close completes or a hangup finishes 140 - IFF the port was initialized. Do not use to free resources. Called 141 - under the port mutex to serialize against activate/shutdowns */ 142 - void (*shutdown)(struct tty_port *port); 143 - /* Called under the port mutex from tty_port_open, serialized using 144 - the port mutex */ 145 - /* FIXME: long term getting the tty argument *out* of this would be 146 - good for consoles */ 147 - int (*activate)(struct tty_port *port, struct tty_struct *tty); 148 - /* Called on the final put of a port */ 149 - void (*destruct)(struct tty_port *port); 150 - }; 151 - 152 - struct tty_port_client_operations { 153 - int (*receive_buf)(struct tty_port *port, const unsigned char *, const unsigned char *, size_t); 154 - void (*write_wakeup)(struct tty_port *port); 155 - }; 156 - 157 - extern const struct tty_port_client_operations tty_port_default_client_ops; 158 - 159 - struct tty_port { 160 - struct tty_bufhead buf; /* Locked internally */ 161 - struct tty_struct *tty; /* Back pointer */ 162 - struct tty_struct *itty; /* internal back ptr */ 163 - const struct tty_port_operations *ops; /* Port operations */ 164 - const struct tty_port_client_operations *client_ops; /* Port client operations */ 165 - spinlock_t lock; /* Lock protecting tty field */ 166 - int blocked_open; /* Waiting to open */ 167 - int count; /* Usage count */ 168 - wait_queue_head_t open_wait; /* Open waiters */ 169 - wait_queue_head_t delta_msr_wait; /* Modem status change */ 170 - unsigned long flags; /* User TTY flags ASYNC_ */ 171 - unsigned long iflags; /* Internal flags TTY_PORT_ */ 172 - unsigned char console:1; /* port is a console */ 173 - struct mutex mutex; /* Locking */ 174 - struct mutex buf_mutex; /* Buffer alloc lock */ 175 - unsigned char *xmit_buf; /* Optional buffer */ 176 - unsigned int close_delay; /* Close port delay */ 177 - unsigned int closing_wait; /* Delay for output */ 178 - int drain_delay; /* Set to zero if no pure time 179 - based drain is needed else 180 - set to size of fifo */ 181 - struct kref kref; /* Ref counter */ 182 - void *client_data; 183 - }; 184 - 185 - /* tty_port::iflags bits -- use atomic bit ops */ 186 - #define TTY_PORT_INITIALIZED 0 /* device is initialized */ 187 - #define TTY_PORT_SUSPENDED 1 /* device is suspended */ 188 - #define TTY_PORT_ACTIVE 2 /* device is open */ 189 - 190 - /* 191 - * uart drivers: use the uart_port::status field and the UPSTAT_* defines 192 - * for s/w-based flow control steering and carrier detection status 193 - */ 194 - #define TTY_PORT_CTS_FLOW 3 /* h/w flow control enabled */ 195 - #define TTY_PORT_CHECK_CD 4 /* carrier detect enabled */ 196 - #define TTY_PORT_KOPENED 5 /* device exclusively opened by 197 - kernel */ 198 - 199 167 struct tty_operations; 200 168 201 169 /** ··· 320 446 extern void tty_wait_until_sent(struct tty_struct *tty, long timeout); 321 447 extern void stop_tty(struct tty_struct *tty); 322 448 extern void start_tty(struct tty_struct *tty); 323 - extern int tty_register_driver(struct tty_driver *driver); 324 - extern void tty_unregister_driver(struct tty_driver *driver); 325 - extern struct device *tty_register_device(struct tty_driver *driver, 326 - unsigned index, struct device *dev); 327 - extern struct device *tty_register_device_attr(struct tty_driver *driver, 328 - unsigned index, struct device *device, 329 - void *drvdata, 330 - const struct attribute_group **attr_grp); 331 - extern void tty_unregister_device(struct tty_driver *driver, unsigned index); 332 449 extern void tty_write_message(struct tty_struct *tty, char *msg); 333 450 extern int tty_send_xchar(struct tty_struct *tty, char ch); 334 451 extern int tty_put_char(struct tty_struct *tty, unsigned char c); ··· 367 502 extern int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); 368 503 extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); 369 504 370 - extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); 371 - extern void tty_ldisc_deref(struct tty_ldisc *); 372 - extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); 373 - extern const struct seq_operations tty_ldiscs_seq_ops; 374 - 375 505 extern void tty_wakeup(struct tty_struct *tty); 376 - extern void tty_ldisc_flush(struct tty_struct *tty); 377 506 378 507 extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 379 508 unsigned int cmd, unsigned long arg); ··· 380 521 struct tty_struct *tty); 381 522 382 523 extern struct mutex tty_mutex; 383 - 384 - extern void tty_port_init(struct tty_port *port); 385 - extern void tty_port_link_device(struct tty_port *port, 386 - struct tty_driver *driver, unsigned index); 387 - extern struct device *tty_port_register_device(struct tty_port *port, 388 - struct tty_driver *driver, unsigned index, 389 - struct device *device); 390 - extern struct device *tty_port_register_device_attr(struct tty_port *port, 391 - struct tty_driver *driver, unsigned index, 392 - struct device *device, void *drvdata, 393 - const struct attribute_group **attr_grp); 394 - extern struct device *tty_port_register_device_serdev(struct tty_port *port, 395 - struct tty_driver *driver, unsigned index, 396 - struct device *device); 397 - extern struct device *tty_port_register_device_attr_serdev(struct tty_port *port, 398 - struct tty_driver *driver, unsigned index, 399 - struct device *device, void *drvdata, 400 - const struct attribute_group **attr_grp); 401 - extern void tty_port_unregister_device(struct tty_port *port, 402 - struct tty_driver *driver, unsigned index); 403 - extern int tty_port_alloc_xmit_buf(struct tty_port *port); 404 - extern void tty_port_free_xmit_buf(struct tty_port *port); 405 - extern void tty_port_destroy(struct tty_port *port); 406 - extern void tty_port_put(struct tty_port *port); 407 - 408 - static inline struct tty_port *tty_port_get(struct tty_port *port) 409 - { 410 - if (port && kref_get_unless_zero(&port->kref)) 411 - return port; 412 - return NULL; 413 - } 414 - 415 - /* If the cts flow control is enabled, return true. */ 416 - static inline bool tty_port_cts_enabled(const struct tty_port *port) 417 - { 418 - return test_bit(TTY_PORT_CTS_FLOW, &port->iflags); 419 - } 420 - 421 - static inline void tty_port_set_cts_flow(struct tty_port *port, bool val) 422 - { 423 - assign_bit(TTY_PORT_CTS_FLOW, &port->iflags, val); 424 - } 425 - 426 - static inline bool tty_port_active(const struct tty_port *port) 427 - { 428 - return test_bit(TTY_PORT_ACTIVE, &port->iflags); 429 - } 430 - 431 - static inline void tty_port_set_active(struct tty_port *port, bool val) 432 - { 433 - assign_bit(TTY_PORT_ACTIVE, &port->iflags, val); 434 - } 435 - 436 - static inline bool tty_port_check_carrier(const struct tty_port *port) 437 - { 438 - return test_bit(TTY_PORT_CHECK_CD, &port->iflags); 439 - } 440 - 441 - static inline void tty_port_set_check_carrier(struct tty_port *port, bool val) 442 - { 443 - assign_bit(TTY_PORT_CHECK_CD, &port->iflags, val); 444 - } 445 - 446 - static inline bool tty_port_suspended(const struct tty_port *port) 447 - { 448 - return test_bit(TTY_PORT_SUSPENDED, &port->iflags); 449 - } 450 - 451 - static inline void tty_port_set_suspended(struct tty_port *port, bool val) 452 - { 453 - assign_bit(TTY_PORT_SUSPENDED, &port->iflags, val); 454 - } 455 - 456 - static inline bool tty_port_initialized(const struct tty_port *port) 457 - { 458 - return test_bit(TTY_PORT_INITIALIZED, &port->iflags); 459 - } 460 - 461 - static inline void tty_port_set_initialized(struct tty_port *port, bool val) 462 - { 463 - assign_bit(TTY_PORT_INITIALIZED, &port->iflags, val); 464 - } 465 - 466 - static inline bool tty_port_kopened(const struct tty_port *port) 467 - { 468 - return test_bit(TTY_PORT_KOPENED, &port->iflags); 469 - } 470 - 471 - static inline void tty_port_set_kopened(struct tty_port *port, bool val) 472 - { 473 - assign_bit(TTY_PORT_KOPENED, &port->iflags, val); 474 - } 475 - 476 - extern struct tty_struct *tty_port_tty_get(struct tty_port *port); 477 - extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 478 - extern int tty_port_carrier_raised(struct tty_port *port); 479 - extern void tty_port_raise_dtr_rts(struct tty_port *port); 480 - extern void tty_port_lower_dtr_rts(struct tty_port *port); 481 - extern void tty_port_hangup(struct tty_port *port); 482 - extern void tty_port_tty_hangup(struct tty_port *port, bool check_clocal); 483 - extern void tty_port_tty_wakeup(struct tty_port *port); 484 - extern int tty_port_block_til_ready(struct tty_port *port, 485 - struct tty_struct *tty, struct file *filp); 486 - extern int tty_port_close_start(struct tty_port *port, 487 - struct tty_struct *tty, struct file *filp); 488 - extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); 489 - extern void tty_port_close(struct tty_port *port, 490 - struct tty_struct *tty, struct file *filp); 491 - extern int tty_port_install(struct tty_port *port, struct tty_driver *driver, 492 - struct tty_struct *tty); 493 - extern int tty_port_open(struct tty_port *port, 494 - struct tty_struct *tty, struct file *filp); 495 - static inline int tty_port_users(struct tty_port *port) 496 - { 497 - return port->count + port->blocked_open; 498 - } 499 - 500 - extern int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc); 501 - extern void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc); 502 - extern int tty_set_ldisc(struct tty_struct *tty, int disc); 503 - extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 504 - const char *f, int count); 505 524 506 525 /* n_tty.c */ 507 526 extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops); ··· 427 690 extern void tty_lock_slave(struct tty_struct *tty); 428 691 extern void tty_unlock_slave(struct tty_struct *tty); 429 692 extern void tty_set_lock_subclass(struct tty_struct *tty); 430 - 431 - #ifdef CONFIG_PROC_FS 432 - extern void proc_tty_register_driver(struct tty_driver *); 433 - extern void proc_tty_unregister_driver(struct tty_driver *); 434 - #else 435 - static inline void proc_tty_register_driver(struct tty_driver *d) {} 436 - static inline void proc_tty_unregister_driver(struct tty_driver *d) {} 437 - #endif 438 693 439 694 #endif
+59
include/linux/tty_buffer.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_TTY_BUFFER_H 3 + #define _LINUX_TTY_BUFFER_H 4 + 5 + #include <linux/atomic.h> 6 + #include <linux/llist.h> 7 + #include <linux/mutex.h> 8 + #include <linux/workqueue.h> 9 + 10 + struct tty_buffer { 11 + union { 12 + struct tty_buffer *next; 13 + struct llist_node free; 14 + }; 15 + int used; 16 + int size; 17 + int commit; 18 + int read; 19 + int flags; 20 + /* Data points here */ 21 + unsigned long data[]; 22 + }; 23 + 24 + /* Values for .flags field of tty_buffer */ 25 + #define TTYB_NORMAL 1 /* buffer has no flags buffer */ 26 + 27 + static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs) 28 + { 29 + return ((unsigned char *)b->data) + ofs; 30 + } 31 + 32 + static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs) 33 + { 34 + return (char *)char_buf_ptr(b, ofs) + b->size; 35 + } 36 + 37 + struct tty_bufhead { 38 + struct tty_buffer *head; /* Queue head */ 39 + struct work_struct work; 40 + struct mutex lock; 41 + atomic_t priority; 42 + struct tty_buffer sentinel; 43 + struct llist_head free; /* Free queue head */ 44 + atomic_t mem_used; /* In-use buffers excluding free list */ 45 + int mem_limit; 46 + struct tty_buffer *tail; /* Active buffer */ 47 + }; 48 + 49 + /* 50 + * When a break, frame error, or parity error happens, these codes are 51 + * stuffed into the flags buffer. 52 + */ 53 + #define TTY_NORMAL 0 54 + #define TTY_BREAK 1 55 + #define TTY_FRAME 2 56 + #define TTY_PARITY 3 57 + #define TTY_OVERRUN 4 58 + 59 + #endif
+24 -15
include/linux/tty_driver.h
··· 233 233 234 234 #include <linux/export.h> 235 235 #include <linux/fs.h> 236 + #include <linux/kref.h> 236 237 #include <linux/list.h> 237 238 #include <linux/cdev.h> 238 239 #include <linux/termios.h> ··· 329 328 330 329 extern struct tty_driver *__tty_alloc_driver(unsigned int lines, 331 330 struct module *owner, unsigned long flags); 332 - extern void put_tty_driver(struct tty_driver *driver); 333 - extern void tty_set_operations(struct tty_driver *driver, 334 - const struct tty_operations *op); 335 331 extern struct tty_driver *tty_find_polling_driver(char *name, int *line); 336 332 337 333 extern void tty_driver_kref_put(struct tty_driver *driver); ··· 337 339 #define tty_alloc_driver(lines, flags) \ 338 340 __tty_alloc_driver(lines, THIS_MODULE, flags) 339 341 340 - /* 341 - * DEPRECATED Do not use this in new code, use tty_alloc_driver instead. 342 - * (And change the return value checks.) 343 - */ 344 - static inline struct tty_driver *alloc_tty_driver(unsigned int lines) 345 - { 346 - struct tty_driver *ret = tty_alloc_driver(lines, 0); 347 - if (IS_ERR(ret)) 348 - return NULL; 349 - return ret; 350 - } 351 - 352 342 static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d) 353 343 { 354 344 kref_get(&d->kref); 355 345 return d; 346 + } 347 + 348 + static inline void tty_set_operations(struct tty_driver *driver, 349 + const struct tty_operations *op) 350 + { 351 + driver->ops = op; 356 352 } 357 353 358 354 /* tty driver magic number */ ··· 425 433 426 434 /* serial subtype definitions */ 427 435 #define SERIAL_TYPE_NORMAL 1 436 + 437 + int tty_register_driver(struct tty_driver *driver); 438 + void tty_unregister_driver(struct tty_driver *driver); 439 + struct device *tty_register_device(struct tty_driver *driver, unsigned index, 440 + struct device *dev); 441 + struct device *tty_register_device_attr(struct tty_driver *driver, 442 + unsigned index, struct device *device, void *drvdata, 443 + const struct attribute_group **attr_grp); 444 + void tty_unregister_device(struct tty_driver *driver, unsigned index); 445 + 446 + #ifdef CONFIG_PROC_FS 447 + void proc_tty_register_driver(struct tty_driver *); 448 + void proc_tty_unregister_driver(struct tty_driver *); 449 + #else 450 + static inline void proc_tty_register_driver(struct tty_driver *d) {} 451 + static inline void proc_tty_unregister_driver(struct tty_driver *d) {} 452 + #endif 428 453 429 454 #endif /* #ifdef _LINUX_TTY_DRIVER_H */
+7 -1
include/linux/tty_flip.h
··· 2 2 #ifndef _LINUX_TTY_FLIP_H 3 3 #define _LINUX_TTY_FLIP_H 4 4 5 - #include <linux/tty.h> 5 + #include <linux/tty_buffer.h> 6 + #include <linux/tty_port.h> 7 + 8 + struct tty_ldisc; 6 9 7 10 extern int tty_buffer_set_limit(struct tty_port *port, int limit); 8 11 extern unsigned int tty_buffer_space_avail(struct tty_port *port); ··· 41 38 { 42 39 return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size); 43 40 } 41 + 42 + int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 43 + const char *f, int count); 44 44 45 45 extern void tty_buffer_lock_exclusive(struct tty_port *port); 46 46 extern void tty_buffer_unlock_exclusive(struct tty_port *port);
+17
include/linux/tty_ldisc.h
··· 2 2 #ifndef _LINUX_TTY_LDISC_H 3 3 #define _LINUX_TTY_LDISC_H 4 4 5 + struct tty_struct; 6 + 5 7 /* 6 8 * This structure defines the interface between the tty line discipline 7 9 * implementation and the tty routines. The following routines can be ··· 128 126 #include <linux/fs.h> 129 127 #include <linux/wait.h> 130 128 #include <linux/atomic.h> 129 + #include <linux/list.h> 130 + #include <linux/lockdep.h> 131 + #include <linux/seq_file.h> 131 132 132 133 /* 133 134 * the semaphore definition ··· 224 219 225 220 #define MODULE_ALIAS_LDISC(ldisc) \ 226 221 MODULE_ALIAS("tty-ldisc-" __stringify(ldisc)) 222 + 223 + extern const struct seq_operations tty_ldiscs_seq_ops; 224 + 225 + struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); 226 + void tty_ldisc_deref(struct tty_ldisc *); 227 + struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); 228 + 229 + void tty_ldisc_flush(struct tty_struct *tty); 230 + 231 + int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc); 232 + void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc); 233 + int tty_set_ldisc(struct tty_struct *tty, int disc); 227 234 228 235 #endif /* _LINUX_TTY_LDISC_H */
+208
include/linux/tty_port.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_TTY_PORT_H 3 + #define _LINUX_TTY_PORT_H 4 + 5 + #include <linux/kref.h> 6 + #include <linux/mutex.h> 7 + #include <linux/tty_buffer.h> 8 + #include <linux/wait.h> 9 + 10 + /* 11 + * Port level information. Each device keeps its own port level information 12 + * so provide a common structure for those ports wanting to use common support 13 + * routines. 14 + * 15 + * The tty port has a different lifetime to the tty so must be kept apart. 16 + * In addition be careful as tty -> port mappings are valid for the life 17 + * of the tty object but in many cases port -> tty mappings are valid only 18 + * until a hangup so don't use the wrong path. 19 + */ 20 + 21 + struct attribute_group; 22 + struct tty_driver; 23 + struct tty_port; 24 + struct tty_struct; 25 + 26 + struct tty_port_operations { 27 + /* Return 1 if the carrier is raised */ 28 + int (*carrier_raised)(struct tty_port *port); 29 + /* Control the DTR line */ 30 + void (*dtr_rts)(struct tty_port *port, int raise); 31 + /* Called when the last close completes or a hangup finishes 32 + IFF the port was initialized. Do not use to free resources. Called 33 + under the port mutex to serialize against activate/shutdowns */ 34 + void (*shutdown)(struct tty_port *port); 35 + /* Called under the port mutex from tty_port_open, serialized using 36 + the port mutex */ 37 + /* FIXME: long term getting the tty argument *out* of this would be 38 + good for consoles */ 39 + int (*activate)(struct tty_port *port, struct tty_struct *tty); 40 + /* Called on the final put of a port */ 41 + void (*destruct)(struct tty_port *port); 42 + }; 43 + 44 + struct tty_port_client_operations { 45 + int (*receive_buf)(struct tty_port *port, const unsigned char *, const unsigned char *, size_t); 46 + void (*write_wakeup)(struct tty_port *port); 47 + }; 48 + 49 + extern const struct tty_port_client_operations tty_port_default_client_ops; 50 + 51 + struct tty_port { 52 + struct tty_bufhead buf; /* Locked internally */ 53 + struct tty_struct *tty; /* Back pointer */ 54 + struct tty_struct *itty; /* internal back ptr */ 55 + const struct tty_port_operations *ops; /* Port operations */ 56 + const struct tty_port_client_operations *client_ops; /* Port client operations */ 57 + spinlock_t lock; /* Lock protecting tty field */ 58 + int blocked_open; /* Waiting to open */ 59 + int count; /* Usage count */ 60 + wait_queue_head_t open_wait; /* Open waiters */ 61 + wait_queue_head_t delta_msr_wait; /* Modem status change */ 62 + unsigned long flags; /* User TTY flags ASYNC_ */ 63 + unsigned long iflags; /* Internal flags TTY_PORT_ */ 64 + unsigned char console:1; /* port is a console */ 65 + struct mutex mutex; /* Locking */ 66 + struct mutex buf_mutex; /* Buffer alloc lock */ 67 + unsigned char *xmit_buf; /* Optional buffer */ 68 + unsigned int close_delay; /* Close port delay */ 69 + unsigned int closing_wait; /* Delay for output */ 70 + int drain_delay; /* Set to zero if no pure time 71 + based drain is needed else 72 + set to size of fifo */ 73 + struct kref kref; /* Ref counter */ 74 + void *client_data; 75 + }; 76 + 77 + /* tty_port::iflags bits -- use atomic bit ops */ 78 + #define TTY_PORT_INITIALIZED 0 /* device is initialized */ 79 + #define TTY_PORT_SUSPENDED 1 /* device is suspended */ 80 + #define TTY_PORT_ACTIVE 2 /* device is open */ 81 + 82 + /* 83 + * uart drivers: use the uart_port::status field and the UPSTAT_* defines 84 + * for s/w-based flow control steering and carrier detection status 85 + */ 86 + #define TTY_PORT_CTS_FLOW 3 /* h/w flow control enabled */ 87 + #define TTY_PORT_CHECK_CD 4 /* carrier detect enabled */ 88 + #define TTY_PORT_KOPENED 5 /* device exclusively opened by 89 + kernel */ 90 + 91 + void tty_port_init(struct tty_port *port); 92 + void tty_port_link_device(struct tty_port *port, struct tty_driver *driver, 93 + unsigned index); 94 + struct device *tty_port_register_device(struct tty_port *port, 95 + struct tty_driver *driver, unsigned index, 96 + struct device *device); 97 + struct device *tty_port_register_device_attr(struct tty_port *port, 98 + struct tty_driver *driver, unsigned index, 99 + struct device *device, void *drvdata, 100 + const struct attribute_group **attr_grp); 101 + struct device *tty_port_register_device_serdev(struct tty_port *port, 102 + struct tty_driver *driver, unsigned index, 103 + struct device *device); 104 + struct device *tty_port_register_device_attr_serdev(struct tty_port *port, 105 + struct tty_driver *driver, unsigned index, 106 + struct device *device, void *drvdata, 107 + const struct attribute_group **attr_grp); 108 + void tty_port_unregister_device(struct tty_port *port, 109 + struct tty_driver *driver, unsigned index); 110 + int tty_port_alloc_xmit_buf(struct tty_port *port); 111 + void tty_port_free_xmit_buf(struct tty_port *port); 112 + void tty_port_destroy(struct tty_port *port); 113 + void tty_port_put(struct tty_port *port); 114 + 115 + static inline struct tty_port *tty_port_get(struct tty_port *port) 116 + { 117 + if (port && kref_get_unless_zero(&port->kref)) 118 + return port; 119 + return NULL; 120 + } 121 + 122 + /* If the cts flow control is enabled, return true. */ 123 + static inline bool tty_port_cts_enabled(const struct tty_port *port) 124 + { 125 + return test_bit(TTY_PORT_CTS_FLOW, &port->iflags); 126 + } 127 + 128 + static inline void tty_port_set_cts_flow(struct tty_port *port, bool val) 129 + { 130 + assign_bit(TTY_PORT_CTS_FLOW, &port->iflags, val); 131 + } 132 + 133 + static inline bool tty_port_active(const struct tty_port *port) 134 + { 135 + return test_bit(TTY_PORT_ACTIVE, &port->iflags); 136 + } 137 + 138 + static inline void tty_port_set_active(struct tty_port *port, bool val) 139 + { 140 + assign_bit(TTY_PORT_ACTIVE, &port->iflags, val); 141 + } 142 + 143 + static inline bool tty_port_check_carrier(const struct tty_port *port) 144 + { 145 + return test_bit(TTY_PORT_CHECK_CD, &port->iflags); 146 + } 147 + 148 + static inline void tty_port_set_check_carrier(struct tty_port *port, bool val) 149 + { 150 + assign_bit(TTY_PORT_CHECK_CD, &port->iflags, val); 151 + } 152 + 153 + static inline bool tty_port_suspended(const struct tty_port *port) 154 + { 155 + return test_bit(TTY_PORT_SUSPENDED, &port->iflags); 156 + } 157 + 158 + static inline void tty_port_set_suspended(struct tty_port *port, bool val) 159 + { 160 + assign_bit(TTY_PORT_SUSPENDED, &port->iflags, val); 161 + } 162 + 163 + static inline bool tty_port_initialized(const struct tty_port *port) 164 + { 165 + return test_bit(TTY_PORT_INITIALIZED, &port->iflags); 166 + } 167 + 168 + static inline void tty_port_set_initialized(struct tty_port *port, bool val) 169 + { 170 + assign_bit(TTY_PORT_INITIALIZED, &port->iflags, val); 171 + } 172 + 173 + static inline bool tty_port_kopened(const struct tty_port *port) 174 + { 175 + return test_bit(TTY_PORT_KOPENED, &port->iflags); 176 + } 177 + 178 + static inline void tty_port_set_kopened(struct tty_port *port, bool val) 179 + { 180 + assign_bit(TTY_PORT_KOPENED, &port->iflags, val); 181 + } 182 + 183 + struct tty_struct *tty_port_tty_get(struct tty_port *port); 184 + void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 185 + int tty_port_carrier_raised(struct tty_port *port); 186 + void tty_port_raise_dtr_rts(struct tty_port *port); 187 + void tty_port_lower_dtr_rts(struct tty_port *port); 188 + void tty_port_hangup(struct tty_port *port); 189 + void tty_port_tty_hangup(struct tty_port *port, bool check_clocal); 190 + void tty_port_tty_wakeup(struct tty_port *port); 191 + int tty_port_block_til_ready(struct tty_port *port, struct tty_struct *tty, 192 + struct file *filp); 193 + int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, 194 + struct file *filp); 195 + void tty_port_close_end(struct tty_port *port, struct tty_struct *tty); 196 + void tty_port_close(struct tty_port *port, struct tty_struct *tty, 197 + struct file *filp); 198 + int tty_port_install(struct tty_port *port, struct tty_driver *driver, 199 + struct tty_struct *tty); 200 + int tty_port_open(struct tty_port *port, struct tty_struct *tty, 201 + struct file *filp); 202 + 203 + static inline int tty_port_users(struct tty_port *port) 204 + { 205 + return port->count + port->blocked_open; 206 + } 207 + 208 + #endif
+15 -15
include/linux/vt_kern.h
··· 148 148 149 149 /* keyboard provided interfaces */ 150 150 int vt_do_diacrit(unsigned int cmd, void __user *up, int eperm); 151 - int vt_do_kdskbmode(int console, unsigned int arg); 152 - int vt_do_kdskbmeta(int console, unsigned int arg); 151 + int vt_do_kdskbmode(unsigned int console, unsigned int arg); 152 + int vt_do_kdskbmeta(unsigned int console, unsigned int arg); 153 153 int vt_do_kbkeycode_ioctl(int cmd, struct kbkeycode __user *user_kbkc, 154 154 int perm); 155 155 int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, 156 - int console); 156 + unsigned int console); 157 157 int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm); 158 - int vt_do_kdskled(int console, int cmd, unsigned long arg, int perm); 159 - int vt_do_kdgkbmode(int console); 160 - int vt_do_kdgkbmeta(int console); 161 - void vt_reset_unicode(int console); 158 + int vt_do_kdskled(unsigned int console, int cmd, unsigned long arg, int perm); 159 + int vt_do_kdgkbmode(unsigned int console); 160 + int vt_do_kdgkbmeta(unsigned int console); 161 + void vt_reset_unicode(unsigned int console); 162 162 int vt_get_shift_state(void); 163 - void vt_reset_keyboard(int console); 164 - int vt_get_leds(int console, int flag); 165 - int vt_get_kbd_mode_bit(int console, int bit); 166 - void vt_set_kbd_mode_bit(int console, int bit); 167 - void vt_clr_kbd_mode_bit(int console, int bit); 168 - void vt_set_led_state(int console, int leds); 169 - void vt_kbd_con_start(int console); 170 - void vt_kbd_con_stop(int console); 163 + void vt_reset_keyboard(unsigned int console); 164 + int vt_get_leds(unsigned int console, int flag); 165 + int vt_get_kbd_mode_bit(unsigned int console, int bit); 166 + void vt_set_kbd_mode_bit(unsigned int console, int bit); 167 + void vt_clr_kbd_mode_bit(unsigned int console, int bit); 168 + void vt_set_led_state(unsigned int console, int leds); 169 + void vt_kbd_con_start(unsigned int console); 170 + void vt_kbd_con_stop(unsigned int console); 171 171 172 172 void vc_scrolldelta_helper(struct vc_data *c, int lines, 173 173 unsigned int rolled_over, void *_base, unsigned int size);
+1
include/uapi/linux/serial_reg.h
··· 62 62 * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654 63 63 * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750 64 64 * TI16C752: 8 16 56 60 8 16 32 56 65 + * OX16C950: 16 32 112 120 16 32 64 112 PORT_16C950 65 66 * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA 66 67 */ 67 68 #define UART_FCR_R_TRIG_00 0x00
+6 -6
net/bluetooth/rfcomm/tty.c
··· 1127 1127 { 1128 1128 int error; 1129 1129 1130 - rfcomm_tty_driver = alloc_tty_driver(RFCOMM_TTY_PORTS); 1131 - if (!rfcomm_tty_driver) 1132 - return -ENOMEM; 1130 + rfcomm_tty_driver = tty_alloc_driver(RFCOMM_TTY_PORTS, 1131 + TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); 1132 + if (IS_ERR(rfcomm_tty_driver)) 1133 + return PTR_ERR(rfcomm_tty_driver); 1133 1134 1134 1135 rfcomm_tty_driver->driver_name = "rfcomm"; 1135 1136 rfcomm_tty_driver->name = "rfcomm"; ··· 1138 1137 rfcomm_tty_driver->minor_start = RFCOMM_TTY_MINOR; 1139 1138 rfcomm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1140 1139 rfcomm_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1141 - rfcomm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 1142 1140 rfcomm_tty_driver->init_termios = tty_std_termios; 1143 1141 rfcomm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL; 1144 1142 rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; ··· 1146 1146 error = tty_register_driver(rfcomm_tty_driver); 1147 1147 if (error) { 1148 1148 BT_ERR("Can't register RFCOMM TTY driver"); 1149 - put_tty_driver(rfcomm_tty_driver); 1149 + tty_driver_kref_put(rfcomm_tty_driver); 1150 1150 return error; 1151 1151 } 1152 1152 ··· 1158 1158 void rfcomm_cleanup_ttys(void) 1159 1159 { 1160 1160 tty_unregister_driver(rfcomm_tty_driver); 1161 - put_tty_driver(rfcomm_tty_driver); 1161 + tty_driver_kref_put(rfcomm_tty_driver); 1162 1162 }