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

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

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

Nothing major in here at all, just lots of tiny serial and tty driver
updates for various reported things, and some good cleanups. These
include:

- more good tty api cleanups from Jiri

- stm32 serial driver updates

- softlockup fix for non-preempt systems under high serial load

- rpmsg serial driver update

- 8250 drivers updates and fixes

- n_gsm line discipline fixes and updates as people are finally
starting to use it.

All of these have been in linux-next for a while now with no reported
issues"

* tag 'tty-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (86 commits)
tty: Fix extra "not" in TTY_DRIVER_REAL_RAW description
serial: cpm_uart: Protect udbg definitions by CONFIG_SERIAL_CPM_CONSOLE
tty: rpmsg: Define tty name via constant string literal
tty: rpmsg: Add pr_fmt() to prefix messages
tty: rpmsg: Use dev_err_probe() in ->probe()
tty: rpmsg: Unify variable used to keep an error code
tty: rpmsg: Assign returned id to a local variable
serial: stm32: push DMA RX data before suspending
serial: stm32: terminate / restart DMA transfer at suspend / resume
serial: stm32: rework RX dma initialization and release
serial: 8250_pci: Remove empty stub pci_quatech_exit()
serial: 8250_pci: Replace custom pci_match_id() implementation
serial: xilinx_uartps: Fix race condition causing stuck TX
serial: sunzilog: Mark sunzilog_putchar() __maybe_unused
Revert "tty: hvc: pass DMA capable memory to put_chars()"
Revert "virtio-console: remove unnecessary kmemdup()"
serial: 8250_pci: Replace dev_*() by pci_*() macros
serial: 8250_pci: Get rid of redundant 'else' keyword
serial: 8250_pci: Refactor the loop in pci_ite887x_init()
tty: add rpmsg driver
...

+1668 -861
+1 -1
Documentation/devicetree/bindings/serial/8250_omap.yaml
··· 86 86 - reg 87 87 - interrupts 88 88 89 - additionalProperties: false 89 + unevaluatedProperties: false 90 90 91 91 if: 92 92 properties:
-36
Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt
··· 1 - * BCM63xx UART 2 - 3 - Required properties: 4 - 5 - - compatible: "brcm,bcm6345-uart" 6 - 7 - - reg: The base address of the UART register bank. 8 - 9 - - interrupts: A single interrupt specifier. 10 - 11 - - clocks: Clock driving the hardware; used to figure out the baud rate 12 - divisor. 13 - 14 - 15 - Optional properties: 16 - 17 - - clock-names: Should be "refclk". 18 - 19 - Example: 20 - 21 - uart0: serial@14e00520 { 22 - compatible = "brcm,bcm6345-uart"; 23 - reg = <0x14e00520 0x18>; 24 - interrupt-parent = <&periph_intc>; 25 - interrupts = <2>; 26 - clocks = <&periph_clk>; 27 - clock-names = "refclk"; 28 - }; 29 - 30 - clocks { 31 - periph_clk: periph_clk@0 { 32 - compatible = "fixed-clock"; 33 - #clock-cells = <0>; 34 - clock-frequency = <54000000>; 35 - }; 36 - };
+47
Documentation/devicetree/bindings/serial/brcm,bcm6345-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/brcm,bcm6345-uart.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: BCM63xx UART 8 + 9 + maintainers: 10 + - Rafał Miłecki <rafal@milecki.pl> 11 + 12 + allOf: 13 + - $ref: serial.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: brcm,bcm6345-uart 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + clocks: 26 + maxItems: 1 27 + 28 + clock-names: 29 + const: refclk 30 + 31 + unevaluatedProperties: false 32 + 33 + required: 34 + - reg 35 + - interrupts 36 + - clocks 37 + 38 + examples: 39 + - | 40 + serial@14e00520 { 41 + compatible = "brcm,bcm6345-uart"; 42 + reg = <0x14e00520 0x18>; 43 + interrupt-parent = <&periph_intc>; 44 + interrupts = <2>; 45 + clocks = <&periph_clk>; 46 + clock-names = "refclk"; 47 + };
+1
Documentation/devicetree/bindings/serial/samsung_uart.yaml
··· 26 26 - samsung,s3c6400-uart 27 27 - samsung,s5pv210-uart 28 28 - samsung,exynos4210-uart 29 + - samsung,exynos850-uart 29 30 30 31 reg: 31 32 maxItems: 1
+1
Documentation/devicetree/bindings/serial/sprd-uart.yaml
··· 19 19 - enum: 20 20 - sprd,sc9860-uart 21 21 - sprd,sc9863a-uart 22 + - sprd,ums512-uart 22 23 - const: sprd,sc9836-uart 23 24 - const: sprd,sc9836-uart 24 25
-23
Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.txt
··· 1 - Xilinx Axi Uartlite controller Device Tree Bindings 2 - --------------------------------------------------------- 3 - 4 - Required properties: 5 - - compatible : Can be either of 6 - "xlnx,xps-uartlite-1.00.a" 7 - "xlnx,opb-uartlite-1.00.b" 8 - - reg : Physical base address and size of the Axi Uartlite 9 - registers map. 10 - - interrupts : Should contain the UART controller interrupt. 11 - 12 - Optional properties: 13 - - port-number : Set Uart port number 14 - - clock-names : Should be "s_axi_aclk" 15 - - clocks : Input clock specifier. Refer to common clock bindings. 16 - 17 - Example: 18 - serial@800c0000 { 19 - compatible = "xlnx,xps-uartlite-1.00.a"; 20 - reg = <0x0 0x800c0000 0x10000>; 21 - interrupts = <0x0 0x6e 0x1>; 22 - port-number = <0>; 23 - };
+89
Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/serial/xlnx,opb-uartlite.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Xilinx Axi Uartlite 8 + 9 + maintainers: 10 + - Peter Korsgaard <jacmet@sunsite.dk> 11 + 12 + properties: 13 + compatible: 14 + contains: 15 + enum: 16 + - xlnx,xps-uartlite-1.00.a 17 + - xlnx,opb-uartlite-1.00.b 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + port-number: 26 + $ref: /schemas/types.yaml#/definitions/uint32 27 + description: Set Uart port number 28 + 29 + clocks: 30 + maxItems: 1 31 + 32 + clock-names: 33 + const: s_axi_aclk 34 + 35 + current-speed: 36 + $ref: /schemas/types.yaml#/definitions/uint32 37 + description: 38 + The fixed baud rate that the device was configured for. 39 + 40 + xlnx,data-bits: 41 + enum: [5, 6, 7, 8] 42 + description: 43 + The fixed number of data bits that the device was configured for. 44 + 45 + xlnx,use-parity: 46 + $ref: /schemas/types.yaml#/definitions/uint32 47 + enum: [0, 1] 48 + description: 49 + Whether parity checking was enabled when the device was configured. 50 + 51 + xlnx,odd-parity: 52 + $ref: /schemas/types.yaml#/definitions/uint32 53 + enum: [0, 1] 54 + description: 55 + Whether odd parity was configured. 56 + 57 + required: 58 + - compatible 59 + - reg 60 + - interrupts 61 + - current-speed 62 + - xlnx,data-bits 63 + - xlnx,use-parity 64 + 65 + allOf: 66 + - $ref: /schemas/serial.yaml# 67 + - if: 68 + properties: 69 + xlnx,use-parity: 70 + contains: 71 + const: 1 72 + then: 73 + required: 74 + - xlnx,odd-parity 75 + 76 + unevaluatedProperties: false 77 + 78 + examples: 79 + - | 80 + serial@800c0000 { 81 + compatible = "xlnx,xps-uartlite-1.00.a"; 82 + reg = <0x800c0000 0x10000>; 83 + interrupts = <0x0 0x6e 0x1>; 84 + port-number = <0>; 85 + current-speed = <115200>; 86 + xlnx,data-bits = <8>; 87 + xlnx,use-parity = <0>; 88 + }; 89 + ...
+62 -9
Documentation/driver-api/serial/n_gsm.rst
··· 12 12 13 13 How to use it 14 14 ------------- 15 - 1. initialize the modem in 0710 mux mode (usually AT+CMUX= command) through 16 - its serial port. Depending on the modem used, you can pass more or less 17 - parameters to this command, 18 - 2. switch the serial line to using the n_gsm line discipline by using 19 - TIOCSETD ioctl, 20 - 3. configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl, 21 - 4. obtain base gsmtty number for the used serial port, 15 + 1. config initiator 16 + ^^^^^^^^^^^^^^^^^^^^^ 17 + 18 + 1.1 initialize the modem in 0710 mux mode (usually AT+CMUX= command) through 19 + its serial port. Depending on the modem used, you can pass more or less 20 + parameters to this command. 21 + 1.2 switch the serial line to using the n_gsm line discipline by using 22 + TIOCSETD ioctl. 23 + 1.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl. 24 + 1.4 obtain base gsmtty number for the used serial port. 22 25 23 26 Major parts of the initialization program : 24 27 (a good starting point is util-linux-ng/sys-utils/ldattach.c):: ··· 73 70 daemon(0,0); 74 71 pause(); 75 72 76 - 5. use these devices as plain serial ports. 73 + 1.5 use these devices as plain serial ports. 77 74 78 75 for example, it's possible: 79 76 80 77 - and to use gnokii to send / receive SMS on ttygsm1 81 78 - to use ppp to establish a datalink on ttygsm2 82 79 83 - 6. first close all virtual ports before closing the physical port. 80 + 1.6 first close all virtual ports before closing the physical port. 84 81 85 82 Note that after closing the physical port the modem is still in multiplexing 86 83 mode. This may prevent a successful re-opening of the port later. To avoid ··· 89 86 for the second time. The byte sequence for the disconnect command frame is:: 90 87 91 88 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9. 89 + 90 + 2. config requester 91 + ^^^^^^^^^^^^^^^^^^^^^ 92 + 93 + 2.1 receive string "AT+CMUX= command" through its serial port,initialize 94 + mux mode config 95 + 2.2 switch the serial line to using the n_gsm line discipline by using 96 + TIOCSETD ioctl. 97 + 2.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl. 98 + 2.4 obtain base gsmtty number for the used serial port, 99 + 100 + #include <stdio.h> 101 + #include <stdint.h> 102 + #include <linux/gsmmux.h> 103 + #include <linux/tty.h> 104 + #define DEFAULT_SPEED B115200 105 + #define SERIAL_PORT /dev/ttyS0 106 + 107 + int ldisc = N_GSM0710; 108 + struct gsm_config c; 109 + struct termios configuration; 110 + uint32_t first; 111 + 112 + /* open the serial port */ 113 + fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 114 + 115 + /* configure the serial port : speed, flow control ... */ 116 + 117 + /* get serial data and check "AT+CMUX=command" parameter ... */ 118 + 119 + /* use n_gsm line discipline */ 120 + ioctl(fd, TIOCSETD, &ldisc); 121 + 122 + /* get n_gsm configuration */ 123 + ioctl(fd, GSMIOC_GETCONF, &c); 124 + /* we are requester and need encoding 0 (basic) */ 125 + c.initiator = 0; 126 + c.encapsulation = 0; 127 + /* our modem defaults to a maximum size of 127 bytes */ 128 + c.mru = 127; 129 + c.mtu = 127; 130 + /* set the new configuration */ 131 + ioctl(fd, GSMIOC_SETCONF, &c); 132 + /* get first gsmtty device node */ 133 + ioctl(fd, GSMIOC_GETFIRST, &first); 134 + printf("first muxed line: /dev/gsmtty%i\n", first); 135 + 136 + /* and wait for ever to keep the line discipline enabled */ 137 + daemon(0,0); 138 + pause(); 92 139 93 140 Additional Documentation 94 141 ------------------------
+1 -1
Documentation/driver-api/serial/tty.rst
··· 58 58 hangup() Called when the tty line is hung up. 59 59 The line discipline should cease I/O to the tty. 60 60 No further calls into the ldisc code will occur. 61 - The return value is ignored. Can sleep. 61 + Can sleep. 62 62 63 63 read() (optional) A process requests reading data from 64 64 the line. Multiple read calls may occur in parallel
+2
arch/sh/boot/dts/j2_mimas_v2.dts
··· 88 88 clock-frequency = <125000000>; 89 89 compatible = "xlnx,xps-uartlite-1.00.a"; 90 90 current-speed = <19200>; 91 + xlnx,use-parity = <0>; 92 + xlnx,data-bits = <8>; 91 93 device_type = "serial"; 92 94 interrupts = <0x12>; 93 95 port-number = <0>;
+1 -1
drivers/bluetooth/hci_ldisc.c
··· 793 793 break; 794 794 795 795 default: 796 - err = n_tty_ioctl_helper(tty, file, cmd, arg); 796 + err = n_tty_ioctl_helper(tty, cmd, arg); 797 797 break; 798 798 } 799 799
+1 -2
drivers/input/serio/serport.c
··· 244 244 } 245 245 #endif 246 246 247 - static int serport_ldisc_hangup(struct tty_struct *tty) 247 + static void serport_ldisc_hangup(struct tty_struct *tty) 248 248 { 249 249 struct serport *serport = (struct serport *) tty->disc_data; 250 250 unsigned long flags; ··· 254 254 spin_unlock_irqrestore(&serport->lock, flags); 255 255 256 256 wake_up_interruptible(&serport->wait); 257 - return 0; 258 257 } 259 258 260 259 static void serport_ldisc_write_wakeup(struct tty_struct * tty)
+2 -3
drivers/net/can/slcan.c
··· 664 664 /* This will complete via sl_free_netdev */ 665 665 } 666 666 667 - static int slcan_hangup(struct tty_struct *tty) 667 + static void slcan_hangup(struct tty_struct *tty) 668 668 { 669 669 slcan_close(tty); 670 - return 0; 671 670 } 672 671 673 672 /* Perform I/O control on an active SLCAN channel. */ ··· 691 692 return -EINVAL; 692 693 693 694 default: 694 - return tty_mode_ioctl(tty, file, cmd, arg); 695 + return tty_mode_ioctl(tty, cmd, arg); 695 696 } 696 697 } 697 698
+1 -1
drivers/net/hamradio/6pack.c
··· 732 732 break; 733 733 } 734 734 default: 735 - err = tty_mode_ioctl(tty, file, cmd, arg); 735 + err = tty_mode_ioctl(tty, cmd, arg); 736 736 } 737 737 738 738 sp_put(sp);
+3 -4
drivers/net/ppp/ppp_async.c
··· 247 247 * Wait for I/O to driver to complete and unregister PPP channel. 248 248 * This is already done by the close routine, so just call that. 249 249 */ 250 - static int ppp_asynctty_hangup(struct tty_struct *tty) 250 + static void ppp_asynctty_hangup(struct tty_struct *tty) 251 251 { 252 252 ppp_asynctty_close(tty); 253 - return 0; 254 253 } 255 254 256 255 /* ··· 310 311 /* flush our buffers and the serial port's buffer */ 311 312 if (arg == TCIOFLUSH || arg == TCOFLUSH) 312 313 ppp_async_flush_output(ap); 313 - err = n_tty_ioctl_helper(tty, file, cmd, arg); 314 + err = n_tty_ioctl_helper(tty, cmd, arg); 314 315 break; 315 316 316 317 case FIONREAD: ··· 322 323 323 324 default: 324 325 /* Try the various mode ioctls */ 325 - err = tty_mode_ioctl(tty, file, cmd, arg); 326 + err = tty_mode_ioctl(tty, cmd, arg); 326 327 } 327 328 328 329 ap_put(ap);
+3 -4
drivers/net/ppp/ppp_synctty.c
··· 245 245 * Wait for I/O to driver to complete and unregister PPP channel. 246 246 * This is already done by the close routine, so just call that. 247 247 */ 248 - static int ppp_sync_hangup(struct tty_struct *tty) 248 + static void ppp_sync_hangup(struct tty_struct *tty) 249 249 { 250 250 ppp_sync_close(tty); 251 - return 0; 252 251 } 253 252 254 253 /* ··· 303 304 /* flush our buffers and the serial port's buffer */ 304 305 if (arg == TCIOFLUSH || arg == TCOFLUSH) 305 306 ppp_sync_flush_output(ap); 306 - err = n_tty_ioctl_helper(tty, file, cmd, arg); 307 + err = n_tty_ioctl_helper(tty, cmd, arg); 307 308 break; 308 309 309 310 case FIONREAD: ··· 314 315 break; 315 316 316 317 default: 317 - err = tty_mode_ioctl(tty, file, cmd, arg); 318 + err = tty_mode_ioctl(tty, cmd, arg); 318 319 break; 319 320 } 320 321
+2 -3
drivers/net/slip/slip.c
··· 907 907 /* This will complete via sl_free_netdev */ 908 908 } 909 909 910 - static int slip_hangup(struct tty_struct *tty) 910 + static void slip_hangup(struct tty_struct *tty) 911 911 { 912 912 slip_close(tty); 913 - return 0; 914 913 } 915 914 /************************************************************************ 916 915 * STANDARD SLIP ENCAPSULATION * ··· 1173 1174 /* VSV changes end */ 1174 1175 #endif 1175 1176 default: 1176 - return tty_mode_ioctl(tty, file, cmd, arg); 1177 + return tty_mode_ioctl(tty, cmd, arg); 1177 1178 } 1178 1179 } 1179 1180
+21
drivers/rpmsg/rpmsg_core.c
··· 327 327 } 328 328 EXPORT_SYMBOL(rpmsg_trysend_offchannel); 329 329 330 + /** 331 + * rpmsg_get_mtu() - get maximum transmission buffer size for sending message. 332 + * @ept: the rpmsg endpoint 333 + * 334 + * This function returns maximum buffer size available for a single outgoing message. 335 + * 336 + * Return: the maximum transmission size on success and an appropriate error 337 + * value on failure. 338 + */ 339 + 340 + ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept) 341 + { 342 + if (WARN_ON(!ept)) 343 + return -EINVAL; 344 + if (!ept->ops->get_mtu) 345 + return -ENOTSUPP; 346 + 347 + return ept->ops->get_mtu(ept); 348 + } 349 + EXPORT_SYMBOL(rpmsg_get_mtu); 350 + 330 351 /* 331 352 * match a rpmsg channel with a channel info struct. 332 353 * this is used to make sure we're not creating rpmsg devices for channels
+2
drivers/rpmsg/rpmsg_internal.h
··· 53 53 * @trysendto: see @rpmsg_trysendto(), optional 54 54 * @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional 55 55 * @poll: see @rpmsg_poll(), optional 56 + * @get_mtu: see @rpmsg_get_mtu(), optional 56 57 * 57 58 * Indirection table for the operations that a rpmsg backend should implement. 58 59 * In addition to @destroy_ept, the backend must at least implement @send and ··· 73 72 void *data, int len); 74 73 __poll_t (*poll)(struct rpmsg_endpoint *ept, struct file *filp, 75 74 poll_table *wait); 75 + ssize_t (*get_mtu)(struct rpmsg_endpoint *ept); 76 76 }; 77 77 78 78 struct device *rpmsg_find_device(struct device *parent,
+10
drivers/rpmsg/virtio_rpmsg_bus.c
··· 149 149 int len, u32 dst); 150 150 static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, 151 151 u32 dst, void *data, int len); 152 + static ssize_t virtio_rpmsg_get_mtu(struct rpmsg_endpoint *ept); 152 153 static struct rpmsg_device *__rpmsg_create_channel(struct virtproc_info *vrp, 153 154 struct rpmsg_channel_info *chinfo); 154 155 ··· 161 160 .trysend = virtio_rpmsg_trysend, 162 161 .trysendto = virtio_rpmsg_trysendto, 163 162 .trysend_offchannel = virtio_rpmsg_trysend_offchannel, 163 + .get_mtu = virtio_rpmsg_get_mtu, 164 164 }; 165 165 166 166 /** ··· 696 694 struct rpmsg_device *rpdev = ept->rpdev; 697 695 698 696 return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); 697 + } 698 + 699 + static ssize_t virtio_rpmsg_get_mtu(struct rpmsg_endpoint *ept) 700 + { 701 + struct rpmsg_device *rpdev = ept->rpdev; 702 + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); 703 + 704 + return vch->vrp->buf_size - sizeof(struct rpmsg_hdr); 699 705 } 700 706 701 707 static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
+12
drivers/tty/Kconfig
··· 368 368 369 369 source "drivers/tty/hvc/Kconfig" 370 370 371 + config RPMSG_TTY 372 + tristate "RPMSG tty driver" 373 + depends on RPMSG 374 + help 375 + Say y here to export rpmsg endpoints as tty devices, usually found 376 + in /dev/ttyRPMSGx. 377 + This makes it possible for user-space programs to send and receive 378 + rpmsg messages as a standard tty protocol. 379 + 380 + To compile this driver as a module, choose M here: the module will be 381 + called rpmsg_tty. 382 + 371 383 endif # TTY 372 384 373 385 source "drivers/tty/serdev/Kconfig"
+1
drivers/tty/Makefile
··· 26 26 obj-$(CONFIG_GOLDFISH_TTY) += goldfish.o 27 27 obj-$(CONFIG_MIPS_EJTAG_FDC_TTY) += mips_ejtag_fdc.o 28 28 obj-$(CONFIG_VCC) += vcc.o 29 + obj-$(CONFIG_RPMSG_TTY) += rpmsg_tty.o 29 30 30 31 obj-y += ipwireless/
+1 -1
drivers/tty/hvc/hvc_console.c
··· 49 49 #define N_OUTBUF 16 50 50 #define N_INBUF 16 51 51 52 - #define __ALIGNED__ __attribute__((__aligned__(sizeof(long)))) 52 + #define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES))) 53 53 54 54 static struct tty_driver *hvc_driver; 55 55 static struct task_struct *hvc_task;
+301 -1
drivers/tty/moxa.c
··· 45 45 #include <asm/io.h> 46 46 #include <linux/uaccess.h> 47 47 48 - #include "moxa.h" 48 + #define MOXA 0x400 49 + #define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */ 50 + #define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */ 51 + #define MOXA_GETDATACOUNT (MOXA + 23) 52 + #define MOXA_GET_IOQUEUE (MOXA + 27) 53 + #define MOXA_FLUSH_QUEUE (MOXA + 28) 54 + #define MOXA_GETMSTATUS (MOXA + 65) 55 + 56 + /* 57 + * System Configuration 58 + */ 59 + 60 + #define Magic_code 0x404 61 + 62 + /* 63 + * for C218 BIOS initialization 64 + */ 65 + #define C218_ConfBase 0x800 66 + #define C218_status (C218_ConfBase + 0) /* BIOS running status */ 67 + #define C218_diag (C218_ConfBase + 2) /* diagnostic status */ 68 + #define C218_key (C218_ConfBase + 4) /* WORD (0x218 for C218) */ 69 + #define C218DLoad_len (C218_ConfBase + 6) /* WORD */ 70 + #define C218check_sum (C218_ConfBase + 8) /* BYTE */ 71 + #define C218chksum_ok (C218_ConfBase + 0x0a) /* BYTE (1:ok) */ 72 + #define C218_TestRx (C218_ConfBase + 0x10) /* 8 bytes for 8 ports */ 73 + #define C218_TestTx (C218_ConfBase + 0x18) /* 8 bytes for 8 ports */ 74 + #define C218_RXerr (C218_ConfBase + 0x20) /* 8 bytes for 8 ports */ 75 + #define C218_ErrFlag (C218_ConfBase + 0x28) /* 8 bytes for 8 ports */ 76 + 77 + #define C218_LoadBuf 0x0F00 78 + #define C218_KeyCode 0x218 79 + #define CP204J_KeyCode 0x204 80 + 81 + /* 82 + * for C320 BIOS initialization 83 + */ 84 + #define C320_ConfBase 0x800 85 + #define C320_LoadBuf 0x0f00 86 + #define STS_init 0x05 /* for C320_status */ 87 + 88 + #define C320_status C320_ConfBase + 0 /* BIOS running status */ 89 + #define C320_diag C320_ConfBase + 2 /* diagnostic status */ 90 + #define C320_key C320_ConfBase + 4 /* WORD (0320H for C320) */ 91 + #define C320DLoad_len C320_ConfBase + 6 /* WORD */ 92 + #define C320check_sum C320_ConfBase + 8 /* WORD */ 93 + #define C320chksum_ok C320_ConfBase + 0x0a /* WORD (1:ok) */ 94 + #define C320bapi_len C320_ConfBase + 0x0c /* WORD */ 95 + #define C320UART_no C320_ConfBase + 0x0e /* WORD */ 96 + 97 + #define C320_KeyCode 0x320 98 + 99 + #define FixPage_addr 0x0000 /* starting addr of static page */ 100 + #define DynPage_addr 0x2000 /* starting addr of dynamic page */ 101 + #define C218_start 0x3000 /* starting addr of C218 BIOS prg */ 102 + #define Control_reg 0x1ff0 /* select page and reset control */ 103 + #define HW_reset 0x80 104 + 105 + /* 106 + * Function Codes 107 + */ 108 + #define FC_CardReset 0x80 109 + #define FC_ChannelReset 1 /* C320 firmware not supported */ 110 + #define FC_EnableCH 2 111 + #define FC_DisableCH 3 112 + #define FC_SetParam 4 113 + #define FC_SetMode 5 114 + #define FC_SetRate 6 115 + #define FC_LineControl 7 116 + #define FC_LineStatus 8 117 + #define FC_XmitControl 9 118 + #define FC_FlushQueue 10 119 + #define FC_SendBreak 11 120 + #define FC_StopBreak 12 121 + #define FC_LoopbackON 13 122 + #define FC_LoopbackOFF 14 123 + #define FC_ClrIrqTable 15 124 + #define FC_SendXon 16 125 + #define FC_SetTermIrq 17 /* C320 firmware not supported */ 126 + #define FC_SetCntIrq 18 /* C320 firmware not supported */ 127 + #define FC_SetBreakIrq 19 128 + #define FC_SetLineIrq 20 129 + #define FC_SetFlowCtl 21 130 + #define FC_GenIrq 22 131 + #define FC_InCD180 23 132 + #define FC_OutCD180 24 133 + #define FC_InUARTreg 23 134 + #define FC_OutUARTreg 24 135 + #define FC_SetXonXoff 25 136 + #define FC_OutCD180CCR 26 137 + #define FC_ExtIQueue 27 138 + #define FC_ExtOQueue 28 139 + #define FC_ClrLineIrq 29 140 + #define FC_HWFlowCtl 30 141 + #define FC_GetClockRate 35 142 + #define FC_SetBaud 36 143 + #define FC_SetDataMode 41 144 + #define FC_GetCCSR 43 145 + #define FC_GetDataError 45 146 + #define FC_RxControl 50 147 + #define FC_ImmSend 51 148 + #define FC_SetXonState 52 149 + #define FC_SetXoffState 53 150 + #define FC_SetRxFIFOTrig 54 151 + #define FC_SetTxFIFOCnt 55 152 + #define FC_UnixRate 56 153 + #define FC_UnixResetTimer 57 154 + 155 + #define RxFIFOTrig1 0 156 + #define RxFIFOTrig4 1 157 + #define RxFIFOTrig8 2 158 + #define RxFIFOTrig14 3 159 + 160 + /* 161 + * Dual-Ported RAM 162 + */ 163 + #define DRAM_global 0 164 + #define INT_data (DRAM_global + 0) 165 + #define Config_base (DRAM_global + 0x108) 166 + 167 + #define IRQindex (INT_data + 0) 168 + #define IRQpending (INT_data + 4) 169 + #define IRQtable (INT_data + 8) 170 + 171 + /* 172 + * Interrupt Status 173 + */ 174 + #define IntrRx 0x01 /* receiver data O.K. */ 175 + #define IntrTx 0x02 /* transmit buffer empty */ 176 + #define IntrFunc 0x04 /* function complete */ 177 + #define IntrBreak 0x08 /* received break */ 178 + #define IntrLine 0x10 /* line status change 179 + for transmitter */ 180 + #define IntrIntr 0x20 /* received INTR code */ 181 + #define IntrQuit 0x40 /* received QUIT code */ 182 + #define IntrEOF 0x80 /* received EOF code */ 183 + 184 + #define IntrRxTrigger 0x100 /* rx data count reach trigger value */ 185 + #define IntrTxTrigger 0x200 /* tx data count below trigger value */ 186 + 187 + #define Magic_no (Config_base + 0) 188 + #define Card_model_no (Config_base + 2) 189 + #define Total_ports (Config_base + 4) 190 + #define Module_cnt (Config_base + 8) 191 + #define Module_no (Config_base + 10) 192 + #define Timer_10ms (Config_base + 14) 193 + #define Disable_IRQ (Config_base + 20) 194 + #define TMS320_PORT1 (Config_base + 22) 195 + #define TMS320_PORT2 (Config_base + 24) 196 + #define TMS320_CLOCK (Config_base + 26) 197 + 198 + /* 199 + * DATA BUFFER in DRAM 200 + */ 201 + #define Extern_table 0x400 /* Base address of the external table 202 + (24 words * 64) total 3K bytes 203 + (24 words * 128) total 6K bytes */ 204 + #define Extern_size 0x60 /* 96 bytes */ 205 + #define RXrptr 0x00 /* read pointer for RX buffer */ 206 + #define RXwptr 0x02 /* write pointer for RX buffer */ 207 + #define TXrptr 0x04 /* read pointer for TX buffer */ 208 + #define TXwptr 0x06 /* write pointer for TX buffer */ 209 + #define HostStat 0x08 /* IRQ flag and general flag */ 210 + #define FlagStat 0x0A 211 + #define FlowControl 0x0C /* B7 B6 B5 B4 B3 B2 B1 B0 */ 212 + /* x x x x | | | | */ 213 + /* | | | + CTS flow */ 214 + /* | | +--- RTS flow */ 215 + /* | +------ TX Xon/Xoff */ 216 + /* +--------- RX Xon/Xoff */ 217 + #define Break_cnt 0x0E /* received break count */ 218 + #define CD180TXirq 0x10 /* if non-0: enable TX irq */ 219 + #define RX_mask 0x12 220 + #define TX_mask 0x14 221 + #define Ofs_rxb 0x16 222 + #define Ofs_txb 0x18 223 + #define Page_rxb 0x1A 224 + #define Page_txb 0x1C 225 + #define EndPage_rxb 0x1E 226 + #define EndPage_txb 0x20 227 + #define Data_error 0x22 228 + #define RxTrigger 0x28 229 + #define TxTrigger 0x2a 230 + 231 + #define rRXwptr 0x34 232 + #define Low_water 0x36 233 + 234 + #define FuncCode 0x40 235 + #define FuncArg 0x42 236 + #define FuncArg1 0x44 237 + 238 + #define C218rx_size 0x2000 /* 8K bytes */ 239 + #define C218tx_size 0x8000 /* 32K bytes */ 240 + 241 + #define C218rx_mask (C218rx_size - 1) 242 + #define C218tx_mask (C218tx_size - 1) 243 + 244 + #define C320p8rx_size 0x2000 245 + #define C320p8tx_size 0x8000 246 + #define C320p8rx_mask (C320p8rx_size - 1) 247 + #define C320p8tx_mask (C320p8tx_size - 1) 248 + 249 + #define C320p16rx_size 0x2000 250 + #define C320p16tx_size 0x4000 251 + #define C320p16rx_mask (C320p16rx_size - 1) 252 + #define C320p16tx_mask (C320p16tx_size - 1) 253 + 254 + #define C320p24rx_size 0x2000 255 + #define C320p24tx_size 0x2000 256 + #define C320p24rx_mask (C320p24rx_size - 1) 257 + #define C320p24tx_mask (C320p24tx_size - 1) 258 + 259 + #define C320p32rx_size 0x1000 260 + #define C320p32tx_size 0x1000 261 + #define C320p32rx_mask (C320p32rx_size - 1) 262 + #define C320p32tx_mask (C320p32tx_size - 1) 263 + 264 + #define Page_size 0x2000U 265 + #define Page_mask (Page_size - 1) 266 + #define C218rx_spage 3 267 + #define C218tx_spage 4 268 + #define C218rx_pageno 1 269 + #define C218tx_pageno 4 270 + #define C218buf_pageno 5 271 + 272 + #define C320p8rx_spage 3 273 + #define C320p8tx_spage 4 274 + #define C320p8rx_pgno 1 275 + #define C320p8tx_pgno 4 276 + #define C320p8buf_pgno 5 277 + 278 + #define C320p16rx_spage 3 279 + #define C320p16tx_spage 4 280 + #define C320p16rx_pgno 1 281 + #define C320p16tx_pgno 2 282 + #define C320p16buf_pgno 3 283 + 284 + #define C320p24rx_spage 3 285 + #define C320p24tx_spage 4 286 + #define C320p24rx_pgno 1 287 + #define C320p24tx_pgno 1 288 + #define C320p24buf_pgno 2 289 + 290 + #define C320p32rx_spage 3 291 + #define C320p32tx_ofs C320p32rx_size 292 + #define C320p32tx_spage 3 293 + #define C320p32buf_pgno 1 294 + 295 + /* 296 + * Host Status 297 + */ 298 + #define WakeupRx 0x01 299 + #define WakeupTx 0x02 300 + #define WakeupBreak 0x08 301 + #define WakeupLine 0x10 302 + #define WakeupIntr 0x20 303 + #define WakeupQuit 0x40 304 + #define WakeupEOF 0x80 /* used in VTIME control */ 305 + #define WakeupRxTrigger 0x100 306 + #define WakeupTxTrigger 0x200 307 + /* 308 + * Flag status 309 + */ 310 + #define Rx_over 0x01 311 + #define Xoff_state 0x02 312 + #define Tx_flowOff 0x04 313 + #define Tx_enable 0x08 314 + #define CTS_state 0x10 315 + #define DSR_state 0x20 316 + #define DCD_state 0x80 317 + /* 318 + * FlowControl 319 + */ 320 + #define CTS_FlowCtl 1 321 + #define RTS_FlowCtl 2 322 + #define Tx_FlowCtl 4 323 + #define Rx_FlowCtl 8 324 + #define IXM_IXANY 0x10 325 + 326 + #define LowWater 128 327 + 328 + #define DTR_ON 1 329 + #define RTS_ON 2 330 + #define CTS_ON 1 331 + #define DSR_ON 2 332 + #define DCD_ON 8 333 + 334 + /* mode definition */ 335 + #define MX_CS8 0x03 336 + #define MX_CS7 0x02 337 + #define MX_CS6 0x01 338 + #define MX_CS5 0x00 339 + 340 + #define MX_STOP1 0x00 341 + #define MX_STOP15 0x04 342 + #define MX_STOP2 0x08 343 + 344 + #define MX_PARNONE 0x00 345 + #define MX_PAREVEN 0x40 346 + #define MX_PARODD 0xC0 347 + #define MX_PARMARK 0xA0 348 + #define MX_PARSPACE 0x20 49 349 50 350 #define MOXA_VERSION "6.0k" 51 351
-307
drivers/tty/moxa.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef MOXA_H_FILE 3 - #define MOXA_H_FILE 4 - 5 - #define MOXA 0x400 6 - #define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */ 7 - #define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */ 8 - #define MOXA_GETDATACOUNT (MOXA + 23) 9 - #define MOXA_GET_IOQUEUE (MOXA + 27) 10 - #define MOXA_FLUSH_QUEUE (MOXA + 28) 11 - #define MOXA_GETMSTATUS (MOXA + 65) 12 - 13 - /* 14 - * System Configuration 15 - */ 16 - 17 - #define Magic_code 0x404 18 - 19 - /* 20 - * for C218 BIOS initialization 21 - */ 22 - #define C218_ConfBase 0x800 23 - #define C218_status (C218_ConfBase + 0) /* BIOS running status */ 24 - #define C218_diag (C218_ConfBase + 2) /* diagnostic status */ 25 - #define C218_key (C218_ConfBase + 4) /* WORD (0x218 for C218) */ 26 - #define C218DLoad_len (C218_ConfBase + 6) /* WORD */ 27 - #define C218check_sum (C218_ConfBase + 8) /* BYTE */ 28 - #define C218chksum_ok (C218_ConfBase + 0x0a) /* BYTE (1:ok) */ 29 - #define C218_TestRx (C218_ConfBase + 0x10) /* 8 bytes for 8 ports */ 30 - #define C218_TestTx (C218_ConfBase + 0x18) /* 8 bytes for 8 ports */ 31 - #define C218_RXerr (C218_ConfBase + 0x20) /* 8 bytes for 8 ports */ 32 - #define C218_ErrFlag (C218_ConfBase + 0x28) /* 8 bytes for 8 ports */ 33 - 34 - #define C218_LoadBuf 0x0F00 35 - #define C218_KeyCode 0x218 36 - #define CP204J_KeyCode 0x204 37 - 38 - /* 39 - * for C320 BIOS initialization 40 - */ 41 - #define C320_ConfBase 0x800 42 - #define C320_LoadBuf 0x0f00 43 - #define STS_init 0x05 /* for C320_status */ 44 - 45 - #define C320_status C320_ConfBase + 0 /* BIOS running status */ 46 - #define C320_diag C320_ConfBase + 2 /* diagnostic status */ 47 - #define C320_key C320_ConfBase + 4 /* WORD (0320H for C320) */ 48 - #define C320DLoad_len C320_ConfBase + 6 /* WORD */ 49 - #define C320check_sum C320_ConfBase + 8 /* WORD */ 50 - #define C320chksum_ok C320_ConfBase + 0x0a /* WORD (1:ok) */ 51 - #define C320bapi_len C320_ConfBase + 0x0c /* WORD */ 52 - #define C320UART_no C320_ConfBase + 0x0e /* WORD */ 53 - 54 - #define C320_KeyCode 0x320 55 - 56 - #define FixPage_addr 0x0000 /* starting addr of static page */ 57 - #define DynPage_addr 0x2000 /* starting addr of dynamic page */ 58 - #define C218_start 0x3000 /* starting addr of C218 BIOS prg */ 59 - #define Control_reg 0x1ff0 /* select page and reset control */ 60 - #define HW_reset 0x80 61 - 62 - /* 63 - * Function Codes 64 - */ 65 - #define FC_CardReset 0x80 66 - #define FC_ChannelReset 1 /* C320 firmware not supported */ 67 - #define FC_EnableCH 2 68 - #define FC_DisableCH 3 69 - #define FC_SetParam 4 70 - #define FC_SetMode 5 71 - #define FC_SetRate 6 72 - #define FC_LineControl 7 73 - #define FC_LineStatus 8 74 - #define FC_XmitControl 9 75 - #define FC_FlushQueue 10 76 - #define FC_SendBreak 11 77 - #define FC_StopBreak 12 78 - #define FC_LoopbackON 13 79 - #define FC_LoopbackOFF 14 80 - #define FC_ClrIrqTable 15 81 - #define FC_SendXon 16 82 - #define FC_SetTermIrq 17 /* C320 firmware not supported */ 83 - #define FC_SetCntIrq 18 /* C320 firmware not supported */ 84 - #define FC_SetBreakIrq 19 85 - #define FC_SetLineIrq 20 86 - #define FC_SetFlowCtl 21 87 - #define FC_GenIrq 22 88 - #define FC_InCD180 23 89 - #define FC_OutCD180 24 90 - #define FC_InUARTreg 23 91 - #define FC_OutUARTreg 24 92 - #define FC_SetXonXoff 25 93 - #define FC_OutCD180CCR 26 94 - #define FC_ExtIQueue 27 95 - #define FC_ExtOQueue 28 96 - #define FC_ClrLineIrq 29 97 - #define FC_HWFlowCtl 30 98 - #define FC_GetClockRate 35 99 - #define FC_SetBaud 36 100 - #define FC_SetDataMode 41 101 - #define FC_GetCCSR 43 102 - #define FC_GetDataError 45 103 - #define FC_RxControl 50 104 - #define FC_ImmSend 51 105 - #define FC_SetXonState 52 106 - #define FC_SetXoffState 53 107 - #define FC_SetRxFIFOTrig 54 108 - #define FC_SetTxFIFOCnt 55 109 - #define FC_UnixRate 56 110 - #define FC_UnixResetTimer 57 111 - 112 - #define RxFIFOTrig1 0 113 - #define RxFIFOTrig4 1 114 - #define RxFIFOTrig8 2 115 - #define RxFIFOTrig14 3 116 - 117 - /* 118 - * Dual-Ported RAM 119 - */ 120 - #define DRAM_global 0 121 - #define INT_data (DRAM_global + 0) 122 - #define Config_base (DRAM_global + 0x108) 123 - 124 - #define IRQindex (INT_data + 0) 125 - #define IRQpending (INT_data + 4) 126 - #define IRQtable (INT_data + 8) 127 - 128 - /* 129 - * Interrupt Status 130 - */ 131 - #define IntrRx 0x01 /* receiver data O.K. */ 132 - #define IntrTx 0x02 /* transmit buffer empty */ 133 - #define IntrFunc 0x04 /* function complete */ 134 - #define IntrBreak 0x08 /* received break */ 135 - #define IntrLine 0x10 /* line status change 136 - for transmitter */ 137 - #define IntrIntr 0x20 /* received INTR code */ 138 - #define IntrQuit 0x40 /* received QUIT code */ 139 - #define IntrEOF 0x80 /* received EOF code */ 140 - 141 - #define IntrRxTrigger 0x100 /* rx data count reach trigger value */ 142 - #define IntrTxTrigger 0x200 /* tx data count below trigger value */ 143 - 144 - #define Magic_no (Config_base + 0) 145 - #define Card_model_no (Config_base + 2) 146 - #define Total_ports (Config_base + 4) 147 - #define Module_cnt (Config_base + 8) 148 - #define Module_no (Config_base + 10) 149 - #define Timer_10ms (Config_base + 14) 150 - #define Disable_IRQ (Config_base + 20) 151 - #define TMS320_PORT1 (Config_base + 22) 152 - #define TMS320_PORT2 (Config_base + 24) 153 - #define TMS320_CLOCK (Config_base + 26) 154 - 155 - /* 156 - * DATA BUFFER in DRAM 157 - */ 158 - #define Extern_table 0x400 /* Base address of the external table 159 - (24 words * 64) total 3K bytes 160 - (24 words * 128) total 6K bytes */ 161 - #define Extern_size 0x60 /* 96 bytes */ 162 - #define RXrptr 0x00 /* read pointer for RX buffer */ 163 - #define RXwptr 0x02 /* write pointer for RX buffer */ 164 - #define TXrptr 0x04 /* read pointer for TX buffer */ 165 - #define TXwptr 0x06 /* write pointer for TX buffer */ 166 - #define HostStat 0x08 /* IRQ flag and general flag */ 167 - #define FlagStat 0x0A 168 - #define FlowControl 0x0C /* B7 B6 B5 B4 B3 B2 B1 B0 */ 169 - /* x x x x | | | | */ 170 - /* | | | + CTS flow */ 171 - /* | | +--- RTS flow */ 172 - /* | +------ TX Xon/Xoff */ 173 - /* +--------- RX Xon/Xoff */ 174 - #define Break_cnt 0x0E /* received break count */ 175 - #define CD180TXirq 0x10 /* if non-0: enable TX irq */ 176 - #define RX_mask 0x12 177 - #define TX_mask 0x14 178 - #define Ofs_rxb 0x16 179 - #define Ofs_txb 0x18 180 - #define Page_rxb 0x1A 181 - #define Page_txb 0x1C 182 - #define EndPage_rxb 0x1E 183 - #define EndPage_txb 0x20 184 - #define Data_error 0x22 185 - #define RxTrigger 0x28 186 - #define TxTrigger 0x2a 187 - 188 - #define rRXwptr 0x34 189 - #define Low_water 0x36 190 - 191 - #define FuncCode 0x40 192 - #define FuncArg 0x42 193 - #define FuncArg1 0x44 194 - 195 - #define C218rx_size 0x2000 /* 8K bytes */ 196 - #define C218tx_size 0x8000 /* 32K bytes */ 197 - 198 - #define C218rx_mask (C218rx_size - 1) 199 - #define C218tx_mask (C218tx_size - 1) 200 - 201 - #define C320p8rx_size 0x2000 202 - #define C320p8tx_size 0x8000 203 - #define C320p8rx_mask (C320p8rx_size - 1) 204 - #define C320p8tx_mask (C320p8tx_size - 1) 205 - 206 - #define C320p16rx_size 0x2000 207 - #define C320p16tx_size 0x4000 208 - #define C320p16rx_mask (C320p16rx_size - 1) 209 - #define C320p16tx_mask (C320p16tx_size - 1) 210 - 211 - #define C320p24rx_size 0x2000 212 - #define C320p24tx_size 0x2000 213 - #define C320p24rx_mask (C320p24rx_size - 1) 214 - #define C320p24tx_mask (C320p24tx_size - 1) 215 - 216 - #define C320p32rx_size 0x1000 217 - #define C320p32tx_size 0x1000 218 - #define C320p32rx_mask (C320p32rx_size - 1) 219 - #define C320p32tx_mask (C320p32tx_size - 1) 220 - 221 - #define Page_size 0x2000U 222 - #define Page_mask (Page_size - 1) 223 - #define C218rx_spage 3 224 - #define C218tx_spage 4 225 - #define C218rx_pageno 1 226 - #define C218tx_pageno 4 227 - #define C218buf_pageno 5 228 - 229 - #define C320p8rx_spage 3 230 - #define C320p8tx_spage 4 231 - #define C320p8rx_pgno 1 232 - #define C320p8tx_pgno 4 233 - #define C320p8buf_pgno 5 234 - 235 - #define C320p16rx_spage 3 236 - #define C320p16tx_spage 4 237 - #define C320p16rx_pgno 1 238 - #define C320p16tx_pgno 2 239 - #define C320p16buf_pgno 3 240 - 241 - #define C320p24rx_spage 3 242 - #define C320p24tx_spage 4 243 - #define C320p24rx_pgno 1 244 - #define C320p24tx_pgno 1 245 - #define C320p24buf_pgno 2 246 - 247 - #define C320p32rx_spage 3 248 - #define C320p32tx_ofs C320p32rx_size 249 - #define C320p32tx_spage 3 250 - #define C320p32buf_pgno 1 251 - 252 - /* 253 - * Host Status 254 - */ 255 - #define WakeupRx 0x01 256 - #define WakeupTx 0x02 257 - #define WakeupBreak 0x08 258 - #define WakeupLine 0x10 259 - #define WakeupIntr 0x20 260 - #define WakeupQuit 0x40 261 - #define WakeupEOF 0x80 /* used in VTIME control */ 262 - #define WakeupRxTrigger 0x100 263 - #define WakeupTxTrigger 0x200 264 - /* 265 - * Flag status 266 - */ 267 - #define Rx_over 0x01 268 - #define Xoff_state 0x02 269 - #define Tx_flowOff 0x04 270 - #define Tx_enable 0x08 271 - #define CTS_state 0x10 272 - #define DSR_state 0x20 273 - #define DCD_state 0x80 274 - /* 275 - * FlowControl 276 - */ 277 - #define CTS_FlowCtl 1 278 - #define RTS_FlowCtl 2 279 - #define Tx_FlowCtl 4 280 - #define Rx_FlowCtl 8 281 - #define IXM_IXANY 0x10 282 - 283 - #define LowWater 128 284 - 285 - #define DTR_ON 1 286 - #define RTS_ON 2 287 - #define CTS_ON 1 288 - #define DSR_ON 2 289 - #define DCD_ON 8 290 - 291 - /* mode definition */ 292 - #define MX_CS8 0x03 293 - #define MX_CS7 0x02 294 - #define MX_CS6 0x01 295 - #define MX_CS5 0x00 296 - 297 - #define MX_STOP1 0x00 298 - #define MX_STOP15 0x04 299 - #define MX_STOP2 0x08 300 - 301 - #define MX_PARNONE 0x00 302 - #define MX_PAREVEN 0x40 303 - #define MX_PARODD 0xC0 304 - #define MX_PARMARK 0xA0 305 - #define MX_PARSPACE 0x20 306 - 307 - #endif
+54 -65
drivers/tty/mxser.c
··· 249 249 unsigned char x_char; /* xon/xoff character */ 250 250 u8 IER; /* Interrupt Enable Register */ 251 251 u8 MCR; /* Modem control register */ 252 + u8 FCR; /* FIFO control register */ 252 253 253 - unsigned char ldisc_stop_rx; 254 + bool ldisc_stop_rx; 254 255 255 256 struct async_icount icount; /* kernel counters for 4 input interrupts */ 256 257 unsigned int timeout; ··· 560 559 * This routine is called to set the UART divisor registers to match 561 560 * the specified baud rate for a serial port. 562 561 */ 563 - static void mxser_change_speed(struct tty_struct *tty) 562 + static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_termios) 564 563 { 565 564 struct mxser_port *info = tty->driver_data; 566 - unsigned cflag, cval, fcr; 565 + unsigned cflag, cval; 567 566 568 567 cflag = tty->termios.c_cflag; 569 568 570 - mxser_set_baud(tty, tty_get_baud_rate(tty)); 569 + if (mxser_set_baud(tty, tty_get_baud_rate(tty))) { 570 + /* Use previous rate on a failure */ 571 + if (old_termios) { 572 + speed_t baud = tty_termios_baud_rate(old_termios); 573 + tty_encode_baud_rate(tty, baud, baud); 574 + } 575 + } 571 576 572 577 /* byte size and parity */ 573 578 switch (cflag & CSIZE) { ··· 601 594 if (cflag & CMSPAR) 602 595 cval |= UART_LCR_SPAR; 603 596 604 - if ((info->type == PORT_8250) || (info->type == PORT_16450)) { 605 - if (info->board->must_hwid) { 606 - fcr = UART_FCR_ENABLE_FIFO; 607 - fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 608 - mxser_set_must_fifo_value(info); 609 - } else 610 - fcr = 0; 611 - } else { 612 - fcr = UART_FCR_ENABLE_FIFO; 613 - if (info->board->must_hwid) { 614 - fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 615 - mxser_set_must_fifo_value(info); 616 - } else { 617 - switch (info->rx_high_water) { 618 - case 1: 619 - fcr |= UART_FCR_TRIGGER_1; 620 - break; 621 - case 4: 622 - fcr |= UART_FCR_TRIGGER_4; 623 - break; 624 - case 8: 625 - fcr |= UART_FCR_TRIGGER_8; 626 - break; 627 - default: 628 - fcr |= UART_FCR_TRIGGER_14; 629 - break; 630 - } 597 + info->FCR = 0; 598 + if (info->board->must_hwid) { 599 + info->FCR |= UART_FCR_ENABLE_FIFO | 600 + MOXA_MUST_FCR_GDA_MODE_ENABLE; 601 + mxser_set_must_fifo_value(info); 602 + } else if (info->type != PORT_8250 && info->type != PORT_16450) { 603 + info->FCR |= UART_FCR_ENABLE_FIFO; 604 + switch (info->rx_high_water) { 605 + case 1: 606 + info->FCR |= UART_FCR_TRIGGER_1; 607 + break; 608 + case 4: 609 + info->FCR |= UART_FCR_TRIGGER_4; 610 + break; 611 + case 8: 612 + info->FCR |= UART_FCR_TRIGGER_8; 613 + break; 614 + default: 615 + info->FCR |= UART_FCR_TRIGGER_14; 616 + break; 631 617 } 632 618 } 633 619 ··· 680 680 } 681 681 682 682 683 - outb(fcr, info->ioaddr + UART_FCR); /* set fcr */ 683 + outb(info->FCR, info->ioaddr + UART_FCR); 684 684 outb(cval, info->ioaddr + UART_LCR); 685 685 } 686 686 ··· 707 707 mxser_handle_cts(tty, port, status); 708 708 } 709 709 710 + static void mxser_disable_and_clear_FIFO(struct mxser_port *info) 711 + { 712 + u8 fcr = UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT; 713 + 714 + if (info->board->must_hwid) 715 + fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 716 + 717 + outb(fcr, info->ioaddr + UART_FCR); 718 + } 719 + 710 720 static int mxser_activate(struct tty_port *port, struct tty_struct *tty) 711 721 { 712 722 struct mxser_port *info = container_of(port, struct mxser_port, port); ··· 741 731 * Clear the FIFO buffers and disable them 742 732 * (they will be reenabled in mxser_change_speed()) 743 733 */ 744 - if (info->board->must_hwid) 745 - outb((UART_FCR_CLEAR_RCVR | 746 - UART_FCR_CLEAR_XMIT | 747 - MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR); 748 - else 749 - outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 750 - info->ioaddr + UART_FCR); 734 + mxser_disable_and_clear_FIFO(info); 751 735 752 736 /* 753 737 * At this point there's no way the LSR could still be 0xFF; ··· 795 791 /* 796 792 * and set the speed of the serial port 797 793 */ 798 - mxser_change_speed(tty); 794 + mxser_change_speed(tty, NULL); 799 795 spin_unlock_irqrestore(&info->slock, flags); 800 796 801 797 return 0; ··· 829 825 outb(0x00, info->ioaddr + UART_IER); 830 826 831 827 /* clear Rx/Tx FIFO's */ 832 - if (info->board->must_hwid) 833 - outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | 834 - MOXA_MUST_FCR_GDA_MODE_ENABLE, 835 - info->ioaddr + UART_FCR); 836 - else 837 - outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 838 - info->ioaddr + UART_FCR); 828 + mxser_disable_and_clear_FIFO(info); 839 829 840 830 /* read data port to reset things */ 841 831 (void) inb(info->ioaddr + UART_RX); ··· 860 862 static void mxser_flush_buffer(struct tty_struct *tty) 861 863 { 862 864 struct mxser_port *info = tty->driver_data; 863 - char fcr; 864 865 unsigned long flags; 865 866 866 867 867 868 spin_lock_irqsave(&info->slock, flags); 868 869 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 869 870 870 - fcr = inb(info->ioaddr + UART_FCR); 871 - outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), 871 + outb(info->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 872 872 info->ioaddr + UART_FCR); 873 - outb(fcr, info->ioaddr + UART_FCR); 874 873 875 874 spin_unlock_irqrestore(&info->slock, flags); 876 875 ··· 1114 1119 if (tty_port_initialized(port)) { 1115 1120 if (old_speed != (port->flags & ASYNC_SPD_MASK)) { 1116 1121 spin_lock_irqsave(&info->slock, sl_flags); 1117 - mxser_change_speed(tty); 1122 + mxser_change_speed(tty, NULL); 1118 1123 spin_unlock_irqrestore(&info->slock, sl_flags); 1119 1124 } 1120 1125 } else { ··· 1330 1335 { 1331 1336 struct mxser_port *info = tty->driver_data; 1332 1337 1333 - info->ldisc_stop_rx = 1; 1338 + info->ldisc_stop_rx = true; 1334 1339 if (I_IXOFF(tty)) { 1335 1340 if (info->board->must_hwid) { 1336 1341 info->IER &= ~MOXA_MUST_RECV_ISR; ··· 1363 1368 struct mxser_port *info = tty->driver_data; 1364 1369 1365 1370 /* startrx */ 1366 - info->ldisc_stop_rx = 0; 1371 + info->ldisc_stop_rx = false; 1367 1372 if (I_IXOFF(tty)) { 1368 1373 if (info->x_char) 1369 1374 info->x_char = 0; ··· 1420 1425 unsigned long flags; 1421 1426 1422 1427 spin_lock_irqsave(&info->slock, flags); 1423 - mxser_change_speed(tty); 1428 + mxser_change_speed(tty, old_termios); 1424 1429 spin_unlock_irqrestore(&info->slock, flags); 1425 1430 1426 1431 if ((old_termios->c_cflag & CRTSCTS) && !C_CRTSCTS(tty)) { ··· 1539 1544 1540 1545 if (hwid == MOXA_OTHER_UART) 1541 1546 return false; 1542 - if (status & UART_LSR_BRK_ERROR_BITS) 1543 - return false; 1544 - if (hwid == MOXA_MUST_MU860_HWID && (status & MOXA_MUST_LSR_RERR)) 1545 - return false; 1546 - if (status & MOXA_MUST_LSR_RERR) 1547 + if (status & (UART_LSR_BRK_ERROR_BITS | MOXA_MUST_LSR_RERR)) 1547 1548 return false; 1548 1549 1549 1550 gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER); ··· 1573 1582 1574 1583 ch = inb(port->ioaddr + UART_RX); 1575 1584 if (hwid && (status & UART_LSR_OE)) 1576 - outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | 1577 - MOXA_MUST_FCR_GDA_MODE_ENABLE, 1585 + outb(port->FCR | UART_FCR_CLEAR_RCVR, 1578 1586 port->ioaddr + UART_FCR); 1579 1587 status &= port->read_status_mask; 1580 1588 if (status & port->ignore_status_mask) { ··· 1685 1695 tty = tty_port_tty_get(&port->port); 1686 1696 if (!tty || port->closing || !tty_port_initialized(&port->port)) { 1687 1697 status = inb(port->ioaddr + UART_LSR); 1688 - outb(MOXA_MUST_FCR_GDA_MODE_ENABLE | UART_FCR_ENABLE_FIFO | 1689 - UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 1698 + outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 1690 1699 port->ioaddr + UART_FCR); 1691 1700 inb(port->ioaddr + UART_MSR); 1692 1701 ··· 1836 1847 tty_port_init(&info->port); 1837 1848 info->port.ops = &mxser_port_ops; 1838 1849 info->board = brd; 1839 - info->ldisc_stop_rx = 0; 1850 + info->ldisc_stop_rx = false; 1840 1851 1841 1852 /* Enhance mode enabled here */ 1842 1853 if (brd->must_hwid != MOXA_OTHER_UART)
+89 -27
drivers/tty/n_gsm.c
··· 271 271 272 272 static struct tty_driver *gsm_tty_driver; 273 273 274 + /* Save dlci open address */ 275 + static int addr_open[256] = { 0 }; 276 + /* Save dlci open count */ 277 + static int addr_cnt; 274 278 /* 275 279 * This section of the driver logic implements the GSM encodings 276 280 * both the basic and the 'advanced'. Reliable transport is not ··· 591 587 return; 592 588 } 593 589 gsmld_output(gsm, cbuf, len); 590 + if (!gsm->initiator) { 591 + cr = cr & gsm->initiator; 592 + control = control & ~PF; 593 + } 594 594 gsm_print_packet("-->", addr, cr, control, NULL, 0); 595 595 } 596 596 ··· 609 601 610 602 static inline void gsm_response(struct gsm_mux *gsm, int addr, int control) 611 603 { 612 - gsm_send(gsm, addr, 0, control); 604 + gsm_send(gsm, addr, 1, control); 613 605 } 614 606 615 607 /** ··· 695 687 print_hex_dump_bytes("gsm_data_kick: ", 696 688 DUMP_PREFIX_OFFSET, 697 689 gsm->txframe, len); 698 - if (gsmld_output(gsm, gsm->txframe, len) < 0) 690 + if (gsmld_output(gsm, gsm->txframe, len) <= 0) 699 691 break; 700 692 /* FIXME: Can eliminate one SOF in many more cases */ 701 693 gsm->tx_bytes -= msg->len; ··· 1185 1177 } 1186 1178 1187 1179 static void gsm_dlci_begin_close(struct gsm_dlci *dlci); 1180 + static void gsm_dlci_close(struct gsm_dlci *dlci); 1188 1181 1189 1182 /** 1190 1183 * gsm_control_message - DLCI 0 control processing ··· 1204 1195 { 1205 1196 u8 buf[1]; 1206 1197 unsigned long flags; 1198 + struct gsm_dlci *dlci; 1199 + int i; 1200 + int address; 1207 1201 1208 1202 switch (command) { 1209 1203 case CMD_CLD: { 1210 - struct gsm_dlci *dlci = gsm->dlci[0]; 1204 + if (addr_cnt > 0) { 1205 + for (i = 0; i < addr_cnt; i++) { 1206 + address = addr_open[i]; 1207 + dlci = gsm->dlci[address]; 1208 + gsm_dlci_close(dlci); 1209 + addr_open[i] = 0; 1210 + } 1211 + } 1211 1212 /* Modem wishes to close down */ 1213 + dlci = gsm->dlci[0]; 1212 1214 if (dlci) { 1213 1215 dlci->dead = true; 1214 1216 gsm->dead = true; 1215 - gsm_dlci_begin_close(dlci); 1217 + gsm_dlci_close(dlci); 1218 + addr_cnt = 0; 1219 + gsm_response(gsm, 0, UA|PF); 1216 1220 } 1217 1221 } 1218 1222 break; ··· 1451 1429 kfifo_reset(&dlci->fifo); 1452 1430 } else 1453 1431 dlci->gsm->dead = true; 1432 + /* Unregister gsmtty driver,report gsmtty dev remove uevent for user */ 1433 + tty_unregister_device(gsm_tty_driver, dlci->addr); 1454 1434 wake_up(&dlci->gsm->event); 1455 1435 /* A DLCI 0 close is a MUX termination so we need to kick that 1456 1436 back to userspace somehow */ ··· 1474 1450 dlci->state = DLCI_OPEN; 1475 1451 if (debug & 8) 1476 1452 pr_debug("DLCI %d goes open.\n", dlci->addr); 1453 + /* Register gsmtty driver,report gsmtty dev add uevent for user */ 1454 + tty_register_device(gsm_tty_driver, dlci->addr, NULL); 1477 1455 wake_up(&dlci->gsm->event); 1478 1456 } 1479 1457 ··· 1774 1748 struct gsm_dlci *dlci; 1775 1749 u8 cr; 1776 1750 int address; 1751 + int i, j, k, address_tmp; 1777 1752 /* We have to sneak a look at the packet body to do the FCS. 1778 1753 A somewhat layering violation in the spec */ 1779 1754 ··· 1806 1779 1807 1780 switch (gsm->control) { 1808 1781 case SABM|PF: 1809 - if (cr == 0) 1782 + if (cr == 1) 1810 1783 goto invalid; 1811 1784 if (dlci == NULL) 1812 1785 dlci = gsm_dlci_alloc(gsm, address); 1813 1786 if (dlci == NULL) 1814 1787 return; 1815 1788 if (dlci->dead) 1816 - gsm_response(gsm, address, DM); 1789 + gsm_response(gsm, address, DM|PF); 1817 1790 else { 1818 - gsm_response(gsm, address, UA); 1791 + gsm_response(gsm, address, UA|PF); 1819 1792 gsm_dlci_open(dlci); 1793 + /* Save dlci open address */ 1794 + if (address) { 1795 + addr_open[addr_cnt] = address; 1796 + addr_cnt++; 1797 + } 1820 1798 } 1821 1799 break; 1822 1800 case DISC|PF: 1823 - if (cr == 0) 1801 + if (cr == 1) 1824 1802 goto invalid; 1825 1803 if (dlci == NULL || dlci->state == DLCI_CLOSED) { 1826 - gsm_response(gsm, address, DM); 1804 + gsm_response(gsm, address, DM|PF); 1827 1805 return; 1828 1806 } 1829 1807 /* Real close complete */ 1830 - gsm_response(gsm, address, UA); 1831 - gsm_dlci_close(dlci); 1808 + if (!address) { 1809 + if (addr_cnt > 0) { 1810 + for (i = 0; i < addr_cnt; i++) { 1811 + address = addr_open[i]; 1812 + dlci = gsm->dlci[address]; 1813 + gsm_dlci_close(dlci); 1814 + addr_open[i] = 0; 1815 + } 1816 + } 1817 + dlci = gsm->dlci[0]; 1818 + gsm_dlci_close(dlci); 1819 + addr_cnt = 0; 1820 + gsm_response(gsm, 0, UA|PF); 1821 + } else { 1822 + gsm_response(gsm, address, UA|PF); 1823 + gsm_dlci_close(dlci); 1824 + /* clear dlci address */ 1825 + for (j = 0; j < addr_cnt; j++) { 1826 + address_tmp = addr_open[j]; 1827 + if (address_tmp == address) { 1828 + for (k = j; k < addr_cnt; k++) 1829 + addr_open[k] = addr_open[k+1]; 1830 + addr_cnt--; 1831 + break; 1832 + } 1833 + } 1834 + } 1832 1835 break; 1833 1836 case UA: 1834 1837 case UA|PF: ··· 2357 2300 * configuration 2358 2301 */ 2359 2302 2360 - if (need_close || need_restart) { 2303 + if (gsm->initiator && (need_close || need_restart)) { 2361 2304 int ret; 2362 2305 2363 2306 ret = gsm_disconnect(gsm); ··· 2415 2358 if (debug & 4) 2416 2359 print_hex_dump_bytes("gsmld_output: ", DUMP_PREFIX_OFFSET, 2417 2360 data, len); 2418 - gsm->tty->ops->write(gsm->tty, data, len); 2419 - return len; 2361 + return gsm->tty->ops->write(gsm->tty, data, len); 2420 2362 } 2421 2363 2422 2364 /** ··· 2440 2384 else { 2441 2385 /* Don't register device 0 - this is the control channel and not 2442 2386 a usable tty interface */ 2443 - base = mux_num_to_base(gsm); /* Base for this MUX */ 2444 - for (i = 1; i < NUM_DLCI; i++) { 2445 - struct device *dev; 2387 + if (gsm->initiator) { 2388 + base = mux_num_to_base(gsm); /* Base for this MUX */ 2389 + for (i = 1; i < NUM_DLCI; i++) { 2390 + struct device *dev; 2446 2391 2447 - dev = tty_register_device(gsm_tty_driver, 2392 + dev = tty_register_device(gsm_tty_driver, 2448 2393 base + i, NULL); 2449 - if (IS_ERR(dev)) { 2450 - for (i--; i >= 1; i--) 2451 - tty_unregister_device(gsm_tty_driver, 2452 - base + i); 2453 - return PTR_ERR(dev); 2394 + if (IS_ERR(dev)) { 2395 + for (i--; i >= 1; i--) 2396 + tty_unregister_device(gsm_tty_driver, 2397 + base + i); 2398 + return PTR_ERR(dev); 2399 + } 2454 2400 } 2455 2401 } 2456 2402 } ··· 2474 2416 int i; 2475 2417 2476 2418 WARN_ON(tty != gsm->tty); 2477 - for (i = 1; i < NUM_DLCI; i++) 2478 - tty_unregister_device(gsm_tty_driver, base + i); 2419 + if (gsm->initiator) { 2420 + for (i = 1; i < NUM_DLCI; i++) 2421 + tty_unregister_device(gsm_tty_driver, base + i); 2422 + } 2479 2423 gsm_cleanup_mux(gsm); 2480 2424 tty_kref_put(gsm->tty); 2481 2425 gsm->tty = NULL; ··· 2711 2651 base = mux_num_to_base(gsm); 2712 2652 return put_user(base + 1, (__u32 __user *)arg); 2713 2653 default: 2714 - return n_tty_ioctl_helper(tty, file, cmd, arg); 2654 + return n_tty_ioctl_helper(tty, cmd, arg); 2715 2655 } 2716 2656 } 2717 2657 ··· 3060 3000 { 3061 3001 struct gsm_dlci *dlci = tty->driver_data; 3062 3002 struct tty_port *port = &dlci->port; 3003 + struct gsm_mux *gsm = dlci->gsm; 3063 3004 3064 3005 port->count++; 3065 3006 tty_port_tty_set(port, tty); ··· 3070 3009 a DM straight back. This is ok as that will have caused a hangup */ 3071 3010 tty_port_set_initialized(port, 1); 3072 3011 /* Start sending off SABM messages */ 3073 - gsm_dlci_begin_open(dlci); 3012 + if (gsm->initiator) 3013 + gsm_dlci_begin_open(dlci); 3074 3014 /* And wait for virtual carrier */ 3075 3015 return tty_port_block_til_ready(port, tty, filp); 3076 3016 }
+1 -1
drivers/tty/n_hdlc.c
··· 630 630 fallthrough; /* to default */ 631 631 632 632 default: 633 - error = n_tty_ioctl_helper(tty, file, cmd, arg); 633 + error = n_tty_ioctl_helper(tty, cmd, arg); 634 634 break; 635 635 } 636 636 return error;
+1 -2
drivers/tty/n_tty.c
··· 2418 2418 up_write(&tty->termios_rwsem); 2419 2419 return put_user(retval, (unsigned int __user *) arg); 2420 2420 default: 2421 - return n_tty_ioctl_helper(tty, file, cmd, arg); 2421 + return n_tty_ioctl_helper(tty, cmd, arg); 2422 2422 } 2423 2423 } 2424 2424 ··· 2450 2450 { 2451 2451 *ops = n_tty_ops; 2452 2452 ops->owner = NULL; 2453 - ops->flags = 0; 2454 2453 } 2455 2454 EXPORT_SYMBOL_GPL(n_tty_inherit_ops); 2456 2455
+275
drivers/tty/rpmsg_tty.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2021 STMicroelectronics - All Rights Reserved 4 + * 5 + * The rpmsg tty driver implements serial communication on the RPMsg bus to makes 6 + * possible for user-space programs to send and receive rpmsg messages as a standard 7 + * tty protocol. 8 + * 9 + * The remote processor can instantiate a new tty by requesting a "rpmsg-tty" RPMsg service. 10 + * The "rpmsg-tty" service is directly used for data exchange. No flow control is implemented yet. 11 + */ 12 + 13 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 14 + 15 + #include <linux/module.h> 16 + #include <linux/rpmsg.h> 17 + #include <linux/slab.h> 18 + #include <linux/tty.h> 19 + #include <linux/tty_flip.h> 20 + 21 + #define RPMSG_TTY_NAME "ttyRPMSG" 22 + #define MAX_TTY_RPMSG 32 23 + 24 + static DEFINE_IDR(tty_idr); /* tty instance id */ 25 + static DEFINE_MUTEX(idr_lock); /* protects tty_idr */ 26 + 27 + static struct tty_driver *rpmsg_tty_driver; 28 + 29 + struct rpmsg_tty_port { 30 + struct tty_port port; /* TTY port data */ 31 + int id; /* TTY rpmsg index */ 32 + struct rpmsg_device *rpdev; /* rpmsg device */ 33 + }; 34 + 35 + static int rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len, void *priv, u32 src) 36 + { 37 + struct rpmsg_tty_port *cport = dev_get_drvdata(&rpdev->dev); 38 + int copied; 39 + 40 + if (!len) 41 + return -EINVAL; 42 + copied = tty_insert_flip_string(&cport->port, data, len); 43 + if (copied != len) 44 + dev_err_ratelimited(&rpdev->dev, "Trunc buffer: available space is %d\n", copied); 45 + tty_flip_buffer_push(&cport->port); 46 + 47 + return 0; 48 + } 49 + 50 + static int rpmsg_tty_install(struct tty_driver *driver, struct tty_struct *tty) 51 + { 52 + struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index); 53 + 54 + tty->driver_data = cport; 55 + 56 + return tty_port_install(&cport->port, driver, tty); 57 + } 58 + 59 + static int rpmsg_tty_open(struct tty_struct *tty, struct file *filp) 60 + { 61 + return tty_port_open(tty->port, tty, filp); 62 + } 63 + 64 + static void rpmsg_tty_close(struct tty_struct *tty, struct file *filp) 65 + { 66 + return tty_port_close(tty->port, tty, filp); 67 + } 68 + 69 + static int rpmsg_tty_write(struct tty_struct *tty, const u8 *buf, int len) 70 + { 71 + struct rpmsg_tty_port *cport = tty->driver_data; 72 + struct rpmsg_device *rpdev; 73 + int msg_max_size, msg_size; 74 + int ret; 75 + 76 + rpdev = cport->rpdev; 77 + 78 + msg_max_size = rpmsg_get_mtu(rpdev->ept); 79 + if (msg_max_size < 0) 80 + return msg_max_size; 81 + 82 + msg_size = min(len, msg_max_size); 83 + 84 + /* 85 + * Use rpmsg_trysend instead of rpmsg_send to send the message so the caller is not 86 + * hung until a rpmsg buffer is available. In such case rpmsg_trysend returns -ENOMEM. 87 + */ 88 + ret = rpmsg_trysend(rpdev->ept, (void *)buf, msg_size); 89 + if (ret) { 90 + dev_dbg_ratelimited(&rpdev->dev, "rpmsg_send failed: %d\n", ret); 91 + return ret; 92 + } 93 + 94 + return msg_size; 95 + } 96 + 97 + static unsigned int rpmsg_tty_write_room(struct tty_struct *tty) 98 + { 99 + struct rpmsg_tty_port *cport = tty->driver_data; 100 + int size; 101 + 102 + size = rpmsg_get_mtu(cport->rpdev->ept); 103 + if (size < 0) 104 + return 0; 105 + 106 + return size; 107 + } 108 + 109 + static const struct tty_operations rpmsg_tty_ops = { 110 + .install = rpmsg_tty_install, 111 + .open = rpmsg_tty_open, 112 + .close = rpmsg_tty_close, 113 + .write = rpmsg_tty_write, 114 + .write_room = rpmsg_tty_write_room, 115 + }; 116 + 117 + static struct rpmsg_tty_port *rpmsg_tty_alloc_cport(void) 118 + { 119 + struct rpmsg_tty_port *cport; 120 + int ret; 121 + 122 + cport = kzalloc(sizeof(*cport), GFP_KERNEL); 123 + if (!cport) 124 + return ERR_PTR(-ENOMEM); 125 + 126 + mutex_lock(&idr_lock); 127 + ret = idr_alloc(&tty_idr, cport, 0, MAX_TTY_RPMSG, GFP_KERNEL); 128 + mutex_unlock(&idr_lock); 129 + 130 + if (ret < 0) { 131 + kfree(cport); 132 + return ERR_PTR(ret); 133 + } 134 + 135 + cport->id = ret; 136 + 137 + return cport; 138 + } 139 + 140 + static void rpmsg_tty_release_cport(struct rpmsg_tty_port *cport) 141 + { 142 + mutex_lock(&idr_lock); 143 + idr_remove(&tty_idr, cport->id); 144 + mutex_unlock(&idr_lock); 145 + 146 + kfree(cport); 147 + } 148 + 149 + static const struct tty_port_operations rpmsg_tty_port_ops = { }; 150 + 151 + static int rpmsg_tty_probe(struct rpmsg_device *rpdev) 152 + { 153 + struct rpmsg_tty_port *cport; 154 + struct device *dev = &rpdev->dev; 155 + struct device *tty_dev; 156 + int ret; 157 + 158 + cport = rpmsg_tty_alloc_cport(); 159 + if (IS_ERR(cport)) 160 + return dev_err_probe(dev, PTR_ERR(cport), "Failed to alloc tty port\n"); 161 + 162 + tty_port_init(&cport->port); 163 + cport->port.ops = &rpmsg_tty_port_ops; 164 + 165 + tty_dev = tty_port_register_device(&cport->port, rpmsg_tty_driver, 166 + cport->id, dev); 167 + if (IS_ERR(tty_dev)) { 168 + ret = dev_err_probe(dev, PTR_ERR(tty_dev), "Failed to register tty port\n"); 169 + goto err_destroy; 170 + } 171 + 172 + cport->rpdev = rpdev; 173 + 174 + dev_set_drvdata(dev, cport); 175 + 176 + dev_dbg(dev, "New channel: 0x%x -> 0x%x: " RPMSG_TTY_NAME "%d\n", 177 + rpdev->src, rpdev->dst, cport->id); 178 + 179 + return 0; 180 + 181 + err_destroy: 182 + tty_port_destroy(&cport->port); 183 + rpmsg_tty_release_cport(cport); 184 + 185 + return ret; 186 + } 187 + 188 + static void rpmsg_tty_remove(struct rpmsg_device *rpdev) 189 + { 190 + struct rpmsg_tty_port *cport = dev_get_drvdata(&rpdev->dev); 191 + 192 + dev_dbg(&rpdev->dev, "Removing rpmsg tty device %d\n", cport->id); 193 + 194 + /* User hang up to release the tty */ 195 + if (tty_port_initialized(&cport->port)) 196 + tty_port_tty_hangup(&cport->port, false); 197 + 198 + tty_unregister_device(rpmsg_tty_driver, cport->id); 199 + 200 + tty_port_destroy(&cport->port); 201 + rpmsg_tty_release_cport(cport); 202 + } 203 + 204 + static struct rpmsg_device_id rpmsg_driver_tty_id_table[] = { 205 + { .name = "rpmsg-tty" }, 206 + { }, 207 + }; 208 + MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_tty_id_table); 209 + 210 + static struct rpmsg_driver rpmsg_tty_rpmsg_drv = { 211 + .drv.name = KBUILD_MODNAME, 212 + .id_table = rpmsg_driver_tty_id_table, 213 + .probe = rpmsg_tty_probe, 214 + .callback = rpmsg_tty_cb, 215 + .remove = rpmsg_tty_remove, 216 + }; 217 + 218 + static int __init rpmsg_tty_init(void) 219 + { 220 + int ret; 221 + 222 + rpmsg_tty_driver = tty_alloc_driver(MAX_TTY_RPMSG, TTY_DRIVER_REAL_RAW | 223 + TTY_DRIVER_DYNAMIC_DEV); 224 + if (IS_ERR(rpmsg_tty_driver)) 225 + return PTR_ERR(rpmsg_tty_driver); 226 + 227 + rpmsg_tty_driver->driver_name = "rpmsg_tty"; 228 + rpmsg_tty_driver->name = RPMSG_TTY_NAME; 229 + rpmsg_tty_driver->major = 0; 230 + rpmsg_tty_driver->type = TTY_DRIVER_TYPE_CONSOLE; 231 + 232 + /* Disable unused mode by default */ 233 + rpmsg_tty_driver->init_termios = tty_std_termios; 234 + rpmsg_tty_driver->init_termios.c_lflag &= ~(ECHO | ICANON); 235 + rpmsg_tty_driver->init_termios.c_oflag &= ~(OPOST | ONLCR); 236 + 237 + tty_set_operations(rpmsg_tty_driver, &rpmsg_tty_ops); 238 + 239 + ret = tty_register_driver(rpmsg_tty_driver); 240 + if (ret < 0) { 241 + pr_err("Couldn't install driver: %d\n", ret); 242 + goto error_put; 243 + } 244 + 245 + ret = register_rpmsg_driver(&rpmsg_tty_rpmsg_drv); 246 + if (ret < 0) { 247 + pr_err("Couldn't register driver: %d\n", ret); 248 + goto error_unregister; 249 + } 250 + 251 + return 0; 252 + 253 + error_unregister: 254 + tty_unregister_driver(rpmsg_tty_driver); 255 + 256 + error_put: 257 + tty_driver_kref_put(rpmsg_tty_driver); 258 + 259 + return ret; 260 + } 261 + 262 + static void __exit rpmsg_tty_exit(void) 263 + { 264 + unregister_rpmsg_driver(&rpmsg_tty_rpmsg_drv); 265 + tty_unregister_driver(rpmsg_tty_driver); 266 + tty_driver_kref_put(rpmsg_tty_driver); 267 + idr_destroy(&tty_idr); 268 + } 269 + 270 + module_init(rpmsg_tty_init); 271 + module_exit(rpmsg_tty_exit); 272 + 273 + MODULE_AUTHOR("Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>"); 274 + MODULE_DESCRIPTION("remote processor messaging tty driver"); 275 + MODULE_LICENSE("GPL v2");
+12 -16
drivers/tty/serial/8250/8250_dw.c
··· 338 338 rate = clk_round_rate(d->clk, newrate); 339 339 if (rate > 0) { 340 340 /* 341 - * Premilinary set the uartclk to the new clock rate so the 342 - * clock update event handler caused by the clk_set_rate() 343 - * calling wouldn't actually update the UART divisor since 344 - * we about to do this anyway. 341 + * Note that any clock-notifer worker will block in 342 + * serial8250_update_uartclk() until we are done. 345 343 */ 346 - swap(p->uartclk, rate); 347 344 ret = clk_set_rate(d->clk, newrate); 348 - if (ret) 349 - swap(p->uartclk, rate); 345 + if (!ret) 346 + p->uartclk = rate; 350 347 } 351 348 clk_prepare_enable(d->clk); 352 349 353 - p->status &= ~UPSTAT_AUTOCTS; 354 - if (termios->c_cflag & CRTSCTS) 355 - p->status |= UPSTAT_AUTOCTS; 356 - 357 - serial8250_do_set_termios(p, termios, old); 350 + dw8250_do_set_termios(p, termios, old); 358 351 } 359 352 360 353 static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios) ··· 386 393 387 394 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) 388 395 { 389 - if (p->dev->of_node) { 390 - struct device_node *np = p->dev->of_node; 396 + struct device_node *np = p->dev->of_node; 397 + 398 + if (np) { 391 399 int id; 392 400 393 401 /* get index of serial line, if found in DT aliases */ ··· 405 411 data->skip_autocfg = true; 406 412 } 407 413 #endif 408 - if (of_device_is_big_endian(p->dev->of_node)) { 414 + 415 + if (of_device_is_big_endian(np)) { 409 416 p->iotype = UPIO_MEM32BE; 410 417 p->serial_in = dw8250_serial_in32be; 411 418 p->serial_out = dw8250_serial_out32be; 412 419 } 420 + 413 421 if (of_device_is_compatible(np, "marvell,armada-38x-uart")) 414 422 p->serial_out = dw8250_serial_out38x; 415 423 ··· 722 726 .name = "dw-apb-uart", 723 727 .pm = &dw8250_pm_ops, 724 728 .of_match_table = dw8250_of_match, 725 - .acpi_match_table = ACPI_PTR(dw8250_acpi_match), 729 + .acpi_match_table = dw8250_acpi_match, 726 730 }, 727 731 .probe = dw8250_probe, 728 732 .remove = dw8250_remove,
+10
drivers/tty/serial/8250/8250_dwlib.c
··· 77 77 serial8250_do_set_divisor(p, baud, quot, quot_frac); 78 78 } 79 79 80 + void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old) 81 + { 82 + p->status &= ~UPSTAT_AUTOCTS; 83 + if (termios->c_cflag & CRTSCTS) 84 + p->status |= UPSTAT_AUTOCTS; 85 + 86 + serial8250_do_set_termios(p, termios, old); 87 + } 88 + EXPORT_SYMBOL_GPL(dw8250_do_set_termios); 89 + 80 90 void dw8250_setup_port(struct uart_port *p) 81 91 { 82 92 struct uart_8250_port *up = up_to_u8250p(p);
+1
drivers/tty/serial/8250/8250_dwlib.h
··· 16 16 u8 dlf_size; 17 17 }; 18 18 19 + void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old); 19 20 void dw8250_setup_port(struct uart_port *p);
+4 -4
drivers/tty/serial/8250/8250_fsl.c
··· 23 23 24 24 #include "8250.h" 25 25 26 - struct fsl8250_data { 27 - int line; 28 - }; 29 - 30 26 int fsl8250_handle_irq(struct uart_port *port) 31 27 { 32 28 unsigned char lsr, orig_lsr; ··· 86 90 EXPORT_SYMBOL_GPL(fsl8250_handle_irq); 87 91 88 92 #ifdef CONFIG_ACPI 93 + struct fsl8250_data { 94 + int line; 95 + }; 96 + 89 97 static int fsl8250_acpi_probe(struct platform_device *pdev) 90 98 { 91 99 struct fsl8250_data *data;
+4 -5
drivers/tty/serial/8250/8250_lpss.c
··· 100 100 reg |= BYT_PRV_CLK_EN | BYT_PRV_CLK_UPDATE; 101 101 writel(reg, p->membase + BYT_PRV_CLK); 102 102 103 - p->status &= ~UPSTAT_AUTOCTS; 104 - if (termios->c_cflag & CRTSCTS) 105 - p->status |= UPSTAT_AUTOCTS; 106 - 107 - serial8250_do_set_termios(p, termios, old); 103 + dw8250_do_set_termios(p, termios, old); 108 104 } 109 105 110 106 static unsigned int byt_get_mctrl(struct uart_port *port) ··· 164 168 * matching with the registered General Purpose DMA controllers. 165 169 */ 166 170 up->dma = dma; 171 + 172 + port->set_termios = dw8250_do_set_termios; 173 + 167 174 return 0; 168 175 } 169 176
+57 -86
drivers/tty/serial/8250/8250_pci.c
··· 75 75 76 76 static void moan_device(const char *str, struct pci_dev *dev) 77 77 { 78 - dev_err(&dev->dev, 79 - "%s: %s\n" 78 + pci_err(dev, "%s\n" 80 79 "Please send the output of lspci -vv, this\n" 81 80 "message (0x%04x,0x%04x,0x%04x,0x%04x), the\n" 82 81 "manufacturer and name of serial board or\n" 83 82 "modem board to <linux-serial@vger.kernel.org>.\n", 84 - pci_name(dev), str, dev->vendor, dev->device, 83 + str, dev->vendor, dev->device, 85 84 dev->subsystem_vendor, dev->subsystem_device); 86 85 } 87 86 ··· 237 238 /* is firmware started? */ 238 239 pci_read_config_dword(dev, 0x44, &oldval); 239 240 if (oldval == 0x00001000L) { /* RESET value */ 240 - dev_dbg(&dev->dev, "Local i960 firmware missing\n"); 241 + pci_dbg(dev, "Local i960 firmware missing\n"); 241 242 return -ENODEV; 242 243 } 243 244 return 0; ··· 514 515 515 516 if (type == 0x1000) 516 517 return pci_siig10x_init(dev); 517 - else if (type == 0x2000) 518 + if (type == 0x2000) 518 519 return pci_siig20x_init(dev); 519 520 520 521 moan_device("Unknown SIIG card", dev); ··· 587 588 * (0,2,3,5,6: serial only -- 7,8,9: serial + parallel) 588 589 */ 589 590 if ((dev->subsystem_device & 0x00f0) >= 0x70) { 590 - dev_info(&dev->dev, 591 - "ignoring Timedia subdevice %04x for parport_serial\n", 592 - dev->subsystem_device); 591 + pci_info(dev, "ignoring Timedia subdevice %04x for parport_serial\n", 592 + dev->subsystem_device); 593 593 return -ENODEV; 594 594 } 595 595 ··· 790 792 bar = 3 * idx; 791 793 792 794 return setup_port(priv, port, bar, 0, board->reg_shift); 793 - } else { 794 - return pci_default_setup(priv, board, port, idx); 795 795 } 796 + 797 + return pci_default_setup(priv, board, port, idx); 796 798 } 797 799 798 800 /* the 99xx series comes with a range of device IDs and a variety ··· 825 827 if (sub_serports > 0) 826 828 return sub_serports; 827 829 828 - dev_err(&dev->dev, 829 - "NetMos/Mostech serial driver ignoring port on ambiguous config.\n"); 830 + pci_err(dev, "NetMos/Mostech serial driver ignoring port on ambiguous config.\n"); 830 831 return 0; 831 832 } 832 833 ··· 894 897 /* enable IO_Space bit */ 895 898 #define ITE_887x_POSIO_ENABLE (1 << 31) 896 899 900 + /* inta_addr are the configuration addresses of the ITE */ 901 + static const short inta_addr[] = { 0x2a0, 0x2c0, 0x220, 0x240, 0x1e0, 0x200, 0x280 }; 897 902 static int pci_ite887x_init(struct pci_dev *dev) 898 903 { 899 - /* inta_addr are the configuration addresses of the ITE */ 900 - static const short inta_addr[] = { 0x2a0, 0x2c0, 0x220, 0x240, 0x1e0, 901 - 0x200, 0x280, 0 }; 902 904 int ret, i, type; 903 905 struct resource *iobase = NULL; 904 906 u32 miscr, uartbar, ioport; 905 907 906 908 /* search for the base-ioport */ 907 - i = 0; 908 - while (inta_addr[i] && iobase == NULL) { 909 + for (i = 0; i < ARRAY_SIZE(inta_addr); i++) { 909 910 iobase = request_region(inta_addr[i], ITE_887x_IOSIZE, 910 911 "ite887x"); 911 912 if (iobase != NULL) { ··· 920 925 break; 921 926 } 922 927 release_region(iobase->start, ITE_887x_IOSIZE); 923 - iobase = NULL; 924 928 } 925 - i++; 926 929 } 927 930 928 - if (!inta_addr[i]) { 929 - dev_err(&dev->dev, "ite887x: could not find iobase\n"); 931 + if (i == ARRAY_SIZE(inta_addr)) { 932 + pci_err(dev, "could not find iobase\n"); 930 933 return -ENODEV; 931 934 } 932 935 ··· 1019 1026 /* EndRun device */ 1020 1027 if (deviceID == 0x07000200) { 1021 1028 number_uarts = ioread8(p + 4); 1022 - dev_dbg(&dev->dev, 1023 - "%d ports detected on EndRun PCI Express device\n", 1024 - number_uarts); 1029 + pci_dbg(dev, "%d ports detected on EndRun PCI Express device\n", number_uarts); 1025 1030 } 1026 1031 pci_iounmap(dev, p); 1027 1032 return number_uarts; ··· 1049 1058 /* Tornado device */ 1050 1059 if (deviceID == 0x07000200) { 1051 1060 number_uarts = ioread8(p + 4); 1052 - dev_dbg(&dev->dev, 1053 - "%d ports detected on Oxford PCI Express device\n", 1054 - number_uarts); 1061 + pci_dbg(dev, "%d ports detected on Oxford PCI Express device\n", number_uarts); 1055 1062 } 1056 1063 pci_iounmap(dev, p); 1057 1064 return number_uarts; ··· 1062 1073 port->bugs |= UART_BUG_PARITY; 1063 1074 return pci_default_setup(priv, board, port, idx); 1064 1075 } 1065 - 1066 - /* Quatech devices have their own extra interface features */ 1067 - 1068 - struct quatech_feature { 1069 - u16 devid; 1070 - bool amcc; 1071 - }; 1072 1076 1073 1077 #define QPCR_TEST_FOR1 0x3F 1074 1078 #define QPCR_TEST_GET1 0x00 ··· 1078 1096 #define QOPR_CLOCK_X8 0x0003 1079 1097 #define QOPR_CLOCK_RATE_MASK 0x0003 1080 1098 1081 - 1082 - static struct quatech_feature quatech_cards[] = { 1083 - { PCI_DEVICE_ID_QUATECH_QSC100, 1 }, 1084 - { PCI_DEVICE_ID_QUATECH_DSC100, 1 }, 1085 - { PCI_DEVICE_ID_QUATECH_DSC100E, 0 }, 1086 - { PCI_DEVICE_ID_QUATECH_DSC200, 1 }, 1087 - { PCI_DEVICE_ID_QUATECH_DSC200E, 0 }, 1088 - { PCI_DEVICE_ID_QUATECH_ESC100D, 1 }, 1089 - { PCI_DEVICE_ID_QUATECH_ESC100M, 1 }, 1090 - { PCI_DEVICE_ID_QUATECH_QSCP100, 1 }, 1091 - { PCI_DEVICE_ID_QUATECH_DSCP100, 1 }, 1092 - { PCI_DEVICE_ID_QUATECH_QSCP200, 1 }, 1093 - { PCI_DEVICE_ID_QUATECH_DSCP200, 1 }, 1094 - { PCI_DEVICE_ID_QUATECH_ESCLP100, 0 }, 1095 - { PCI_DEVICE_ID_QUATECH_QSCLP100, 0 }, 1096 - { PCI_DEVICE_ID_QUATECH_DSCLP100, 0 }, 1097 - { PCI_DEVICE_ID_QUATECH_SSCLP100, 0 }, 1098 - { PCI_DEVICE_ID_QUATECH_QSCLP200, 0 }, 1099 - { PCI_DEVICE_ID_QUATECH_DSCLP200, 0 }, 1100 - { PCI_DEVICE_ID_QUATECH_SSCLP200, 0 }, 1101 - { PCI_DEVICE_ID_QUATECH_SPPXP_100, 0 }, 1099 + /* Quatech devices have their own extra interface features */ 1100 + static struct pci_device_id quatech_cards[] = { 1101 + { PCI_DEVICE_DATA(QUATECH, QSC100, 1) }, 1102 + { PCI_DEVICE_DATA(QUATECH, DSC100, 1) }, 1103 + { PCI_DEVICE_DATA(QUATECH, DSC100E, 0) }, 1104 + { PCI_DEVICE_DATA(QUATECH, DSC200, 1) }, 1105 + { PCI_DEVICE_DATA(QUATECH, DSC200E, 0) }, 1106 + { PCI_DEVICE_DATA(QUATECH, ESC100D, 1) }, 1107 + { PCI_DEVICE_DATA(QUATECH, ESC100M, 1) }, 1108 + { PCI_DEVICE_DATA(QUATECH, QSCP100, 1) }, 1109 + { PCI_DEVICE_DATA(QUATECH, DSCP100, 1) }, 1110 + { PCI_DEVICE_DATA(QUATECH, QSCP200, 1) }, 1111 + { PCI_DEVICE_DATA(QUATECH, DSCP200, 1) }, 1112 + { PCI_DEVICE_DATA(QUATECH, ESCLP100, 0) }, 1113 + { PCI_DEVICE_DATA(QUATECH, QSCLP100, 0) }, 1114 + { PCI_DEVICE_DATA(QUATECH, DSCLP100, 0) }, 1115 + { PCI_DEVICE_DATA(QUATECH, SSCLP100, 0) }, 1116 + { PCI_DEVICE_DATA(QUATECH, QSCLP200, 0) }, 1117 + { PCI_DEVICE_DATA(QUATECH, DSCLP200, 0) }, 1118 + { PCI_DEVICE_DATA(QUATECH, SSCLP200, 0) }, 1119 + { PCI_DEVICE_DATA(QUATECH, SPPXP_100, 0) }, 1102 1120 { 0, } 1103 - }; 1104 - 1105 - static int pci_quatech_amcc(u16 devid) 1106 - { 1107 - struct quatech_feature *qf = &quatech_cards[0]; 1108 - while (qf->devid) { 1109 - if (qf->devid == devid) 1110 - return qf->amcc; 1111 - qf++; 1112 - } 1113 - pr_err("quatech: unknown port type '0x%04X'.\n", devid); 1114 - return 0; 1115 1121 }; 1116 1122 1117 1123 static int pci_quatech_rqopr(struct uart_8250_port *port) ··· 1261 1291 1262 1292 static int pci_quatech_init(struct pci_dev *dev) 1263 1293 { 1264 - if (pci_quatech_amcc(dev->device)) { 1294 + const struct pci_device_id *match; 1295 + bool amcc = false; 1296 + 1297 + match = pci_match_id(quatech_cards, dev); 1298 + if (match) 1299 + amcc = match->driver_data; 1300 + else 1301 + pci_err(dev, "unknown port type '0x%04X'.\n", dev->device); 1302 + 1303 + if (amcc) { 1265 1304 unsigned long base = pci_resource_start(dev, 0); 1266 1305 if (base) { 1267 1306 u32 tmp; ··· 1294 1315 port->port.uartclk = pci_quatech_clock(port); 1295 1316 /* For now just warn about RS422 */ 1296 1317 if (pci_quatech_rs422(port)) 1297 - pr_warn("quatech: software control of RS422 features not currently supported.\n"); 1318 + pci_warn(priv->dev, "software control of RS422 features not currently supported.\n"); 1298 1319 return pci_default_setup(priv, board, port, idx); 1299 - } 1300 - 1301 - static void pci_quatech_exit(struct pci_dev *dev) 1302 - { 1303 1320 } 1304 1321 1305 1322 static int pci_default_setup(struct serial_private *priv, ··· 1500 1525 /* Get the io address from configuration space */ 1501 1526 pci_read_config_word(pdev, config_base + 4, &iobase); 1502 1527 1503 - dev_dbg(&pdev->dev, "%s: idx=%d iobase=0x%x", __func__, idx, iobase); 1528 + pci_dbg(pdev, "idx=%d iobase=0x%x", idx, iobase); 1504 1529 1505 1530 port->port.iotype = UPIO_PORT; 1506 1531 port->port.iobase = iobase; ··· 1664 1689 struct uart_8250_port *port, int idx) 1665 1690 { 1666 1691 port->port.quirks |= UPQ_NO_TXEN_TEST; 1667 - dev_dbg(&priv->dev->dev, 1692 + pci_dbg(priv->dev, 1668 1693 "serial8250: skipping TxEn test for device [%04x:%04x] subsystem [%04x:%04x]\n", 1669 1694 priv->dev->vendor, priv->dev->device, 1670 1695 priv->dev->subsystem_vendor, priv->dev->subsystem_device); ··· 2172 2197 .subdevice = PCI_ANY_ID, 2173 2198 .init = pci_quatech_init, 2174 2199 .setup = pci_quatech_setup, 2175 - .exit = pci_quatech_exit, 2176 2200 }, 2177 2201 /* 2178 2202 * Panacom ··· 3955 3981 nr_ports = rc; 3956 3982 } 3957 3983 3958 - priv = kzalloc(sizeof(struct serial_private) + 3959 - sizeof(unsigned int) * nr_ports, 3960 - GFP_KERNEL); 3984 + priv = kzalloc(struct_size(priv, line, nr_ports), GFP_KERNEL); 3961 3985 if (!priv) { 3962 3986 priv = ERR_PTR(-ENOMEM); 3963 3987 goto err_deinit; ··· 3972 4000 uart.port.irq = 0; 3973 4001 } else { 3974 4002 if (pci_match_id(pci_use_msi, dev)) { 3975 - dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n"); 4003 + pci_dbg(dev, "Using MSI(-X) interrupts\n"); 3976 4004 pci_set_master(dev); 3977 4005 uart.port.flags &= ~UPF_SHARE_IRQ; 3978 4006 rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES); 3979 4007 } else { 3980 - dev_dbg(&dev->dev, "Using legacy interrupts\n"); 4008 + pci_dbg(dev, "Using legacy interrupts\n"); 3981 4009 rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY); 3982 4010 } 3983 4011 if (rc < 0) { ··· 3995 4023 if (quirk->setup(priv, board, &uart, i)) 3996 4024 break; 3997 4025 3998 - dev_dbg(&dev->dev, "Setup PCI port: port %lx, irq %d, type %d\n", 4026 + pci_dbg(dev, "Setup PCI port: port %lx, irq %d, type %d\n", 3999 4027 uart.port.iobase, uart.port.irq, uart.port.iotype); 4000 4028 4001 4029 priv->line[i] = serial8250_register_8250_port(&uart); 4002 4030 if (priv->line[i] < 0) { 4003 - dev_err(&dev->dev, 4031 + pci_err(dev, 4004 4032 "Couldn't register serial port %lx, irq %d, type %d, error %d\n", 4005 4033 uart.port.iobase, uart.port.irq, 4006 4034 uart.port.iotype, priv->line[i]); ··· 4096 4124 } 4097 4125 4098 4126 if (ent->driver_data >= ARRAY_SIZE(pci_boards)) { 4099 - dev_err(&dev->dev, "invalid driver_data: %ld\n", 4100 - ent->driver_data); 4127 + pci_err(dev, "invalid driver_data: %ld\n", ent->driver_data); 4101 4128 return -EINVAL; 4102 4129 } 4103 4130 ··· 4179 4208 err = pci_enable_device(pdev); 4180 4209 /* FIXME: We cannot simply error out here */ 4181 4210 if (err) 4182 - dev_err(dev, "Unable to re-enable ports, trying to continue.\n"); 4211 + pci_err(pdev, "Unable to re-enable ports, trying to continue.\n"); 4183 4212 pciserial_resume_ports(priv); 4184 4213 } 4185 4214 return 0;
-4
drivers/tty/serial/8250/8250_pnp.c
··· 56 56 { "BRI1400", 0 }, 57 57 /* Boca 33.6 Kbps Internal FD34FSVD */ 58 58 { "BRI3400", 0 }, 59 - /* Boca 33.6 Kbps Internal FD34FSVD */ 60 - { "BRI0A49", 0 }, 61 - /* Best Data Products Inc. Smart One 336F PnP Modem */ 62 - { "BDP3336", 0 }, 63 59 /* Computer Peripherals Inc */ 64 60 /* EuroViVa CommCenter-33.6 SP PnP */ 65 61 { "CPI4050", 0 },
+22 -9
drivers/tty/serial/8250/8250_port.c
··· 1338 1338 up->tx_loadsz = uart_config[port->type].tx_loadsz; 1339 1339 1340 1340 if (port->type == PORT_UNKNOWN) 1341 - goto out_lock; 1341 + goto out_unlock; 1342 1342 1343 1343 /* 1344 1344 * Reset the UART. ··· 1355 1355 else 1356 1356 serial_out(up, UART_IER, 0); 1357 1357 1358 - out_lock: 1358 + out_unlock: 1359 1359 spin_unlock_irqrestore(&port->lock, flags); 1360 1360 1361 1361 /* ··· 2696 2696 void serial8250_update_uartclk(struct uart_port *port, unsigned int uartclk) 2697 2697 { 2698 2698 struct uart_8250_port *up = up_to_u8250p(port); 2699 + struct tty_port *tport = &port->state->port; 2699 2700 unsigned int baud, quot, frac = 0; 2700 2701 struct ktermios *termios; 2702 + struct tty_struct *tty; 2701 2703 unsigned long flags; 2702 2704 2703 - mutex_lock(&port->state->port.mutex); 2705 + tty = tty_port_tty_get(tport); 2706 + if (!tty) { 2707 + mutex_lock(&tport->mutex); 2708 + port->uartclk = uartclk; 2709 + mutex_unlock(&tport->mutex); 2710 + return; 2711 + } 2712 + 2713 + down_write(&tty->termios_rwsem); 2714 + mutex_lock(&tport->mutex); 2704 2715 2705 2716 if (port->uartclk == uartclk) 2706 - goto out_lock; 2717 + goto out_unlock; 2707 2718 2708 2719 port->uartclk = uartclk; 2709 2720 2710 - if (!tty_port_initialized(&port->state->port)) 2711 - goto out_lock; 2721 + if (!tty_port_initialized(tport)) 2722 + goto out_unlock; 2712 2723 2713 - termios = &port->state->port.tty->termios; 2724 + termios = &tty->termios; 2714 2725 2715 2726 baud = serial8250_get_baud_rate(port, termios, NULL); 2716 2727 quot = serial8250_get_divisor(port, baud, &frac); ··· 2737 2726 spin_unlock_irqrestore(&port->lock, flags); 2738 2727 serial8250_rpm_put(up); 2739 2728 2740 - out_lock: 2741 - mutex_unlock(&port->state->port.mutex); 2729 + out_unlock: 2730 + mutex_unlock(&tport->mutex); 2731 + up_write(&tty->termios_rwsem); 2732 + tty_kref_put(tty); 2742 2733 } 2743 2734 EXPORT_SYMBOL_GPL(serial8250_update_uartclk); 2744 2735
+1 -1
drivers/tty/serial/8250/Kconfig
··· 380 380 config SERIAL_8250_EM 381 381 tristate "Support for Emma Mobile integrated serial port" 382 382 depends on SERIAL_8250 && HAVE_CLK 383 - depends on ARM || COMPILE_TEST 383 + depends on (ARM && ARCH_RENESAS) || COMPILE_TEST 384 384 help 385 385 Selecting this option will add support for the integrated serial 386 386 port hardware found on the Emma Mobile line of processors.
+5 -4
drivers/tty/serial/Kconfig
··· 239 239 depends on PLAT_SAMSUNG || ARCH_S5PV210 || ARCH_EXYNOS || ARCH_APPLE || COMPILE_TEST 240 240 select SERIAL_CORE 241 241 help 242 - Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, 243 - providing /dev/ttySAC0, 1 and 2 (note, some machines may not 244 - provide all of these ports, depending on how the serial port 245 - pins are configured. 242 + Support for the on-chip UARTs on the Samsung 243 + S3C24xx/S3C64xx/S5Pv210/Exynos and Apple M1 SoCs, providing 244 + /dev/ttySAC0, 1 and 2 (note, some machines may not provide all of 245 + these ports, depending on how the serial port pins are configured. 246 + Choose Y/M here only if you build for such SoC. 246 247 247 248 config SERIAL_SAMSUNG_UARTS_4 248 249 bool
+2 -2
drivers/tty/serial/atmel_serial.c
··· 2084 2084 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 2085 2085 2086 2086 switch (state) { 2087 - case 0: 2087 + case UART_PM_STATE_ON: 2088 2088 /* 2089 2089 * Enable the peripheral clock for this serial port. 2090 2090 * This is called on uart_open() or a resume event. ··· 2094 2094 /* re-enable interrupts if we disabled some on suspend */ 2095 2095 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->backup_imr); 2096 2096 break; 2097 - case 3: 2097 + case UART_PM_STATE_OFF: 2098 2098 /* Back up the interrupt mask and disable all interrupts */ 2099 2099 atmel_port->backup_imr = atmel_uart_readl(port, ATMEL_US_IMR); 2100 2100 atmel_uart_writel(port, ATMEL_US_IDR, -1);
+2
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 1090 1090 cpm_uart_early_write(pinfo, ch, 1, false); 1091 1091 } 1092 1092 1093 + #ifdef CONFIG_SERIAL_CPM_CONSOLE 1093 1094 static struct uart_port *udbg_port; 1094 1095 1095 1096 static void udbg_cpm_putc(char c) ··· 1115 1114 cpu_relax(); 1116 1115 return c; 1117 1116 } 1117 + #endif /* CONFIG_SERIAL_CPM_CONSOLE */ 1118 1118 1119 1119 #endif /* CONFIG_CONSOLE_POLL */ 1120 1120
+14 -2
drivers/tty/serial/imx.c
··· 2017 2017 * If the port was already initialised (eg, by a boot loader), 2018 2018 * try to determine the current setup. 2019 2019 */ 2020 - static void __init 2020 + static void 2021 2021 imx_uart_console_get_options(struct imx_port *sport, int *baud, 2022 2022 int *parity, int *bits) 2023 2023 { ··· 2076 2076 } 2077 2077 } 2078 2078 2079 - static int __init 2079 + static int 2080 2080 imx_uart_console_setup(struct console *co, char *options) 2081 2081 { 2082 2082 struct imx_port *sport; ··· 2124 2124 return retval; 2125 2125 } 2126 2126 2127 + static int 2128 + imx_uart_console_exit(struct console *co) 2129 + { 2130 + struct imx_port *sport = imx_uart_ports[co->index]; 2131 + 2132 + clk_disable_unprepare(sport->clk_per); 2133 + clk_disable_unprepare(sport->clk_ipg); 2134 + 2135 + return 0; 2136 + } 2137 + 2127 2138 static struct uart_driver imx_uart_uart_driver; 2128 2139 static struct console imx_uart_console = { 2129 2140 .name = DEV_NAME, 2130 2141 .write = imx_uart_console_write, 2131 2142 .device = uart_console_device, 2132 2143 .setup = imx_uart_console_setup, 2144 + .exit = imx_uart_console_exit, 2133 2145 .flags = CON_PRINTBUFFER, 2134 2146 .index = -1, 2135 2147 .data = &imx_uart_uart_driver,
+3 -4
drivers/tty/serial/max310x.c
··· 1426 1426 return ret; 1427 1427 } 1428 1428 1429 - static int max310x_remove(struct device *dev) 1429 + static void max310x_remove(struct device *dev) 1430 1430 { 1431 1431 struct max310x_port *s = dev_get_drvdata(dev); 1432 1432 int i; ··· 1441 1441 } 1442 1442 1443 1443 clk_disable_unprepare(s->clk); 1444 - 1445 - return 0; 1446 1444 } 1447 1445 1448 1446 static const struct of_device_id __maybe_unused max310x_dt_ids[] = { ··· 1489 1491 1490 1492 static int max310x_spi_remove(struct spi_device *spi) 1491 1493 { 1492 - return max310x_remove(&spi->dev); 1494 + max310x_remove(&spi->dev); 1495 + return 0; 1493 1496 } 1494 1497 1495 1498 static const struct spi_device_id max310x_id_table[] = {
+5 -8
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 + bool has_usi; 69 69 unsigned int port_type; 70 70 unsigned int fifosize; 71 71 unsigned long rx_fifomask; ··· 2780 2780 #endif 2781 2781 2782 2782 #if defined(CONFIG_ARCH_EXYNOS) 2783 - #define EXYNOS_COMMON_SERIAL_DRV_DATA_USI(_has_usi) \ 2783 + #define EXYNOS_COMMON_SERIAL_DRV_DATA(_has_usi) \ 2784 2784 .info = &(struct s3c24xx_uart_info) { \ 2785 2785 .name = "Samsung Exynos UART", \ 2786 2786 .type = TYPE_S3C6400, \ ··· 2804 2804 .has_fracval = 1, \ 2805 2805 } \ 2806 2806 2807 - #define EXYNOS_COMMON_SERIAL_DRV_DATA \ 2808 - EXYNOS_COMMON_SERIAL_DRV_DATA_USI(0) 2809 - 2810 2807 static struct s3c24xx_serial_drv_data exynos4210_serial_drv_data = { 2811 - EXYNOS_COMMON_SERIAL_DRV_DATA, 2808 + EXYNOS_COMMON_SERIAL_DRV_DATA(false), 2812 2809 .fifosize = { 256, 64, 16, 16 }, 2813 2810 }; 2814 2811 2815 2812 static struct s3c24xx_serial_drv_data exynos5433_serial_drv_data = { 2816 - EXYNOS_COMMON_SERIAL_DRV_DATA, 2813 + EXYNOS_COMMON_SERIAL_DRV_DATA(false), 2817 2814 .fifosize = { 64, 256, 16, 256 }, 2818 2815 }; 2819 2816 2820 2817 static struct s3c24xx_serial_drv_data exynos850_serial_drv_data = { 2821 - EXYNOS_COMMON_SERIAL_DRV_DATA_USI(1), 2818 + EXYNOS_COMMON_SERIAL_DRV_DATA(true), 2822 2819 .fifosize = { 256, 64, 64, 64 }, 2823 2820 }; 2824 2821
+7 -5
drivers/tty/serial/sc16is7xx.c
··· 1365 1365 return ret; 1366 1366 } 1367 1367 1368 - static int sc16is7xx_remove(struct device *dev) 1368 + static void sc16is7xx_remove(struct device *dev) 1369 1369 { 1370 1370 struct sc16is7xx_port *s = dev_get_drvdata(dev); 1371 1371 int i; ··· 1385 1385 kthread_stop(s->kworker_task); 1386 1386 1387 1387 clk_disable_unprepare(s->clk); 1388 - 1389 - return 0; 1390 1388 } 1391 1389 1392 1390 static const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = { ··· 1442 1444 1443 1445 static int sc16is7xx_spi_remove(struct spi_device *spi) 1444 1446 { 1445 - return sc16is7xx_remove(&spi->dev); 1447 + sc16is7xx_remove(&spi->dev); 1448 + 1449 + return 0; 1446 1450 } 1447 1451 1448 1452 static const struct spi_device_id sc16is7xx_spi_id_table[] = { ··· 1497 1497 1498 1498 static int sc16is7xx_i2c_remove(struct i2c_client *client) 1499 1499 { 1500 - return sc16is7xx_remove(&client->dev); 1500 + sc16is7xx_remove(&client->dev); 1501 + 1502 + return 0; 1501 1503 } 1502 1504 1503 1505 static const struct i2c_device_id sc16is7xx_i2c_id_table[] = {
+14 -2
drivers/tty/serial/serial_core.c
··· 222 222 if (retval == 0) { 223 223 if (uart_console(uport) && uport->cons->cflag) { 224 224 tty->termios.c_cflag = uport->cons->cflag; 225 + tty->termios.c_ispeed = uport->cons->ispeed; 226 + tty->termios.c_ospeed = uport->cons->ospeed; 225 227 uport->cons->cflag = 0; 228 + uport->cons->ispeed = 0; 229 + uport->cons->ospeed = 0; 226 230 } 227 231 /* 228 232 * Initialise the hardware port settings. ··· 294 290 /* 295 291 * Turn off DTR and RTS early. 296 292 */ 297 - if (uport && uart_console(uport) && tty) 293 + if (uport && uart_console(uport) && tty) { 298 294 uport->cons->cflag = tty->termios.c_cflag; 295 + uport->cons->ispeed = tty->termios.c_ispeed; 296 + uport->cons->ospeed = tty->termios.c_ospeed; 297 + } 299 298 300 299 if (!tty || C_HUPCL(tty)) 301 300 uart_port_dtr_rts(uport, 0); ··· 2101 2094 * Allow the setting of the UART parameters with a NULL console 2102 2095 * too: 2103 2096 */ 2104 - if (co) 2097 + if (co) { 2105 2098 co->cflag = termios.c_cflag; 2099 + co->ispeed = termios.c_ispeed; 2100 + co->ospeed = termios.c_ospeed; 2101 + } 2106 2102 2107 2103 return 0; 2108 2104 } ··· 2239 2229 */ 2240 2230 memset(&termios, 0, sizeof(struct ktermios)); 2241 2231 termios.c_cflag = uport->cons->cflag; 2232 + termios.c_ispeed = uport->cons->ispeed; 2233 + termios.c_ospeed = uport->cons->ospeed; 2242 2234 2243 2235 /* 2244 2236 * If that's unset, use the tty termios setting.
+1 -1
drivers/tty/serial/sifive.c
··· 887 887 888 888 static void __ssp_remove_console_port(struct sifive_serial_port *ssp) 889 889 { 890 - sifive_serial_console_ports[ssp->port.line] = 0; 890 + sifive_serial_console_ports[ssp->port.line] = NULL; 891 891 } 892 892 893 893 #define SIFIVE_SERIAL_CONSOLE (&sifive_serial_console)
+307 -83
drivers/tty/serial/stm32-usart.c
··· 165 165 return uart_get_rs485_mode(port); 166 166 } 167 167 168 - static int stm32_usart_pending_rx(struct uart_port *port, u32 *sr, 169 - int *last_res, bool threaded) 168 + static bool stm32_usart_rx_dma_enabled(struct uart_port *port) 170 169 { 171 170 struct stm32_port *stm32_port = to_stm32_port(port); 172 171 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 173 - enum dma_status status; 174 - struct dma_tx_state state; 175 172 176 - *sr = readl_relaxed(port->membase + ofs->isr); 173 + if (!stm32_port->rx_ch) 174 + return false; 177 175 178 - if (threaded && stm32_port->rx_ch) { 179 - status = dmaengine_tx_status(stm32_port->rx_ch, 180 - stm32_port->rx_ch->cookie, 181 - &state); 182 - if (status == DMA_IN_PROGRESS && (*last_res != state.residue)) 183 - return 1; 184 - else 185 - return 0; 186 - } else if (*sr & USART_SR_RXNE) { 187 - return 1; 188 - } 189 - return 0; 176 + return !!(readl_relaxed(port->membase + ofs->cr3) & USART_CR3_DMAR); 190 177 } 191 178 192 - static unsigned long stm32_usart_get_char(struct uart_port *port, u32 *sr, 193 - int *last_res) 179 + /* Return true when data is pending (in pio mode), and false when no data is pending. */ 180 + static bool stm32_usart_pending_rx_pio(struct uart_port *port, u32 *sr) 181 + { 182 + struct stm32_port *stm32_port = to_stm32_port(port); 183 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 184 + 185 + *sr = readl_relaxed(port->membase + ofs->isr); 186 + /* Get pending characters in RDR or FIFO */ 187 + if (*sr & USART_SR_RXNE) { 188 + /* Get all pending characters from the RDR or the FIFO when using interrupts */ 189 + if (!stm32_usart_rx_dma_enabled(port)) 190 + return true; 191 + 192 + /* Handle only RX data errors when using DMA */ 193 + if (*sr & USART_SR_ERR_MASK) 194 + return true; 195 + } 196 + 197 + return false; 198 + } 199 + 200 + static unsigned long stm32_usart_get_char_pio(struct uart_port *port) 194 201 { 195 202 struct stm32_port *stm32_port = to_stm32_port(port); 196 203 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 197 204 unsigned long c; 198 205 199 - if (stm32_port->rx_ch) { 200 - c = stm32_port->rx_buf[RX_BUF_L - (*last_res)--]; 201 - if ((*last_res) == 0) 202 - *last_res = RX_BUF_L; 203 - } else { 204 - c = readl_relaxed(port->membase + ofs->rdr); 205 - /* apply RDR data mask */ 206 - c &= stm32_port->rdr_mask; 207 - } 206 + c = readl_relaxed(port->membase + ofs->rdr); 207 + /* Apply RDR data mask */ 208 + c &= stm32_port->rdr_mask; 208 209 209 210 return c; 210 211 } 211 212 212 - static void stm32_usart_receive_chars(struct uart_port *port, bool threaded) 213 + static unsigned int stm32_usart_receive_chars_pio(struct uart_port *port) 213 214 { 214 - struct tty_port *tport = &port->state->port; 215 215 struct stm32_port *stm32_port = to_stm32_port(port); 216 216 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 217 217 unsigned long c; 218 + unsigned int size = 0; 218 219 u32 sr; 219 220 char flag; 220 221 221 - spin_lock(&port->lock); 222 - 223 - while (stm32_usart_pending_rx(port, &sr, &stm32_port->last_res, 224 - threaded)) { 222 + while (stm32_usart_pending_rx_pio(port, &sr)) { 225 223 sr |= USART_SR_DUMMY_RX; 226 224 flag = TTY_NORMAL; 227 225 ··· 238 240 writel_relaxed(sr & USART_SR_ERR_MASK, 239 241 port->membase + ofs->icr); 240 242 241 - c = stm32_usart_get_char(port, &sr, &stm32_port->last_res); 243 + c = stm32_usart_get_char_pio(port); 242 244 port->icount.rx++; 245 + size++; 243 246 if (sr & USART_SR_ERR_MASK) { 244 247 if (sr & USART_SR_ORE) { 245 248 port->icount.overrun++; ··· 274 275 uart_insert_char(port, sr, USART_SR_ORE, c, flag); 275 276 } 276 277 277 - uart_unlock_and_check_sysrq(port); 278 + return size; 279 + } 278 280 279 - tty_flip_buffer_push(tport); 281 + static void stm32_usart_push_buffer_dma(struct uart_port *port, unsigned int dma_size) 282 + { 283 + struct stm32_port *stm32_port = to_stm32_port(port); 284 + struct tty_port *ttyport = &stm32_port->port.state->port; 285 + unsigned char *dma_start; 286 + int dma_count, i; 287 + 288 + dma_start = stm32_port->rx_buf + (RX_BUF_L - stm32_port->last_res); 289 + 290 + /* 291 + * Apply rdr_mask on buffer in order to mask parity bit. 292 + * This loop is useless in cs8 mode because DMA copies only 293 + * 8 bits and already ignores parity bit. 294 + */ 295 + if (!(stm32_port->rdr_mask == (BIT(8) - 1))) 296 + for (i = 0; i < dma_size; i++) 297 + *(dma_start + i) &= stm32_port->rdr_mask; 298 + 299 + dma_count = tty_insert_flip_string(ttyport, dma_start, dma_size); 300 + port->icount.rx += dma_count; 301 + if (dma_count != dma_size) 302 + port->icount.buf_overrun++; 303 + stm32_port->last_res -= dma_count; 304 + if (stm32_port->last_res == 0) 305 + stm32_port->last_res = RX_BUF_L; 306 + } 307 + 308 + static unsigned int stm32_usart_receive_chars_dma(struct uart_port *port) 309 + { 310 + struct stm32_port *stm32_port = to_stm32_port(port); 311 + unsigned int dma_size, size = 0; 312 + 313 + /* DMA buffer is configured in cyclic mode and handles the rollback of the buffer. */ 314 + if (stm32_port->rx_dma_state.residue > stm32_port->last_res) { 315 + /* Conditional first part: from last_res to end of DMA buffer */ 316 + dma_size = stm32_port->last_res; 317 + stm32_usart_push_buffer_dma(port, dma_size); 318 + size = dma_size; 319 + } 320 + 321 + dma_size = stm32_port->last_res - stm32_port->rx_dma_state.residue; 322 + stm32_usart_push_buffer_dma(port, dma_size); 323 + size += dma_size; 324 + 325 + return size; 326 + } 327 + 328 + static unsigned int stm32_usart_receive_chars(struct uart_port *port, bool force_dma_flush) 329 + { 330 + struct stm32_port *stm32_port = to_stm32_port(port); 331 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 332 + enum dma_status rx_dma_status; 333 + u32 sr; 334 + unsigned int size = 0; 335 + 336 + if (stm32_usart_rx_dma_enabled(port) || force_dma_flush) { 337 + rx_dma_status = dmaengine_tx_status(stm32_port->rx_ch, 338 + stm32_port->rx_ch->cookie, 339 + &stm32_port->rx_dma_state); 340 + if (rx_dma_status == DMA_IN_PROGRESS) { 341 + /* Empty DMA buffer */ 342 + size = stm32_usart_receive_chars_dma(port); 343 + sr = readl_relaxed(port->membase + ofs->isr); 344 + if (sr & USART_SR_ERR_MASK) { 345 + /* Disable DMA request line */ 346 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 347 + 348 + /* Switch to PIO mode to handle the errors */ 349 + size += stm32_usart_receive_chars_pio(port); 350 + 351 + /* Switch back to DMA mode */ 352 + stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAR); 353 + } 354 + } else { 355 + /* Disable RX DMA */ 356 + dmaengine_terminate_async(stm32_port->rx_ch); 357 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 358 + /* Fall back to interrupt mode */ 359 + dev_dbg(port->dev, "DMA error, fallback to irq mode\n"); 360 + size = stm32_usart_receive_chars_pio(port); 361 + } 362 + } else { 363 + size = stm32_usart_receive_chars_pio(port); 364 + } 365 + 366 + return size; 280 367 } 281 368 282 369 static void stm32_usart_tx_dma_complete(void *arg) ··· 395 310 stm32_usart_set_bits(port, ofs->cr3, USART_CR3_TXFTIE); 396 311 else 397 312 stm32_usart_set_bits(port, ofs->cr1, USART_CR1_TXEIE); 313 + } 314 + 315 + static void stm32_usart_rx_dma_complete(void *arg) 316 + { 317 + struct uart_port *port = arg; 318 + struct tty_port *tport = &port->state->port; 319 + unsigned int size; 320 + unsigned long flags; 321 + 322 + spin_lock_irqsave(&port->lock, flags); 323 + size = stm32_usart_receive_chars(port, false); 324 + uart_unlock_and_check_sysrq_irqrestore(port, flags); 325 + if (size) 326 + tty_flip_buffer_push(tport); 398 327 } 399 328 400 329 static void stm32_usart_tx_interrupt_disable(struct uart_port *port) ··· 561 462 struct stm32_port *stm32_port = to_stm32_port(port); 562 463 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 563 464 u32 sr; 465 + unsigned int size; 564 466 565 467 sr = readl_relaxed(port->membase + ofs->isr); 566 468 ··· 578 478 pm_wakeup_event(tport->tty->dev, 0); 579 479 } 580 480 581 - if ((sr & USART_SR_RXNE) && !(stm32_port->rx_ch)) 582 - stm32_usart_receive_chars(port, false); 481 + /* 482 + * rx errors in dma mode has to be handled ASAP to avoid overrun as the DMA request 483 + * line has been masked by HW and rx data are stacking in FIFO. 484 + */ 485 + if (!stm32_port->throttled) { 486 + if (((sr & USART_SR_RXNE) && !stm32_usart_rx_dma_enabled(port)) || 487 + ((sr & USART_SR_ERR_MASK) && stm32_usart_rx_dma_enabled(port))) { 488 + spin_lock(&port->lock); 489 + size = stm32_usart_receive_chars(port, false); 490 + uart_unlock_and_check_sysrq(port); 491 + if (size) 492 + tty_flip_buffer_push(tport); 493 + } 494 + } 583 495 584 496 if ((sr & USART_SR_TXE) && !(stm32_port->tx_ch)) { 585 497 spin_lock(&port->lock); ··· 599 487 spin_unlock(&port->lock); 600 488 } 601 489 602 - if (stm32_port->rx_ch) 490 + if (stm32_usart_rx_dma_enabled(port)) 603 491 return IRQ_WAKE_THREAD; 604 492 else 605 493 return IRQ_HANDLED; ··· 608 496 static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr) 609 497 { 610 498 struct uart_port *port = ptr; 499 + struct tty_port *tport = &port->state->port; 611 500 struct stm32_port *stm32_port = to_stm32_port(port); 501 + unsigned int size; 502 + unsigned long flags; 612 503 613 - if (stm32_port->rx_ch) 614 - stm32_usart_receive_chars(port, true); 504 + /* Receiver timeout irq for DMA RX */ 505 + if (!stm32_port->throttled) { 506 + spin_lock_irqsave(&port->lock, flags); 507 + size = stm32_usart_receive_chars(port, false); 508 + uart_unlock_and_check_sysrq_irqrestore(port, flags); 509 + if (size) 510 + tty_flip_buffer_push(tport); 511 + } 615 512 616 513 return IRQ_HANDLED; 617 514 } ··· 733 612 unsigned long flags; 734 613 735 614 spin_lock_irqsave(&port->lock, flags); 615 + 616 + /* 617 + * Disable DMA request line if enabled, so the RX data gets queued into the FIFO. 618 + * Hardware flow control is triggered when RX FIFO is full. 619 + */ 620 + if (stm32_usart_rx_dma_enabled(port)) 621 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 622 + 736 623 stm32_usart_clr_bits(port, ofs->cr1, stm32_port->cr1_irq); 737 624 if (stm32_port->cr3_irq) 738 625 stm32_usart_clr_bits(port, ofs->cr3, stm32_port->cr3_irq); 739 626 627 + stm32_port->throttled = true; 740 628 spin_unlock_irqrestore(&port->lock, flags); 741 629 } 742 630 ··· 761 631 if (stm32_port->cr3_irq) 762 632 stm32_usart_set_bits(port, ofs->cr3, stm32_port->cr3_irq); 763 633 634 + /* 635 + * Switch back to DMA mode (re-enable DMA request line). 636 + * Hardware flow control is stopped when FIFO is not full any more. 637 + */ 638 + if (stm32_port->rx_ch) 639 + stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAR); 640 + 641 + stm32_port->throttled = false; 764 642 spin_unlock_irqrestore(&port->lock, flags); 765 643 } 766 644 ··· 778 640 struct stm32_port *stm32_port = to_stm32_port(port); 779 641 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 780 642 643 + /* Disable DMA request line. */ 644 + if (stm32_port->rx_ch) 645 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 646 + 781 647 stm32_usart_clr_bits(port, ofs->cr1, stm32_port->cr1_irq); 782 648 if (stm32_port->cr3_irq) 783 649 stm32_usart_clr_bits(port, ofs->cr3, stm32_port->cr3_irq); ··· 790 648 /* Handle breaks - ignored by us */ 791 649 static void stm32_usart_break_ctl(struct uart_port *port, int break_state) 792 650 { 651 + } 652 + 653 + static int stm32_usart_start_rx_dma_cyclic(struct uart_port *port) 654 + { 655 + struct stm32_port *stm32_port = to_stm32_port(port); 656 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 657 + struct dma_async_tx_descriptor *desc; 658 + int ret; 659 + 660 + stm32_port->last_res = RX_BUF_L; 661 + /* Prepare a DMA cyclic transaction */ 662 + desc = dmaengine_prep_dma_cyclic(stm32_port->rx_ch, 663 + stm32_port->rx_dma_buf, 664 + RX_BUF_L, RX_BUF_P, 665 + DMA_DEV_TO_MEM, 666 + DMA_PREP_INTERRUPT); 667 + if (!desc) { 668 + dev_err(port->dev, "rx dma prep cyclic failed\n"); 669 + return -ENODEV; 670 + } 671 + 672 + desc->callback = stm32_usart_rx_dma_complete; 673 + desc->callback_param = port; 674 + 675 + /* Push current DMA transaction in the pending queue */ 676 + ret = dma_submit_error(dmaengine_submit(desc)); 677 + if (ret) { 678 + dmaengine_terminate_sync(stm32_port->rx_ch); 679 + return ret; 680 + } 681 + 682 + /* Issue pending DMA requests */ 683 + dma_async_issue_pending(stm32_port->rx_ch); 684 + 685 + /* 686 + * DMA request line not re-enabled at resume when port is throttled. 687 + * It will be re-enabled by unthrottle ops. 688 + */ 689 + if (!stm32_port->throttled) 690 + stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAR); 691 + 692 + return 0; 793 693 } 794 694 795 695 static int stm32_usart_startup(struct uart_port *port) ··· 859 675 /* RX FIFO Flush */ 860 676 if (ofs->rqr != UNDEF_REG) 861 677 writel_relaxed(USART_RQR_RXFRQ, port->membase + ofs->rqr); 678 + 679 + if (stm32_port->rx_ch) { 680 + ret = stm32_usart_start_rx_dma_cyclic(port); 681 + if (ret) { 682 + free_irq(port->irq, port); 683 + return ret; 684 + } 685 + } 862 686 863 687 /* RX enabling */ 864 688 val = stm32_port->cr1_irq | USART_CR1_RE | BIT(cfg->uart_enable_bit); ··· 899 707 /* Send the TC error message only when ISR_TC is not set */ 900 708 if (ret) 901 709 dev_err(port->dev, "Transmission is not complete\n"); 710 + 711 + /* Disable RX DMA. */ 712 + if (stm32_port->rx_ch) 713 + dmaengine_terminate_async(stm32_port->rx_ch); 902 714 903 715 /* flush RX & TX FIFO */ 904 716 if (ofs->rqr != UNDEF_REG) ··· 1006 810 stm32_port->cr1_irq = USART_CR1_RTOIE; 1007 811 writel_relaxed(bits, port->membase + ofs->rtor); 1008 812 cr2 |= USART_CR2_RTOEN; 1009 - /* Not using dma, enable fifo threshold irq */ 1010 - if (!stm32_port->rx_ch) 1011 - stm32_port->cr3_irq = USART_CR3_RXFTIE; 813 + /* 814 + * Enable fifo threshold irq in two cases, either when there is no DMA, or when 815 + * wake up over usart, from low power until the DMA gets re-enabled by resume. 816 + */ 817 + stm32_port->cr3_irq = USART_CR3_RXFTIE; 1012 818 } 1013 819 1014 820 cr1 |= stm32_port->cr1_irq; ··· 1073 875 if ((termios->c_cflag & CREAD) == 0) 1074 876 port->ignore_status_mask |= USART_SR_DUMMY_RX; 1075 877 1076 - if (stm32_port->rx_ch) 878 + if (stm32_port->rx_ch) { 879 + /* 880 + * Setup DMA to collect only valid data and enable error irqs. 881 + * This also enables break reception when using DMA. 882 + */ 883 + cr1 |= USART_CR1_PEIE; 884 + cr3 |= USART_CR3_EIE; 1077 885 cr3 |= USART_CR3_DMAR; 886 + cr3 |= USART_CR3_DDRE; 887 + } 1078 888 1079 889 if (rs485conf->flags & SER_RS485_ENABLED) { 1080 890 stm32_usart_config_reg_rs485(&cr1, &cr3, ··· 1372 1166 struct uart_port *port = &stm32port->port; 1373 1167 struct device *dev = &pdev->dev; 1374 1168 struct dma_slave_config config; 1375 - struct dma_async_tx_descriptor *desc = NULL; 1376 1169 int ret; 1377 1170 1378 1171 /* ··· 1398 1193 stm32_usart_of_dma_rx_remove(stm32port, pdev); 1399 1194 return ret; 1400 1195 } 1401 - 1402 - /* Prepare a DMA cyclic transaction */ 1403 - desc = dmaengine_prep_dma_cyclic(stm32port->rx_ch, 1404 - stm32port->rx_dma_buf, 1405 - RX_BUF_L, RX_BUF_P, DMA_DEV_TO_MEM, 1406 - DMA_PREP_INTERRUPT); 1407 - if (!desc) { 1408 - dev_err(dev, "rx dma prep cyclic failed\n"); 1409 - stm32_usart_of_dma_rx_remove(stm32port, pdev); 1410 - return -ENODEV; 1411 - } 1412 - 1413 - /* No callback as dma buffer is drained on usart interrupt */ 1414 - desc->callback = NULL; 1415 - desc->callback_param = NULL; 1416 - 1417 - /* Push current DMA transaction in the pending queue */ 1418 - ret = dma_submit_error(dmaengine_submit(desc)); 1419 - if (ret) { 1420 - dmaengine_terminate_sync(stm32port->rx_ch); 1421 - stm32_usart_of_dma_rx_remove(stm32port, pdev); 1422 - return ret; 1423 - } 1424 - 1425 - /* Issue pending DMA requests */ 1426 - dma_async_issue_pending(stm32port->rx_ch); 1427 1196 1428 1197 return 0; 1429 1198 } ··· 1551 1372 struct stm32_port *stm32_port = to_stm32_port(port); 1552 1373 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 1553 1374 int err; 1375 + u32 cr3; 1554 1376 1555 1377 pm_runtime_get_sync(&pdev->dev); 1556 1378 err = uart_remove_one_port(&stm32_usart_driver, port); ··· 1562 1382 pm_runtime_set_suspended(&pdev->dev); 1563 1383 pm_runtime_put_noidle(&pdev->dev); 1564 1384 1565 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 1385 + stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_PEIE); 1386 + cr3 = readl_relaxed(port->membase + ofs->cr3); 1387 + cr3 &= ~USART_CR3_EIE; 1388 + cr3 &= ~USART_CR3_DMAR; 1389 + cr3 &= ~USART_CR3_DDRE; 1390 + writel_relaxed(cr3, port->membase + ofs->cr3); 1566 1391 1567 1392 if (stm32_port->tx_ch) { 1568 1393 dmaengine_terminate_async(stm32_port->tx_ch); ··· 1576 1391 } 1577 1392 1578 1393 if (stm32_port->rx_ch) { 1579 - dmaengine_terminate_async(stm32_port->rx_ch); 1580 1394 stm32_usart_of_dma_rx_remove(stm32_port, pdev); 1581 1395 dma_release_channel(stm32_port->rx_ch); 1582 1396 } ··· 1688 1504 .cons = STM32_SERIAL_CONSOLE, 1689 1505 }; 1690 1506 1691 - static void __maybe_unused stm32_usart_serial_en_wakeup(struct uart_port *port, 1692 - bool enable) 1507 + static int __maybe_unused stm32_usart_serial_en_wakeup(struct uart_port *port, 1508 + bool enable) 1693 1509 { 1694 1510 struct stm32_port *stm32_port = to_stm32_port(port); 1695 1511 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 1512 + struct tty_port *tport = &port->state->port; 1513 + int ret; 1514 + unsigned int size; 1515 + unsigned long flags; 1696 1516 1697 - if (!stm32_port->wakeup_src) 1698 - return; 1517 + if (!stm32_port->wakeup_src || !tty_port_initialized(tport)) 1518 + return 0; 1699 1519 1700 1520 /* 1701 1521 * Enable low-power wake-up and wake-up irq if argument is set to ··· 1708 1520 if (enable) { 1709 1521 stm32_usart_set_bits(port, ofs->cr1, USART_CR1_UESM); 1710 1522 stm32_usart_set_bits(port, ofs->cr3, USART_CR3_WUFIE); 1523 + 1524 + /* 1525 + * When DMA is used for reception, it must be disabled before 1526 + * entering low-power mode and re-enabled when exiting from 1527 + * low-power mode. 1528 + */ 1529 + if (stm32_port->rx_ch) { 1530 + spin_lock_irqsave(&port->lock, flags); 1531 + /* Avoid race with RX IRQ when DMAR is cleared */ 1532 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 1533 + /* Poll data from DMA RX buffer if any */ 1534 + size = stm32_usart_receive_chars(port, true); 1535 + dmaengine_terminate_async(stm32_port->rx_ch); 1536 + uart_unlock_and_check_sysrq_irqrestore(port, flags); 1537 + if (size) 1538 + tty_flip_buffer_push(tport); 1539 + } 1540 + 1541 + /* Poll data from RX FIFO if any */ 1542 + stm32_usart_receive_chars(port, false); 1711 1543 } else { 1544 + if (stm32_port->rx_ch) { 1545 + ret = stm32_usart_start_rx_dma_cyclic(port); 1546 + if (ret) 1547 + return ret; 1548 + } 1549 + 1712 1550 stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_UESM); 1713 1551 stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_WUFIE); 1714 1552 } 1553 + 1554 + return 0; 1715 1555 } 1716 1556 1717 1557 static int __maybe_unused stm32_usart_serial_suspend(struct device *dev) 1718 1558 { 1719 1559 struct uart_port *port = dev_get_drvdata(dev); 1560 + int ret; 1720 1561 1721 1562 uart_suspend_port(&stm32_usart_driver, port); 1722 1563 1723 - if (device_may_wakeup(dev) || device_wakeup_path(dev)) 1724 - stm32_usart_serial_en_wakeup(port, true); 1564 + if (device_may_wakeup(dev) || device_wakeup_path(dev)) { 1565 + ret = stm32_usart_serial_en_wakeup(port, true); 1566 + if (ret) 1567 + return ret; 1568 + } 1725 1569 1726 1570 /* 1727 1571 * When "no_console_suspend" is enabled, keep the pinctrl default state ··· 1774 1554 static int __maybe_unused stm32_usart_serial_resume(struct device *dev) 1775 1555 { 1776 1556 struct uart_port *port = dev_get_drvdata(dev); 1557 + int ret; 1777 1558 1778 1559 pinctrl_pm_select_default_state(dev); 1779 1560 1780 - if (device_may_wakeup(dev) || device_wakeup_path(dev)) 1781 - stm32_usart_serial_en_wakeup(port, false); 1561 + if (device_may_wakeup(dev) || device_wakeup_path(dev)) { 1562 + ret = stm32_usart_serial_en_wakeup(port, false); 1563 + if (ret) 1564 + return ret; 1565 + } 1782 1566 1783 1567 return uart_resume_port(&stm32_usart_driver, port); 1784 1568 }
+8 -5
drivers/tty/serial/stm32-usart.h
··· 109 109 /* USART_SR (F4) / USART_ISR (F7) */ 110 110 #define USART_SR_PE BIT(0) 111 111 #define USART_SR_FE BIT(1) 112 - #define USART_SR_NF BIT(2) 112 + #define USART_SR_NE BIT(2) /* F7 (NF for F4) */ 113 113 #define USART_SR_ORE BIT(3) 114 114 #define USART_SR_IDLE BIT(4) 115 115 #define USART_SR_RXNE BIT(5) ··· 126 126 #define USART_SR_SBKF BIT(18) /* F7 */ 127 127 #define USART_SR_WUF BIT(20) /* H7 */ 128 128 #define USART_SR_TEACK BIT(21) /* F7 */ 129 - #define USART_SR_ERR_MASK (USART_SR_ORE | USART_SR_FE | USART_SR_PE) 129 + #define USART_SR_ERR_MASK (USART_SR_ORE | USART_SR_NE | USART_SR_FE |\ 130 + USART_SR_PE) 130 131 /* Dummy bits */ 131 132 #define USART_SR_DUMMY_RX BIT(16) 132 133 ··· 247 246 #define STM32_SERIAL_NAME "ttySTM" 248 247 #define STM32_MAX_PORTS 8 249 248 250 - #define RX_BUF_L 200 /* dma rx buffer length */ 251 - #define RX_BUF_P RX_BUF_L /* dma rx buffer period */ 252 - #define TX_BUF_L 200 /* dma tx buffer length */ 249 + #define RX_BUF_L 4096 /* dma rx buffer length */ 250 + #define RX_BUF_P (RX_BUF_L / 2) /* dma rx buffer period */ 251 + #define TX_BUF_L RX_BUF_L /* dma tx buffer length */ 253 252 254 253 struct stm32_port { 255 254 struct uart_port port; ··· 265 264 u32 cr3_irq; /* USART_CR3_RXFTIE */ 266 265 int last_res; 267 266 bool tx_dma_busy; /* dma tx busy */ 267 + bool throttled; /* port throttled */ 268 268 bool hw_flow_control; 269 269 bool swap; /* swap RX & TX pins */ 270 270 bool fifoen; ··· 274 272 bool wakeup_src; 275 273 int rdr_mask; /* receive data register mask */ 276 274 struct mctrl_gpios *gpios; /* modem control gpios */ 275 + struct dma_tx_state rx_dma_state; 277 276 }; 278 277 279 278 static struct stm32_port stm32_ports[STM32_MAX_PORTS];
+1 -1
drivers/tty/serial/sunzilog.c
··· 1125 1125 1126 1126 #define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */ 1127 1127 1128 - static void sunzilog_putchar(struct uart_port *port, int ch) 1128 + static void __maybe_unused sunzilog_putchar(struct uart_port *port, int ch) 1129 1129 { 1130 1130 struct zilog_channel __iomem *channel = ZILOG_CHANNEL_FROM_PORT(port); 1131 1131 int loops = ZS_PUT_CHAR_MAX_DELAY;
+80 -11
drivers/tty/serial/uartlite.c
··· 8 8 9 9 #include <linux/platform_device.h> 10 10 #include <linux/module.h> 11 + #include <linux/bitfield.h> 11 12 #include <linux/console.h> 12 13 #include <linux/serial.h> 13 14 #include <linux/serial_core.h> ··· 64 63 static struct uart_port *console_port; 65 64 #endif 66 65 66 + /** 67 + * struct uartlite_data: Driver private data 68 + * reg_ops: Functions to read/write registers 69 + * clk: Our parent clock, if present 70 + * baud: The baud rate configured when this device was synthesized 71 + * cflags: The cflags for parity and data bits 72 + */ 67 73 struct uartlite_data { 68 74 const struct uartlite_reg_ops *reg_ops; 69 75 struct clk *clk; 76 + unsigned int baud; 77 + tcflag_t cflags; 70 78 }; 71 79 72 80 struct uartlite_reg_ops { ··· 128 118 } 129 119 130 120 static struct uart_port ulite_ports[ULITE_NR_UARTS]; 121 + 122 + static struct uart_driver ulite_uart_driver; 131 123 132 124 /* --------------------------------------------------------------------- 133 125 * Core UART driver operations ··· 318 306 struct ktermios *old) 319 307 { 320 308 unsigned long flags; 321 - unsigned int baud; 309 + struct uartlite_data *pdata = port->private_data; 310 + 311 + /* Set termios to what the hardware supports */ 312 + termios->c_cflag &= ~(BRKINT | CSTOPB | PARENB | PARODD | CSIZE); 313 + termios->c_cflag |= pdata->cflags & (PARENB | PARODD | CSIZE); 314 + tty_termios_encode_baud_rate(termios, pdata->baud, pdata->baud); 322 315 323 316 spin_lock_irqsave(&port->lock, flags); 324 317 ··· 346 329 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN; 347 330 348 331 /* update timeout */ 349 - baud = uart_get_baud_rate(port, termios, old, 0, 460800); 350 - uart_update_timeout(port, termios->c_cflag, baud); 332 + uart_update_timeout(port, termios->c_cflag, pdata->baud); 351 333 352 334 spin_unlock_irqrestore(&port->lock, flags); 353 335 } ··· 547 531 548 532 return uart_set_options(port, co, baud, parity, bits, flow); 549 533 } 550 - 551 - static struct uart_driver ulite_uart_driver; 552 534 553 535 static struct console ulite_console = { 554 536 .name = ULITE_NAME, ··· 779 765 struct uartlite_data *pdata; 780 766 int irq, ret; 781 767 int id = pdev->id; 782 - #ifdef CONFIG_OF 783 - const __be32 *prop; 784 768 785 - prop = of_get_property(pdev->dev.of_node, "port-number", NULL); 786 - if (prop) 787 - id = be32_to_cpup(prop); 788 - #endif 789 769 pdata = devm_kzalloc(&pdev->dev, sizeof(struct uartlite_data), 790 770 GFP_KERNEL); 791 771 if (!pdata) 792 772 return -ENOMEM; 773 + 774 + if (IS_ENABLED(CONFIG_OF)) { 775 + const char *prop; 776 + struct device_node *np = pdev->dev.of_node; 777 + u32 val = 0; 778 + 779 + prop = "port-number"; 780 + ret = of_property_read_u32(np, prop, &id); 781 + if (ret && ret != -EINVAL) 782 + of_err: 783 + return dev_err_probe(&pdev->dev, ret, 784 + "could not read %s\n", prop); 785 + 786 + prop = "current-speed"; 787 + ret = of_property_read_u32(np, prop, &pdata->baud); 788 + if (ret) 789 + goto of_err; 790 + 791 + prop = "xlnx,use-parity"; 792 + ret = of_property_read_u32(np, prop, &val); 793 + if (ret && ret != -EINVAL) 794 + goto of_err; 795 + 796 + if (val) { 797 + prop = "xlnx,odd-parity"; 798 + ret = of_property_read_u32(np, prop, &val); 799 + if (ret) 800 + goto of_err; 801 + 802 + if (val) 803 + pdata->cflags |= PARODD; 804 + pdata->cflags |= PARENB; 805 + } 806 + 807 + val = 8; 808 + prop = "xlnx,data-bits"; 809 + ret = of_property_read_u32(np, prop, &val); 810 + if (ret && ret != -EINVAL) 811 + goto of_err; 812 + 813 + switch (val) { 814 + case 5: 815 + pdata->cflags |= CS5; 816 + break; 817 + case 6: 818 + pdata->cflags |= CS6; 819 + break; 820 + case 7: 821 + pdata->cflags |= CS7; 822 + break; 823 + case 8: 824 + pdata->cflags |= CS8; 825 + break; 826 + default: 827 + return dev_err_probe(&pdev->dev, -EINVAL, 828 + "bad data bits %d\n", val); 829 + } 830 + } else { 831 + pdata->baud = 9600; 832 + pdata->cflags = CS8; 833 + } 793 834 794 835 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 795 836 if (!res)
+2 -1
drivers/tty/serial/xilinx_uartps.c
··· 601 601 if (uart_circ_empty(&port->state->xmit)) 602 602 return; 603 603 604 + writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); 605 + 604 606 cdns_uart_handle_tx(port); 605 607 606 - writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); 607 608 /* Enable the TX Empty interrupt */ 608 609 writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IER); 609 610 }
+2
drivers/tty/sysrq.c
··· 843 843 sysrq->shift = KEY_RESERVED; 844 844 else if (value != 2) 845 845 sysrq->shift = code; 846 + if (sysrq->active) 847 + sysrq->shift_use = sysrq->shift; 846 848 break; 847 849 848 850 case KEY_SYSRQ:
+1 -1
drivers/tty/tty_baudrate.c
··· 154 154 termios->c_ospeed = obaud; 155 155 156 156 #ifdef IBSHIFT 157 - if ((termios->c_cflag >> IBSHIFT) & CBAUD) 157 + if (((termios->c_cflag >> IBSHIFT) & CBAUD) != B0) 158 158 ibinput = 1; /* An input speed was specified */ 159 159 #endif 160 160 #ifdef BOTHER
+3
drivers/tty/tty_buffer.c
··· 544 544 if (!count) 545 545 break; 546 546 head->read += count; 547 + 548 + if (need_resched()) 549 + cond_resched(); 547 550 } 548 551 549 552 mutex_unlock(&buf->lock);
+4 -8
drivers/tty/tty_ioctl.c
··· 675 675 /** 676 676 * tty_mode_ioctl - mode related ioctls 677 677 * @tty: tty for the ioctl 678 - * @file: file pointer for the tty 679 678 * @cmd: command 680 679 * @arg: ioctl argument 681 680 * ··· 683 684 * consistent mode setting. 684 685 */ 685 686 686 - int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 687 - unsigned int cmd, unsigned long arg) 687 + int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) 688 688 { 689 689 struct tty_struct *real_tty; 690 690 void __user *p = (void __user *)arg; 691 691 int ret = 0; 692 692 struct ktermios kterm; 693 - 694 - BUG_ON(file == NULL); 695 693 696 694 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && 697 695 tty->driver->subtype == PTY_TYPE_MASTER) ··· 854 858 } 855 859 EXPORT_SYMBOL_GPL(tty_perform_flush); 856 860 857 - int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 858 - unsigned int cmd, unsigned long arg) 861 + int n_tty_ioctl_helper(struct tty_struct *tty, unsigned int cmd, 862 + unsigned long arg) 859 863 { 860 864 int retval; 861 865 ··· 900 904 return __tty_perform_flush(tty, arg); 901 905 default: 902 906 /* Try the mode commands */ 903 - return tty_mode_ioctl(tty, file, cmd, arg); 907 + return tty_mode_ioctl(tty, cmd, arg); 904 908 } 905 909 } 906 910 EXPORT_SYMBOL(n_tty_ioctl_helper);
+2
include/linux/console.h
··· 149 149 short flags; 150 150 short index; 151 151 int cflag; 152 + uint ispeed; 153 + uint ospeed; 152 154 void *data; 153 155 struct console *next; 154 156 };
+10
include/linux/rpmsg.h
··· 186 186 __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, 187 187 poll_table *wait); 188 188 189 + ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept); 190 + 189 191 #else 190 192 191 193 static inline int rpmsg_register_device(struct rpmsg_device *rpdev) ··· 296 294 WARN_ON(1); 297 295 298 296 return 0; 297 + } 298 + 299 + static inline ssize_t rpmsg_get_mtu(struct rpmsg_endpoint *ept) 300 + { 301 + /* This shouldn't be possible */ 302 + WARN_ON(1); 303 + 304 + return -ENXIO; 299 305 } 300 306 301 307 #endif /* IS_ENABLED(CONFIG_RPMSG) */
+69 -71
include/linux/tty.h
··· 252 252 } 253 253 254 254 #ifdef CONFIG_TTY 255 - extern void tty_kref_put(struct tty_struct *tty); 256 - extern struct pid *tty_get_pgrp(struct tty_struct *tty); 257 - extern void tty_vhangup_self(void); 258 - extern void disassociate_ctty(int priv); 259 - extern dev_t tty_devnum(struct tty_struct *tty); 260 - extern void proc_clear_tty(struct task_struct *p); 261 - extern struct tty_struct *get_current_tty(void); 255 + void tty_kref_put(struct tty_struct *tty); 256 + struct pid *tty_get_pgrp(struct tty_struct *tty); 257 + void tty_vhangup_self(void); 258 + void disassociate_ctty(int priv); 259 + dev_t tty_devnum(struct tty_struct *tty); 260 + void proc_clear_tty(struct task_struct *p); 261 + struct tty_struct *get_current_tty(void); 262 262 /* tty_io.c */ 263 - extern int __init tty_init(void); 264 - extern const char *tty_name(const struct tty_struct *tty); 265 - extern struct tty_struct *tty_kopen_exclusive(dev_t device); 266 - extern struct tty_struct *tty_kopen_shared(dev_t device); 267 - extern void tty_kclose(struct tty_struct *tty); 268 - extern int tty_dev_name_to_number(const char *name, dev_t *number); 263 + int __init tty_init(void); 264 + const char *tty_name(const struct tty_struct *tty); 265 + struct tty_struct *tty_kopen_exclusive(dev_t device); 266 + struct tty_struct *tty_kopen_shared(dev_t device); 267 + void tty_kclose(struct tty_struct *tty); 268 + int tty_dev_name_to_number(const char *name, dev_t *number); 269 269 #else 270 270 static inline void tty_kref_put(struct tty_struct *tty) 271 271 { } ··· 296 296 297 297 extern struct ktermios tty_std_termios; 298 298 299 - extern int vcs_init(void); 299 + int vcs_init(void); 300 300 301 301 extern struct class *tty_class; 302 302 ··· 316 316 return tty; 317 317 } 318 318 319 - extern const char *tty_driver_name(const struct tty_struct *tty); 320 - extern void tty_wait_until_sent(struct tty_struct *tty, long timeout); 321 - extern void stop_tty(struct tty_struct *tty); 322 - extern void start_tty(struct tty_struct *tty); 323 - extern void tty_write_message(struct tty_struct *tty, char *msg); 324 - extern int tty_send_xchar(struct tty_struct *tty, char ch); 325 - extern int tty_put_char(struct tty_struct *tty, unsigned char c); 326 - extern unsigned int tty_chars_in_buffer(struct tty_struct *tty); 327 - extern unsigned int tty_write_room(struct tty_struct *tty); 328 - extern void tty_driver_flush_buffer(struct tty_struct *tty); 329 - extern void tty_unthrottle(struct tty_struct *tty); 330 - extern int tty_throttle_safe(struct tty_struct *tty); 331 - extern int tty_unthrottle_safe(struct tty_struct *tty); 332 - extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws); 333 - extern int tty_get_icount(struct tty_struct *tty, 334 - struct serial_icounter_struct *icount); 335 - extern int is_current_pgrp_orphaned(void); 336 - extern void tty_hangup(struct tty_struct *tty); 337 - extern void tty_vhangup(struct tty_struct *tty); 338 - extern int tty_hung_up_p(struct file *filp); 339 - extern void do_SAK(struct tty_struct *tty); 340 - extern void __do_SAK(struct tty_struct *tty); 341 - extern void no_tty(void); 342 - extern speed_t tty_termios_baud_rate(struct ktermios *termios); 343 - extern void tty_termios_encode_baud_rate(struct ktermios *termios, 344 - speed_t ibaud, speed_t obaud); 345 - extern void tty_encode_baud_rate(struct tty_struct *tty, 346 - speed_t ibaud, speed_t obaud); 319 + const char *tty_driver_name(const struct tty_struct *tty); 320 + void tty_wait_until_sent(struct tty_struct *tty, long timeout); 321 + void stop_tty(struct tty_struct *tty); 322 + void start_tty(struct tty_struct *tty); 323 + void tty_write_message(struct tty_struct *tty, char *msg); 324 + int tty_send_xchar(struct tty_struct *tty, char ch); 325 + int tty_put_char(struct tty_struct *tty, unsigned char c); 326 + unsigned int tty_chars_in_buffer(struct tty_struct *tty); 327 + unsigned int tty_write_room(struct tty_struct *tty); 328 + void tty_driver_flush_buffer(struct tty_struct *tty); 329 + void tty_unthrottle(struct tty_struct *tty); 330 + int tty_throttle_safe(struct tty_struct *tty); 331 + int tty_unthrottle_safe(struct tty_struct *tty); 332 + int tty_do_resize(struct tty_struct *tty, struct winsize *ws); 333 + int tty_get_icount(struct tty_struct *tty, 334 + struct serial_icounter_struct *icount); 335 + int is_current_pgrp_orphaned(void); 336 + void tty_hangup(struct tty_struct *tty); 337 + void tty_vhangup(struct tty_struct *tty); 338 + int tty_hung_up_p(struct file *filp); 339 + void do_SAK(struct tty_struct *tty); 340 + void __do_SAK(struct tty_struct *tty); 341 + void no_tty(void); 342 + speed_t tty_termios_baud_rate(struct ktermios *termios); 343 + void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, 344 + speed_t obaud); 345 + void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, 346 + speed_t obaud); 347 347 348 348 /** 349 349 * tty_get_baud_rate - get tty bit rates ··· 363 363 unsigned char tty_get_char_size(unsigned int cflag); 364 364 unsigned char tty_get_frame_size(unsigned int cflag); 365 365 366 - extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 367 - extern int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); 368 - extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); 366 + void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 367 + int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); 368 + int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); 369 369 370 - extern void tty_wakeup(struct tty_struct *tty); 370 + void tty_wakeup(struct tty_struct *tty); 371 371 372 - extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 373 - unsigned int cmd, unsigned long arg); 374 - extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); 375 - extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); 376 - extern void tty_release_struct(struct tty_struct *tty, int idx); 377 - extern void tty_init_termios(struct tty_struct *tty); 378 - extern void tty_save_termios(struct tty_struct *tty); 379 - extern int tty_standard_install(struct tty_driver *driver, 372 + int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); 373 + int tty_perform_flush(struct tty_struct *tty, unsigned long arg); 374 + struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx); 375 + void tty_release_struct(struct tty_struct *tty, int idx); 376 + void tty_init_termios(struct tty_struct *tty); 377 + void tty_save_termios(struct tty_struct *tty); 378 + int tty_standard_install(struct tty_driver *driver, 380 379 struct tty_struct *tty); 381 380 382 381 extern struct mutex tty_mutex; 383 382 384 383 /* n_tty.c */ 385 - extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops); 384 + void n_tty_inherit_ops(struct tty_ldisc_ops *ops); 386 385 #ifdef CONFIG_TTY 387 - extern void __init n_tty_init(void); 386 + void __init n_tty_init(void); 388 387 #else 389 388 static inline void n_tty_init(void) { } 390 389 #endif 391 390 392 391 /* tty_audit.c */ 393 392 #ifdef CONFIG_AUDIT 394 - extern void tty_audit_exit(void); 395 - extern void tty_audit_fork(struct signal_struct *sig); 396 - extern int tty_audit_push(void); 393 + void tty_audit_exit(void); 394 + void tty_audit_fork(struct signal_struct *sig); 395 + int tty_audit_push(void); 397 396 #else 398 397 static inline void tty_audit_exit(void) 399 398 { ··· 407 408 #endif 408 409 409 410 /* tty_ioctl.c */ 410 - extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 411 - unsigned int cmd, unsigned long arg); 411 + int n_tty_ioctl_helper(struct tty_struct *tty, unsigned int cmd, 412 + unsigned long arg); 412 413 413 414 /* vt.c */ 414 415 415 - extern int vt_ioctl(struct tty_struct *tty, 416 - unsigned int cmd, unsigned long arg); 416 + int vt_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); 417 417 418 - extern long vt_compat_ioctl(struct tty_struct *tty, 419 - unsigned int cmd, unsigned long arg); 418 + long vt_compat_ioctl(struct tty_struct *tty, unsigned int cmd, 419 + unsigned long arg); 420 420 421 421 /* tty_mutex.c */ 422 422 /* functions for preparation of BKL removal */ 423 - extern void tty_lock(struct tty_struct *tty); 424 - extern int tty_lock_interruptible(struct tty_struct *tty); 425 - extern void tty_unlock(struct tty_struct *tty); 426 - extern void tty_lock_slave(struct tty_struct *tty); 427 - extern void tty_unlock_slave(struct tty_struct *tty); 428 - extern void tty_set_lock_subclass(struct tty_struct *tty); 423 + void tty_lock(struct tty_struct *tty); 424 + int tty_lock_interruptible(struct tty_struct *tty); 425 + void tty_unlock(struct tty_struct *tty); 426 + void tty_lock_slave(struct tty_struct *tty); 427 + void tty_unlock_slave(struct tty_struct *tty); 428 + void tty_set_lock_subclass(struct tty_struct *tty); 429 429 430 430 #endif
+5 -5
include/linux/tty_driver.h
··· 327 327 328 328 extern struct list_head tty_drivers; 329 329 330 - extern struct tty_driver *__tty_alloc_driver(unsigned int lines, 331 - struct module *owner, unsigned long flags); 332 - extern struct tty_driver *tty_find_polling_driver(char *name, int *line); 330 + struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner, 331 + unsigned long flags); 332 + struct tty_driver *tty_find_polling_driver(char *name, int *line); 333 333 334 - extern void tty_driver_kref_put(struct tty_driver *driver); 334 + void tty_driver_kref_put(struct tty_driver *driver); 335 335 336 336 /* Use TTY_DRIVER_* flags below */ 337 337 #define tty_alloc_driver(lines, flags) \ ··· 360 360 * Used for PTY's, in particular. 361 361 * 362 362 * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will 363 - * guarantee never not to set any special character handling 363 + * guarantee never to set any special character handling 364 364 * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || 365 365 * !INPCK)). That is, if there is no reason for the driver to 366 366 * send notifications of parity and break characters up to the
+10 -10
include/linux/tty_flip.h
··· 7 7 8 8 struct tty_ldisc; 9 9 10 - extern int tty_buffer_set_limit(struct tty_port *port, int limit); 11 - extern unsigned int tty_buffer_space_avail(struct tty_port *port); 12 - extern int tty_buffer_request_room(struct tty_port *port, size_t size); 13 - extern int tty_insert_flip_string_flags(struct tty_port *port, 10 + int tty_buffer_set_limit(struct tty_port *port, int limit); 11 + unsigned int tty_buffer_space_avail(struct tty_port *port); 12 + int tty_buffer_request_room(struct tty_port *port, size_t size); 13 + int tty_insert_flip_string_flags(struct tty_port *port, 14 14 const unsigned char *chars, const char *flags, size_t size); 15 - extern int tty_insert_flip_string_fixed_flag(struct tty_port *port, 15 + int tty_insert_flip_string_fixed_flag(struct tty_port *port, 16 16 const unsigned char *chars, char flag, size_t size); 17 - extern int tty_prepare_flip_string(struct tty_port *port, 18 - unsigned char **chars, size_t size); 19 - extern void tty_flip_buffer_push(struct tty_port *port); 17 + int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, 18 + size_t size); 19 + void tty_flip_buffer_push(struct tty_port *port); 20 20 void tty_schedule_flip(struct tty_port *port); 21 21 int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag); 22 22 ··· 45 45 int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 46 46 const char *f, int count); 47 47 48 - extern void tty_buffer_lock_exclusive(struct tty_port *port); 49 - extern void tty_buffer_unlock_exclusive(struct tty_port *port); 48 + void tty_buffer_lock_exclusive(struct tty_port *port); 49 + void tty_buffer_unlock_exclusive(struct tty_port *port); 50 50 51 51 #endif /* _LINUX_TTY_FLIP_H */
+12 -15
include/linux/tty_ldisc.h
··· 146 146 #endif 147 147 }; 148 148 149 - extern void __init_ldsem(struct ld_semaphore *sem, const char *name, 149 + void __init_ldsem(struct ld_semaphore *sem, const char *name, 150 150 struct lock_class_key *key); 151 151 152 152 #define init_ldsem(sem) \ ··· 157 157 } while (0) 158 158 159 159 160 - extern int ldsem_down_read(struct ld_semaphore *sem, long timeout); 161 - extern int ldsem_down_read_trylock(struct ld_semaphore *sem); 162 - extern int ldsem_down_write(struct ld_semaphore *sem, long timeout); 163 - extern int ldsem_down_write_trylock(struct ld_semaphore *sem); 164 - extern void ldsem_up_read(struct ld_semaphore *sem); 165 - extern void ldsem_up_write(struct ld_semaphore *sem); 160 + int ldsem_down_read(struct ld_semaphore *sem, long timeout); 161 + int ldsem_down_read_trylock(struct ld_semaphore *sem); 162 + int ldsem_down_write(struct ld_semaphore *sem, long timeout); 163 + int ldsem_down_write_trylock(struct ld_semaphore *sem); 164 + void ldsem_up_read(struct ld_semaphore *sem); 165 + void ldsem_up_write(struct ld_semaphore *sem); 166 166 167 167 #ifdef CONFIG_DEBUG_LOCK_ALLOC 168 - extern int ldsem_down_read_nested(struct ld_semaphore *sem, int subclass, 169 - long timeout); 170 - extern int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, 171 - long timeout); 168 + int ldsem_down_read_nested(struct ld_semaphore *sem, int subclass, 169 + long timeout); 170 + int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass, 171 + long timeout); 172 172 #else 173 173 # define ldsem_down_read_nested(sem, subclass, timeout) \ 174 174 ldsem_down_read(sem, timeout) ··· 180 180 struct tty_ldisc_ops { 181 181 char *name; 182 182 int num; 183 - int flags; 184 183 185 184 /* 186 185 * The following routines are called from above. ··· 199 200 void (*set_termios)(struct tty_struct *tty, struct ktermios *old); 200 201 __poll_t (*poll)(struct tty_struct *, struct file *, 201 202 struct poll_table_struct *); 202 - int (*hangup)(struct tty_struct *tty); 203 + void (*hangup)(struct tty_struct *tty); 203 204 204 205 /* 205 206 * The following routines are called from below. ··· 218 219 struct tty_ldisc_ops *ops; 219 220 struct tty_struct *tty; 220 221 }; 221 - 222 - #define LDISC_FLAG_DEFINED 0x00000001 223 222 224 223 #define MODULE_ALIAS_LDISC(ldisc) \ 225 224 MODULE_ALIAS("tty-ldisc-" __stringify(ldisc))
+1 -1
net/nfc/nci/uart.c
··· 337 337 return -EBUSY; 338 338 break; 339 339 default: 340 - err = n_tty_ioctl_helper(tty, file, cmd, arg); 340 + err = n_tty_ioctl_helper(tty, cmd, arg); 341 341 break; 342 342 } 343 343
+1 -2
sound/soc/codecs/cx20442.c
··· 252 252 } 253 253 254 254 /* Line discipline .hangup() */ 255 - static int v253_hangup(struct tty_struct *tty) 255 + static void v253_hangup(struct tty_struct *tty) 256 256 { 257 257 v253_close(tty); 258 - return 0; 259 258 } 260 259 261 260 /* Line discipline .receive_buf() */
+1 -2
sound/soc/ti/ams-delta.c
··· 330 330 } 331 331 332 332 /* Line discipline .hangup() */ 333 - static int cx81801_hangup(struct tty_struct *tty) 333 + static void cx81801_hangup(struct tty_struct *tty) 334 334 { 335 335 cx81801_close(tty); 336 - return 0; 337 336 } 338 337 339 338 /* Line discipline .receive_buf() */