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

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

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

A bit more than normal, but nothing major, lots of cleanups.
Highlights are:

- lots of tty api cleanups and mxser driver cleanups from Jiri

- build warning fixes

- various serial driver updates

- coding style cleanups

- various tty driver minor fixes and updates

- removal of broken and disable r3964 line discipline (finally!)

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

* tag 'tty-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (227 commits)
serial: mvebu-uart: remove unused member nb from struct mvebu_uart
arm64: dts: marvell: armada-37xx: Fix reg for standard variant of UART
dt-bindings: mvebu-uart: fix documentation
serial: mvebu-uart: correctly calculate minimal possible baudrate
serial: mvebu-uart: do not allow changing baudrate when uartclk is not available
serial: mvebu-uart: fix calculation of clock divisor
tty: make linux/tty_flip.h self-contained
serial: Prefer unsigned int to bare use of unsigned
serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs
serial: qcom_geni_serial: use DT aliases according to DT bindings
Revert "tty: serial: Add UART driver for Cortina-Access platform"
tty: serial: Add UART driver for Cortina-Access platform
MAINTAINERS: add me back as mxser maintainer
mxser: Documentation, fix typos
mxser: Documentation, make the docs up-to-date
mxser: Documentation, remove traces of callout device
mxser: introduce mxser_16550A_or_MUST helper
mxser: rename flags to old_speed in mxser_set_serial_info
mxser: use port variable in mxser_set_serial_info
mxser: access info->MCR under info->slock
...

+2108 -5144
+5
Documentation/admin-guide/kernel-parameters.txt
··· 1122 1122 the driver will use only 32-bit accessors to read/write 1123 1123 the device registers. 1124 1124 1125 + liteuart,<addr> 1126 + Start an early console on a litex serial port at the 1127 + specified address. The serial port must already be 1128 + setup and configured. Options are not yet supported. 1129 + 1125 1130 meson,<addr> 1126 1131 Start an early, polled-mode console on a meson serial 1127 1132 port at the specified address. The serial port must
+1 -1
Documentation/devicetree/bindings/serial/8250.yaml
··· 10 10 - devicetree@vger.kernel.org 11 11 12 12 allOf: 13 - - $ref: /schemas/serial.yaml# 13 + - $ref: serial.yaml# 14 14 - if: 15 15 anyOf: 16 16 - required:
+118
Documentation/devicetree/bindings/serial/8250_omap.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/8250_omap.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Bindings for 8250 compliant UARTs on TI's OMAP2+ and K3 SoCs 8 + 9 + maintainers: 10 + - Vignesh Raghavendra <vigneshr@ti.com> 11 + 12 + allOf: 13 + - $ref: /schemas/serial/serial.yaml# 14 + - $ref: /schemas/serial/rs485.yaml# 15 + 16 + properties: 17 + compatible: 18 + oneOf: 19 + - enum: 20 + - ti,am3352-uart 21 + - ti,am4372-uart 22 + - ti,am654-uart 23 + - ti,dra742-uart 24 + - ti,omap2-uart 25 + - ti,omap3-uart 26 + - ti,omap4-uart 27 + - items: 28 + - enum: 29 + - ti,am64-uart 30 + - ti,j721e-uart 31 + - const: ti,am654-uart 32 + 33 + ti,hwmods: 34 + description: 35 + Must be "uart<n>", n being the instance number (1-based) 36 + This property is applicable only on legacy platforms mainly omap2/3 37 + and ti81xx and should not be used on other platforms. 38 + $ref: /schemas/types.yaml#/definitions/string 39 + deprecated: true 40 + 41 + dmas: 42 + minItems: 1 43 + maxItems: 2 44 + 45 + dma-names: 46 + items: 47 + - const: tx 48 + - const: rx 49 + 50 + reg: 51 + maxItems: 1 52 + 53 + interrupts: 54 + minItems: 1 55 + maxItems: 2 56 + description: 57 + First entry is module IRQ required for normal IO operation. 58 + Second entry is optional and corresponds to system wakeup IRQ 59 + where supported. 60 + 61 + clocks: 62 + maxItems: 1 63 + 64 + clock-names: 65 + const: fclk 66 + 67 + rts-gpios: true 68 + cts-gpios: true 69 + dtr-gpios: true 70 + dsr-gpios: true 71 + rng-gpios: true 72 + dcd-gpios: true 73 + rs485-rts-delay: true 74 + rs485-rts-active-low: true 75 + rs485-rx-during-tx: true 76 + rs485-rts-active-high: true 77 + linux,rs485-enabled-at-boot-time: true 78 + rts-gpio: true 79 + power-domains: true 80 + clock-frequency: true 81 + current-speed: true 82 + 83 + required: 84 + - compatible 85 + - reg 86 + - interrupts 87 + 88 + additionalProperties: false 89 + 90 + if: 91 + properties: 92 + compatible: 93 + oneOf: 94 + - const: ti,omap2-uart 95 + - const: ti,omap3-uart 96 + - const: ti,omap4-uart 97 + 98 + then: 99 + properties: 100 + ti,hwmods: 101 + items: 102 + - pattern: "^uart([1-9])$" 103 + 104 + else: 105 + properties: 106 + ti,hwmods: false 107 + 108 + examples: 109 + - | 110 + serial@49042000 { 111 + compatible = "ti,omap3-uart"; 112 + reg = <0x49042000 0x400>; 113 + interrupts = <80>; 114 + dmas = <&sdma 81 &sdma 82>; 115 + dma-names = "tx", "rx"; 116 + ti,hwmods = "uart4"; 117 + clock-frequency = <48000000>; 118 + };
+5
Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
··· 55 55 - const: pclk 56 56 - const: baud 57 57 58 + fifo-size: 59 + description: The fifo size supported by the UART channel. 60 + $ref: /schemas/types.yaml#/definitions/uint32 61 + enum: [64, 128] 62 + 58 63 required: 59 64 - compatible 60 65 - reg
+1 -1
Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml
··· 10 10 - Al Cooper <alcooperx@gmail.com> 11 11 12 12 allOf: 13 - - $ref: /schemas/serial.yaml# 13 + - $ref: serial.yaml# 14 14 15 15 description: |+ 16 16 The Broadcom UART is based on the basic 8250 UART but with
+12
Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
··· 71 71 received, and that the peripheral should invert its input using the 72 72 INVR registers. 73 73 74 + fsl,dma-info: 75 + $ref: /schemas/types.yaml#/definitions/uint32-array 76 + minItems: 2 77 + maxItems: 2 78 + description: | 79 + First cell contains the size of DMA buffer chunks, second cell contains 80 + the amount of chunks used for the device. Multiplying both numbers is 81 + the total size of memory used for receiving data. 82 + When not being configured the system will use default settings, which 83 + are sensible for most use cases. If you need low latency processing on 84 + slow connections this needs to be configured appropriately. 85 + 74 86 uart-has-rtscts: true 75 87 76 88 rs485-rts-delay: true
+1 -1
Documentation/devicetree/bindings/serial/ingenic,uart.yaml
··· 10 10 - Paul Cercueil <paul@crapouillou.net> 11 11 12 12 allOf: 13 - - $ref: /schemas/serial.yaml# 13 + - $ref: serial.yaml# 14 14 15 15 properties: 16 16 $nodename:
+3 -3
Documentation/devicetree/bindings/serial/mvebu-uart.txt
··· 5 5 - compatible: 6 6 - "marvell,armada-3700-uart" for the standard variant of the UART 7 7 (32 bytes FIFO, no DMA, level interrupts, 8-bit access to the 8 - FIFO, baudrate limited to 230400). 8 + FIFO), called also UART1. 9 9 - "marvell,armada-3700-uart-ext" for the extended variant of the 10 10 UART (128 bytes FIFO, DMA, front interrupts, 8-bit or 32-bit 11 - accesses to the FIFO, baudrate unlimited by the dividers). 11 + accesses to the FIFO), called also UART2. 12 12 - reg: offset and length of the register set for the device. 13 13 - clocks: UART reference clock used to derive the baudrate. If no clock 14 14 is provided (possible only with the "marvell,armada-3700-uart" ··· 33 33 Example: 34 34 uart0: serial@12000 { 35 35 compatible = "marvell,armada-3700-uart"; 36 - reg = <0x12000 0x200>; 36 + reg = <0x12000 0x18>; 37 37 clocks = <&xtalclk>; 38 38 interrupts = 39 39 <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
-40
Documentation/devicetree/bindings/serial/omap_serial.txt
··· 1 - OMAP UART controller 2 - 3 - Required properties: 4 - - compatible : should be "ti,am64-uart", "ti,am654-uart" for AM64 controllers 5 - - compatible : should be "ti,j721e-uart", "ti,am654-uart" for J721E controllers 6 - - compatible : should be "ti,am654-uart" for AM654 controllers 7 - - compatible : should be "ti,omap2-uart" for OMAP2 controllers 8 - - compatible : should be "ti,omap3-uart" for OMAP3 controllers 9 - - compatible : should be "ti,omap4-uart" for OMAP4 controllers 10 - - compatible : should be "ti,am4372-uart" for AM437x controllers 11 - - compatible : should be "ti,am3352-uart" for AM335x controllers 12 - - compatible : should be "ti,dra742-uart" for DRA7x controllers 13 - - reg : address and length of the register space 14 - - interrupts or interrupts-extended : Should contain the uart interrupt 15 - specifier or both the interrupt 16 - controller phandle and interrupt 17 - specifier. 18 - - ti,hwmods : Must be "uart<n>", n being the instance number (1-based) 19 - 20 - Optional properties: 21 - - clock-frequency : frequency of the clock input to the UART 22 - - dmas : DMA specifier, consisting of a phandle to the DMA controller 23 - node and a DMA channel number. 24 - - dma-names : "rx" for receive channel, "tx" for transmit channel. 25 - - rs485-rts-delay, rs485-rx-during-tx, linux,rs485-enabled-at-boot-time: see rs485.txt 26 - - rs485-rts-active-high: drive RTS high when sending (default is low). 27 - - clocks: phandle to the functional clock as per 28 - Documentation/devicetree/bindings/clock/clock-bindings.txt 29 - 30 - Example: 31 - 32 - uart4: serial@49042000 { 33 - compatible = "ti,omap3-uart"; 34 - reg = <0x49042000 0x400>; 35 - interrupts = <80>; 36 - dmas = <&sdma 81 &sdma 82>; 37 - dma-names = "tx", "rx"; 38 - ti,hwmods = "uart4"; 39 - clock-frequency = <48000000>; 40 - };
+5 -8
Documentation/devicetree/bindings/serial/pl011.yaml
··· 10 10 - Rob Herring <robh@kernel.org> 11 11 12 12 allOf: 13 - - $ref: /schemas/serial.yaml# 13 + - $ref: serial.yaml# 14 14 15 15 # Need a custom select here or 'arm,primecell' will match on lots of nodes 16 16 select: ··· 24 24 25 25 properties: 26 26 compatible: 27 - oneOf: 28 - - items: 29 - - const: arm,pl011 30 - - const: arm,primecell 31 - - items: 32 - - const: arm,primecell 27 + items: 28 + - const: arm,pl011 29 + - const: arm,primecell 33 30 34 31 reg: 35 32 maxItems: 1 ··· 100 103 poll-rate-ms: [ auto-poll ] 101 104 poll-timeout-ms: [ auto-poll ] 102 105 103 - additionalProperties: false 106 + unevaluatedProperties: false 104 107 105 108 examples: 106 109 - |
+2 -2
Documentation/devicetree/bindings/serial/qca,ar9330-uart.yaml
··· 10 10 - Oleksij Rempel <o.rempel@pengutronix.de> 11 11 12 12 allOf: 13 - - $ref: /schemas/serial.yaml# 13 + - $ref: serial.yaml# 14 14 15 15 properties: 16 16 compatible: ··· 35 35 - clocks 36 36 - clock-names 37 37 38 - additionalProperties: false 38 + unevaluatedProperties: false 39 39 40 40 examples: 41 41 - |
+1 -1
Documentation/devicetree/bindings/serial/renesas,em-uart.yaml
··· 35 35 - clocks 36 36 - clock-names 37 37 38 - additionalProperties: false 38 + unevaluatedProperties: false 39 39 40 40 examples: 41 41 - |
+4
Documentation/devicetree/bindings/serial/renesas,scif.yaml
··· 64 64 - const: renesas,rcar-gen3-scif # R-Car Gen3 and RZ/G2 65 65 - const: renesas,scif # generic SCIF compatible UART 66 66 67 + - items: 68 + - enum: 69 + - renesas,scif-r9a07g044 # RZ/G2{L,LC} 70 + 67 71 reg: 68 72 maxItems: 1 69 73
+1 -1
Documentation/devicetree/bindings/serial/samsung_uart.yaml
··· 81 81 unevaluatedProperties: false 82 82 83 83 allOf: 84 - - $ref: /schemas/serial.yaml# 84 + - $ref: serial.yaml# 85 85 86 86 - if: 87 87 properties:
+2
Documentation/devicetree/bindings/serial/serial.yaml
··· 23 23 $nodename: 24 24 pattern: "^serial(@.*)?$" 25 25 26 + label: true 27 + 26 28 cts-gpios: 27 29 maxItems: 1 28 30 description:
+2 -2
Documentation/devicetree/bindings/serial/sifive-serial.yaml
··· 12 12 - Palmer Dabbelt <palmer@sifive.com> 13 13 14 14 allOf: 15 - - $ref: /schemas/serial.yaml# 15 + - $ref: serial.yaml# 16 16 17 17 properties: 18 18 compatible: ··· 49 49 - interrupts 50 50 - clocks 51 51 52 - additionalProperties: false 52 + unevaluatedProperties: false 53 53 54 54 examples: 55 55 - |
+3 -1
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 10 10 - Rob Herring <robh@kernel.org> 11 11 12 12 allOf: 13 - - $ref: /schemas/serial.yaml# 13 + - $ref: serial.yaml# 14 14 15 15 properties: 16 16 compatible: ··· 23 23 - items: 24 24 - enum: 25 25 - rockchip,px30-uart 26 + - rockchip,rk1808-uart 26 27 - rockchip,rk3036-uart 27 28 - rockchip,rk3066-uart 28 29 - rockchip,rk3188-uart ··· 32 31 - rockchip,rk3328-uart 33 32 - rockchip,rk3368-uart 34 33 - rockchip,rk3399-uart 34 + - rockchip,rk3568-uart 35 35 - rockchip,rv1108-uart 36 36 - const: snps,dw-apb-uart 37 37 - items:
+1 -2
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
··· 112 112 - interrupts 113 113 - clocks 114 114 115 - additionalProperties: 116 - type: object 115 + unevaluatedProperties: false 117 116 118 117 examples: 119 118 - |
+39 -457
Documentation/driver-api/serial/moxa-smartio.rst
··· 2 2 MOXA Smartio/Industio Family Device Driver Installation Guide 3 3 ============================================================= 4 4 5 - .. note:: 6 - 7 - This file is outdated. It needs some care in order to make it 8 - updated to Kernel 5.0 and upper 9 - 10 5 Copyright (C) 2008, Moxa Inc. 11 - 12 - Date: 01/21/2008 6 + Copyright (C) 2021, Jiri Slaby 13 7 14 8 .. Content 15 9 ··· 11 17 2. System Requirement 12 18 3. Installation 13 19 3.1 Hardware installation 14 - 3.2 Driver files 15 - 3.3 Device naming convention 16 - 3.4 Module driver configuration 17 - 3.5 Static driver configuration for Linux kernel 2.4.x and 2.6.x. 18 - 3.6 Custom configuration 19 - 3.7 Verify driver installation 20 + 3.2 Device naming convention 20 21 4. Utilities 21 22 5. Setserial 22 23 6. Troubleshooting ··· 20 31 ^^^^^^^^^^^^^^^ 21 32 22 33 The Smartio/Industio/UPCI family Linux driver supports following multiport 23 - boards. 34 + boards: 24 35 25 36 - 2 ports multiport board 26 37 CP-102U, CP-102UL, CP-102UF 27 38 CP-132U-I, CP-132UL, 28 39 CP-132, CP-132I, CP132S, CP-132IS, 29 - CI-132, CI-132I, CI-132IS, 30 - (C102H, C102HI, C102HIS, C102P, CP-102, CP-102S) 40 + (CP-102, CP-102S) 31 41 32 42 - 4 ports multiport board 33 43 CP-104EL, ··· 34 46 CP-134U, CP-134U-I, 35 47 C104H/PCI, C104HS/PCI, 36 48 CP-114, CP-114I, CP-114S, CP-114IS, CP-114UL, 37 - C104H, C104HS, 38 - CI-104J, CI-104JS, 39 - CI-134, CI-134I, CI-134IS, 40 - (C114HI, CT-114I, C104P), 49 + (C114HI, CT-114I), 41 50 POS-104UL, 42 51 CB-114, 43 52 CB-134I ··· 43 58 CP-118EL, CP-168EL, 44 59 CP-118U, CP-168U, 45 60 C168H/PCI, 46 - C168H, C168HS, 47 - (C168P), 48 61 CB-108 49 62 50 - This driver and installation procedure have been developed upon Linux Kernel 51 - 2.4.x and 2.6.x. This driver supports Intel x86 hardware platform. In order 52 - to maintain compatibility, this version has also been properly tested with 53 - RedHat, Mandrake, Fedora and S.u.S.E Linux. However, if compatibility problem 54 - occurs, please contact Moxa at support@moxa.com.tw. 63 + If a compatibility problem occurs, please contact Moxa at 64 + support@moxa.com.tw. 55 65 56 66 In addition to device driver, useful utilities are also provided in this 57 67 version. They are: ··· 58 78 Monitor program to observe data count and line status signals. 59 79 - msterm A simple terminal program which is useful in testing serial 60 80 ports. 61 - - io-irq.exe 62 - Configuration program to setup ISA boards. Please note that 63 - this program can only be executed under DOS. 64 81 65 82 All the drivers and utilities are published in form of source code under 66 83 GNU General Public License in this version. Please refer to GNU General 67 84 Public License announcement in each source code file for more detail. 68 85 69 - In Moxa's Web sites, you may always find latest driver at http://www.moxa.com/. 86 + In Moxa's Web sites, you may always find the latest driver at 87 + https://www.moxa.com/. 70 88 71 - This version of driver can be installed as Loadable Module (Module driver) 72 - or built-in into kernel (Static driver). You may refer to following 73 - installation procedure for suitable one. Before you install the driver, 89 + This version of driver can be installed as a Loadable Module (Module driver) 90 + or built-in into kernel (Static driver). Before you install the driver, 74 91 please refer to hardware installation procedure in the User's Manual. 75 92 76 - We assume the user should be familiar with following documents. 93 + We assume the user should be familiar with following documents: 77 94 78 95 - Serial-HOWTO 79 96 - Kernel-HOWTO ··· 78 101 2. System Requirement 79 102 ^^^^^^^^^^^^^^^^^^^^^ 80 103 81 - - Hardware platform: Intel x86 machine 82 - - Kernel version: 2.4.x or 2.6.x 83 - - gcc version 2.72 or later 84 104 - Maximum 4 boards can be installed in combination 85 105 86 106 3. Installation ··· 86 112 3.1 Hardware installation 87 113 ========================= 88 114 89 - There are two types of buses, ISA and PCI, for Smartio/Industio 90 - family multiport board. 91 - 92 - ISA board 93 - --------- 94 - 95 - You'll have to configure CAP address, I/O address, Interrupt Vector 96 - as well as IRQ before installing this driver. Please refer to hardware 97 - installation procedure in User's Manual before proceed any further. 98 - Please make sure the JP1 is open after the ISA board is set properly. 99 - 100 115 PCI/UPCI board 101 116 -------------- 102 117 103 - You may need to adjust IRQ usage in BIOS to avoid from IRQ conflict 104 - with other ISA devices. Please refer to hardware installation 105 - procedure in User's Manual in advance. 118 + You may need to adjust IRQ usage in BIOS to avoid IRQ conflict with other 119 + ISA devices. Please refer to hardware installation procedure in User's 120 + Manual in advance. 106 121 107 122 PCI IRQ Sharing 108 123 --------------- ··· 101 138 together on one system and they can share the same IRQ. 102 139 103 140 104 - 3.2 Driver files 105 - ================ 106 141 107 - The driver file may be obtained from ftp, CD-ROM or floppy disk. The 108 - first step, anyway, is to copy driver file "mxser.tgz" into specified 109 - directory. e.g. /moxa. The execute commands as below:: 110 - 111 - # cd / 112 - # mkdir moxa 113 - # cd /moxa 114 - # tar xvf /dev/fd0 115 - 116 - or:: 117 - 118 - # cd / 119 - # mkdir moxa 120 - # cd /moxa 121 - # cp /mnt/cdrom/<driver directory>/mxser.tgz . 122 - # tar xvfz mxser.tgz 123 - 124 - 125 - 3.3 Device naming convention 142 + 3.2 Device naming convention 126 143 ============================ 127 144 128 - You may find all the driver and utilities files in /moxa/mxser. 129 - Following installation procedure depends on the model you'd like to 130 - run the driver. If you prefer module driver, please refer to 3.4. 131 - If static driver is required, please refer to 3.5. 132 - 133 - Dialin and callout port 134 - ----------------------- 135 - 136 - This driver remains traditional serial device properties. There are 137 - two special file name for each serial port. One is dial-in port 138 - which is named "ttyMxx". For callout port, the naming convention 139 - is "cumxx". 145 + The device node is named "ttyMxx". 140 146 141 147 Device naming when more than 2 boards installed 142 148 ----------------------------------------------- ··· 113 181 Naming convention for each Smartio/Industio multiport board is 114 182 pre-defined as below. 115 183 116 - ============ =============== ============== 117 - Board Num. Dial-in Port Callout port 118 - 1st board ttyM0 - ttyM7 cum0 - cum7 119 - 2nd board ttyM8 - ttyM15 cum8 - cum15 120 - 3rd board ttyM16 - ttyM23 cum16 - cum23 121 - 4th board ttyM24 - ttym31 cum24 - cum31 122 - ============ =============== ============== 123 - 124 - .. note:: 125 - 126 - Under Kernel 2.6 and upper, the cum Device is Obsolete. So use ttyM* 127 - device instead. 128 - 129 - Board sequence 130 - -------------- 131 - 132 - This driver will activate ISA boards according to the parameter set 133 - in the driver. After all specified ISA board activated, PCI board 134 - will be installed in the system automatically driven. 135 - Therefore the board number is sorted by the CAP address of ISA boards. 136 - For PCI boards, their sequence will be after ISA boards and C168H/PCI 137 - has higher priority than C104H/PCI boards. 138 - 139 - 3.4 Module driver configuration 140 - =============================== 141 - 142 - Module driver is easiest way to install. If you prefer static driver 143 - installation, please skip this paragraph. 144 - 145 - 146 - ------------- Prepare to use the MOXA driver -------------------- 147 - 148 - 3.4.1 Create tty device with correct major number 149 - ------------------------------------------------- 150 - 151 - Before using MOXA driver, your system must have the tty devices 152 - which are created with driver's major number. We offer one shell 153 - script "msmknod" to simplify the procedure. 154 - This step is only needed to be executed once. But you still 155 - need to do this procedure when: 156 - 157 - a. You change the driver's major number. Please refer the "3.7" 158 - section. 159 - b. Your total installed MOXA boards number is changed. Maybe you 160 - add/delete one MOXA board. 161 - c. You want to change the tty name. This needs to modify the 162 - shell script "msmknod" 163 - 164 - The procedure is:: 165 - 166 - # cd /moxa/mxser/driver 167 - # ./msmknod 168 - 169 - This shell script will require the major number for dial-in 170 - device and callout device to create tty device. You also need 171 - to specify the total installed MOXA board number. Default major 172 - numbers for dial-in device and callout device are 30, 35. If 173 - you need to change to other number, please refer section "3.7" 174 - for more detailed procedure. 175 - Msmknod will delete any special files occupying the same device 176 - naming. 177 - 178 - 3.4.2 Build the MOXA driver and utilities 179 - ----------------------------------------- 180 - 181 - Before using the MOXA driver and utilities, you need compile the 182 - all the source code. This step is only need to be executed once. 183 - But you still re-compile the source code if you modify the source 184 - code. For example, if you change the driver's major number (see 185 - "3.7" section), then you need to do this step again. 186 - 187 - Find "Makefile" in /moxa/mxser, then run 188 - 189 - # make clean; make install 190 - 191 - ..note:: 192 - 193 - For Red Hat 9, Red Hat Enterprise Linux AS3/ES3/WS3 & Fedora Core1: 194 - # make clean; make installsp1 195 - 196 - For Red Hat Enterprise Linux AS4/ES4/WS4: 197 - # make clean; make installsp2 198 - 199 - The driver files "mxser.o" and utilities will be properly compiled 200 - and copied to system directories respectively. 201 - 202 - ------------- Load MOXA driver-------------------- 203 - 204 - 3.4.3 Load the MOXA driver 205 - -------------------------- 206 - 207 - :: 208 - 209 - # modprobe mxser <argument> 210 - 211 - will activate the module driver. You may run "lsmod" to check 212 - if "mxser" is activated. If the MOXA board is ISA board, the 213 - <argument> is needed. Please refer to section "3.4.5" for more 214 - information. 215 - 216 - ------------- Load MOXA driver on boot -------------------- 217 - 218 - 3.4.4 Load the mxser driver 219 - --------------------------- 220 - 221 - 222 - For the above description, you may manually execute 223 - "modprobe mxser" to activate this driver and run 224 - "rmmod mxser" to remove it. 225 - 226 - However, it's better to have a boot time configuration to 227 - eliminate manual operation. Boot time configuration can be 228 - achieved by rc file. We offer one "rc.mxser" file to simplify 229 - the procedure under "moxa/mxser/driver". 230 - 231 - But if you use ISA board, please modify the "modprobe ..." command 232 - to add the argument (see "3.4.5" section). After modifying the 233 - rc.mxser, please try to execute "/moxa/mxser/driver/rc.mxser" 234 - manually to make sure the modification is ok. If any error 235 - encountered, please try to modify again. If the modification is 236 - completed, follow the below step. 237 - 238 - Run following command for setting rc files:: 239 - 240 - # cd /moxa/mxser/driver 241 - # cp ./rc.mxser /etc/rc.d 242 - # cd /etc/rc.d 243 - 244 - Check "rc.serial" is existed or not. If "rc.serial" doesn't exist, 245 - create it by vi, run "chmod 755 rc.serial" to change the permission. 246 - 247 - Add "/etc/rc.d/rc.mxser" in last line. 248 - 249 - Reboot and check if moxa.o activated by "lsmod" command. 250 - 251 - 3.4.5. specify CAP address 252 - -------------------------- 253 - 254 - If you'd like to drive Smartio/Industio ISA boards in the system, 255 - you'll have to add parameter to specify CAP address of given 256 - board while activating "mxser.o". The format for parameters are 257 - as follows.:: 258 - 259 - modprobe mxser ioaddr=0x???,0x???,0x???,0x??? 260 - | | | | 261 - | | | +- 4th ISA board 262 - | | +------ 3rd ISA board 263 - | +------------ 2nd ISA board 264 - +-------------------1st ISA board 265 - 266 - 3.5 Static driver configuration for Linux kernel 2.4.x and 2.6.x 267 - ================================================================ 268 - 269 - Note: 270 - To use static driver, you must install the linux kernel 271 - source package. 272 - 273 - 3.5.1 Backup the built-in driver in the kernel 274 - ---------------------------------------------- 275 - 276 - :: 277 - 278 - # cd /usr/src/linux/drivers/char 279 - # mv mxser.c mxser.c.old 280 - 281 - For Red Hat 7.x user, you need to create link: 282 - # cd /usr/src 283 - # ln -s linux-2.4 linux 284 - 285 - 3.5.2 Create link 286 - ----------------- 287 - :: 288 - 289 - # cd /usr/src/linux/drivers/char 290 - # ln -s /moxa/mxser/driver/mxser.c mxser.c 291 - 292 - 3.5.3 Add CAP address list for ISA boards. 293 - ------------------------------------------ 294 - 295 - For PCI boards user, please skip this step. 296 - 297 - In module mode, the CAP address for ISA board is given by 298 - parameter. In static driver configuration, you'll have to 299 - assign it within driver's source code. If you will not 300 - install any ISA boards, you may skip to next portion. 301 - The instructions to modify driver source code are as 302 - below. 303 - 304 - a. run:: 305 - 306 - # cd /moxa/mxser/driver 307 - # vi mxser.c 308 - 309 - b. Find the array mxserBoardCAP[] as below:: 310 - 311 - static int mxserBoardCAP[] = {0x00, 0x00, 0x00, 0x00}; 312 - 313 - c. Change the address within this array using vi. For 314 - example, to driver 2 ISA boards with CAP address 315 - 0x280 and 0x180 as 1st and 2nd board. Just to change 316 - the source code as follows:: 317 - 318 - static int mxserBoardCAP[] = {0x280, 0x180, 0x00, 0x00}; 319 - 320 - 3.5.4 Setup kernel configuration 321 - -------------------------------- 322 - 323 - Configure the kernel:: 324 - 325 - # cd /usr/src/linux 326 - # make menuconfig 327 - 328 - You will go into a menu-driven system. Please select [Character 329 - devices][Non-standard serial port support], enable the [Moxa 330 - SmartIO support] driver with "[*]" for built-in (not "[M]"), then 331 - select [Exit] to exit this program. 332 - 333 - 3.5.5 Rebuild kernel 334 - -------------------- 335 - 336 - The following are for Linux kernel rebuilding, for your 337 - reference only. 338 - 339 - For appropriate details, please refer to the Linux document: 340 - 341 - a. Run the following commands:: 342 - 343 - cd /usr/src/linux 344 - make clean # take a few minutes 345 - make dep # take a few minutes 346 - make bzImage # take probably 10-20 minutes 347 - make install # copy boot image to correct position 348 - 349 - f. Please make sure the boot kernel (vmlinuz) is in the 350 - correct position. 351 - g. If you use 'lilo' utility, you should check /etc/lilo.conf 352 - 'image' item specified the path which is the 'vmlinuz' path, 353 - or you will load wrong (or old) boot kernel image (vmlinuz). 354 - After checking /etc/lilo.conf, please run "lilo". 355 - 356 - Note that if the result of "make bzImage" is ERROR, then you have to 357 - go back to Linux configuration Setup. Type "make menuconfig" in 358 - directory /usr/src/linux. 359 - 360 - 361 - 3.5.6 Make tty device and special file 362 - -------------------------------------- 363 - 364 - :: 365 - # cd /moxa/mxser/driver 366 - # ./msmknod 367 - 368 - 3.5.7 Make utility 369 - ------------------ 370 - 371 - :: 372 - 373 - # cd /moxa/mxser/utility 374 - # make clean; make install 375 - 376 - 3.5.8 Reboot 377 - ------------ 378 - 379 - 380 - 381 - 3.6 Custom configuration 382 - ======================== 383 - 384 - Although this driver already provides you default configuration, you 385 - still can change the device name and major number. The instruction to 386 - change these parameters are shown as below. 387 - 388 - a. Change Device name 389 - 390 - If you'd like to use other device names instead of default naming 391 - convention, all you have to do is to modify the internal code 392 - within the shell script "msmknod". First, you have to open "msmknod" 393 - by vi. Locate each line contains "ttyM" and "cum" and change them 394 - to the device name you desired. "msmknod" creates the device names 395 - you need next time executed. 396 - 397 - b. Change Major number 398 - 399 - If major number 30 and 35 had been occupied, you may have to select 400 - 2 free major numbers for this driver. There are 3 steps to change 401 - major numbers. 402 - 403 - 3.6.1 Find free major numbers 404 - ----------------------------- 405 - 406 - In /proc/devices, you may find all the major numbers occupied 407 - in the system. Please select 2 major numbers that are available. 408 - e.g. 40, 45. 409 - 410 - 3.6.2 Create special files 411 - -------------------------- 412 - 413 - Run /moxa/mxser/driver/msmknod to create special files with 414 - specified major numbers. 415 - 416 - 3.6.3 Modify driver with new major number 417 - ----------------------------------------- 418 - 419 - Run vi to open /moxa/mxser/driver/mxser.c. Locate the line 420 - contains "MXSERMAJOR". Change the content as below:: 421 - 422 - #define MXSERMAJOR 40 423 - #define MXSERCUMAJOR 45 424 - 425 - 3.6.4 Run "make clean; make install" in /moxa/mxser/driver. 426 - 427 - 3.7 Verify driver installation 428 - ============================== 429 - 430 - You may refer to /var/log/messages to check the latest status 431 - log reported by this driver whenever it's activated. 184 + ============ =============== 185 + Board Num. Device node 186 + 1st board ttyM0 - ttyM7 187 + 2nd board ttyM8 - ttyM15 188 + 3rd board ttyM16 - ttyM23 189 + 4th board ttyM24 - ttyM31 190 + ============ =============== 432 191 433 192 4. Utilities 434 193 ^^^^^^^^^^^^ ··· 128 505 msterm. These 3 utilities are released in form of source code. They should 129 506 be compiled into executable file and copied into /usr/bin. 130 507 131 - Before using these utilities, please load driver (refer 3.4 & 3.5) and 132 - make sure you had run the "msmknod" utility. 133 - 134 508 msdiag - Diagnostic 135 509 =================== 136 510 137 511 This utility provides the function to display what Moxa Smartio/Industio 138 - board found by driver in the system. 512 + board was found by the driver in the system. 139 513 140 514 msmon - Port Monitoring 141 515 ======================= ··· 162 542 163 543 Supported Setserial parameters are listed as below. 164 544 165 - ============== ========================================================= 166 - uart set UART type(16450-->disable FIFO, 16550A-->enable FIFO) 167 - close_delay set the amount of time(in 1/100 of a second) that DTR 545 + ============== ============================================================= 546 + uart set UART type(16450 --> disable FIFO, 16550A --> enable FIFO) 547 + close_delay set the amount of time (in 1/100 of a second) that DTR 168 548 should be kept low while being closed. 169 - closing_wait set the amount of time(in 1/100 of a second) that the 549 + closing_wait set the amount of time (in 1/100 of a second) that the 170 550 serial port should wait for data to be drained while 171 - being closed, before the receiver is disable. 172 - spd_hi Use 57.6kb when the application requests 38.4kb. 173 - spd_vhi Use 115.2kb when the application requests 38.4kb. 174 - spd_shi Use 230.4kb when the application requests 38.4kb. 175 - spd_warp Use 460.8kb when the application requests 38.4kb. 176 - spd_normal Use 38.4kb when the application requests 38.4kb. 177 - spd_cust Use the custom divisor to set the speed when the 551 + being closed, before the receiver is disabled. 552 + spd_hi Use 57.6kb when the application requests 38.4kb. 553 + spd_vhi Use 115.2kb when the application requests 38.4kb. 554 + spd_shi Use 230.4kb when the application requests 38.4kb. 555 + spd_warp Use 460.8kb when the application requests 38.4kb. 556 + spd_normal Use 38.4kb when the application requests 38.4kb. 557 + spd_cust Use the custom divisor to set the speed when the 178 558 application requests 38.4kb. 179 - divisor This option set the custom division. 180 - baud_base This option set the base baud rate. 181 - ============== ========================================================= 559 + divisor This option sets the custom division. 560 + baud_base This option sets the base baud rate. 561 + ============== ============================================================= 182 562 183 563 6. Troubleshooting 184 564 ^^^^^^^^^^^^^^^^^^ ··· 195 575 Solution: 196 576 To avoid this problem, please unplug fifth and after board, because Moxa 197 577 driver supports up to 4 boards. 198 - 199 - Error msg: 200 - Request_irq fail, IRQ(?) may be conflict with another device. 201 - 202 - Solution: 203 - Other PCI or ISA devices occupy the assigned IRQ. If you are not sure 204 - which device causes the situation, please check /proc/interrupts to find 205 - free IRQ and simply change another free IRQ for Moxa board. 206 - 207 - Error msg: 208 - Board #: C1xx Series(CAP=xxx) interrupt number invalid. 209 - 210 - Solution: 211 - Each port within the same multiport board shares the same IRQ. Please set 212 - one IRQ (IRQ doesn't equal to zero) for one Moxa board. 213 - 214 - Error msg: 215 - No interrupt vector be set for Moxa ISA board(CAP=xxx). 216 - 217 - Solution: 218 - Moxa ISA board needs an interrupt vector.Please refer to user's manual 219 - "Hardware Installation" chapter to set interrupt vector. 220 - 221 - Error msg: 222 - Couldn't install MOXA Smartio/Industio family driver! 223 - 224 - Solution: 225 - Load Moxa driver fail, the major number may conflict with other devices. 226 - Please refer to previous section 3.7 to change a free major number for 227 - Moxa driver. 228 - 229 - Error msg: 230 - Couldn't install MOXA Smartio/Industio family callout driver! 231 - 232 - Solution: 233 - Load Moxa callout driver fail, the callout device major number may 234 - conflict with other devices. Please refer to previous section 3.7 to 235 - change a free callout device major number for Moxa driver.
+2 -2
Documentation/networking/caif/caif.rst
··· 69 69 70 70 - 0x01 - tty->warned is on. 71 71 - 0x04 - tty->packed is on. 72 - - 0x08 - tty->flow_stopped is on. 72 + - 0x08 - tty->flow.tco_stopped is on. 73 73 - 0x10 - tty->hw_stopped is on. 74 - - 0x20 - tty->stopped is on. 74 + - 0x20 - tty->flow.stopped is on. 75 75 76 76 * last_tx_msg: Binary blob Prints the last transmitted frame. 77 77
+7 -2
MAINTAINERS
··· 12527 12527 F: drivers/net/phy/motorcomm.c 12528 12528 12529 12529 MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD 12530 - S: Orphan 12530 + M: Jiri Slaby <jirislaby@kernel.org> 12531 + S: Maintained 12531 12532 F: Documentation/driver-api/serial/moxa-smartio.rst 12532 12533 F: drivers/tty/mxser.* 12533 12534 ··· 18772 18771 F: Documentation/driver-api/serial/ 18773 18772 F: drivers/tty/ 18774 18773 F: drivers/tty/serial/serial_core.c 18774 + F: include/linux/selection.h 18775 18775 F: include/linux/serial.h 18776 18776 F: include/linux/serial_core.h 18777 - F: include/linux/tty.h 18777 + F: include/linux/sysrq.h 18778 + F: include/linux/tty*.h 18779 + F: include/linux/vt.h 18780 + F: include/linux/vt_*.h 18778 18781 F: include/uapi/linux/serial.h 18779 18782 F: include/uapi/linux/serial_core.h 18780 18783 F: include/uapi/linux/tty.h
+1 -8
arch/alpha/kernel/srmcons.c
··· 142 142 return count; 143 143 } 144 144 145 - static int 145 + static unsigned int 146 146 srmcons_write_room(struct tty_struct *tty) 147 147 { 148 148 return 512; 149 - } 150 - 151 - static int 152 - srmcons_chars_in_buffer(struct tty_struct *tty) 153 - { 154 - return 0; 155 149 } 156 150 157 151 static int ··· 194 200 .close = srmcons_close, 195 201 .write = srmcons_write, 196 202 .write_room = srmcons_write_room, 197 - .chars_in_buffer= srmcons_chars_in_buffer, 198 203 }; 199 204 200 205 static int __init
+2
arch/arm/boot/dts/imx53-ppd.dts
··· 651 651 &uart2 { 652 652 pinctrl-names = "default"; 653 653 pinctrl-0 = <&pinctrl_uart2>; 654 + fsl,dma-info = <24 20>; 654 655 status = "okay"; 655 656 }; 656 657 ··· 671 670 &uart5 { 672 671 pinctrl-names = "default"; 673 672 pinctrl-0 = <&pinctrl_uart5>; 673 + fsl,dma-info = <4096 4>; 674 674 status = "okay"; 675 675 }; 676 676
+1 -1
arch/arm64/boot/dts/marvell/armada-37xx.dtsi
··· 134 134 135 135 uart0: serial@12000 { 136 136 compatible = "marvell,armada-3700-uart"; 137 - reg = <0x12000 0x200>; 137 + reg = <0x12000 0x18>; 138 138 clocks = <&xtalclk>; 139 139 interrupts = 140 140 <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
+1 -1
arch/m68k/emu/nfcon.c
··· 85 85 return 1; 86 86 } 87 87 88 - static int nfcon_tty_write_room(struct tty_struct *tty) 88 + static unsigned int nfcon_tty_write_room(struct tty_struct *tty) 89 89 { 90 90 return 64; 91 91 }
+2 -1
arch/mips/mti-malta/malta-platform.c
··· 33 33 .irq = int, \ 34 34 .uartclk = 1843200, \ 35 35 .iotype = UPIO_PORT, \ 36 - .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \ 36 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | \ 37 + UPF_MAGIC_MULTIPLIER, \ 37 38 .regshift = 0, \ 38 39 } 39 40
+1 -7
arch/parisc/kernel/pdc_cons.c
··· 103 103 return count; 104 104 } 105 105 106 - static int pdc_console_tty_write_room(struct tty_struct *tty) 106 + static unsigned int pdc_console_tty_write_room(struct tty_struct *tty) 107 107 { 108 108 return 32768; /* no limit, no buffer used */ 109 - } 110 - 111 - static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty) 112 - { 113 - return 0; /* no buffer */ 114 109 } 115 110 116 111 static const struct tty_operations pdc_console_tty_ops = { ··· 113 118 .close = pdc_console_tty_close, 114 119 .write = pdc_console_tty_write, 115 120 .write_room = pdc_console_tty_write_room, 116 - .chars_in_buffer = pdc_console_tty_chars_in_buffer, 117 121 }; 118 122 119 123 static void pdc_console_poll(struct timer_list *unused)
-1
arch/powerpc/configs/ppc6xx_defconfig
··· 621 621 CONFIG_HW_RANDOM_VIRTIO=m 622 622 CONFIG_NVRAM=y 623 623 CONFIG_DTLK=m 624 - CONFIG_R3964=m 625 624 CONFIG_CARDMAN_4000=m 626 625 CONFIG_CARDMAN_4040=m 627 626 CONFIG_IPWIRELESS=m
+5 -10
arch/um/drivers/line.c
··· 32 32 * 33 33 * Should be called while holding line->lock (this does not modify data). 34 34 */ 35 - static int write_room(struct line *line) 35 + static unsigned int write_room(struct line *line) 36 36 { 37 37 int n; 38 38 ··· 47 47 return n - 1; 48 48 } 49 49 50 - int line_write_room(struct tty_struct *tty) 50 + unsigned int line_write_room(struct tty_struct *tty) 51 51 { 52 52 struct line *line = tty->driver_data; 53 53 unsigned long flags; 54 - int room; 54 + unsigned int room; 55 55 56 56 spin_lock_irqsave(&line->lock, flags); 57 57 room = write_room(line); ··· 60 60 return room; 61 61 } 62 62 63 - int line_chars_in_buffer(struct tty_struct *tty) 63 + unsigned int line_chars_in_buffer(struct tty_struct *tty) 64 64 { 65 65 struct line *line = tty->driver_data; 66 66 unsigned long flags; 67 - int ret; 67 + unsigned int ret; 68 68 69 69 spin_lock_irqsave(&line->lock, flags); 70 70 /* write_room subtracts 1 for the needed NULL, so we readd it.*/ ··· 209 209 out_up: 210 210 spin_unlock_irqrestore(&line->lock, flags); 211 211 return ret; 212 - } 213 - 214 - void line_set_termios(struct tty_struct *tty, struct ktermios * old) 215 - { 216 - /* nothing */ 217 212 } 218 213 219 214 void line_throttle(struct tty_struct *tty)
+2 -3
arch/um/drivers/line.h
··· 66 66 char *init, char *name); 67 67 extern int line_write(struct tty_struct *tty, const unsigned char *buf, 68 68 int len); 69 - extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); 70 - extern int line_chars_in_buffer(struct tty_struct *tty); 69 + extern unsigned int line_chars_in_buffer(struct tty_struct *tty); 71 70 extern void line_flush_buffer(struct tty_struct *tty); 72 71 extern void line_flush_chars(struct tty_struct *tty); 73 - extern int line_write_room(struct tty_struct *tty); 72 + extern unsigned int line_write_room(struct tty_struct *tty); 74 73 extern void line_throttle(struct tty_struct *tty); 75 74 extern void line_unthrottle(struct tty_struct *tty); 76 75
-1
arch/um/drivers/ssl.c
··· 99 99 .chars_in_buffer = line_chars_in_buffer, 100 100 .flush_buffer = line_flush_buffer, 101 101 .flush_chars = line_flush_chars, 102 - .set_termios = line_set_termios, 103 102 .throttle = line_throttle, 104 103 .unthrottle = line_unthrottle, 105 104 .install = ssl_install,
-1
arch/um/drivers/stdio_console.c
··· 106 106 .chars_in_buffer = line_chars_in_buffer, 107 107 .flush_buffer = line_flush_buffer, 108 108 .flush_chars = line_flush_chars, 109 - .set_termios = line_set_termios, 110 109 .throttle = line_throttle, 111 110 .unthrottle = line_unthrottle, 112 111 .hangup = line_hangup,
+1 -8
arch/xtensa/platforms/iss/console.c
··· 100 100 { 101 101 } 102 102 103 - static int rs_write_room(struct tty_struct *tty) 103 + static unsigned int rs_write_room(struct tty_struct *tty) 104 104 { 105 105 /* Let's say iss can always accept 2K characters.. */ 106 106 return 2 * 1024; 107 - } 108 - 109 - static int rs_chars_in_buffer(struct tty_struct *tty) 110 - { 111 - /* the iss doesn't buffer characters */ 112 - return 0; 113 107 } 114 108 115 109 static void rs_hangup(struct tty_struct *tty) ··· 129 135 .put_char = rs_put_char, 130 136 .flush_chars = rs_flush_chars, 131 137 .write_room = rs_write_room, 132 - .chars_in_buffer = rs_chars_in_buffer, 133 138 .hangup = rs_hangup, 134 139 .wait_until_sent = rs_wait_until_sent, 135 140 .proc_show = rs_proc_show,
+5 -4
drivers/accessibility/speakup/spk_ttyio.c
··· 72 72 } 73 73 74 74 static int spk_ttyio_receive_buf2(struct tty_struct *tty, 75 - const unsigned char *cp, char *fp, int count) 75 + const unsigned char *cp, 76 + const char *fp, int count) 76 77 { 77 78 struct spk_ldisc_data *ldisc_data = tty->disc_data; 78 79 struct spk_synth *synth = ldisc_data->synth; ··· 105 104 106 105 static struct tty_ldisc_ops spk_ttyio_ldisc_ops = { 107 106 .owner = THIS_MODULE, 107 + .num = N_SPEAKUP, 108 108 .name = "speakup_ldisc", 109 109 .open = spk_ttyio_ldisc_open, 110 110 .close = spk_ttyio_ldisc_close, ··· 213 211 214 212 void spk_ttyio_register_ldisc(void) 215 213 { 216 - if (tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops)) 214 + if (tty_register_ldisc(&spk_ttyio_ldisc_ops)) 217 215 pr_warn("speakup: Error registering line discipline. Most synths won't work.\n"); 218 216 } 219 217 220 218 void spk_ttyio_unregister_ldisc(void) 221 219 { 222 - if (tty_unregister_ldisc(N_SPEAKUP)) 223 - pr_warn("speakup: Couldn't unregister ldisc\n"); 220 + tty_unregister_ldisc(&spk_ttyio_ldisc_ops); 224 221 } 225 222 226 223 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
+4 -8
drivers/bluetooth/hci_ldisc.c
··· 593 593 * Return Value: None 594 594 */ 595 595 static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, 596 - char *flags, int count) 596 + const char *flags, int count) 597 597 { 598 598 struct hci_uart *hu = tty->disc_data; 599 599 ··· 821 821 822 822 static struct tty_ldisc_ops hci_uart_ldisc = { 823 823 .owner = THIS_MODULE, 824 + .num = N_HCI, 824 825 .name = "n_hci", 825 826 .open = hci_uart_tty_open, 826 827 .close = hci_uart_tty_close, ··· 841 840 BT_INFO("HCI UART driver ver %s", VERSION); 842 841 843 842 /* Register the tty discipline */ 844 - err = tty_register_ldisc(N_HCI, &hci_uart_ldisc); 843 + err = tty_register_ldisc(&hci_uart_ldisc); 845 844 if (err) { 846 845 BT_ERR("HCI line discipline registration failed. (%d)", err); 847 846 return err; ··· 883 882 884 883 static void __exit hci_uart_exit(void) 885 884 { 886 - int err; 887 - 888 885 #ifdef CONFIG_BT_HCIUART_H4 889 886 h4_deinit(); 890 887 #endif ··· 914 915 mrvl_deinit(); 915 916 #endif 916 917 917 - /* Release tty registration of line discipline */ 918 - err = tty_unregister_ldisc(N_HCI); 919 - if (err) 920 - BT_ERR("Can't unregister HCI line discipline (%d)", err); 918 + tty_unregister_ldisc(&hci_uart_ldisc); 921 919 } 922 920 923 921 module_init(hci_uart_init);
-13
drivers/char/Kconfig
··· 218 218 219 219 If unsure, say N. 220 220 221 - config R3964 222 - tristate "Siemens R3964 line discipline" 223 - depends on TTY && BROKEN 224 - help 225 - This driver allows synchronous communication with devices using the 226 - Siemens R3964 packet protocol. Unless you are dealing with special 227 - hardware like PLCs, you are unlikely to need this. 228 - 229 - To compile this driver as a module, choose M here: the 230 - module will be called n_r3964. 231 - 232 - If unsure, say N. 233 - 234 221 config APPLICOM 235 222 tristate "Applicom intelligent fieldbus card support" 236 223 depends on PCI
+20 -38
drivers/char/ttyprintk.c
··· 52 52 53 53 static int tpk_printk(const unsigned char *buf, int count) 54 54 { 55 - int i = tpk_curr; 56 - 57 - if (buf == NULL) { 58 - tpk_flush(); 59 - return i; 60 - } 55 + int i; 61 56 62 57 for (i = 0; i < count; i++) { 63 58 if (tpk_curr >= TPK_STR_SIZE) { ··· 95 100 static void tpk_close(struct tty_struct *tty, struct file *filp) 96 101 { 97 102 struct ttyprintk_port *tpkp = tty->driver_data; 98 - unsigned long flags; 99 - 100 - spin_lock_irqsave(&tpkp->spinlock, flags); 101 - /* flush tpk_printk buffer */ 102 - tpk_printk(NULL, 0); 103 - spin_unlock_irqrestore(&tpkp->spinlock, flags); 104 103 105 104 tty_port_close(&tpkp->port, tty, filp); 106 105 } ··· 109 120 unsigned long flags; 110 121 int ret; 111 122 112 - 113 123 /* exclusive use of tpk_printk within this tty */ 114 124 spin_lock_irqsave(&tpkp->spinlock, flags); 115 125 ret = tpk_printk(buf, count); ··· 120 132 /* 121 133 * TTY operations write_room function. 122 134 */ 123 - static int tpk_write_room(struct tty_struct *tty) 135 + static unsigned int tpk_write_room(struct tty_struct *tty) 124 136 { 125 137 return TPK_MAX_ROOM; 126 - } 127 - 128 - /* 129 - * TTY operations ioctl function. 130 - */ 131 - static int tpk_ioctl(struct tty_struct *tty, 132 - unsigned int cmd, unsigned long arg) 133 - { 134 - struct ttyprintk_port *tpkp = tty->driver_data; 135 - 136 - if (!tpkp) 137 - return -EINVAL; 138 - 139 - switch (cmd) { 140 - /* Stop TIOCCONS */ 141 - case TIOCCONS: 142 - return -EOPNOTSUPP; 143 - default: 144 - return -ENOIOCTLCMD; 145 - } 146 - return 0; 147 138 } 148 139 149 140 /* ··· 135 168 tty_port_hangup(&tpkp->port); 136 169 } 137 170 171 + /* 172 + * TTY port operations shutdown function. 173 + */ 174 + static void tpk_port_shutdown(struct tty_port *tport) 175 + { 176 + struct ttyprintk_port *tpkp = 177 + container_of(tport, struct ttyprintk_port, port); 178 + unsigned long flags; 179 + 180 + spin_lock_irqsave(&tpkp->spinlock, flags); 181 + tpk_flush(); 182 + spin_unlock_irqrestore(&tpkp->spinlock, flags); 183 + } 184 + 138 185 static const struct tty_operations ttyprintk_ops = { 139 186 .open = tpk_open, 140 187 .close = tpk_close, 141 188 .write = tpk_write, 142 189 .write_room = tpk_write_room, 143 - .ioctl = tpk_ioctl, 144 190 .hangup = tpk_hangup, 145 191 }; 146 192 147 - static const struct tty_port_operations null_ops = { }; 193 + static const struct tty_port_operations tpk_port_ops = { 194 + .shutdown = tpk_port_shutdown, 195 + }; 148 196 149 197 static struct tty_driver *ttyprintk_driver; 150 198 ··· 177 195 return PTR_ERR(ttyprintk_driver); 178 196 179 197 tty_port_init(&tpk_port.port); 180 - tpk_port.port.ops = &null_ops; 198 + tpk_port.port.ops = &tpk_port_ops; 181 199 182 200 ttyprintk_driver->driver_name = "ttyprintk"; 183 201 ttyprintk_driver->name = "ttyprintk";
+5 -3
drivers/input/serio/serport.c
··· 114 114 * 'interrupt' routine. 115 115 */ 116 116 117 - static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 117 + static void serport_ldisc_receive(struct tty_struct *tty, 118 + const unsigned char *cp, const char *fp, int count) 118 119 { 119 120 struct serport *serport = (struct serport*) tty->disc_data; 120 121 unsigned long flags; ··· 274 273 275 274 static struct tty_ldisc_ops serport_ldisc = { 276 275 .owner = THIS_MODULE, 276 + .num = N_MOUSE, 277 277 .name = "input", 278 278 .open = serport_ldisc_open, 279 279 .close = serport_ldisc_close, ··· 295 293 static int __init serport_init(void) 296 294 { 297 295 int retval; 298 - retval = tty_register_ldisc(N_MOUSE, &serport_ldisc); 296 + retval = tty_register_ldisc(&serport_ldisc); 299 297 if (retval) 300 298 printk(KERN_ERR "serport.c: Error registering line discipline.\n"); 301 299 ··· 304 302 305 303 static void __exit serport_exit(void) 306 304 { 307 - tty_unregister_ldisc(N_MOUSE); 305 + tty_unregister_ldisc(&serport_ldisc); 308 306 } 309 307 310 308 module_init(serport_init);
+2 -2
drivers/ipack/devices/ipoctal.c
··· 458 458 return char_copied; 459 459 } 460 460 461 - static int ipoctal_write_room(struct tty_struct *tty) 461 + static unsigned int ipoctal_write_room(struct tty_struct *tty) 462 462 { 463 463 struct ipoctal_channel *channel = tty->driver_data; 464 464 465 465 return PAGE_SIZE - channel->nb_bytes; 466 466 } 467 467 468 - static int ipoctal_chars_in_buffer(struct tty_struct *tty) 468 + static unsigned int ipoctal_chars_in_buffer(struct tty_struct *tty) 469 469 { 470 470 struct ipoctal_channel *channel = tty->driver_data; 471 471
+4 -36
drivers/isdn/capi/capi.c
··· 1158 1158 struct capiminor *mp = tty->driver_data; 1159 1159 struct sk_buff *skb; 1160 1160 1161 - pr_debug("capinc_tty_flush_chars\n"); 1162 - 1163 1161 spin_lock_bh(&mp->outlock); 1164 1162 skb = mp->outskb; 1165 1163 if (skb) { ··· 1173 1175 handle_minor_recv(mp); 1174 1176 } 1175 1177 1176 - static int capinc_tty_write_room(struct tty_struct *tty) 1178 + static unsigned int capinc_tty_write_room(struct tty_struct *tty) 1177 1179 { 1178 1180 struct capiminor *mp = tty->driver_data; 1179 - int room; 1181 + unsigned int room; 1180 1182 1181 1183 room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue); 1182 1184 room *= CAPI_MAX_BLKSIZE; 1183 - pr_debug("capinc_tty_write_room = %d\n", room); 1185 + pr_debug("capinc_tty_write_room = %u\n", room); 1184 1186 return room; 1185 1187 } 1186 1188 1187 - static int capinc_tty_chars_in_buffer(struct tty_struct *tty) 1189 + static unsigned int capinc_tty_chars_in_buffer(struct tty_struct *tty) 1188 1190 { 1189 1191 struct capiminor *mp = tty->driver_data; 1190 1192 ··· 1195 1197 return mp->outbytes; 1196 1198 } 1197 1199 1198 - static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old) 1199 - { 1200 - pr_debug("capinc_tty_set_termios\n"); 1201 - } 1202 - 1203 1200 static void capinc_tty_throttle(struct tty_struct *tty) 1204 1201 { 1205 1202 struct capiminor *mp = tty->driver_data; 1206 - pr_debug("capinc_tty_throttle\n"); 1207 1203 mp->ttyinstop = 1; 1208 1204 } 1209 1205 ··· 1205 1213 { 1206 1214 struct capiminor *mp = tty->driver_data; 1207 1215 1208 - pr_debug("capinc_tty_unthrottle\n"); 1209 1216 mp->ttyinstop = 0; 1210 1217 handle_minor_recv(mp); 1211 1218 } ··· 1213 1222 { 1214 1223 struct capiminor *mp = tty->driver_data; 1215 1224 1216 - pr_debug("capinc_tty_stop\n"); 1217 1225 mp->ttyoutstop = 1; 1218 1226 } 1219 1227 ··· 1220 1230 { 1221 1231 struct capiminor *mp = tty->driver_data; 1222 1232 1223 - pr_debug("capinc_tty_start\n"); 1224 1233 mp->ttyoutstop = 0; 1225 1234 handle_minor_send(mp); 1226 1235 } ··· 1228 1239 { 1229 1240 struct capiminor *mp = tty->driver_data; 1230 1241 1231 - pr_debug("capinc_tty_hangup\n"); 1232 1242 tty_port_hangup(&mp->port); 1233 - } 1234 - 1235 - static int capinc_tty_break_ctl(struct tty_struct *tty, int state) 1236 - { 1237 - pr_debug("capinc_tty_break_ctl(%d)\n", state); 1238 - return 0; 1239 - } 1240 - 1241 - static void capinc_tty_flush_buffer(struct tty_struct *tty) 1242 - { 1243 - pr_debug("capinc_tty_flush_buffer\n"); 1244 - } 1245 - 1246 - static void capinc_tty_set_ldisc(struct tty_struct *tty) 1247 - { 1248 - pr_debug("capinc_tty_set_ldisc\n"); 1249 1243 } 1250 1244 1251 1245 static void capinc_tty_send_xchar(struct tty_struct *tty, char ch) ··· 1244 1272 .flush_chars = capinc_tty_flush_chars, 1245 1273 .write_room = capinc_tty_write_room, 1246 1274 .chars_in_buffer = capinc_tty_chars_in_buffer, 1247 - .set_termios = capinc_tty_set_termios, 1248 1275 .throttle = capinc_tty_throttle, 1249 1276 .unthrottle = capinc_tty_unthrottle, 1250 1277 .stop = capinc_tty_stop, 1251 1278 .start = capinc_tty_start, 1252 1279 .hangup = capinc_tty_hangup, 1253 - .break_ctl = capinc_tty_break_ctl, 1254 - .flush_buffer = capinc_tty_flush_buffer, 1255 - .set_ldisc = capinc_tty_set_ldisc, 1256 1280 .send_xchar = capinc_tty_send_xchar, 1257 1281 .install = capinc_tty_install, 1258 1282 .cleanup = capinc_tty_cleanup,
+1 -1
drivers/misc/bcm-vk/bcm_vk_tty.c
··· 214 214 return count; 215 215 } 216 216 217 - static int bcm_vk_tty_write_room(struct tty_struct *tty) 217 + static unsigned int bcm_vk_tty_write_room(struct tty_struct *tty) 218 218 { 219 219 struct bcm_vk *vk = dev_get_drvdata(tty->dev); 220 220
+13 -17
drivers/misc/ti-st/st_core.c
··· 52 52 */ 53 53 int st_get_uart_wr_room(struct st_data_s *st_gdata) 54 54 { 55 - struct tty_struct *tty; 56 55 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { 57 56 pr_err("tty unavailable to perform write"); 58 57 return -1; 59 58 } 60 - tty = st_gdata->tty; 61 - return tty->ops->write_room(tty); 59 + 60 + return tty_write_room(st_gdata->tty); 62 61 } 63 62 64 63 /* ··· 797 798 } 798 799 799 800 static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, 800 - char *tty_flags, int count) 801 + const char *tty_flags, int count) 801 802 { 802 803 #ifdef VERBOSE 803 804 print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE, ··· 844 845 } 845 846 846 847 static struct tty_ldisc_ops st_ldisc_ops = { 848 + .num = N_TI_WL, 847 849 .name = "n_st", 848 850 .open = st_tty_open, 849 851 .close = st_tty_close, ··· 860 860 struct st_data_s *st_gdata; 861 861 long err; 862 862 863 - err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops); 863 + err = tty_register_ldisc(&st_ldisc_ops); 864 864 if (err) { 865 865 pr_err("error registering %d line discipline %ld", 866 866 N_TI_WL, err); ··· 871 871 st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL); 872 872 if (!st_gdata) { 873 873 pr_err("memory allocation failed"); 874 - err = tty_unregister_ldisc(N_TI_WL); 875 - if (err) 876 - pr_err("unable to un-register ldisc %ld", err); 877 874 err = -ENOMEM; 878 - return err; 875 + goto err_unreg_ldisc; 879 876 } 880 877 881 878 /* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's ··· 887 890 err = st_ll_init(st_gdata); 888 891 if (err) { 889 892 pr_err("error during st_ll initialization(%ld)", err); 890 - kfree(st_gdata); 891 - err = tty_unregister_ldisc(N_TI_WL); 892 - if (err) 893 - pr_err("unable to un-register ldisc"); 894 - return err; 893 + goto err_free_gdata; 895 894 } 896 895 897 896 INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup); 898 897 899 898 *core_data = st_gdata; 900 899 return 0; 900 + err_free_gdata: 901 + kfree(st_gdata); 902 + err_unreg_ldisc: 903 + tty_unregister_ldisc(&st_ldisc_ops); 904 + return err; 901 905 } 902 906 903 907 void st_core_exit(struct st_data_s *st_gdata) ··· 916 918 kfree_skb(st_gdata->rx_skb); 917 919 kfree_skb(st_gdata->tx_skb); 918 920 /* TTY ldisc cleanup */ 919 - err = tty_unregister_ldisc(N_TI_WL); 920 - if (err) 921 - pr_err("unable to un-register ldisc %ld", err); 921 + tty_unregister_ldisc(&st_ldisc_ops); 922 922 /* free the global data pointer */ 923 923 kfree(st_gdata); 924 924 }
+3 -3
drivers/mmc/core/sdio_uart.c
··· 439 439 tty = tty_port_tty_get(&port->port); 440 440 441 441 if (tty == NULL || !kfifo_len(xmit) || 442 - tty->stopped || tty->hw_stopped) { 442 + tty->flow.stopped || tty->hw_stopped) { 443 443 sdio_uart_stop_tx(port); 444 444 tty_kref_put(tty); 445 445 return; ··· 797 797 return ret; 798 798 } 799 799 800 - static int sdio_uart_write_room(struct tty_struct *tty) 800 + static unsigned int sdio_uart_write_room(struct tty_struct *tty) 801 801 { 802 802 struct sdio_uart_port *port = tty->driver_data; 803 803 return FIFO_SIZE - kfifo_len(&port->xmit_fifo); 804 804 } 805 805 806 - static int sdio_uart_chars_in_buffer(struct tty_struct *tty) 806 + static unsigned int sdio_uart_chars_in_buffer(struct tty_struct *tty) 807 807 { 808 808 struct sdio_uart_port *port = tty->driver_data; 809 809 return kfifo_len(&port->xmit_fifo);
+7 -6
drivers/net/caif/caif_serial.c
··· 87 87 static inline void update_tty_status(struct ser_device *ser) 88 88 { 89 89 ser->tty_status = 90 - ser->tty->stopped << 5 | 91 - ser->tty->flow_stopped << 3 | 92 - ser->tty->packet << 2; 90 + ser->tty->flow.stopped << 5 | 91 + ser->tty->flow.tco_stopped << 3 | 92 + ser->tty->ctrl.packet << 2; 93 93 } 94 94 static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) 95 95 { ··· 159 159 #endif 160 160 161 161 static void ldisc_receive(struct tty_struct *tty, const u8 *data, 162 - char *flags, int count) 162 + const char *flags, int count) 163 163 { 164 164 struct sk_buff *skb = NULL; 165 165 struct ser_device *ser; ··· 380 380 /* The line discipline structure. */ 381 381 static struct tty_ldisc_ops caif_ldisc = { 382 382 .owner = THIS_MODULE, 383 + .num = N_CAIF, 383 384 .name = "n_caif", 384 385 .open = ldisc_open, 385 386 .close = ldisc_close, ··· 430 429 { 431 430 int ret; 432 431 433 - ret = tty_register_ldisc(N_CAIF, &caif_ldisc); 432 + ret = tty_register_ldisc(&caif_ldisc); 434 433 if (ret < 0) 435 434 pr_err("cannot register CAIF ldisc=%d err=%d\n", N_CAIF, ret); 436 435 ··· 445 444 spin_unlock(&ser_lock); 446 445 ser_release(NULL); 447 446 cancel_work_sync(&ser_release_work); 448 - tty_unregister_ldisc(N_CAIF); 447 + tty_unregister_ldisc(&caif_ldisc); 449 448 debugfs_remove_recursive(debugfsdir); 450 449 } 451 450
+5 -5
drivers/net/can/slcan.c
··· 467 467 */ 468 468 469 469 static void slcan_receive_buf(struct tty_struct *tty, 470 - const unsigned char *cp, char *fp, int count) 470 + const unsigned char *cp, const char *fp, 471 + int count) 471 472 { 472 473 struct slcan *sl = (struct slcan *) tty->disc_data; 473 474 ··· 698 697 699 698 static struct tty_ldisc_ops slc_ldisc = { 700 699 .owner = THIS_MODULE, 700 + .num = N_SLCAN, 701 701 .name = "slcan", 702 702 .open = slcan_open, 703 703 .close = slcan_close, ··· 723 721 return -ENOMEM; 724 722 725 723 /* Fill in our line protocol discipline, and register it */ 726 - status = tty_register_ldisc(N_SLCAN, &slc_ldisc); 724 + status = tty_register_ldisc(&slc_ldisc); 727 725 if (status) { 728 726 printk(KERN_ERR "slcan: can't register line discipline\n"); 729 727 kfree(slcan_devs); ··· 784 782 kfree(slcan_devs); 785 783 slcan_devs = NULL; 786 784 787 - i = tty_unregister_ldisc(N_SLCAN); 788 - if (i) 789 - printk(KERN_ERR "slcan: can't unregister ldisc (err %d)\n", i); 785 + tty_unregister_ldisc(&slc_ldisc); 790 786 } 791 787 792 788 module_init(slcan_init);
+5 -9
drivers/net/hamradio/6pack.c
··· 428 428 * and sent on to some IP layer for further processing. 429 429 */ 430 430 static void sixpack_receive_buf(struct tty_struct *tty, 431 - const unsigned char *cp, char *fp, int count) 431 + const unsigned char *cp, const char *fp, int count) 432 432 { 433 433 struct sixpack *sp; 434 434 int count1; ··· 742 742 743 743 static struct tty_ldisc_ops sp_ldisc = { 744 744 .owner = THIS_MODULE, 745 + .num = N_6PACK, 745 746 .name = "6pack", 746 747 .open = sixpack_open, 747 748 .close = sixpack_close, ··· 765 764 printk(msg_banner); 766 765 767 766 /* Register the provided line protocol discipline */ 768 - if ((status = tty_register_ldisc(N_6PACK, &sp_ldisc)) != 0) 767 + status = tty_register_ldisc(&sp_ldisc); 768 + if (status) 769 769 printk(msg_regfail, status); 770 770 771 771 return status; 772 772 } 773 773 774 - static const char msg_unregfail[] = KERN_ERR \ 775 - "6pack: can't unregister line discipline (err = %d)\n"; 776 - 777 774 static void __exit sixpack_exit_driver(void) 778 775 { 779 - int ret; 780 - 781 - if ((ret = tty_unregister_ldisc(N_6PACK))) 782 - printk(msg_unregfail, ret); 776 + tty_unregister_ldisc(&sp_ldisc); 783 777 } 784 778 785 779 /* encode an AX.25 packet into 6pack */
+4 -9
drivers/net/hamradio/mkiss.c
··· 872 872 * and sent on to the AX.25 layer for further processing. 873 873 */ 874 874 static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp, 875 - char *fp, int count) 875 + const char *fp, int count) 876 876 { 877 877 struct mkiss *ax = mkiss_get(tty); 878 878 ··· 934 934 935 935 static struct tty_ldisc_ops ax_ldisc = { 936 936 .owner = THIS_MODULE, 937 + .num = N_AX25, 937 938 .name = "mkiss", 938 939 .open = mkiss_open, 939 940 .close = mkiss_close, ··· 954 953 955 954 printk(banner); 956 955 957 - status = tty_register_ldisc(N_AX25, &ax_ldisc); 956 + status = tty_register_ldisc(&ax_ldisc); 958 957 if (status != 0) 959 958 printk(msg_regfail, status); 960 959 961 960 return status; 962 961 } 963 962 964 - static const char msg_unregfail[] = KERN_ERR \ 965 - "mkiss: can't unregister line discipline (err = %d)\n"; 966 - 967 963 static void __exit mkiss_exit_driver(void) 968 964 { 969 - int ret; 970 - 971 - if ((ret = tty_unregister_ldisc(N_AX25))) 972 - printk(msg_unregfail, ret); 965 + tty_unregister_ldisc(&ax_ldisc); 973 966 } 974 967 975 968 MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>");
+6 -6
drivers/net/ppp/ppp_async.c
··· 98 98 static int ppp_async_push(struct asyncppp *ap); 99 99 static void ppp_async_flush_output(struct asyncppp *ap); 100 100 static void ppp_async_input(struct asyncppp *ap, const unsigned char *buf, 101 - char *flags, int count); 101 + const char *flags, int count); 102 102 static int ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd, 103 103 unsigned long arg); 104 104 static void ppp_async_process(struct tasklet_struct *t); ··· 340 340 /* May sleep, don't call from interrupt level or with interrupts disabled */ 341 341 static void 342 342 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, 343 - char *cflags, int count) 343 + const char *cflags, int count) 344 344 { 345 345 struct asyncppp *ap = ap_get(tty); 346 346 unsigned long flags; ··· 372 372 373 373 static struct tty_ldisc_ops ppp_ldisc = { 374 374 .owner = THIS_MODULE, 375 + .num = N_PPP, 375 376 .name = "ppp", 376 377 .open = ppp_asynctty_open, 377 378 .close = ppp_asynctty_close, ··· 390 389 { 391 390 int err; 392 391 393 - err = tty_register_ldisc(N_PPP, &ppp_ldisc); 392 + err = tty_register_ldisc(&ppp_ldisc); 394 393 if (err != 0) 395 394 printk(KERN_ERR "PPP_async: error %d registering line disc.\n", 396 395 err); ··· 830 829 831 830 static void 832 831 ppp_async_input(struct asyncppp *ap, const unsigned char *buf, 833 - char *flags, int count) 832 + const char *flags, int count) 834 833 { 835 834 struct sk_buff *skb; 836 835 int c, i, j, n, s, f; ··· 1016 1015 1017 1016 static void __exit ppp_async_cleanup(void) 1018 1017 { 1019 - if (tty_unregister_ldisc(N_PPP) != 0) 1020 - printk(KERN_ERR "failed to unregister PPP line discipline\n"); 1018 + tty_unregister_ldisc(&ppp_ldisc); 1021 1019 } 1022 1020 1023 1021 module_init(ppp_async_init);
+6 -6
drivers/net/ppp/ppp_synctty.c
··· 94 94 static int ppp_sync_push(struct syncppp *ap); 95 95 static void ppp_sync_flush_output(struct syncppp *ap); 96 96 static void ppp_sync_input(struct syncppp *ap, const unsigned char *buf, 97 - char *flags, int count); 97 + const char *flags, int count); 98 98 99 99 static const struct ppp_channel_ops sync_ops = { 100 100 .start_xmit = ppp_sync_send, ··· 333 333 /* May sleep, don't call from interrupt level or with interrupts disabled */ 334 334 static void 335 335 ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, 336 - char *cflags, int count) 336 + const char *cflags, int count) 337 337 { 338 338 struct syncppp *ap = sp_get(tty); 339 339 unsigned long flags; ··· 365 365 366 366 static struct tty_ldisc_ops ppp_sync_ldisc = { 367 367 .owner = THIS_MODULE, 368 + .num = N_SYNC_PPP, 368 369 .name = "pppsync", 369 370 .open = ppp_sync_open, 370 371 .close = ppp_sync_close, ··· 383 382 { 384 383 int err; 385 384 386 - err = tty_register_ldisc(N_SYNC_PPP, &ppp_sync_ldisc); 385 + err = tty_register_ldisc(&ppp_sync_ldisc); 387 386 if (err != 0) 388 387 printk(KERN_ERR "PPP_sync: error %d registering line disc.\n", 389 388 err); ··· 666 665 */ 667 666 static void 668 667 ppp_sync_input(struct syncppp *ap, const unsigned char *buf, 669 - char *flags, int count) 668 + const char *flags, int count) 670 669 { 671 670 struct sk_buff *skb; 672 671 unsigned char *p; ··· 727 726 static void __exit 728 727 ppp_sync_cleanup(void) 729 728 { 730 - if (tty_unregister_ldisc(N_SYNC_PPP) != 0) 731 - printk(KERN_ERR "failed to unregister Sync PPP line discipline\n"); 729 + tty_unregister_ldisc(&ppp_sync_ldisc); 732 730 } 733 731 734 732 module_init(ppp_sync_init);
+4 -5
drivers/net/slip/slip.c
··· 685 685 */ 686 686 687 687 static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, 688 - char *fp, int count) 688 + const char *fp, int count) 689 689 { 690 690 struct slip *sl = tty->disc_data; 691 691 ··· 1263 1263 1264 1264 static struct tty_ldisc_ops sl_ldisc = { 1265 1265 .owner = THIS_MODULE, 1266 + .num = N_SLIP, 1266 1267 .name = "slip", 1267 1268 .open = slip_open, 1268 1269 .close = slip_close, ··· 1299 1298 return -ENOMEM; 1300 1299 1301 1300 /* Fill in our line protocol discipline, and register it */ 1302 - status = tty_register_ldisc(N_SLIP, &sl_ldisc); 1301 + status = tty_register_ldisc(&sl_ldisc); 1303 1302 if (status != 0) { 1304 1303 printk(KERN_ERR "SLIP: can't register line discipline (err = %d)\n", status); 1305 1304 kfree(slip_devs); ··· 1360 1359 kfree(slip_devs); 1361 1360 slip_devs = NULL; 1362 1361 1363 - i = tty_unregister_ldisc(N_SLIP); 1364 - if (i != 0) 1365 - printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i); 1362 + tty_unregister_ldisc(&sl_ldisc); 1366 1363 } 1367 1364 1368 1365 module_init(slip_init);
+4 -4
drivers/net/usb/hso.c
··· 1356 1356 } 1357 1357 1358 1358 /* how much room is there for writing */ 1359 - static int hso_serial_write_room(struct tty_struct *tty) 1359 + static unsigned int hso_serial_write_room(struct tty_struct *tty) 1360 1360 { 1361 1361 struct hso_serial *serial = tty->driver_data; 1362 - int room; 1362 + unsigned int room; 1363 1363 unsigned long flags; 1364 1364 1365 1365 spin_lock_irqsave(&serial->serial_lock, flags); ··· 1403 1403 } 1404 1404 1405 1405 /* how many characters in the buffer */ 1406 - static int hso_serial_chars_in_buffer(struct tty_struct *tty) 1406 + static unsigned int hso_serial_chars_in_buffer(struct tty_struct *tty) 1407 1407 { 1408 1408 struct hso_serial *serial = tty->driver_data; 1409 - int chars; 1410 1409 unsigned long flags; 1410 + unsigned int chars; 1411 1411 1412 1412 /* sanity check */ 1413 1413 if (serial == NULL)
+3 -8
drivers/pps/clients/pps-ldisc.c
··· 112 112 113 113 /* Init PPS_TTY data */ 114 114 pps_ldisc_ops.owner = THIS_MODULE; 115 + pps_ldisc_ops.num = N_PPS; 115 116 pps_ldisc_ops.name = "pps_tty"; 116 117 pps_ldisc_ops.dcd_change = pps_tty_dcd_change; 117 118 pps_ldisc_ops.open = pps_tty_open; 118 119 pps_ldisc_ops.close = pps_tty_close; 119 120 120 - err = tty_register_ldisc(N_PPS, &pps_ldisc_ops); 121 + err = tty_register_ldisc(&pps_ldisc_ops); 121 122 if (err) 122 123 pr_err("can't register PPS line discipline\n"); 123 124 else ··· 129 128 130 129 static void __exit pps_tty_cleanup(void) 131 130 { 132 - int err; 133 - 134 - err = tty_unregister_ldisc(N_PPS); 135 - if (err) 136 - pr_err("can't unregister PPS line discipline\n"); 137 - else 138 - pr_info("PPS line discipline removed\n"); 131 + tty_unregister_ldisc(&pps_ldisc_ops); 139 132 } 140 133 141 134 module_init(pps_tty_init);
+2 -2
drivers/s390/char/con3215.c
··· 925 925 /* 926 926 * Returns the amount of free space in the output buffer. 927 927 */ 928 - static int tty3215_write_room(struct tty_struct *tty) 928 + static unsigned int tty3215_write_room(struct tty_struct *tty) 929 929 { 930 930 struct raw3215_info *raw = tty->driver_data; 931 931 ··· 981 981 /* 982 982 * Returns the number of characters in the output buffer 983 983 */ 984 - static int tty3215_chars_in_buffer(struct tty_struct *tty) 984 + static unsigned int tty3215_chars_in_buffer(struct tty_struct *tty) 985 985 { 986 986 struct raw3215_info *raw = tty->driver_data; 987 987
+2 -2
drivers/s390/char/sclp_rw.c
··· 318 318 /* 319 319 * Return number of characters in buffer 320 320 */ 321 - int 321 + unsigned int 322 322 sclp_chars_in_buffer(struct sclp_buffer *buffer) 323 323 { 324 - int count; 324 + unsigned int count; 325 325 326 326 count = buffer->char_sum; 327 327 if (buffer->current_line != NULL)
+1 -1
drivers/s390/char/sclp_rw.h
··· 86 86 int sclp_buffer_space(struct sclp_buffer *); 87 87 int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int); 88 88 int sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int)); 89 - int sclp_chars_in_buffer(struct sclp_buffer *); 89 + unsigned int sclp_chars_in_buffer(struct sclp_buffer *); 90 90 91 91 #endif /* __SCLP_RW_H__ */
+4 -5
drivers/s390/char/sclp_tty.c
··· 86 86 * a string of newlines. Every newline creates a new message which 87 87 * needs 82 bytes. 88 88 */ 89 - static int 89 + static unsigned int 90 90 sclp_tty_write_room (struct tty_struct *tty) 91 91 { 92 92 unsigned long flags; 93 93 struct list_head *l; 94 - int count; 94 + unsigned int count; 95 95 96 96 spin_lock_irqsave(&sclp_tty_lock, flags); 97 97 count = 0; ··· 280 280 * characters in the write buffer (will not be written as long as there is a 281 281 * final line feed missing). 282 282 */ 283 - static int 283 + static unsigned int 284 284 sclp_tty_chars_in_buffer(struct tty_struct *tty) 285 285 { 286 286 unsigned long flags; 287 287 struct sclp_buffer *t; 288 - int count; 288 + unsigned int count = 0; 289 289 290 290 spin_lock_irqsave(&sclp_tty_lock, flags); 291 - count = 0; 292 291 if (sclp_ttybuf != NULL) 293 292 count = sclp_chars_in_buffer(sclp_ttybuf); 294 293 list_for_each_entry(t, &sclp_tty_outqueue, list) {
+4 -5
drivers/s390/char/sclp_vt220.c
··· 604 604 * to change as output buffers get emptied, or if the output flow 605 605 * control is acted. 606 606 */ 607 - static int 607 + static unsigned int 608 608 sclp_vt220_write_room(struct tty_struct *tty) 609 609 { 610 610 unsigned long flags; 611 611 struct list_head *l; 612 - int count; 612 + unsigned int count; 613 613 614 614 spin_lock_irqsave(&sclp_vt220_lock, flags); 615 615 count = 0; ··· 624 624 /* 625 625 * Return number of buffered chars. 626 626 */ 627 - static int 627 + static unsigned int 628 628 sclp_vt220_chars_in_buffer(struct tty_struct *tty) 629 629 { 630 630 unsigned long flags; 631 631 struct list_head *l; 632 632 struct sclp_vt220_request *r; 633 - int count; 633 + unsigned int count = 0; 634 634 635 635 spin_lock_irqsave(&sclp_vt220_lock, flags); 636 - count = 0; 637 636 if (sclp_vt220_current_request != NULL) 638 637 count = sclp_vt220_chars_stored(sclp_vt220_current_request); 639 638 list_for_each(l, &sclp_vt220_outqueue) {
+2 -20
drivers/s390/char/tty3270.c
··· 1071 1071 /* 1072 1072 * We always have room. 1073 1073 */ 1074 - static int 1074 + static unsigned int 1075 1075 tty3270_write_room(struct tty_struct *tty) 1076 1076 { 1077 1077 return INT_MAX; ··· 1640 1640 int i_msg, i; 1641 1641 1642 1642 spin_lock_bh(&tp->view.lock); 1643 - for (i_msg = 0; !tty->stopped && i_msg < count; i_msg++) { 1643 + for (i_msg = 0; !tty->flow.stopped && i_msg < count; i_msg++) { 1644 1644 if (tp->esc_state != 0) { 1645 1645 /* Continue escape sequence. */ 1646 1646 tty3270_escape_sequence(tp, buf[i_msg]); ··· 1754 1754 tty3270_do_write(tp, tty, tp->char_buf, tp->char_count); 1755 1755 tp->char_count = 0; 1756 1756 } 1757 - } 1758 - 1759 - /* 1760 - * Returns the number of characters in the output buffer. This is 1761 - * used in tty_wait_until_sent to wait until all characters have 1762 - * appeared on the screen. 1763 - */ 1764 - static int 1765 - tty3270_chars_in_buffer(struct tty_struct *tty) 1766 - { 1767 - return 0; 1768 - } 1769 - 1770 - static void 1771 - tty3270_flush_buffer(struct tty_struct *tty) 1772 - { 1773 1757 } 1774 1758 1775 1759 /* ··· 1876 1892 .put_char = tty3270_put_char, 1877 1893 .flush_chars = tty3270_flush_chars, 1878 1894 .write_room = tty3270_write_room, 1879 - .chars_in_buffer = tty3270_chars_in_buffer, 1880 - .flush_buffer = tty3270_flush_buffer, 1881 1895 .throttle = tty3270_throttle, 1882 1896 .unthrottle = tty3270_unthrottle, 1883 1897 .hangup = tty3270_hangup,
+7 -7
drivers/staging/fwserial/fwserial.c
··· 721 721 722 722 /* try to write as many dma transactions out as possible */ 723 723 n = -EAGAIN; 724 - while (!tty->stopped && !tty->hw_stopped && 724 + while (!tty->flow.stopped && !tty->hw_stopped && 725 725 !test_bit(STOP_TX, &port->flags)) { 726 726 txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC); 727 727 if (!txn) { ··· 1112 1112 return (n < 0) ? 0 : n; 1113 1113 } 1114 1114 1115 - static int fwtty_write_room(struct tty_struct *tty) 1115 + static unsigned int fwtty_write_room(struct tty_struct *tty) 1116 1116 { 1117 1117 struct fwtty_port *port = tty->driver_data; 1118 - int n; 1118 + unsigned int n; 1119 1119 1120 1120 spin_lock_bh(&port->lock); 1121 1121 n = dma_fifo_avail(&port->tx_fifo); 1122 1122 spin_unlock_bh(&port->lock); 1123 1123 1124 - fwtty_dbg(port, "%d\n", n); 1124 + fwtty_dbg(port, "%u\n", n); 1125 1125 1126 1126 return n; 1127 1127 } 1128 1128 1129 - static int fwtty_chars_in_buffer(struct tty_struct *tty) 1129 + static unsigned int fwtty_chars_in_buffer(struct tty_struct *tty) 1130 1130 { 1131 1131 struct fwtty_port *port = tty->driver_data; 1132 - int n; 1132 + unsigned int n; 1133 1133 1134 1134 spin_lock_bh(&port->lock); 1135 1135 n = dma_fifo_level(&port->tx_fifo); 1136 1136 spin_unlock_bh(&port->lock); 1137 1137 1138 - fwtty_dbg(port, "%d\n", n); 1138 + fwtty_dbg(port, "%u\n", n); 1139 1139 1140 1140 return n; 1141 1141 }
+1 -1
drivers/staging/gdm724x/gdm_tty.c
··· 183 183 return len; 184 184 } 185 185 186 - static int gdm_tty_write_room(struct tty_struct *tty) 186 + static unsigned int gdm_tty_write_room(struct tty_struct *tty) 187 187 { 188 188 struct gdm *gdm = tty->driver_data; 189 189
+4 -18
drivers/staging/greybus/uart.c
··· 440 440 return count; 441 441 } 442 442 443 - static int gb_tty_write_room(struct tty_struct *tty) 443 + static unsigned int gb_tty_write_room(struct tty_struct *tty) 444 444 { 445 445 struct gb_tty *gb_tty = tty->driver_data; 446 446 unsigned long flags; ··· 457 457 return room; 458 458 } 459 459 460 - static int gb_tty_chars_in_buffer(struct tty_struct *tty) 460 + static unsigned int gb_tty_chars_in_buffer(struct tty_struct *tty) 461 461 { 462 462 struct gb_tty *gb_tty = tty->driver_data; 463 463 unsigned long flags; 464 - int chars; 464 + unsigned int chars; 465 465 466 466 spin_lock_irqsave(&gb_tty->write_lock, flags); 467 467 chars = kfifo_len(&gb_tty->write_fifo); ··· 494 494 (termios->c_cflag & PARODD ? 1 : 2) + 495 495 (termios->c_cflag & CMSPAR ? 2 : 0) : 0; 496 496 497 - switch (termios->c_cflag & CSIZE) { 498 - case CS5: 499 - newline.data_bits = 5; 500 - break; 501 - case CS6: 502 - newline.data_bits = 6; 503 - break; 504 - case CS7: 505 - newline.data_bits = 7; 506 - break; 507 - case CS8: 508 - default: 509 - newline.data_bits = 8; 510 - break; 511 - } 497 + newline.data_bits = tty_get_char_size(termios->c_cflag); 512 498 513 499 /* FIXME: needs to clear unsupported bits in the termios */ 514 500 gb_tty->clocal = ((termios->c_cflag & CLOCAL) != 0);
+1 -1
drivers/tty/Kconfig
··· 204 204 205 205 config MOXA_SMARTIO 206 206 tristate "Moxa SmartIO support v. 2.0" 207 - depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) 207 + depends on SERIAL_NONSTANDARD && PCI 208 208 help 209 209 Say Y here if you have a Moxa SmartIO multiport serial card and/or 210 210 want to help develop a new version of this driver.
-1
drivers/tty/Makefile
··· 9 9 obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o 10 10 obj-$(CONFIG_N_HDLC) += n_hdlc.o 11 11 obj-$(CONFIG_N_GSM) += n_gsm.o 12 - obj-$(CONFIG_R3964) += n_r3964.o 13 12 14 13 obj-y += vt/ 15 14 obj-$(CONFIG_HVC_DRIVER) += hvc/
+6 -6
drivers/tty/amiserial.c
··· 148 148 * ------------------------------------------------------------ 149 149 * rs_stop() and rs_start() 150 150 * 151 - * This routines are called before setting or resetting tty->stopped. 151 + * This routines are called before setting or resetting tty->flow.stopped. 152 152 * They enable or disable transmitter interrupts, as necessary. 153 153 * ------------------------------------------------------------ 154 154 */ ··· 309 309 return; 310 310 } 311 311 if (info->xmit.head == info->xmit.tail 312 - || info->tport.tty->stopped 312 + || info->tport.tty->flow.stopped 313 313 || info->tport.tty->hw_stopped) { 314 314 info->IER &= ~UART_IER_THRI; 315 315 custom.intena = IF_TBE; ··· 768 768 unsigned long flags; 769 769 770 770 if (info->xmit.head == info->xmit.tail 771 - || tty->stopped 771 + || tty->flow.stopped 772 772 || tty->hw_stopped 773 773 || !info->xmit.buf) 774 774 return; ··· 812 812 local_irq_restore(flags); 813 813 814 814 if (info->xmit.head != info->xmit.tail 815 - && !tty->stopped 815 + && !tty->flow.stopped 816 816 && !tty->hw_stopped 817 817 && !(info->IER & UART_IER_THRI)) { 818 818 info->IER |= UART_IER_THRI; ··· 827 827 return ret; 828 828 } 829 829 830 - static int rs_write_room(struct tty_struct *tty) 830 + static unsigned int rs_write_room(struct tty_struct *tty) 831 831 { 832 832 struct serial_state *info = tty->driver_data; 833 833 834 834 return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE); 835 835 } 836 836 837 - static int rs_chars_in_buffer(struct tty_struct *tty) 837 + static unsigned int rs_chars_in_buffer(struct tty_struct *tty) 838 838 { 839 839 struct serial_state *info = tty->driver_data; 840 840
+2 -2
drivers/tty/ehv_bytechan.c
··· 536 536 * how much write room the driver can guarantee will be sent OR BUFFERED. This 537 537 * driver MUST honor the return value. 538 538 */ 539 - static int ehv_bc_tty_write_room(struct tty_struct *ttys) 539 + static unsigned int ehv_bc_tty_write_room(struct tty_struct *ttys) 540 540 { 541 541 struct ehv_bc_data *bc = ttys->driver_data; 542 542 unsigned long flags; 543 - int count; 543 + unsigned int count; 544 544 545 545 spin_lock_irqsave(&bc->lock, flags); 546 546 count = CIRC_SPACE(bc->head, bc->tail, BUF_SIZE);
+2 -2
drivers/tty/goldfish.c
··· 193 193 return count; 194 194 } 195 195 196 - static int goldfish_tty_write_room(struct tty_struct *tty) 196 + static unsigned int goldfish_tty_write_room(struct tty_struct *tty) 197 197 { 198 198 return 0x10000; 199 199 } 200 200 201 - static int goldfish_tty_chars_in_buffer(struct tty_struct *tty) 201 + static unsigned int goldfish_tty_chars_in_buffer(struct tty_struct *tty) 202 202 { 203 203 struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; 204 204 void __iomem *base = qtty->base;
+4 -4
drivers/tty/hvc/hvc_console.c
··· 292 292 if (vtermnos[index] != -1) 293 293 return -1; 294 294 295 - /* make sure no no tty has been registered in this index */ 295 + /* make sure no tty has been registered in this index */ 296 296 hp = hvc_get_by_index(index); 297 297 if (hp) { 298 298 tty_port_put(&hp->port); ··· 586 586 * how much write room the driver can guarantee will be sent OR BUFFERED. This 587 587 * driver MUST honor the return value. 588 588 */ 589 - static int hvc_write_room(struct tty_struct *tty) 589 + static unsigned int hvc_write_room(struct tty_struct *tty) 590 590 { 591 591 struct hvc_struct *hp = tty->driver_data; 592 592 ··· 596 596 return hp->outbuf_size - hp->n_outbuf; 597 597 } 598 598 599 - static int hvc_chars_in_buffer(struct tty_struct *tty) 599 + static unsigned int hvc_chars_in_buffer(struct tty_struct *tty) 600 600 { 601 601 struct hvc_struct *hp = tty->driver_data; 602 602 ··· 620 620 /* 621 621 * Maximum number of bytes to get from the console driver if hvc_poll is 622 622 * called from driver (and can't sleep). Any more than this and we break 623 - * and start polling with khvcd. This value was derived from from an OpenBMC 623 + * and start polling with khvcd. This value was derived from an OpenBMC 624 624 * console with the OPAL driver that results in about 0.25ms interrupts off 625 625 * latency. 626 626 */
-2
drivers/tty/hvc/hvc_iucv.c
··· 438 438 struct hvc_iucv_private *priv; 439 439 440 440 priv = container_of(work, struct hvc_iucv_private, sndbuf_work.work); 441 - if (!priv) 442 - return; 443 441 444 442 spin_lock_bh(&priv->lock); 445 443 hvc_iucv_send(priv);
+2 -2
drivers/tty/hvc/hvcs.c
··· 1376 1376 * absolutely WILL BUFFER if we can't send it. This driver MUST honor the 1377 1377 * return value, hence the reason for hvcs_struct buffering. 1378 1378 */ 1379 - static int hvcs_write_room(struct tty_struct *tty) 1379 + static unsigned int hvcs_write_room(struct tty_struct *tty) 1380 1380 { 1381 1381 struct hvcs_struct *hvcsd = tty->driver_data; 1382 1382 ··· 1386 1386 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; 1387 1387 } 1388 1388 1389 - static int hvcs_chars_in_buffer(struct tty_struct *tty) 1389 + static unsigned int hvcs_chars_in_buffer(struct tty_struct *tty) 1390 1390 { 1391 1391 struct hvcs_struct *hvcsd = tty->driver_data; 1392 1392
+3 -3
drivers/tty/hvc/hvsi.c
··· 890 890 spin_unlock_irqrestore(&hp->lock, flags); 891 891 } 892 892 893 - static int hvsi_write_room(struct tty_struct *tty) 893 + static unsigned int hvsi_write_room(struct tty_struct *tty) 894 894 { 895 895 struct hvsi_struct *hp = tty->driver_data; 896 896 897 897 return N_OUTBUF - hp->n_outbuf; 898 898 } 899 899 900 - static int hvsi_chars_in_buffer(struct tty_struct *tty) 900 + static unsigned int hvsi_chars_in_buffer(struct tty_struct *tty) 901 901 { 902 902 struct hvsi_struct *hp = tty->driver_data; 903 903 ··· 929 929 * will see there is no room in outbuf and return. 930 930 */ 931 931 while ((count > 0) && (hvsi_write_room(tty) > 0)) { 932 - int chunksize = min(count, hvsi_write_room(tty)); 932 + int chunksize = min_t(int, count, hvsi_write_room(tty)); 933 933 934 934 BUG_ON(hp->n_outbuf < 0); 935 935 memcpy(hp->outbuf + hp->n_outbuf, source, chunksize);
+2 -4
drivers/tty/ipwireless/tty.c
··· 54 54 unsigned int control_lines; 55 55 struct mutex ipw_tty_mutex; 56 56 int tx_bytes_queued; 57 - int closing; 58 57 }; 59 58 60 59 static struct ipw_tty *ttys[IPWIRELESS_PCMCIA_MINORS]; ··· 227 228 return count; 228 229 } 229 230 230 - static int ipw_write_room(struct tty_struct *linux_tty) 231 + static unsigned int ipw_write_room(struct tty_struct *linux_tty) 231 232 { 232 233 struct ipw_tty *tty = linux_tty->driver_data; 233 234 int room; ··· 269 270 return 0; /* Keeps the PCMCIA scripts happy. */ 270 271 } 271 272 272 - static int ipw_chars_in_buffer(struct tty_struct *linux_tty) 273 + static unsigned int ipw_chars_in_buffer(struct tty_struct *linux_tty) 273 274 { 274 275 struct ipw_tty *tty = linux_tty->driver_data; 275 276 ··· 524 525 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 525 526 ": deregistering %s device ttyIPWp%d\n", 526 527 tty_type_name(ttyj->tty_type), j); 527 - ttyj->closing = 1; 528 528 if (ttyj->port.tty != NULL) { 529 529 mutex_unlock(&ttyj->ipw_tty_mutex); 530 530 tty_vhangup(ttyj->port.tty);
+4 -4
drivers/tty/mips_ejtag_fdc.c
··· 840 840 return total; 841 841 } 842 842 843 - static int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty) 843 + static unsigned int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty) 844 844 { 845 845 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; 846 846 struct mips_ejtag_fdc_tty *priv = dport->driver; 847 - int room; 847 + unsigned int room; 848 848 849 849 /* Report the space in the xmit buffer */ 850 850 spin_lock(&dport->xmit_lock); ··· 854 854 return room; 855 855 } 856 856 857 - static int mips_ejtag_fdc_tty_chars_in_buffer(struct tty_struct *tty) 857 + static unsigned int mips_ejtag_fdc_tty_chars_in_buffer(struct tty_struct *tty) 858 858 { 859 859 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; 860 - int chars; 860 + unsigned int chars; 861 861 862 862 /* Report the number of bytes in the xmit buffer */ 863 863 spin_lock(&dport->xmit_lock);
+11 -11
drivers/tty/moxa.c
··· 188 188 static int moxa_open(struct tty_struct *, struct file *); 189 189 static void moxa_close(struct tty_struct *, struct file *); 190 190 static int moxa_write(struct tty_struct *, const unsigned char *, int); 191 - static int moxa_write_room(struct tty_struct *); 191 + static unsigned int moxa_write_room(struct tty_struct *); 192 192 static void moxa_flush_buffer(struct tty_struct *); 193 - static int moxa_chars_in_buffer(struct tty_struct *); 193 + static unsigned int moxa_chars_in_buffer(struct tty_struct *); 194 194 static void moxa_set_termios(struct tty_struct *, struct ktermios *); 195 195 static void moxa_stop(struct tty_struct *); 196 196 static void moxa_start(struct tty_struct *); ··· 216 216 static void MoxaPortFlushData(struct moxa_port *, int); 217 217 static int MoxaPortWriteData(struct tty_struct *, const unsigned char *, int); 218 218 static int MoxaPortReadData(struct moxa_port *); 219 - static int MoxaPortTxQueue(struct moxa_port *); 219 + static unsigned int MoxaPortTxQueue(struct moxa_port *); 220 220 static int MoxaPortRxQueue(struct moxa_port *); 221 - static int MoxaPortTxFree(struct moxa_port *); 221 + static unsigned int MoxaPortTxFree(struct moxa_port *); 222 222 static void MoxaPortTxDisable(struct moxa_port *); 223 223 static void MoxaPortTxEnable(struct moxa_port *); 224 224 static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *); ··· 1217 1217 return len; 1218 1218 } 1219 1219 1220 - static int moxa_write_room(struct tty_struct *tty) 1220 + static unsigned int moxa_write_room(struct tty_struct *tty) 1221 1221 { 1222 1222 struct moxa_port *ch; 1223 1223 1224 - if (tty->stopped) 1224 + if (tty->flow.stopped) 1225 1225 return 0; 1226 1226 ch = tty->driver_data; 1227 1227 if (ch == NULL) ··· 1239 1239 tty_wakeup(tty); 1240 1240 } 1241 1241 1242 - static int moxa_chars_in_buffer(struct tty_struct *tty) 1242 + static unsigned int moxa_chars_in_buffer(struct tty_struct *tty) 1243 1243 { 1244 1244 struct moxa_port *ch = tty->driver_data; 1245 - int chars; 1245 + unsigned int chars; 1246 1246 1247 1247 chars = MoxaPortTxQueue(ch); 1248 1248 if (chars) ··· 1374 1374 clear_bit(EMPTYWAIT, &p->statusflags); 1375 1375 tty_wakeup(tty); 1376 1376 } 1377 - if (test_bit(LOWWAIT, &p->statusflags) && !tty->stopped && 1377 + if (test_bit(LOWWAIT, &p->statusflags) && !tty->flow.stopped && 1378 1378 MoxaPortTxQueue(p) <= WAKEUP_CHARS) { 1379 1379 clear_bit(LOWWAIT, &p->statusflags); 1380 1380 tty_wakeup(tty); ··· 1981 1981 } 1982 1982 1983 1983 1984 - static int MoxaPortTxQueue(struct moxa_port *port) 1984 + static unsigned int MoxaPortTxQueue(struct moxa_port *port) 1985 1985 { 1986 1986 void __iomem *ofsAddr = port->tableAddr; 1987 1987 u16 rptr, wptr, mask; ··· 1992 1992 return (wptr - rptr) & mask; 1993 1993 } 1994 1994 1995 - static int MoxaPortTxFree(struct moxa_port *port) 1995 + static unsigned int MoxaPortTxFree(struct moxa_port *port) 1996 1996 { 1997 1997 void __iomem *ofsAddr = port->tableAddr; 1998 1998 u16 rptr, wptr, mask;
+586 -1376
drivers/tty/mxser.c
··· 41 41 #include <asm/irq.h> 42 42 #include <linux/uaccess.h> 43 43 44 - #include "mxser.h" 44 + /* 45 + * Semi-public control interfaces 46 + */ 45 47 46 - #define MXSER_VERSION "2.0.5" /* 1.14 */ 48 + /* 49 + * MOXA ioctls 50 + */ 51 + 52 + #define MOXA 0x400 53 + #define MOXA_SET_OP_MODE (MOXA + 66) 54 + #define MOXA_GET_OP_MODE (MOXA + 67) 55 + 56 + #define RS232_MODE 0 57 + #define RS485_2WIRE_MODE 1 58 + #define RS422_MODE 2 59 + #define RS485_4WIRE_MODE 3 60 + #define OP_MODE_MASK 3 61 + 62 + /* --------------------------------------------------- */ 63 + 64 + /* 65 + * Follow just what Moxa Must chip defines. 66 + * 67 + * When LCR register (offset 0x03) is written the following value, the Must chip 68 + * will enter enhanced mode. And a write to EFR (offset 0x02) bit 6,7 will 69 + * change bank. 70 + */ 71 + #define MOXA_MUST_ENTER_ENHANCED 0xBF 72 + 73 + /* when enhanced mode is enabled, access to general bank register */ 74 + #define MOXA_MUST_GDL_REGISTER 0x07 75 + #define MOXA_MUST_GDL_MASK 0x7F 76 + #define MOXA_MUST_GDL_HAS_BAD_DATA 0x80 77 + 78 + #define MOXA_MUST_LSR_RERR 0x80 /* error in receive FIFO */ 79 + /* enhanced register bank select and enhanced mode setting register */ 80 + /* This works only when LCR register equals to 0xBF */ 81 + #define MOXA_MUST_EFR_REGISTER 0x02 82 + #define MOXA_MUST_EFR_EFRB_ENABLE 0x10 /* enhanced mode enable */ 83 + /* enhanced register bank set 0, 1, 2 */ 84 + #define MOXA_MUST_EFR_BANK0 0x00 85 + #define MOXA_MUST_EFR_BANK1 0x40 86 + #define MOXA_MUST_EFR_BANK2 0x80 87 + #define MOXA_MUST_EFR_BANK3 0xC0 88 + #define MOXA_MUST_EFR_BANK_MASK 0xC0 89 + 90 + /* set XON1 value register, when LCR=0xBF and change to bank0 */ 91 + #define MOXA_MUST_XON1_REGISTER 0x04 92 + 93 + /* set XON2 value register, when LCR=0xBF and change to bank0 */ 94 + #define MOXA_MUST_XON2_REGISTER 0x05 95 + 96 + /* set XOFF1 value register, when LCR=0xBF and change to bank0 */ 97 + #define MOXA_MUST_XOFF1_REGISTER 0x06 98 + 99 + /* set XOFF2 value register, when LCR=0xBF and change to bank0 */ 100 + #define MOXA_MUST_XOFF2_REGISTER 0x07 101 + 102 + #define MOXA_MUST_RBRTL_REGISTER 0x04 103 + #define MOXA_MUST_RBRTH_REGISTER 0x05 104 + #define MOXA_MUST_RBRTI_REGISTER 0x06 105 + #define MOXA_MUST_THRTL_REGISTER 0x07 106 + #define MOXA_MUST_ENUM_REGISTER 0x04 107 + #define MOXA_MUST_HWID_REGISTER 0x05 108 + #define MOXA_MUST_ECR_REGISTER 0x06 109 + #define MOXA_MUST_CSR_REGISTER 0x07 110 + 111 + #define MOXA_MUST_FCR_GDA_MODE_ENABLE 0x20 /* good data mode enable */ 112 + #define MOXA_MUST_FCR_GDA_ONLY_ENABLE 0x10 /* only good data put into RxFIFO */ 113 + 114 + #define MOXA_MUST_IER_ECTSI 0x80 /* enable CTS interrupt */ 115 + #define MOXA_MUST_IER_ERTSI 0x40 /* enable RTS interrupt */ 116 + #define MOXA_MUST_IER_XINT 0x20 /* enable Xon/Xoff interrupt */ 117 + #define MOXA_MUST_IER_EGDAI 0x10 /* enable GDA interrupt */ 118 + 119 + #define MOXA_MUST_RECV_ISR (UART_IER_RDI | MOXA_MUST_IER_EGDAI) 120 + 121 + /* GDA interrupt pending */ 122 + #define MOXA_MUST_IIR_GDA 0x1C 123 + #define MOXA_MUST_IIR_RDA 0x04 124 + #define MOXA_MUST_IIR_RTO 0x0C 125 + #define MOXA_MUST_IIR_LSR 0x06 126 + 127 + /* received Xon/Xoff or specical interrupt pending */ 128 + #define MOXA_MUST_IIR_XSC 0x10 129 + 130 + /* RTS/CTS change state interrupt pending */ 131 + #define MOXA_MUST_IIR_RTSCTS 0x20 132 + #define MOXA_MUST_IIR_MASK 0x3E 133 + 134 + #define MOXA_MUST_MCR_XON_FLAG 0x40 135 + #define MOXA_MUST_MCR_XON_ANY 0x80 136 + #define MOXA_MUST_MCR_TX_XON 0x08 137 + 138 + #define MOXA_MUST_EFR_SF_MASK 0x0F /* software flow control on chip mask value */ 139 + #define MOXA_MUST_EFR_SF_TX1 0x08 /* send Xon1/Xoff1 */ 140 + #define MOXA_MUST_EFR_SF_TX2 0x04 /* send Xon2/Xoff2 */ 141 + #define MOXA_MUST_EFR_SF_TX12 0x0C /* send Xon1,Xon2/Xoff1,Xoff2 */ 142 + #define MOXA_MUST_EFR_SF_TX_NO 0x00 /* don't send Xon/Xoff */ 143 + #define MOXA_MUST_EFR_SF_TX_MASK 0x0C /* Tx software flow control mask */ 144 + #define MOXA_MUST_EFR_SF_RX_NO 0x00 /* don't receive Xon/Xoff */ 145 + #define MOXA_MUST_EFR_SF_RX1 0x02 /* receive Xon1/Xoff1 */ 146 + #define MOXA_MUST_EFR_SF_RX2 0x01 /* receive Xon2/Xoff2 */ 147 + #define MOXA_MUST_EFR_SF_RX12 0x03 /* receive Xon1,Xon2/Xoff1,Xoff2 */ 148 + #define MOXA_MUST_EFR_SF_RX_MASK 0x03 /* Rx software flow control mask */ 149 + 47 150 #define MXSERMAJOR 174 48 151 49 152 #define MXSER_BOARDS 4 /* Max. boards */ ··· 154 51 #define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD) 155 52 #define MXSER_ISR_PASS_LIMIT 100 156 53 157 - /*CheckIsMoxaMust return value*/ 158 - #define MOXA_OTHER_UART 0x00 159 - #define MOXA_MUST_MU150_HWID 0x01 160 - #define MOXA_MUST_MU860_HWID 0x02 161 - 162 54 #define WAKEUP_CHARS 256 163 55 164 - #define UART_MCR_AFE 0x20 165 - #define UART_LSR_SPECIAL 0x1E 56 + #define MXSER_BAUD_BASE 921600 57 + #define MXSER_CUSTOM_DIVISOR (MXSER_BAUD_BASE * 16) 166 58 167 59 #define PCI_DEVICE_ID_POS104UL 0x1044 168 60 #define PCI_DEVICE_ID_CB108 0x1080 ··· 168 70 #define PCI_DEVICE_ID_CB134I 0x1341 169 71 #define PCI_DEVICE_ID_CP138U 0x1380 170 72 73 + #define MXSER_NPORTS(ddata) ((ddata) & 0xffU) 74 + #define MXSER_HIGHBAUD 0x0100 171 75 172 - #define C168_ASIC_ID 1 173 - #define C104_ASIC_ID 2 174 - #define C102_ASIC_ID 0xB 175 - #define CI132_ASIC_ID 4 176 - #define CI134_ASIC_ID 3 177 - #define CI104J_ASIC_ID 5 76 + enum mxser_must_hwid { 77 + MOXA_OTHER_UART = 0x00, 78 + MOXA_MUST_MU150_HWID = 0x01, 79 + MOXA_MUST_MU860_HWID = 0x02, 80 + }; 178 81 179 - #define MXSER_HIGHBAUD 1 180 - #define MXSER_HAS2 2 181 - 182 - /* This is only for PCI */ 183 82 static const struct { 184 - int type; 185 - int tx_fifo; 186 - int rx_fifo; 187 - int xmit_fifo_size; 188 - int rx_high_water; 189 - int rx_trigger; 190 - int rx_low_water; 191 - long max_baud; 83 + u8 type; 84 + u8 fifo_size; 85 + u8 rx_high_water; 86 + u8 rx_low_water; 87 + speed_t max_baud; 192 88 } Gpci_uart_info[] = { 193 - {MOXA_OTHER_UART, 16, 16, 16, 14, 14, 1, 921600L}, 194 - {MOXA_MUST_MU150_HWID, 64, 64, 64, 48, 48, 16, 230400L}, 195 - {MOXA_MUST_MU860_HWID, 128, 128, 128, 96, 96, 32, 921600L} 89 + { MOXA_OTHER_UART, 16, 14, 1, 921600 }, 90 + { MOXA_MUST_MU150_HWID, 64, 48, 16, 230400 }, 91 + { MOXA_MUST_MU860_HWID, 128, 96, 32, 921600 } 196 92 }; 197 93 #define UART_INFO_NUM ARRAY_SIZE(Gpci_uart_info) 198 94 199 - struct mxser_cardinfo { 200 - char *name; 201 - unsigned int nports; 202 - unsigned int flags; 203 - }; 204 - 205 - static const struct mxser_cardinfo mxser_cards[] = { 206 - /* 0*/ { "C168 series", 8, }, 207 - { "C104 series", 4, }, 208 - { "CI-104J series", 4, }, 209 - { "C168H/PCI series", 8, }, 210 - { "C104H/PCI series", 4, }, 211 - /* 5*/ { "C102 series", 4, MXSER_HAS2 }, /* C102-ISA */ 212 - { "CI-132 series", 4, MXSER_HAS2 }, 213 - { "CI-134 series", 4, }, 214 - { "CP-132 series", 2, }, 215 - { "CP-114 series", 4, }, 216 - /*10*/ { "CT-114 series", 4, }, 217 - { "CP-102 series", 2, MXSER_HIGHBAUD }, 218 - { "CP-104U series", 4, }, 219 - { "CP-168U series", 8, }, 220 - { "CP-132U series", 2, }, 221 - /*15*/ { "CP-134U series", 4, }, 222 - { "CP-104JU series", 4, }, 223 - { "Moxa UC7000 Serial", 8, }, /* RC7000 */ 224 - { "CP-118U series", 8, }, 225 - { "CP-102UL series", 2, }, 226 - /*20*/ { "CP-102U series", 2, }, 227 - { "CP-118EL series", 8, }, 228 - { "CP-168EL series", 8, }, 229 - { "CP-104EL series", 4, }, 230 - { "CB-108 series", 8, }, 231 - /*25*/ { "CB-114 series", 4, }, 232 - { "CB-134I series", 4, }, 233 - { "CP-138U series", 8, }, 234 - { "POS-104UL series", 4, }, 235 - { "CP-114UL series", 4, }, 236 - /*30*/ { "CP-102UF series", 2, }, 237 - { "CP-112UL series", 2, }, 238 - }; 239 95 240 96 /* driver_data correspond to the lines in the structure above 241 97 see also ISA probe function before you change something */ 242 98 static const struct pci_device_id mxser_pcibrds[] = { 243 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168), .driver_data = 3 }, 99 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168), .driver_data = 8 }, 244 100 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104), .driver_data = 4 }, 245 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132), .driver_data = 8 }, 246 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114), .driver_data = 9 }, 247 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114), .driver_data = 10 }, 248 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102), .driver_data = 11 }, 249 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U), .driver_data = 12 }, 250 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U), .driver_data = 13 }, 251 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U), .driver_data = 14 }, 252 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U), .driver_data = 15 }, 253 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 16 }, 254 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000), .driver_data = 17 }, 255 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U), .driver_data = 18 }, 256 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 19 }, 257 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U), .driver_data = 20 }, 258 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 21 }, 259 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 22 }, 260 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 23 }, 261 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108), .driver_data = 24 }, 262 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114), .driver_data = 25 }, 263 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I), .driver_data = 26 }, 264 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U), .driver_data = 27 }, 265 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL), .driver_data = 28 }, 266 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL), .driver_data = 29 }, 267 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF), .driver_data = 30 }, 268 - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL), .driver_data = 31 }, 101 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132), .driver_data = 2 }, 102 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114), .driver_data = 4 }, 103 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114), .driver_data = 4 }, 104 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102), .driver_data = 2 | MXSER_HIGHBAUD }, 105 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U), .driver_data = 4 }, 106 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U), .driver_data = 8 }, 107 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U), .driver_data = 2 }, 108 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U), .driver_data = 4 }, 109 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 4 }, 110 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000), .driver_data = 8 }, /* RC7000 */ 111 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U), .driver_data = 8 }, 112 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 2 }, 113 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U), .driver_data = 2 }, 114 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 8 }, 115 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 8 }, 116 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 4 }, 117 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB108), .driver_data = 8 }, 118 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB114), .driver_data = 4 }, 119 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CB134I), .driver_data = 4 }, 120 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U), .driver_data = 8 }, 121 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL), .driver_data = 4 }, 122 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL), .driver_data = 4 }, 123 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF), .driver_data = 2 }, 124 + { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL), .driver_data = 2 }, 269 125 { } 270 126 }; 271 127 MODULE_DEVICE_TABLE(pci, mxser_pcibrds); 272 128 273 - static unsigned long ioaddr[MXSER_BOARDS]; 274 129 static int ttymajor = MXSERMAJOR; 275 130 276 131 /* Variables for insmod */ 277 132 278 133 MODULE_AUTHOR("Casper Yang"); 279 134 MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver"); 280 - module_param_hw_array(ioaddr, ulong, ioport, NULL, 0); 281 - MODULE_PARM_DESC(ioaddr, "ISA io addresses to look for a moxa board"); 282 135 module_param(ttymajor, int, 0); 283 136 MODULE_LICENSE("GPL"); 284 - 285 - struct mxser_log { 286 - int tick; 287 - unsigned long rxcnt[MXSER_PORTS]; 288 - unsigned long txcnt[MXSER_PORTS]; 289 - }; 290 - 291 - struct mxser_mon { 292 - unsigned long rxcnt; 293 - unsigned long txcnt; 294 - unsigned long up_rxcnt; 295 - unsigned long up_txcnt; 296 - int modem_status; 297 - unsigned char hold_reason; 298 - }; 299 - 300 - struct mxser_mon_ext { 301 - unsigned long rx_cnt[32]; 302 - unsigned long tx_cnt[32]; 303 - unsigned long up_rxcnt[32]; 304 - unsigned long up_txcnt[32]; 305 - int modem_status[32]; 306 - 307 - long baudrate[32]; 308 - int databits[32]; 309 - int stopbits[32]; 310 - int parity[32]; 311 - int flowctrl[32]; 312 - int fifo[32]; 313 - int iftype[32]; 314 - }; 315 137 316 138 struct mxser_board; 317 139 ··· 241 223 242 224 unsigned long ioaddr; 243 225 unsigned long opmode_ioaddr; 244 - int max_baud; 245 226 246 - int rx_high_water; 247 - int rx_trigger; /* Rx fifo trigger level */ 248 - int rx_low_water; 249 - int baud_base; /* max. speed */ 227 + u8 rx_high_water; 228 + u8 rx_low_water; 250 229 int type; /* UART type */ 251 230 252 - int x_char; /* xon/xoff character */ 253 - int IER; /* Interrupt Enable Register */ 254 - int MCR; /* Modem control register */ 231 + unsigned char x_char; /* xon/xoff character */ 232 + u8 IER; /* Interrupt Enable Register */ 233 + u8 MCR; /* Modem control register */ 255 234 256 - unsigned char stop_rx; 257 235 unsigned char ldisc_stop_rx; 258 - 259 - int custom_divisor; 260 - unsigned char err_shadow; 261 236 262 237 struct async_icount icount; /* kernel counters for 4 input interrupts */ 263 238 unsigned int timeout; 264 239 265 - int read_status_mask; 266 - int ignore_status_mask; 267 - unsigned int xmit_fifo_size; 268 - int xmit_head; 269 - int xmit_tail; 270 - int xmit_cnt; 240 + u8 read_status_mask; 241 + u8 ignore_status_mask; 242 + u8 xmit_fifo_size; 243 + unsigned int xmit_head; 244 + unsigned int xmit_tail; 245 + unsigned int xmit_cnt; 271 246 int closing; 272 - 273 - struct ktermios normal_termios; 274 - 275 - struct mxser_mon mon_data; 276 247 277 248 spinlock_t slock; 278 249 }; 279 250 280 251 struct mxser_board { 281 252 unsigned int idx; 253 + unsigned short nports; 282 254 int irq; 283 - const struct mxser_cardinfo *info; 284 255 unsigned long vector; 285 - unsigned long vector_mask; 286 256 287 - int chip_flag; 288 - int uart_type; 257 + enum mxser_must_hwid must_hwid; 258 + speed_t max_baud; 289 259 290 - struct mxser_port ports[MXSER_PORTS_PER_BOARD]; 260 + struct mxser_port ports[]; 291 261 }; 292 262 293 - struct mxser_mstatus { 294 - tcflag_t cflag; 295 - int cts; 296 - int dsr; 297 - int ri; 298 - int dcd; 299 - }; 300 - 301 - static struct mxser_board mxser_boards[MXSER_BOARDS]; 263 + static DECLARE_BITMAP(mxser_boards, MXSER_BOARDS); 302 264 static struct tty_driver *mxvar_sdriver; 303 - static struct mxser_log mxvar_log; 304 - static int mxser_set_baud_method[MXSER_PORTS + 1]; 305 265 306 - static void mxser_enable_must_enchance_mode(unsigned long baseio) 266 + static u8 __mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set, 267 + bool restore_LCR) 307 268 { 308 - u8 oldlcr; 309 - u8 efr; 269 + u8 oldlcr, efr; 310 270 311 271 oldlcr = inb(baseio + UART_LCR); 312 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 272 + outb(MOXA_MUST_ENTER_ENHANCED, baseio + UART_LCR); 313 273 314 274 efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 315 - efr |= MOXA_MUST_EFR_EFRB_ENABLE; 275 + efr &= ~clear; 276 + efr |= set; 316 277 317 278 outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 318 - outb(oldlcr, baseio + UART_LCR); 279 + 280 + if (restore_LCR) 281 + outb(oldlcr, baseio + UART_LCR); 282 + 283 + return oldlcr; 319 284 } 320 285 321 - #ifdef CONFIG_PCI 322 - static void mxser_disable_must_enchance_mode(unsigned long baseio) 286 + static u8 mxser_must_select_bank(unsigned long baseio, u8 bank) 323 287 { 324 - u8 oldlcr; 325 - u8 efr; 326 - 327 - oldlcr = inb(baseio + UART_LCR); 328 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 329 - 330 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 331 - efr &= ~MOXA_MUST_EFR_EFRB_ENABLE; 332 - 333 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 334 - outb(oldlcr, baseio + UART_LCR); 288 + return __mxser_must_set_EFR(baseio, MOXA_MUST_EFR_BANK_MASK, bank, 289 + false); 335 290 } 336 - #endif 337 291 338 292 static void mxser_set_must_xon1_value(unsigned long baseio, u8 value) 339 293 { 340 - u8 oldlcr; 341 - u8 efr; 342 - 343 - oldlcr = inb(baseio + UART_LCR); 344 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 345 - 346 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 347 - efr &= ~MOXA_MUST_EFR_BANK_MASK; 348 - efr |= MOXA_MUST_EFR_BANK0; 349 - 350 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 294 + u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK0); 351 295 outb(value, baseio + MOXA_MUST_XON1_REGISTER); 352 296 outb(oldlcr, baseio + UART_LCR); 353 297 } 354 298 355 299 static void mxser_set_must_xoff1_value(unsigned long baseio, u8 value) 356 300 { 357 - u8 oldlcr; 358 - u8 efr; 359 - 360 - oldlcr = inb(baseio + UART_LCR); 361 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 362 - 363 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 364 - efr &= ~MOXA_MUST_EFR_BANK_MASK; 365 - efr |= MOXA_MUST_EFR_BANK0; 366 - 367 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 301 + u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK0); 368 302 outb(value, baseio + MOXA_MUST_XOFF1_REGISTER); 369 303 outb(oldlcr, baseio + UART_LCR); 370 304 } 371 305 372 306 static void mxser_set_must_fifo_value(struct mxser_port *info) 373 307 { 374 - u8 oldlcr; 375 - u8 efr; 376 - 377 - oldlcr = inb(info->ioaddr + UART_LCR); 378 - outb(MOXA_MUST_ENTER_ENCHANCE, info->ioaddr + UART_LCR); 379 - 380 - efr = inb(info->ioaddr + MOXA_MUST_EFR_REGISTER); 381 - efr &= ~MOXA_MUST_EFR_BANK_MASK; 382 - efr |= MOXA_MUST_EFR_BANK1; 383 - 384 - outb(efr, info->ioaddr + MOXA_MUST_EFR_REGISTER); 385 - outb((u8)info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTH_REGISTER); 386 - outb((u8)info->rx_trigger, info->ioaddr + MOXA_MUST_RBRTI_REGISTER); 387 - outb((u8)info->rx_low_water, info->ioaddr + MOXA_MUST_RBRTL_REGISTER); 308 + u8 oldlcr = mxser_must_select_bank(info->ioaddr, MOXA_MUST_EFR_BANK1); 309 + outb(info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTH_REGISTER); 310 + outb(info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTI_REGISTER); 311 + outb(info->rx_low_water, info->ioaddr + MOXA_MUST_RBRTL_REGISTER); 388 312 outb(oldlcr, info->ioaddr + UART_LCR); 389 313 } 390 314 391 315 static void mxser_set_must_enum_value(unsigned long baseio, u8 value) 392 316 { 393 - u8 oldlcr; 394 - u8 efr; 395 - 396 - oldlcr = inb(baseio + UART_LCR); 397 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 398 - 399 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 400 - efr &= ~MOXA_MUST_EFR_BANK_MASK; 401 - efr |= MOXA_MUST_EFR_BANK2; 402 - 403 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 317 + u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK2); 404 318 outb(value, baseio + MOXA_MUST_ENUM_REGISTER); 405 319 outb(oldlcr, baseio + UART_LCR); 406 320 } 407 321 408 - #ifdef CONFIG_PCI 409 - static void mxser_get_must_hardware_id(unsigned long baseio, u8 *pId) 322 + static u8 mxser_get_must_hardware_id(unsigned long baseio) 410 323 { 411 - u8 oldlcr; 412 - u8 efr; 413 - 414 - oldlcr = inb(baseio + UART_LCR); 415 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 416 - 417 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 418 - efr &= ~MOXA_MUST_EFR_BANK_MASK; 419 - efr |= MOXA_MUST_EFR_BANK2; 420 - 421 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 422 - *pId = inb(baseio + MOXA_MUST_HWID_REGISTER); 324 + u8 oldlcr = mxser_must_select_bank(baseio, MOXA_MUST_EFR_BANK2); 325 + u8 id = inb(baseio + MOXA_MUST_HWID_REGISTER); 423 326 outb(oldlcr, baseio + UART_LCR); 424 - } 425 - #endif 426 327 427 - static void SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(unsigned long baseio) 428 - { 429 - u8 oldlcr; 430 - u8 efr; 431 - 432 - oldlcr = inb(baseio + UART_LCR); 433 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 434 - 435 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 436 - efr &= ~MOXA_MUST_EFR_SF_MASK; 437 - 438 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 439 - outb(oldlcr, baseio + UART_LCR); 328 + return id; 440 329 } 441 330 442 - static void mxser_enable_must_tx_software_flow_control(unsigned long baseio) 331 + static void mxser_must_set_EFR(unsigned long baseio, u8 clear, u8 set) 443 332 { 444 - u8 oldlcr; 445 - u8 efr; 446 - 447 - oldlcr = inb(baseio + UART_LCR); 448 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 449 - 450 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 451 - efr &= ~MOXA_MUST_EFR_SF_TX_MASK; 452 - efr |= MOXA_MUST_EFR_SF_TX1; 453 - 454 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 455 - outb(oldlcr, baseio + UART_LCR); 333 + __mxser_must_set_EFR(baseio, clear, set, true); 456 334 } 457 335 458 - static void mxser_disable_must_tx_software_flow_control(unsigned long baseio) 336 + static void mxser_must_set_enhance_mode(unsigned long baseio, bool enable) 459 337 { 460 - u8 oldlcr; 461 - u8 efr; 462 - 463 - oldlcr = inb(baseio + UART_LCR); 464 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 465 - 466 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 467 - efr &= ~MOXA_MUST_EFR_SF_TX_MASK; 468 - 469 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 470 - outb(oldlcr, baseio + UART_LCR); 338 + mxser_must_set_EFR(baseio, 339 + enable ? 0 : MOXA_MUST_EFR_EFRB_ENABLE, 340 + enable ? MOXA_MUST_EFR_EFRB_ENABLE : 0); 471 341 } 472 342 473 - static void mxser_enable_must_rx_software_flow_control(unsigned long baseio) 343 + static void mxser_must_no_sw_flow_control(unsigned long baseio) 474 344 { 475 - u8 oldlcr; 476 - u8 efr; 477 - 478 - oldlcr = inb(baseio + UART_LCR); 479 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 480 - 481 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 482 - efr &= ~MOXA_MUST_EFR_SF_RX_MASK; 483 - efr |= MOXA_MUST_EFR_SF_RX1; 484 - 485 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 486 - outb(oldlcr, baseio + UART_LCR); 345 + mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_MASK, 0); 487 346 } 488 347 489 - static void mxser_disable_must_rx_software_flow_control(unsigned long baseio) 348 + static void mxser_must_set_tx_sw_flow_control(unsigned long baseio, bool enable) 490 349 { 491 - u8 oldlcr; 492 - u8 efr; 493 - 494 - oldlcr = inb(baseio + UART_LCR); 495 - outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR); 496 - 497 - efr = inb(baseio + MOXA_MUST_EFR_REGISTER); 498 - efr &= ~MOXA_MUST_EFR_SF_RX_MASK; 499 - 500 - outb(efr, baseio + MOXA_MUST_EFR_REGISTER); 501 - outb(oldlcr, baseio + UART_LCR); 350 + mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_TX_MASK, 351 + enable ? MOXA_MUST_EFR_SF_TX1 : 0); 502 352 } 503 353 504 - #ifdef CONFIG_PCI 505 - static int CheckIsMoxaMust(unsigned long io) 354 + static void mxser_must_set_rx_sw_flow_control(unsigned long baseio, bool enable) 355 + { 356 + mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_RX_MASK, 357 + enable ? MOXA_MUST_EFR_SF_RX1 : 0); 358 + } 359 + 360 + static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io) 506 361 { 507 362 u8 oldmcr, hwid; 508 363 int i; 509 364 510 365 outb(0, io + UART_LCR); 511 - mxser_disable_must_enchance_mode(io); 366 + mxser_must_set_enhance_mode(io, false); 512 367 oldmcr = inb(io + UART_MCR); 513 368 outb(0, io + UART_MCR); 514 369 mxser_set_must_xon1_value(io, 0x11); ··· 390 499 return MOXA_OTHER_UART; 391 500 } 392 501 393 - mxser_get_must_hardware_id(io, &hwid); 394 - for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */ 502 + hwid = mxser_get_must_hardware_id(io); 503 + for (i = 1; i < UART_INFO_NUM; i++) /* 0 = OTHER_UART */ 395 504 if (hwid == Gpci_uart_info[i].type) 396 - return (int)hwid; 397 - } 505 + return hwid; 506 + 398 507 return MOXA_OTHER_UART; 399 508 } 400 - #endif 401 509 402 - static void process_txrx_fifo(struct mxser_port *info) 510 + static bool mxser_16550A_or_MUST(struct mxser_port *info) 403 511 { 404 - int i; 512 + return info->type == PORT_16550A || info->board->must_hwid; 513 + } 405 514 406 - if ((info->type == PORT_16450) || (info->type == PORT_8250)) { 407 - info->rx_trigger = 1; 515 + static void mxser_process_txrx_fifo(struct mxser_port *info) 516 + { 517 + unsigned int i; 518 + 519 + if (info->type == PORT_16450 || info->type == PORT_8250) { 408 520 info->rx_high_water = 1; 409 521 info->rx_low_water = 1; 410 522 info->xmit_fifo_size = 1; 411 - } else 412 - for (i = 0; i < UART_INFO_NUM; i++) 413 - if (info->board->chip_flag == Gpci_uart_info[i].type) { 414 - info->rx_trigger = Gpci_uart_info[i].rx_trigger; 415 - info->rx_low_water = Gpci_uart_info[i].rx_low_water; 416 - info->rx_high_water = Gpci_uart_info[i].rx_high_water; 417 - info->xmit_fifo_size = Gpci_uart_info[i].xmit_fifo_size; 418 - break; 419 - } 523 + return; 524 + } 525 + 526 + for (i = 0; i < UART_INFO_NUM; i++) 527 + if (info->board->must_hwid == Gpci_uart_info[i].type) { 528 + info->rx_low_water = Gpci_uart_info[i].rx_low_water; 529 + info->rx_high_water = Gpci_uart_info[i].rx_high_water; 530 + info->xmit_fifo_size = Gpci_uart_info[i].fifo_size; 531 + break; 532 + } 420 533 } 421 534 422 - static unsigned char mxser_get_msr(int baseaddr, int mode, int port) 535 + static void __mxser_start_tx(struct mxser_port *info) 423 536 { 424 - static unsigned char mxser_msr[MXSER_PORTS + 1]; 425 - unsigned char status = 0; 537 + outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER); 538 + info->IER |= UART_IER_THRI; 539 + outb(info->IER, info->ioaddr + UART_IER); 540 + } 426 541 427 - status = inb(baseaddr + UART_MSR); 542 + static void mxser_start_tx(struct mxser_port *info) 543 + { 544 + unsigned long flags; 428 545 429 - mxser_msr[port] &= 0x0F; 430 - mxser_msr[port] |= status; 431 - status = mxser_msr[port]; 432 - if (mode) 433 - mxser_msr[port] = 0; 546 + spin_lock_irqsave(&info->slock, flags); 547 + __mxser_start_tx(info); 548 + spin_unlock_irqrestore(&info->slock, flags); 549 + } 434 550 435 - return status; 551 + static void __mxser_stop_tx(struct mxser_port *info) 552 + { 553 + info->IER &= ~UART_IER_THRI; 554 + outb(info->IER, info->ioaddr + UART_IER); 436 555 } 437 556 438 557 static int mxser_carrier_raised(struct tty_port *port) ··· 455 554 { 456 555 struct mxser_port *mp = container_of(port, struct mxser_port, port); 457 556 unsigned long flags; 557 + u8 mcr; 458 558 459 559 spin_lock_irqsave(&mp->slock, flags); 560 + mcr = inb(mp->ioaddr + UART_MCR); 460 561 if (on) 461 - outb(inb(mp->ioaddr + UART_MCR) | 462 - UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR); 562 + mcr |= UART_MCR_DTR | UART_MCR_RTS; 463 563 else 464 - outb(inb(mp->ioaddr + UART_MCR)&~(UART_MCR_DTR | UART_MCR_RTS), 465 - mp->ioaddr + UART_MCR); 564 + mcr &= ~(UART_MCR_DTR | UART_MCR_RTS); 565 + outb(mcr, mp->ioaddr + UART_MCR); 466 566 spin_unlock_irqrestore(&mp->slock, flags); 467 567 } 468 568 469 - static int mxser_set_baud(struct tty_struct *tty, long newspd) 569 + static int mxser_set_baud(struct tty_struct *tty, speed_t newspd) 470 570 { 471 571 struct mxser_port *info = tty->driver_data; 472 572 unsigned int quot = 0, baud; 473 573 unsigned char cval; 474 574 u64 timeout; 475 575 476 - if (!info->ioaddr) 477 - return -1; 478 - 479 - if (newspd > info->max_baud) 576 + if (newspd > info->board->max_baud) 480 577 return -1; 481 578 482 579 if (newspd == 134) { 483 - quot = 2 * info->baud_base / 269; 580 + quot = 2 * MXSER_BAUD_BASE / 269; 484 581 tty_encode_baud_rate(tty, 134, 134); 485 582 } else if (newspd) { 486 - quot = info->baud_base / newspd; 583 + quot = MXSER_BAUD_BASE / newspd; 487 584 if (quot == 0) 488 585 quot = 1; 489 - baud = info->baud_base/quot; 586 + baud = MXSER_BAUD_BASE / quot; 490 587 tty_encode_baud_rate(tty, baud, baud); 491 588 } else { 492 589 quot = 0; ··· 495 596 * u64 domain 496 597 */ 497 598 timeout = (u64)info->xmit_fifo_size * HZ * 10 * quot; 498 - do_div(timeout, info->baud_base); 599 + do_div(timeout, MXSER_BAUD_BASE); 499 600 info->timeout = timeout + HZ / 50; /* Add .02 seconds of slop */ 500 601 501 602 if (quot) { ··· 517 618 518 619 #ifdef BOTHER 519 620 if (C_BAUD(tty) == BOTHER) { 520 - quot = info->baud_base % newspd; 621 + quot = MXSER_BAUD_BASE % newspd; 521 622 quot *= 8; 522 623 if (quot % newspd > newspd / 2) { 523 624 quot /= newspd; ··· 533 634 return 0; 534 635 } 535 636 637 + static void mxser_handle_cts(struct tty_struct *tty, struct mxser_port *info, 638 + u8 msr) 639 + { 640 + bool cts = msr & UART_MSR_CTS; 641 + 642 + if (tty->hw_stopped) { 643 + if (cts) { 644 + tty->hw_stopped = 0; 645 + 646 + if (!mxser_16550A_or_MUST(info)) 647 + __mxser_start_tx(info); 648 + tty_wakeup(tty); 649 + } 650 + return; 651 + } else if (cts) 652 + return; 653 + 654 + tty->hw_stopped = 1; 655 + if (!mxser_16550A_or_MUST(info)) 656 + __mxser_stop_tx(info); 657 + } 658 + 536 659 /* 537 660 * This routine is called to set the UART divisor registers to match 538 661 * the specified baud rate for a serial port. ··· 563 642 { 564 643 struct mxser_port *info = tty->driver_data; 565 644 unsigned cflag, cval, fcr; 566 - unsigned char status; 567 645 568 646 cflag = tty->termios.c_cflag; 569 - if (!info->ioaddr) 570 - return; 571 647 572 - if (mxser_set_baud_method[tty->index] == 0) 573 - mxser_set_baud(tty, tty_get_baud_rate(tty)); 648 + mxser_set_baud(tty, tty_get_baud_rate(tty)); 574 649 575 650 /* byte size and parity */ 576 651 switch (cflag & CSIZE) { 652 + default: 577 653 case CS5: 578 - cval = 0x00; 654 + cval = UART_LCR_WLEN5; 579 655 break; 580 656 case CS6: 581 - cval = 0x01; 657 + cval = UART_LCR_WLEN6; 582 658 break; 583 659 case CS7: 584 - cval = 0x02; 660 + cval = UART_LCR_WLEN7; 585 661 break; 586 662 case CS8: 587 - cval = 0x03; 663 + cval = UART_LCR_WLEN8; 588 664 break; 589 - default: 590 - cval = 0x00; 591 - break; /* too keep GCC shut... */ 592 665 } 666 + 593 667 if (cflag & CSTOPB) 594 - cval |= 0x04; 668 + cval |= UART_LCR_STOP; 595 669 if (cflag & PARENB) 596 670 cval |= UART_LCR_PARITY; 597 671 if (!(cflag & PARODD)) ··· 595 679 cval |= UART_LCR_SPAR; 596 680 597 681 if ((info->type == PORT_8250) || (info->type == PORT_16450)) { 598 - if (info->board->chip_flag) { 682 + if (info->board->must_hwid) { 599 683 fcr = UART_FCR_ENABLE_FIFO; 600 684 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 601 685 mxser_set_must_fifo_value(info); ··· 603 687 fcr = 0; 604 688 } else { 605 689 fcr = UART_FCR_ENABLE_FIFO; 606 - if (info->board->chip_flag) { 690 + if (info->board->must_hwid) { 607 691 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 608 692 mxser_set_must_fifo_value(info); 609 693 } else { 610 - switch (info->rx_trigger) { 694 + switch (info->rx_high_water) { 611 695 case 1: 612 696 fcr |= UART_FCR_TRIGGER_1; 613 697 break; ··· 630 714 tty_port_set_cts_flow(&info->port, cflag & CRTSCTS); 631 715 if (cflag & CRTSCTS) { 632 716 info->IER |= UART_IER_MSI; 633 - if ((info->type == PORT_16550A) || (info->board->chip_flag)) { 717 + if (mxser_16550A_or_MUST(info)) { 634 718 info->MCR |= UART_MCR_AFE; 635 719 } else { 636 - status = inb(info->ioaddr + UART_MSR); 637 - if (tty->hw_stopped) { 638 - if (status & UART_MSR_CTS) { 639 - tty->hw_stopped = 0; 640 - if (info->type != PORT_16550A && 641 - !info->board->chip_flag) { 642 - outb(info->IER & ~UART_IER_THRI, 643 - info->ioaddr + 644 - UART_IER); 645 - info->IER |= UART_IER_THRI; 646 - outb(info->IER, info->ioaddr + 647 - UART_IER); 648 - } 649 - tty_wakeup(tty); 650 - } 651 - } else { 652 - if (!(status & UART_MSR_CTS)) { 653 - tty->hw_stopped = 1; 654 - if ((info->type != PORT_16550A) && 655 - (!info->board->chip_flag)) { 656 - info->IER &= ~UART_IER_THRI; 657 - outb(info->IER, info->ioaddr + 658 - UART_IER); 659 - } 660 - } 661 - } 720 + mxser_handle_cts(tty, info, 721 + inb(info->ioaddr + UART_MSR)); 662 722 } 663 723 } 664 724 outb(info->MCR, info->ioaddr + UART_MCR); ··· 672 780 UART_LSR_FE; 673 781 } 674 782 } 675 - if (info->board->chip_flag) { 783 + if (info->board->must_hwid) { 676 784 mxser_set_must_xon1_value(info->ioaddr, START_CHAR(tty)); 677 785 mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(tty)); 678 - if (I_IXON(tty)) { 679 - mxser_enable_must_rx_software_flow_control( 680 - info->ioaddr); 681 - } else { 682 - mxser_disable_must_rx_software_flow_control( 683 - info->ioaddr); 684 - } 685 - if (I_IXOFF(tty)) { 686 - mxser_enable_must_tx_software_flow_control( 687 - info->ioaddr); 688 - } else { 689 - mxser_disable_must_tx_software_flow_control( 690 - info->ioaddr); 691 - } 786 + mxser_must_set_rx_sw_flow_control(info->ioaddr, I_IXON(tty)); 787 + mxser_must_set_tx_sw_flow_control(info->ioaddr, I_IXOFF(tty)); 692 788 } 693 789 694 790 ··· 696 816 port->icount.dcd++; 697 817 if (status & UART_MSR_DCTS) 698 818 port->icount.cts++; 699 - port->mon_data.modem_status = status; 700 819 wake_up_interruptible(&port->port.delta_msr_wait); 701 820 702 821 if (tty_port_check_carrier(&port->port) && (status & UART_MSR_DDCD)) { ··· 703 824 wake_up_interruptible(&port->port.open_wait); 704 825 } 705 826 706 - if (tty_port_cts_enabled(&port->port)) { 707 - if (tty->hw_stopped) { 708 - if (status & UART_MSR_CTS) { 709 - tty->hw_stopped = 0; 710 - 711 - if ((port->type != PORT_16550A) && 712 - (!port->board->chip_flag)) { 713 - outb(port->IER & ~UART_IER_THRI, 714 - port->ioaddr + UART_IER); 715 - port->IER |= UART_IER_THRI; 716 - outb(port->IER, port->ioaddr + 717 - UART_IER); 718 - } 719 - tty_wakeup(tty); 720 - } 721 - } else { 722 - if (!(status & UART_MSR_CTS)) { 723 - tty->hw_stopped = 1; 724 - if (port->type != PORT_16550A && 725 - !port->board->chip_flag) { 726 - port->IER &= ~UART_IER_THRI; 727 - outb(port->IER, port->ioaddr + 728 - UART_IER); 729 - } 730 - } 731 - } 732 - } 827 + if (tty_port_cts_enabled(&port->port)) 828 + mxser_handle_cts(tty, port, status); 733 829 } 734 830 735 831 static int mxser_activate(struct tty_port *port, struct tty_struct *tty) ··· 719 865 720 866 spin_lock_irqsave(&info->slock, flags); 721 867 722 - if (!info->ioaddr || !info->type) { 868 + if (!info->type) { 723 869 set_bit(TTY_IO_ERROR, &tty->flags); 724 870 free_page(page); 725 871 spin_unlock_irqrestore(&info->slock, flags); ··· 731 877 * Clear the FIFO buffers and disable them 732 878 * (they will be reenabled in mxser_change_speed()) 733 879 */ 734 - if (info->board->chip_flag) 880 + if (info->board->must_hwid) 735 881 outb((UART_FCR_CLEAR_RCVR | 736 882 UART_FCR_CLEAR_XMIT | 737 883 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->ioaddr + UART_FCR); ··· 773 919 */ 774 920 info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; 775 921 776 - if (info->board->chip_flag) 922 + if (info->board->must_hwid) 777 923 info->IER |= MOXA_MUST_IER_EGDAI; 778 924 outb(info->IER, info->ioaddr + UART_IER); /* enable interrupts */ 779 925 ··· 825 971 outb(0x00, info->ioaddr + UART_IER); 826 972 827 973 /* clear Rx/Tx FIFO's */ 828 - if (info->board->chip_flag) 974 + if (info->board->must_hwid) 829 975 outb(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | 830 976 MOXA_MUST_FCR_GDA_MODE_ENABLE, 831 977 info->ioaddr + UART_FCR); ··· 837 983 (void) inb(info->ioaddr + UART_RX); 838 984 839 985 840 - if (info->board->chip_flag) 841 - SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr); 986 + if (info->board->must_hwid) 987 + mxser_must_no_sw_flow_control(info->ioaddr); 842 988 843 989 spin_unlock_irqrestore(&info->slock, flags); 844 990 } ··· 851 997 */ 852 998 static int mxser_open(struct tty_struct *tty, struct file *filp) 853 999 { 854 - struct mxser_port *info; 855 - int line; 1000 + struct tty_port *tport = tty->port; 1001 + struct mxser_port *port = container_of(tport, struct mxser_port, port); 856 1002 857 - line = tty->index; 858 - if (line == MXSER_PORTS) 859 - return 0; 860 - info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD]; 861 - if (!info->ioaddr) 862 - return -ENODEV; 1003 + tty->driver_data = port; 863 1004 864 - tty->driver_data = info; 865 - return tty_port_open(&info->port, tty, filp); 1005 + return tty_port_open(tport, tty, filp); 866 1006 } 867 1007 868 1008 static void mxser_flush_buffer(struct tty_struct *tty) ··· 891 1043 * line status register. 892 1044 */ 893 1045 info->IER &= ~UART_IER_RLSI; 894 - if (info->board->chip_flag) 1046 + if (info->board->must_hwid) 895 1047 info->IER &= ~MOXA_MUST_RECV_ISR; 896 1048 897 1049 outb(info->IER, info->ioaddr + UART_IER); ··· 919 1071 struct mxser_port *info = tty->driver_data; 920 1072 struct tty_port *port = &info->port; 921 1073 922 - if (tty->index == MXSER_PORTS || info == NULL) 1074 + if (info == NULL) 923 1075 return; 924 1076 if (tty_port_close_start(port, tty, filp) == 0) 925 1077 return; ··· 966 1118 total += c; 967 1119 } 968 1120 969 - if (info->xmit_cnt && !tty->stopped) { 970 - if (!tty->hw_stopped || 971 - (info->type == PORT_16550A) || 972 - (info->board->chip_flag)) { 973 - spin_lock_irqsave(&info->slock, flags); 974 - outb(info->IER & ~UART_IER_THRI, info->ioaddr + 975 - UART_IER); 976 - info->IER |= UART_IER_THRI; 977 - outb(info->IER, info->ioaddr + UART_IER); 978 - spin_unlock_irqrestore(&info->slock, flags); 979 - } 980 - } 1121 + if (info->xmit_cnt && !tty->flow.stopped) 1122 + if (!tty->hw_stopped || mxser_16550A_or_MUST(info)) 1123 + mxser_start_tx(info); 1124 + 981 1125 return total; 982 1126 } 983 1127 ··· 989 1149 info->xmit_head &= SERIAL_XMIT_SIZE - 1; 990 1150 info->xmit_cnt++; 991 1151 spin_unlock_irqrestore(&info->slock, flags); 992 - if (!tty->stopped) { 993 - if (!tty->hw_stopped || 994 - (info->type == PORT_16550A) || 995 - info->board->chip_flag) { 996 - spin_lock_irqsave(&info->slock, flags); 997 - outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER); 998 - info->IER |= UART_IER_THRI; 999 - outb(info->IER, info->ioaddr + UART_IER); 1000 - spin_unlock_irqrestore(&info->slock, flags); 1001 - } 1002 - } 1152 + 1003 1153 return 1; 1004 1154 } 1005 1155 ··· 997 1167 static void mxser_flush_chars(struct tty_struct *tty) 998 1168 { 999 1169 struct mxser_port *info = tty->driver_data; 1000 - unsigned long flags; 1001 1170 1002 - if (info->xmit_cnt <= 0 || tty->stopped || !info->port.xmit_buf || 1003 - (tty->hw_stopped && info->type != PORT_16550A && 1004 - !info->board->chip_flag)) 1171 + if (!info->xmit_cnt || tty->flow.stopped || !info->port.xmit_buf || 1172 + (tty->hw_stopped && !mxser_16550A_or_MUST(info))) 1005 1173 return; 1006 1174 1007 - spin_lock_irqsave(&info->slock, flags); 1008 - 1009 - outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER); 1010 - info->IER |= UART_IER_THRI; 1011 - outb(info->IER, info->ioaddr + UART_IER); 1012 - 1013 - spin_unlock_irqrestore(&info->slock, flags); 1175 + mxser_start_tx(info); 1014 1176 } 1015 1177 1016 - static int mxser_write_room(struct tty_struct *tty) 1178 + static unsigned int mxser_write_room(struct tty_struct *tty) 1017 1179 { 1018 1180 struct mxser_port *info = tty->driver_data; 1019 1181 int ret; ··· 1014 1192 return ret < 0 ? 0 : ret; 1015 1193 } 1016 1194 1017 - static int mxser_chars_in_buffer(struct tty_struct *tty) 1195 + static unsigned int mxser_chars_in_buffer(struct tty_struct *tty) 1018 1196 { 1019 1197 struct mxser_port *info = tty->driver_data; 1020 1198 return info->xmit_cnt; ··· 1032 1210 struct tty_port *port = &info->port; 1033 1211 unsigned int closing_wait, close_delay; 1034 1212 1035 - if (tty->index == MXSER_PORTS) 1036 - return -ENOTTY; 1037 - 1038 1213 mutex_lock(&port->mutex); 1039 1214 1040 1215 close_delay = jiffies_to_msecs(info->port.close_delay) / 10; ··· 1044 1225 ss->port = info->ioaddr, 1045 1226 ss->irq = info->board->irq, 1046 1227 ss->flags = info->port.flags, 1047 - ss->baud_base = info->baud_base, 1228 + ss->baud_base = MXSER_BAUD_BASE, 1048 1229 ss->close_delay = close_delay; 1049 1230 ss->closing_wait = closing_wait; 1050 - ss->custom_divisor = info->custom_divisor, 1231 + ss->custom_divisor = MXSER_CUSTOM_DIVISOR, 1051 1232 mutex_unlock(&port->mutex); 1052 1233 return 0; 1053 1234 } ··· 1059 1240 struct tty_port *port = &info->port; 1060 1241 speed_t baud; 1061 1242 unsigned long sl_flags; 1062 - unsigned int flags, close_delay, closing_wait; 1243 + unsigned int old_speed, close_delay, closing_wait; 1063 1244 int retval = 0; 1064 1245 1065 - if (tty->index == MXSER_PORTS) 1066 - return -ENOTTY; 1067 1246 if (tty_io_error(tty)) 1068 1247 return -EIO; 1069 1248 1070 1249 mutex_lock(&port->mutex); 1071 - if (!info->ioaddr) { 1072 - mutex_unlock(&port->mutex); 1073 - return -ENODEV; 1074 - } 1075 1250 1076 1251 if (ss->irq != info->board->irq || 1077 1252 ss->port != info->ioaddr) { ··· 1073 1260 return -EINVAL; 1074 1261 } 1075 1262 1076 - flags = port->flags & ASYNC_SPD_MASK; 1263 + old_speed = port->flags & ASYNC_SPD_MASK; 1077 1264 1078 1265 close_delay = msecs_to_jiffies(ss->close_delay * 10); 1079 1266 closing_wait = ss->closing_wait; ··· 1081 1268 closing_wait = msecs_to_jiffies(closing_wait * 10); 1082 1269 1083 1270 if (!capable(CAP_SYS_ADMIN)) { 1084 - if ((ss->baud_base != info->baud_base) || 1085 - (close_delay != info->port.close_delay) || 1086 - (closing_wait != info->port.closing_wait) || 1087 - ((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) { 1271 + if ((ss->baud_base != MXSER_BAUD_BASE) || 1272 + (close_delay != port->close_delay) || 1273 + (closing_wait != port->closing_wait) || 1274 + ((ss->flags & ~ASYNC_USR_MASK) != (port->flags & ~ASYNC_USR_MASK))) { 1088 1275 mutex_unlock(&port->mutex); 1089 1276 return -EPERM; 1090 1277 } 1091 - info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) | 1092 - (ss->flags & ASYNC_USR_MASK)); 1278 + port->flags = (port->flags & ~ASYNC_USR_MASK) | 1279 + (ss->flags & ASYNC_USR_MASK); 1093 1280 } else { 1094 1281 /* 1095 1282 * OK, past this point, all the error checking has been done. ··· 1100 1287 port->close_delay = close_delay; 1101 1288 port->closing_wait = closing_wait; 1102 1289 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && 1103 - (ss->baud_base != info->baud_base || 1290 + (ss->baud_base != MXSER_BAUD_BASE || 1104 1291 ss->custom_divisor != 1105 - info->custom_divisor)) { 1292 + MXSER_CUSTOM_DIVISOR)) { 1106 1293 if (ss->custom_divisor == 0) { 1107 1294 mutex_unlock(&port->mutex); 1108 1295 return -EINVAL; ··· 1113 1300 1114 1301 info->type = ss->type; 1115 1302 1116 - process_txrx_fifo(info); 1303 + mxser_process_txrx_fifo(info); 1117 1304 } 1118 1305 1119 1306 if (tty_port_initialized(port)) { 1120 - if (flags != (port->flags & ASYNC_SPD_MASK)) { 1307 + if (old_speed != (port->flags & ASYNC_SPD_MASK)) { 1121 1308 spin_lock_irqsave(&info->slock, sl_flags); 1122 1309 mxser_change_speed(tty); 1123 1310 spin_unlock_irqrestore(&info->slock, sl_flags); ··· 1161 1348 unsigned char control, status; 1162 1349 unsigned long flags; 1163 1350 1164 - 1165 - if (tty->index == MXSER_PORTS) 1166 - return -ENOIOCTLCMD; 1167 1351 if (tty_io_error(tty)) 1168 1352 return -EIO; 1169 1353 1170 - control = info->MCR; 1171 - 1172 1354 spin_lock_irqsave(&info->slock, flags); 1355 + control = info->MCR; 1173 1356 status = inb(info->ioaddr + UART_MSR); 1174 1357 if (status & UART_MSR_ANY_DELTA) 1175 1358 mxser_check_modem_status(tty, info, status); 1176 1359 spin_unlock_irqrestore(&info->slock, flags); 1360 + 1177 1361 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) | 1178 1362 ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | 1179 1363 ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) | ··· 1185 1375 struct mxser_port *info = tty->driver_data; 1186 1376 unsigned long flags; 1187 1377 1188 - 1189 - if (tty->index == MXSER_PORTS) 1190 - return -ENOIOCTLCMD; 1191 1378 if (tty_io_error(tty)) 1192 1379 return -EIO; 1193 1380 ··· 1202 1395 1203 1396 outb(info->MCR, info->ioaddr + UART_MCR); 1204 1397 spin_unlock_irqrestore(&info->slock, flags); 1205 - return 0; 1206 - } 1207 - 1208 - static int __init mxser_program_mode(int port) 1209 - { 1210 - int id, i, j, n; 1211 - 1212 - outb(0, port); 1213 - outb(0, port); 1214 - outb(0, port); 1215 - (void)inb(port); 1216 - (void)inb(port); 1217 - outb(0, port); 1218 - (void)inb(port); 1219 - 1220 - id = inb(port + 1) & 0x1F; 1221 - if ((id != C168_ASIC_ID) && 1222 - (id != C104_ASIC_ID) && 1223 - (id != C102_ASIC_ID) && 1224 - (id != CI132_ASIC_ID) && 1225 - (id != CI134_ASIC_ID) && 1226 - (id != CI104J_ASIC_ID)) 1227 - return -1; 1228 - for (i = 0, j = 0; i < 4; i++) { 1229 - n = inb(port + 2); 1230 - if (n == 'M') { 1231 - j = 1; 1232 - } else if ((j == 1) && (n == 1)) { 1233 - j = 2; 1234 - break; 1235 - } else 1236 - j = 0; 1237 - } 1238 - if (j != 2) 1239 - id = -2; 1240 - return id; 1241 - } 1242 - 1243 - static void __init mxser_normal_mode(int port) 1244 - { 1245 - int i, n; 1246 - 1247 - outb(0xA5, port + 1); 1248 - outb(0x80, port + 3); 1249 - outb(12, port + 0); /* 9600 bps */ 1250 - outb(0, port + 1); 1251 - outb(0x03, port + 3); /* 8 data bits */ 1252 - outb(0x13, port + 4); /* loop back mode */ 1253 - for (i = 0; i < 16; i++) { 1254 - n = inb(port + 5); 1255 - if ((n & 0x61) == 0x60) 1256 - break; 1257 - if ((n & 1) == 1) 1258 - (void)inb(port); 1259 - } 1260 - outb(0x00, port + 4); 1261 - } 1262 - 1263 - #define CHIP_SK 0x01 /* Serial Data Clock in Eprom */ 1264 - #define CHIP_DO 0x02 /* Serial Data Output in Eprom */ 1265 - #define CHIP_CS 0x04 /* Serial Chip Select in Eprom */ 1266 - #define CHIP_DI 0x08 /* Serial Data Input in Eprom */ 1267 - #define EN_CCMD 0x000 /* Chip's command register */ 1268 - #define EN0_RSARLO 0x008 /* Remote start address reg 0 */ 1269 - #define EN0_RSARHI 0x009 /* Remote start address reg 1 */ 1270 - #define EN0_RCNTLO 0x00A /* Remote byte count reg WR */ 1271 - #define EN0_RCNTHI 0x00B /* Remote byte count reg WR */ 1272 - #define EN0_DCFG 0x00E /* Data configuration reg WR */ 1273 - #define EN0_PORT 0x010 /* Rcv missed frame error counter RD */ 1274 - #define ENC_PAGE0 0x000 /* Select page 0 of chip registers */ 1275 - #define ENC_PAGE3 0x0C0 /* Select page 3 of chip registers */ 1276 - static int __init mxser_read_register(int port, unsigned short *regs) 1277 - { 1278 - int i, k, value, id; 1279 - unsigned int j; 1280 - 1281 - id = mxser_program_mode(port); 1282 - if (id < 0) 1283 - return id; 1284 - for (i = 0; i < 14; i++) { 1285 - k = (i & 0x3F) | 0x180; 1286 - for (j = 0x100; j > 0; j >>= 1) { 1287 - outb(CHIP_CS, port); 1288 - if (k & j) { 1289 - outb(CHIP_CS | CHIP_DO, port); 1290 - outb(CHIP_CS | CHIP_DO | CHIP_SK, port); /* A? bit of read */ 1291 - } else { 1292 - outb(CHIP_CS, port); 1293 - outb(CHIP_CS | CHIP_SK, port); /* A? bit of read */ 1294 - } 1295 - } 1296 - (void)inb(port); 1297 - value = 0; 1298 - for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) { 1299 - outb(CHIP_CS, port); 1300 - outb(CHIP_CS | CHIP_SK, port); 1301 - if (inb(port) & CHIP_DI) 1302 - value |= j; 1303 - } 1304 - regs[i] = value; 1305 - outb(0, port); 1306 - } 1307 - mxser_normal_mode(port); 1308 - return id; 1309 - } 1310 - 1311 - static int mxser_ioctl_special(unsigned int cmd, void __user *argp) 1312 - { 1313 - struct mxser_port *ip; 1314 - struct tty_port *port; 1315 - struct tty_struct *tty; 1316 - int result, status; 1317 - unsigned int i, j; 1318 - int ret = 0; 1319 - 1320 - switch (cmd) { 1321 - case MOXA_GET_MAJOR: 1322 - printk_ratelimited(KERN_WARNING "mxser: '%s' uses deprecated ioctl " 1323 - "%x (GET_MAJOR), fix your userspace\n", 1324 - current->comm, cmd); 1325 - return put_user(ttymajor, (int __user *)argp); 1326 - 1327 - case MOXA_CHKPORTENABLE: 1328 - result = 0; 1329 - for (i = 0; i < MXSER_BOARDS; i++) 1330 - for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) 1331 - if (mxser_boards[i].ports[j].ioaddr) 1332 - result |= (1 << i); 1333 - return put_user(result, (unsigned long __user *)argp); 1334 - case MOXA_GETDATACOUNT: 1335 - /* The receive side is locked by port->slock but it isn't 1336 - clear that an exact snapshot is worth copying here */ 1337 - if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) 1338 - ret = -EFAULT; 1339 - return ret; 1340 - case MOXA_GETMSTATUS: { 1341 - struct mxser_mstatus ms, __user *msu = argp; 1342 - for (i = 0; i < MXSER_BOARDS; i++) 1343 - for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { 1344 - ip = &mxser_boards[i].ports[j]; 1345 - port = &ip->port; 1346 - memset(&ms, 0, sizeof(ms)); 1347 - 1348 - mutex_lock(&port->mutex); 1349 - if (!ip->ioaddr) 1350 - goto copy; 1351 - 1352 - tty = tty_port_tty_get(port); 1353 - 1354 - if (!tty) 1355 - ms.cflag = ip->normal_termios.c_cflag; 1356 - else 1357 - ms.cflag = tty->termios.c_cflag; 1358 - tty_kref_put(tty); 1359 - spin_lock_irq(&ip->slock); 1360 - status = inb(ip->ioaddr + UART_MSR); 1361 - spin_unlock_irq(&ip->slock); 1362 - if (status & UART_MSR_DCD) 1363 - ms.dcd = 1; 1364 - if (status & UART_MSR_DSR) 1365 - ms.dsr = 1; 1366 - if (status & UART_MSR_CTS) 1367 - ms.cts = 1; 1368 - copy: 1369 - mutex_unlock(&port->mutex); 1370 - if (copy_to_user(msu, &ms, sizeof(ms))) 1371 - return -EFAULT; 1372 - msu++; 1373 - } 1374 - return 0; 1375 - } 1376 - case MOXA_ASPP_MON_EXT: { 1377 - struct mxser_mon_ext *me; /* it's 2k, stack unfriendly */ 1378 - unsigned int cflag, iflag, p; 1379 - u8 opmode; 1380 - 1381 - me = kzalloc(sizeof(*me), GFP_KERNEL); 1382 - if (!me) 1383 - return -ENOMEM; 1384 - 1385 - for (i = 0, p = 0; i < MXSER_BOARDS; i++) { 1386 - for (j = 0; j < MXSER_PORTS_PER_BOARD; j++, p++) { 1387 - if (p >= ARRAY_SIZE(me->rx_cnt)) { 1388 - i = MXSER_BOARDS; 1389 - break; 1390 - } 1391 - ip = &mxser_boards[i].ports[j]; 1392 - port = &ip->port; 1393 - 1394 - mutex_lock(&port->mutex); 1395 - if (!ip->ioaddr) { 1396 - mutex_unlock(&port->mutex); 1397 - continue; 1398 - } 1399 - 1400 - spin_lock_irq(&ip->slock); 1401 - status = mxser_get_msr(ip->ioaddr, 0, p); 1402 - 1403 - if (status & UART_MSR_TERI) 1404 - ip->icount.rng++; 1405 - if (status & UART_MSR_DDSR) 1406 - ip->icount.dsr++; 1407 - if (status & UART_MSR_DDCD) 1408 - ip->icount.dcd++; 1409 - if (status & UART_MSR_DCTS) 1410 - ip->icount.cts++; 1411 - 1412 - ip->mon_data.modem_status = status; 1413 - me->rx_cnt[p] = ip->mon_data.rxcnt; 1414 - me->tx_cnt[p] = ip->mon_data.txcnt; 1415 - me->up_rxcnt[p] = ip->mon_data.up_rxcnt; 1416 - me->up_txcnt[p] = ip->mon_data.up_txcnt; 1417 - me->modem_status[p] = 1418 - ip->mon_data.modem_status; 1419 - spin_unlock_irq(&ip->slock); 1420 - 1421 - tty = tty_port_tty_get(&ip->port); 1422 - 1423 - if (!tty) { 1424 - cflag = ip->normal_termios.c_cflag; 1425 - iflag = ip->normal_termios.c_iflag; 1426 - me->baudrate[p] = tty_termios_baud_rate(&ip->normal_termios); 1427 - } else { 1428 - cflag = tty->termios.c_cflag; 1429 - iflag = tty->termios.c_iflag; 1430 - me->baudrate[p] = tty_get_baud_rate(tty); 1431 - } 1432 - tty_kref_put(tty); 1433 - 1434 - me->databits[p] = cflag & CSIZE; 1435 - me->stopbits[p] = cflag & CSTOPB; 1436 - me->parity[p] = cflag & (PARENB | PARODD | 1437 - CMSPAR); 1438 - 1439 - if (cflag & CRTSCTS) 1440 - me->flowctrl[p] |= 0x03; 1441 - 1442 - if (iflag & (IXON | IXOFF)) 1443 - me->flowctrl[p] |= 0x0C; 1444 - 1445 - if (ip->type == PORT_16550A) 1446 - me->fifo[p] = 1; 1447 - 1448 - if (ip->board->chip_flag == MOXA_MUST_MU860_HWID) { 1449 - opmode = inb(ip->opmode_ioaddr)>>((p % 4) * 2); 1450 - opmode &= OP_MODE_MASK; 1451 - } else { 1452 - opmode = RS232_MODE; 1453 - } 1454 - me->iftype[p] = opmode; 1455 - mutex_unlock(&port->mutex); 1456 - } 1457 - } 1458 - if (copy_to_user(argp, me, sizeof(*me))) 1459 - ret = -EFAULT; 1460 - kfree(me); 1461 - return ret; 1462 - } 1463 - default: 1464 - return -ENOIOCTLCMD; 1465 - } 1466 1398 return 0; 1467 1399 } 1468 1400 ··· 1226 1680 return ret; 1227 1681 } 1228 1682 1683 + /* We should likely switch to TIOCGRS485/TIOCSRS485. */ 1684 + static int mxser_ioctl_op_mode(struct mxser_port *port, int index, bool set, 1685 + int __user *u_opmode) 1686 + { 1687 + int opmode, p = index % 4; 1688 + int shiftbit = p * 2; 1689 + u8 val; 1690 + 1691 + if (port->board->must_hwid != MOXA_MUST_MU860_HWID) 1692 + return -EFAULT; 1693 + 1694 + if (set) { 1695 + if (get_user(opmode, u_opmode)) 1696 + return -EFAULT; 1697 + 1698 + if (opmode & ~OP_MODE_MASK) 1699 + return -EINVAL; 1700 + 1701 + spin_lock_irq(&port->slock); 1702 + val = inb(port->opmode_ioaddr); 1703 + val &= ~(OP_MODE_MASK << shiftbit); 1704 + val |= (opmode << shiftbit); 1705 + outb(val, port->opmode_ioaddr); 1706 + spin_unlock_irq(&port->slock); 1707 + 1708 + return 0; 1709 + } 1710 + 1711 + spin_lock_irq(&port->slock); 1712 + opmode = inb(port->opmode_ioaddr) >> shiftbit; 1713 + spin_unlock_irq(&port->slock); 1714 + 1715 + return put_user(opmode & OP_MODE_MASK, u_opmode); 1716 + } 1717 + 1229 1718 static int mxser_ioctl(struct tty_struct *tty, 1230 1719 unsigned int cmd, unsigned long arg) 1231 1720 { ··· 1269 1688 unsigned long flags; 1270 1689 void __user *argp = (void __user *)arg; 1271 1690 1272 - if (tty->index == MXSER_PORTS) 1273 - return mxser_ioctl_special(cmd, argp); 1274 - 1275 - if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) { 1276 - int p; 1277 - unsigned long opmode; 1278 - static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f }; 1279 - int shiftbit; 1280 - unsigned char val, mask; 1281 - 1282 - if (info->board->chip_flag != MOXA_MUST_MU860_HWID) 1283 - return -EFAULT; 1284 - 1285 - p = tty->index % 4; 1286 - if (cmd == MOXA_SET_OP_MODE) { 1287 - if (get_user(opmode, (int __user *) argp)) 1288 - return -EFAULT; 1289 - if (opmode != RS232_MODE && 1290 - opmode != RS485_2WIRE_MODE && 1291 - opmode != RS422_MODE && 1292 - opmode != RS485_4WIRE_MODE) 1293 - return -EFAULT; 1294 - mask = ModeMask[p]; 1295 - shiftbit = p * 2; 1296 - spin_lock_irq(&info->slock); 1297 - val = inb(info->opmode_ioaddr); 1298 - val &= mask; 1299 - val |= (opmode << shiftbit); 1300 - outb(val, info->opmode_ioaddr); 1301 - spin_unlock_irq(&info->slock); 1302 - } else { 1303 - shiftbit = p * 2; 1304 - spin_lock_irq(&info->slock); 1305 - opmode = inb(info->opmode_ioaddr) >> shiftbit; 1306 - spin_unlock_irq(&info->slock); 1307 - opmode &= OP_MODE_MASK; 1308 - if (put_user(opmode, (int __user *)argp)) 1309 - return -EFAULT; 1310 - } 1311 - return 0; 1312 - } 1691 + if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) 1692 + return mxser_ioctl_op_mode(info, tty->index, 1693 + cmd == MOXA_SET_OP_MODE, argp); 1313 1694 1314 1695 if (cmd != TIOCMIWAIT && tty_io_error(tty)) 1315 1696 return -EIO; ··· 1292 1749 1293 1750 return wait_event_interruptible(info->port.delta_msr_wait, 1294 1751 mxser_cflags_changed(info, arg, &cnow)); 1295 - case MOXA_HighSpeedOn: 1296 - return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); 1297 - case MOXA_SDS_RSTICOUNTER: 1298 - spin_lock_irq(&info->slock); 1299 - info->mon_data.rxcnt = 0; 1300 - info->mon_data.txcnt = 0; 1301 - spin_unlock_irq(&info->slock); 1302 - return 0; 1303 - 1304 - case MOXA_ASPP_OQUEUE:{ 1305 - int len, lsr; 1306 - 1307 - len = mxser_chars_in_buffer(tty); 1308 - spin_lock_irq(&info->slock); 1309 - lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE; 1310 - spin_unlock_irq(&info->slock); 1311 - len += (lsr ? 0 : 1); 1312 - 1313 - return put_user(len, (int __user *)argp); 1314 - } 1315 - case MOXA_ASPP_MON: { 1316 - int mcr, status; 1317 - 1318 - spin_lock_irq(&info->slock); 1319 - status = mxser_get_msr(info->ioaddr, 1, tty->index); 1320 - mxser_check_modem_status(tty, info, status); 1321 - 1322 - mcr = inb(info->ioaddr + UART_MCR); 1323 - spin_unlock_irq(&info->slock); 1324 - 1325 - if (mcr & MOXA_MUST_MCR_XON_FLAG) 1326 - info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD; 1327 - else 1328 - info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFHOLD; 1329 - 1330 - if (mcr & MOXA_MUST_MCR_TX_XON) 1331 - info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFXENT; 1332 - else 1333 - info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT; 1334 - 1335 - if (tty->hw_stopped) 1336 - info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD; 1337 - else 1338 - info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD; 1339 - 1340 - if (copy_to_user(argp, &info->mon_data, 1341 - sizeof(struct mxser_mon))) 1342 - return -EFAULT; 1343 - 1344 - return 0; 1345 - } 1346 - case MOXA_ASPP_LSTATUS: { 1347 - if (put_user(info->err_shadow, (unsigned char __user *)argp)) 1348 - return -EFAULT; 1349 - 1350 - info->err_shadow = 0; 1351 - return 0; 1352 - } 1353 - case MOXA_SET_BAUD_METHOD: { 1354 - int method; 1355 - 1356 - if (get_user(method, (int __user *)argp)) 1357 - return -EFAULT; 1358 - mxser_set_baud_method[tty->index] = method; 1359 - return put_user(method, (int __user *)argp); 1360 - } 1361 1752 default: 1362 1753 return -ENOIOCTLCMD; 1363 1754 } ··· 1337 1860 1338 1861 info->ldisc_stop_rx = 1; 1339 1862 if (I_IXOFF(tty)) { 1340 - if (info->board->chip_flag) { 1863 + if (info->board->must_hwid) { 1341 1864 info->IER &= ~MOXA_MUST_RECV_ISR; 1342 1865 outb(info->IER, info->ioaddr + UART_IER); 1343 1866 } else { ··· 1373 1896 if (info->x_char) 1374 1897 info->x_char = 0; 1375 1898 else { 1376 - if (info->board->chip_flag) { 1899 + if (info->board->must_hwid) { 1377 1900 info->IER |= MOXA_MUST_RECV_ISR; 1378 1901 outb(info->IER, info->ioaddr + UART_IER); 1379 1902 } else { ··· 1394 1917 /* 1395 1918 * mxser_stop() and mxser_start() 1396 1919 * 1397 - * This routines are called before setting or resetting tty->stopped. 1920 + * This routines are called before setting or resetting tty->flow.stopped. 1398 1921 * They enable or disable transmitter interrupts, as necessary. 1399 1922 */ 1400 1923 static void mxser_stop(struct tty_struct *tty) ··· 1403 1926 unsigned long flags; 1404 1927 1405 1928 spin_lock_irqsave(&info->slock, flags); 1406 - if (info->IER & UART_IER_THRI) { 1407 - info->IER &= ~UART_IER_THRI; 1408 - outb(info->IER, info->ioaddr + UART_IER); 1409 - } 1929 + if (info->IER & UART_IER_THRI) 1930 + __mxser_stop_tx(info); 1410 1931 spin_unlock_irqrestore(&info->slock, flags); 1411 1932 } 1412 1933 ··· 1414 1939 unsigned long flags; 1415 1940 1416 1941 spin_lock_irqsave(&info->slock, flags); 1417 - if (info->xmit_cnt && info->port.xmit_buf) { 1418 - outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER); 1419 - info->IER |= UART_IER_THRI; 1420 - outb(info->IER, info->ioaddr + UART_IER); 1421 - } 1942 + if (info->xmit_cnt && info->port.xmit_buf) 1943 + __mxser_start_tx(info); 1422 1944 spin_unlock_irqrestore(&info->slock, flags); 1423 1945 } 1424 1946 ··· 1435 1963 1436 1964 /* Handle sw stopped */ 1437 1965 if ((old_termios->c_iflag & IXON) && !I_IXON(tty)) { 1438 - tty->stopped = 0; 1966 + tty->flow.stopped = 0; 1439 1967 1440 - if (info->board->chip_flag) { 1968 + if (info->board->must_hwid) { 1441 1969 spin_lock_irqsave(&info->slock, flags); 1442 - mxser_disable_must_rx_software_flow_control( 1443 - info->ioaddr); 1970 + mxser_must_set_rx_sw_flow_control(info->ioaddr, false); 1444 1971 spin_unlock_irqrestore(&info->slock, flags); 1445 1972 } 1446 1973 ··· 1522 2051 { 1523 2052 struct mxser_port *info = tty->driver_data; 1524 2053 unsigned long flags; 2054 + u8 lcr; 1525 2055 1526 2056 spin_lock_irqsave(&info->slock, flags); 2057 + lcr = inb(info->ioaddr + UART_LCR); 1527 2058 if (break_state == -1) 1528 - outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC, 1529 - info->ioaddr + UART_LCR); 2059 + lcr |= UART_LCR_SBC; 1530 2060 else 1531 - outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC, 1532 - info->ioaddr + UART_LCR); 2061 + lcr &= ~UART_LCR_SBC; 2062 + outb(lcr, info->ioaddr + UART_LCR); 1533 2063 spin_unlock_irqrestore(&info->slock, flags); 2064 + 1534 2065 return 0; 1535 2066 } 1536 2067 1537 - static void mxser_receive_chars(struct tty_struct *tty, 1538 - struct mxser_port *port, int *status) 2068 + static bool mxser_receive_chars_new(struct tty_struct *tty, 2069 + struct mxser_port *port, u8 status) 1539 2070 { 1540 - unsigned char ch, gdl; 1541 - int ignored = 0; 1542 - int cnt = 0; 1543 - int recv_room; 1544 - int max = 256; 2071 + enum mxser_must_hwid hwid = port->board->must_hwid; 2072 + u8 gdl; 1545 2073 1546 - recv_room = tty->receive_room; 1547 - if (recv_room == 0 && !port->ldisc_stop_rx) 2074 + if (hwid == MOXA_OTHER_UART) 2075 + return false; 2076 + if (status & UART_LSR_BRK_ERROR_BITS) 2077 + return false; 2078 + if (hwid == MOXA_MUST_MU860_HWID && (status & MOXA_MUST_LSR_RERR)) 2079 + return false; 2080 + if (status & MOXA_MUST_LSR_RERR) 2081 + return false; 2082 + 2083 + gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER); 2084 + if (hwid == MOXA_MUST_MU150_HWID) 2085 + gdl &= MOXA_MUST_GDL_MASK; 2086 + 2087 + if (gdl >= tty->receive_room && !port->ldisc_stop_rx) 1548 2088 mxser_stoprx(tty); 1549 - if (port->board->chip_flag != MOXA_OTHER_UART) { 1550 2089 1551 - if (*status & UART_LSR_SPECIAL) 1552 - goto intr_old; 1553 - if (port->board->chip_flag == MOXA_MUST_MU860_HWID && 1554 - (*status & MOXA_MUST_LSR_RERR)) 1555 - goto intr_old; 1556 - if (*status & MOXA_MUST_LSR_RERR) 1557 - goto intr_old; 1558 - 1559 - gdl = inb(port->ioaddr + MOXA_MUST_GDL_REGISTER); 1560 - 1561 - if (port->board->chip_flag == MOXA_MUST_MU150_HWID) 1562 - gdl &= MOXA_MUST_GDL_MASK; 1563 - if (gdl >= recv_room) { 1564 - if (!port->ldisc_stop_rx) 1565 - mxser_stoprx(tty); 1566 - } 1567 - while (gdl--) { 1568 - ch = inb(port->ioaddr + UART_RX); 1569 - tty_insert_flip_char(&port->port, ch, 0); 1570 - cnt++; 1571 - } 1572 - goto end_intr; 2090 + while (gdl--) { 2091 + u8 ch = inb(port->ioaddr + UART_RX); 2092 + tty_insert_flip_char(&port->port, ch, 0); 1573 2093 } 1574 - intr_old: 2094 + 2095 + return true; 2096 + } 2097 + 2098 + static u8 mxser_receive_chars_old(struct tty_struct *tty, 2099 + struct mxser_port *port, u8 status) 2100 + { 2101 + enum mxser_must_hwid hwid = port->board->must_hwid; 2102 + int recv_room = tty->receive_room; 2103 + int ignored = 0; 2104 + int max = 256; 2105 + int cnt = 0; 2106 + u8 ch; 1575 2107 1576 2108 do { 1577 2109 if (max-- < 0) 1578 2110 break; 1579 2111 1580 2112 ch = inb(port->ioaddr + UART_RX); 1581 - if (port->board->chip_flag && (*status & UART_LSR_OE)) 1582 - outb(0x23, port->ioaddr + UART_FCR); 1583 - *status &= port->read_status_mask; 1584 - if (*status & port->ignore_status_mask) { 2113 + if (hwid && (status & UART_LSR_OE)) 2114 + outb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | 2115 + MOXA_MUST_FCR_GDA_MODE_ENABLE, 2116 + port->ioaddr + UART_FCR); 2117 + status &= port->read_status_mask; 2118 + if (status & port->ignore_status_mask) { 1585 2119 if (++ignored > 100) 1586 2120 break; 1587 2121 } else { 1588 2122 char flag = 0; 1589 - if (*status & UART_LSR_SPECIAL) { 1590 - if (*status & UART_LSR_BI) { 2123 + if (status & UART_LSR_BRK_ERROR_BITS) { 2124 + if (status & UART_LSR_BI) { 1591 2125 flag = TTY_BREAK; 1592 2126 port->icount.brk++; 1593 2127 1594 2128 if (port->port.flags & ASYNC_SAK) 1595 2129 do_SAK(tty); 1596 - } else if (*status & UART_LSR_PE) { 2130 + } else if (status & UART_LSR_PE) { 1597 2131 flag = TTY_PARITY; 1598 2132 port->icount.parity++; 1599 - } else if (*status & UART_LSR_FE) { 2133 + } else if (status & UART_LSR_FE) { 1600 2134 flag = TTY_FRAME; 1601 2135 port->icount.frame++; 1602 - } else if (*status & UART_LSR_OE) { 2136 + } else if (status & UART_LSR_OE) { 1603 2137 flag = TTY_OVERRUN; 1604 2138 port->icount.overrun++; 1605 - } else 1606 - flag = TTY_BREAK; 2139 + } 1607 2140 } 1608 2141 tty_insert_flip_char(&port->port, ch, flag); 1609 2142 cnt++; ··· 1619 2144 1620 2145 } 1621 2146 1622 - if (port->board->chip_flag) 2147 + if (hwid) 1623 2148 break; 1624 2149 1625 - *status = inb(port->ioaddr + UART_LSR); 1626 - } while (*status & UART_LSR_DR); 2150 + status = inb(port->ioaddr + UART_LSR); 2151 + } while (status & UART_LSR_DR); 1627 2152 1628 - end_intr: 1629 - mxvar_log.rxcnt[tty->index] += cnt; 1630 - port->mon_data.rxcnt += cnt; 1631 - port->mon_data.up_rxcnt += cnt; 2153 + return status; 2154 + } 2155 + 2156 + static u8 mxser_receive_chars(struct tty_struct *tty, 2157 + struct mxser_port *port, u8 status) 2158 + { 2159 + if (tty->receive_room == 0 && !port->ldisc_stop_rx) 2160 + mxser_stoprx(tty); 2161 + 2162 + if (!mxser_receive_chars_new(tty, port, status)) 2163 + status = mxser_receive_chars_old(tty, port, status); 1632 2164 1633 2165 tty_flip_buffer_push(&port->port); 2166 + 2167 + return status; 1634 2168 } 1635 2169 1636 2170 static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port) ··· 1649 2165 if (port->x_char) { 1650 2166 outb(port->x_char, port->ioaddr + UART_TX); 1651 2167 port->x_char = 0; 1652 - mxvar_log.txcnt[tty->index]++; 1653 - port->mon_data.txcnt++; 1654 - port->mon_data.up_txcnt++; 1655 2168 port->icount.tx++; 1656 2169 return; 1657 2170 } ··· 1656 2175 if (port->port.xmit_buf == NULL) 1657 2176 return; 1658 2177 1659 - if (port->xmit_cnt <= 0 || tty->stopped || 1660 - (tty->hw_stopped && 1661 - (port->type != PORT_16550A) && 1662 - (!port->board->chip_flag))) { 1663 - port->IER &= ~UART_IER_THRI; 1664 - outb(port->IER, port->ioaddr + UART_IER); 2178 + if (!port->xmit_cnt || tty->flow.stopped || 2179 + (tty->hw_stopped && !mxser_16550A_or_MUST(port))) { 2180 + __mxser_stop_tx(port); 1665 2181 return; 1666 2182 } 1667 2183 ··· 1668 2190 outb(port->port.xmit_buf[port->xmit_tail++], 1669 2191 port->ioaddr + UART_TX); 1670 2192 port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1); 1671 - if (--port->xmit_cnt <= 0) 2193 + if (!--port->xmit_cnt) 1672 2194 break; 1673 2195 } while (--count > 0); 1674 - mxvar_log.txcnt[tty->index] += (cnt - port->xmit_cnt); 1675 2196 1676 - port->mon_data.txcnt += (cnt - port->xmit_cnt); 1677 - port->mon_data.up_txcnt += (cnt - port->xmit_cnt); 1678 2197 port->icount.tx += (cnt - port->xmit_cnt); 1679 2198 1680 2199 if (port->xmit_cnt < WAKEUP_CHARS) 1681 2200 tty_wakeup(tty); 1682 2201 1683 - if (port->xmit_cnt <= 0) { 1684 - port->IER &= ~UART_IER_THRI; 1685 - outb(port->IER, port->ioaddr + UART_IER); 2202 + if (!port->xmit_cnt) 2203 + __mxser_stop_tx(port); 2204 + } 2205 + 2206 + static bool mxser_port_isr(struct mxser_port *port) 2207 + { 2208 + struct tty_struct *tty; 2209 + u8 iir, msr, status; 2210 + bool error = false; 2211 + 2212 + iir = inb(port->ioaddr + UART_IIR); 2213 + if (iir & UART_IIR_NO_INT) 2214 + return true; 2215 + 2216 + iir &= MOXA_MUST_IIR_MASK; 2217 + tty = tty_port_tty_get(&port->port); 2218 + if (!tty || port->closing || !tty_port_initialized(&port->port)) { 2219 + status = inb(port->ioaddr + UART_LSR); 2220 + outb(MOXA_MUST_FCR_GDA_MODE_ENABLE | UART_FCR_ENABLE_FIFO | 2221 + UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, 2222 + port->ioaddr + UART_FCR); 2223 + inb(port->ioaddr + UART_MSR); 2224 + 2225 + error = true; 2226 + goto put_tty; 1686 2227 } 2228 + 2229 + status = inb(port->ioaddr + UART_LSR); 2230 + 2231 + if (port->board->must_hwid) { 2232 + if (iir == MOXA_MUST_IIR_GDA || 2233 + iir == MOXA_MUST_IIR_RDA || 2234 + iir == MOXA_MUST_IIR_RTO || 2235 + iir == MOXA_MUST_IIR_LSR) 2236 + status = mxser_receive_chars(tty, port, status); 2237 + } else { 2238 + status &= port->read_status_mask; 2239 + if (status & UART_LSR_DR) 2240 + status = mxser_receive_chars(tty, port, status); 2241 + } 2242 + 2243 + msr = inb(port->ioaddr + UART_MSR); 2244 + if (msr & UART_MSR_ANY_DELTA) 2245 + mxser_check_modem_status(tty, port, msr); 2246 + 2247 + if (port->board->must_hwid) { 2248 + if (iir == 0x02 && (status & UART_LSR_THRE)) 2249 + mxser_transmit_chars(tty, port); 2250 + } else { 2251 + if (status & UART_LSR_THRE) 2252 + mxser_transmit_chars(tty, port); 2253 + } 2254 + 2255 + put_tty: 2256 + tty_kref_put(tty); 2257 + 2258 + return error; 1687 2259 } 1688 2260 1689 2261 /* ··· 1741 2213 */ 1742 2214 static irqreturn_t mxser_interrupt(int irq, void *dev_id) 1743 2215 { 1744 - int status, iir, i; 1745 - struct mxser_board *brd = NULL; 2216 + struct mxser_board *brd = dev_id; 1746 2217 struct mxser_port *port; 1747 - int max, irqbits, bits, msr; 1748 2218 unsigned int int_cnt, pass_counter = 0; 2219 + unsigned int i, max = brd->nports; 1749 2220 int handled = IRQ_NONE; 1750 - struct tty_struct *tty; 2221 + u8 irqbits, bits, mask = BIT(max) - 1; 1751 2222 1752 - for (i = 0; i < MXSER_BOARDS; i++) 1753 - if (dev_id == &mxser_boards[i]) { 1754 - brd = dev_id; 1755 - break; 1756 - } 1757 - 1758 - if (i == MXSER_BOARDS) 1759 - goto irq_stop; 1760 - if (brd == NULL) 1761 - goto irq_stop; 1762 - max = brd->info->nports; 1763 2223 while (pass_counter++ < MXSER_ISR_PASS_LIMIT) { 1764 - irqbits = inb(brd->vector) & brd->vector_mask; 1765 - if (irqbits == brd->vector_mask) 2224 + irqbits = inb(brd->vector) & mask; 2225 + if (irqbits == mask) 1766 2226 break; 1767 2227 1768 2228 handled = IRQ_HANDLED; 1769 2229 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) { 1770 - if (irqbits == brd->vector_mask) 2230 + if (irqbits == mask) 1771 2231 break; 1772 2232 if (bits & irqbits) 1773 2233 continue; ··· 1764 2248 int_cnt = 0; 1765 2249 spin_lock(&port->slock); 1766 2250 do { 1767 - iir = inb(port->ioaddr + UART_IIR); 1768 - if (iir & UART_IIR_NO_INT) 2251 + if (mxser_port_isr(port)) 1769 2252 break; 1770 - iir &= MOXA_MUST_IIR_MASK; 1771 - tty = tty_port_tty_get(&port->port); 1772 - if (!tty || port->closing || 1773 - !tty_port_initialized(&port->port)) { 1774 - status = inb(port->ioaddr + UART_LSR); 1775 - outb(0x27, port->ioaddr + UART_FCR); 1776 - inb(port->ioaddr + UART_MSR); 1777 - tty_kref_put(tty); 1778 - break; 1779 - } 1780 - 1781 - status = inb(port->ioaddr + UART_LSR); 1782 - 1783 - if (status & UART_LSR_PE) 1784 - port->err_shadow |= NPPI_NOTIFY_PARITY; 1785 - if (status & UART_LSR_FE) 1786 - port->err_shadow |= NPPI_NOTIFY_FRAMING; 1787 - if (status & UART_LSR_OE) 1788 - port->err_shadow |= 1789 - NPPI_NOTIFY_HW_OVERRUN; 1790 - if (status & UART_LSR_BI) 1791 - port->err_shadow |= NPPI_NOTIFY_BREAK; 1792 - 1793 - if (port->board->chip_flag) { 1794 - if (iir == MOXA_MUST_IIR_GDA || 1795 - iir == MOXA_MUST_IIR_RDA || 1796 - iir == MOXA_MUST_IIR_RTO || 1797 - iir == MOXA_MUST_IIR_LSR) 1798 - mxser_receive_chars(tty, port, 1799 - &status); 1800 - 1801 - } else { 1802 - status &= port->read_status_mask; 1803 - if (status & UART_LSR_DR) 1804 - mxser_receive_chars(tty, port, 1805 - &status); 1806 - } 1807 - msr = inb(port->ioaddr + UART_MSR); 1808 - if (msr & UART_MSR_ANY_DELTA) 1809 - mxser_check_modem_status(tty, port, msr); 1810 - 1811 - if (port->board->chip_flag) { 1812 - if (iir == 0x02 && (status & 1813 - UART_LSR_THRE)) 1814 - mxser_transmit_chars(tty, port); 1815 - } else { 1816 - if (status & UART_LSR_THRE) 1817 - mxser_transmit_chars(tty, port); 1818 - } 1819 - tty_kref_put(tty); 1820 2253 } while (int_cnt++ < MXSER_ISR_PASS_LIMIT); 1821 2254 spin_unlock(&port->slock); 1822 2255 } 1823 2256 } 1824 2257 1825 - irq_stop: 1826 2258 return handled; 1827 2259 } 1828 2260 ··· 1810 2346 * The MOXA Smartio/Industio serial driver boot-time initialization code! 1811 2347 */ 1812 2348 1813 - static bool allow_overlapping_vector; 1814 - module_param(allow_overlapping_vector, bool, S_IRUGO); 1815 - MODULE_PARM_DESC(allow_overlapping_vector, "whether we allow ISA cards to be configured such that vector overlabs IO ports (default=no)"); 1816 - 1817 - static bool mxser_overlapping_vector(struct mxser_board *brd) 1818 - { 1819 - return allow_overlapping_vector && 1820 - brd->vector >= brd->ports[0].ioaddr && 1821 - brd->vector < brd->ports[0].ioaddr + 8 * brd->info->nports; 1822 - } 1823 - 1824 - static int mxser_request_vector(struct mxser_board *brd) 1825 - { 1826 - if (mxser_overlapping_vector(brd)) 1827 - return 0; 1828 - return request_region(brd->vector, 1, "mxser(vector)") ? 0 : -EIO; 1829 - } 1830 - 1831 - static void mxser_release_vector(struct mxser_board *brd) 1832 - { 1833 - if (mxser_overlapping_vector(brd)) 1834 - return; 1835 - release_region(brd->vector, 1); 1836 - } 1837 - 1838 - static void mxser_release_ISA_res(struct mxser_board *brd) 1839 - { 1840 - release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); 1841 - mxser_release_vector(brd); 1842 - } 1843 - 1844 - static int mxser_initbrd(struct mxser_board *brd) 2349 + static void mxser_initbrd(struct mxser_board *brd, bool high_baud) 1845 2350 { 1846 2351 struct mxser_port *info; 1847 2352 unsigned int i; 1848 - int retval; 2353 + bool is_mu860; 1849 2354 1850 - printk(KERN_INFO "mxser: max. baud rate = %d bps\n", 1851 - brd->ports[0].max_baud); 2355 + brd->must_hwid = mxser_must_get_hwid(brd->ports[0].ioaddr); 2356 + is_mu860 = brd->must_hwid == MOXA_MUST_MU860_HWID; 1852 2357 1853 - for (i = 0; i < brd->info->nports; i++) { 2358 + for (i = 0; i < UART_INFO_NUM; i++) { 2359 + if (Gpci_uart_info[i].type == brd->must_hwid) { 2360 + brd->max_baud = Gpci_uart_info[i].max_baud; 2361 + 2362 + /* exception....CP-102 */ 2363 + if (high_baud) 2364 + brd->max_baud = 921600; 2365 + break; 2366 + } 2367 + } 2368 + 2369 + if (is_mu860) { 2370 + /* set to RS232 mode by default */ 2371 + outb(0, brd->vector + 4); 2372 + outb(0, brd->vector + 0x0c); 2373 + } 2374 + 2375 + for (i = 0; i < brd->nports; i++) { 1854 2376 info = &brd->ports[i]; 2377 + if (is_mu860) { 2378 + if (i < 4) 2379 + info->opmode_ioaddr = brd->vector + 4; 2380 + else 2381 + info->opmode_ioaddr = brd->vector + 0x0c; 2382 + } 1855 2383 tty_port_init(&info->port); 1856 2384 info->port.ops = &mxser_port_ops; 1857 2385 info->board = brd; 1858 - info->stop_rx = 0; 1859 2386 info->ldisc_stop_rx = 0; 1860 2387 1861 2388 /* Enhance mode enabled here */ 1862 - if (brd->chip_flag != MOXA_OTHER_UART) 1863 - mxser_enable_must_enchance_mode(info->ioaddr); 2389 + if (brd->must_hwid != MOXA_OTHER_UART) 2390 + mxser_must_set_enhance_mode(info->ioaddr, true); 1864 2391 1865 - info->type = brd->uart_type; 2392 + info->type = PORT_16550A; 1866 2393 1867 - process_txrx_fifo(info); 2394 + mxser_process_txrx_fifo(info); 1868 2395 1869 - info->custom_divisor = info->baud_base * 16; 1870 2396 info->port.close_delay = 5 * HZ / 10; 1871 2397 info->port.closing_wait = 30 * HZ; 1872 - info->normal_termios = mxvar_sdriver->init_termios; 1873 - memset(&info->mon_data, 0, sizeof(struct mxser_mon)); 1874 - info->err_shadow = 0; 1875 2398 spin_lock_init(&info->slock); 1876 2399 1877 2400 /* before set INT ISR, disable all int */ 1878 2401 outb(inb(info->ioaddr + UART_IER) & 0xf0, 1879 2402 info->ioaddr + UART_IER); 1880 2403 } 1881 - 1882 - retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser", 1883 - brd); 1884 - if (retval) { 1885 - for (i = 0; i < brd->info->nports; i++) 1886 - tty_port_destroy(&brd->ports[i].port); 1887 - printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " 1888 - "conflict with another device.\n", 1889 - brd->info->name, brd->irq); 1890 - } 1891 - 1892 - return retval; 1893 - } 1894 - 1895 - static void mxser_board_remove(struct mxser_board *brd) 1896 - { 1897 - unsigned int i; 1898 - 1899 - for (i = 0; i < brd->info->nports; i++) { 1900 - tty_unregister_device(mxvar_sdriver, brd->idx + i); 1901 - tty_port_destroy(&brd->ports[i].port); 1902 - } 1903 - free_irq(brd->irq, brd); 1904 - } 1905 - 1906 - static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) 1907 - { 1908 - int id, i, bits, ret; 1909 - unsigned short regs[16], irq; 1910 - unsigned char scratch, scratch2; 1911 - 1912 - brd->chip_flag = MOXA_OTHER_UART; 1913 - 1914 - id = mxser_read_register(cap, regs); 1915 - switch (id) { 1916 - case C168_ASIC_ID: 1917 - brd->info = &mxser_cards[0]; 1918 - break; 1919 - case C104_ASIC_ID: 1920 - brd->info = &mxser_cards[1]; 1921 - break; 1922 - case CI104J_ASIC_ID: 1923 - brd->info = &mxser_cards[2]; 1924 - break; 1925 - case C102_ASIC_ID: 1926 - brd->info = &mxser_cards[5]; 1927 - break; 1928 - case CI132_ASIC_ID: 1929 - brd->info = &mxser_cards[6]; 1930 - break; 1931 - case CI134_ASIC_ID: 1932 - brd->info = &mxser_cards[7]; 1933 - break; 1934 - default: 1935 - return 0; 1936 - } 1937 - 1938 - irq = 0; 1939 - /* some ISA cards have 2 ports, but we want to see them as 4-port (why?) 1940 - Flag-hack checks if configuration should be read as 2-port here. */ 1941 - if (brd->info->nports == 2 || (brd->info->flags & MXSER_HAS2)) { 1942 - irq = regs[9] & 0xF000; 1943 - irq = irq | (irq >> 4); 1944 - if (irq != (regs[9] & 0xFF00)) 1945 - goto err_irqconflict; 1946 - } else if (brd->info->nports == 4) { 1947 - irq = regs[9] & 0xF000; 1948 - irq = irq | (irq >> 4); 1949 - irq = irq | (irq >> 8); 1950 - if (irq != regs[9]) 1951 - goto err_irqconflict; 1952 - } else if (brd->info->nports == 8) { 1953 - irq = regs[9] & 0xF000; 1954 - irq = irq | (irq >> 4); 1955 - irq = irq | (irq >> 8); 1956 - if ((irq != regs[9]) || (irq != regs[10])) 1957 - goto err_irqconflict; 1958 - } 1959 - 1960 - if (!irq) { 1961 - printk(KERN_ERR "mxser: interrupt number unset\n"); 1962 - return -EIO; 1963 - } 1964 - brd->irq = ((int)(irq & 0xF000) >> 12); 1965 - for (i = 0; i < 8; i++) 1966 - brd->ports[i].ioaddr = (int) regs[i + 1] & 0xFFF8; 1967 - if ((regs[12] & 0x80) == 0) { 1968 - printk(KERN_ERR "mxser: invalid interrupt vector\n"); 1969 - return -EIO; 1970 - } 1971 - brd->vector = (int)regs[11]; /* interrupt vector */ 1972 - if (id == 1) 1973 - brd->vector_mask = 0x00FF; 1974 - else 1975 - brd->vector_mask = 0x000F; 1976 - for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) { 1977 - if (regs[12] & bits) { 1978 - brd->ports[i].baud_base = 921600; 1979 - brd->ports[i].max_baud = 921600; 1980 - } else { 1981 - brd->ports[i].baud_base = 115200; 1982 - brd->ports[i].max_baud = 115200; 1983 - } 1984 - } 1985 - scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB); 1986 - outb(scratch2 | UART_LCR_DLAB, cap + UART_LCR); 1987 - outb(0, cap + UART_EFR); /* EFR is the same as FCR */ 1988 - outb(scratch2, cap + UART_LCR); 1989 - outb(UART_FCR_ENABLE_FIFO, cap + UART_FCR); 1990 - scratch = inb(cap + UART_IIR); 1991 - 1992 - if (scratch & 0xC0) 1993 - brd->uart_type = PORT_16550A; 1994 - else 1995 - brd->uart_type = PORT_16450; 1996 - if (!request_region(brd->ports[0].ioaddr, 8 * brd->info->nports, 1997 - "mxser(IO)")) { 1998 - printk(KERN_ERR "mxser: can't request ports I/O region: " 1999 - "0x%.8lx-0x%.8lx\n", 2000 - brd->ports[0].ioaddr, brd->ports[0].ioaddr + 2001 - 8 * brd->info->nports - 1); 2002 - return -EIO; 2003 - } 2004 - 2005 - ret = mxser_request_vector(brd); 2006 - if (ret) { 2007 - release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); 2008 - printk(KERN_ERR "mxser: can't request interrupt vector region: " 2009 - "0x%.8lx-0x%.8lx\n", 2010 - brd->ports[0].ioaddr, brd->ports[0].ioaddr + 2011 - 8 * brd->info->nports - 1); 2012 - return ret; 2013 - } 2014 - return brd->info->nports; 2015 - 2016 - err_irqconflict: 2017 - printk(KERN_ERR "mxser: invalid interrupt number\n"); 2018 - return -EIO; 2019 2404 } 2020 2405 2021 2406 static int mxser_probe(struct pci_dev *pdev, 2022 2407 const struct pci_device_id *ent) 2023 2408 { 2024 - #ifdef CONFIG_PCI 2025 2409 struct mxser_board *brd; 2026 - unsigned int i, j; 2410 + unsigned int i, base; 2027 2411 unsigned long ioaddress; 2412 + unsigned short nports = MXSER_NPORTS(ent->driver_data); 2028 2413 struct device *tty_dev; 2029 2414 int retval = -EINVAL; 2030 2415 2031 - for (i = 0; i < MXSER_BOARDS; i++) 2032 - if (mxser_boards[i].info == NULL) 2033 - break; 2034 - 2416 + i = find_first_zero_bit(mxser_boards, MXSER_BOARDS); 2035 2417 if (i >= MXSER_BOARDS) { 2036 2418 dev_err(&pdev->dev, "too many boards found (maximum %d), board " 2037 2419 "not configured\n", MXSER_BOARDS); 2038 2420 goto err; 2039 2421 } 2040 2422 2041 - brd = &mxser_boards[i]; 2042 - brd->idx = i * MXSER_PORTS_PER_BOARD; 2043 - dev_info(&pdev->dev, "found MOXA %s board (BusNo=%d, DevNo=%d)\n", 2044 - mxser_cards[ent->driver_data].name, 2045 - pdev->bus->number, PCI_SLOT(pdev->devfn)); 2423 + brd = devm_kzalloc(&pdev->dev, struct_size(brd, ports, nports), 2424 + GFP_KERNEL); 2425 + if (!brd) 2426 + goto err; 2046 2427 2047 - retval = pci_enable_device(pdev); 2428 + brd->idx = i; 2429 + __set_bit(brd->idx, mxser_boards); 2430 + base = i * MXSER_PORTS_PER_BOARD; 2431 + 2432 + retval = pcim_enable_device(pdev); 2048 2433 if (retval) { 2049 2434 dev_err(&pdev->dev, "PCI enable failed\n"); 2050 - goto err; 2435 + goto err_zero; 2051 2436 } 2052 2437 2053 2438 /* io address */ 2054 2439 ioaddress = pci_resource_start(pdev, 2); 2055 2440 retval = pci_request_region(pdev, 2, "mxser(IO)"); 2056 2441 if (retval) 2057 - goto err_dis; 2442 + goto err_zero; 2058 2443 2059 - brd->info = &mxser_cards[ent->driver_data]; 2060 - for (i = 0; i < brd->info->nports; i++) 2444 + brd->nports = nports; 2445 + for (i = 0; i < nports; i++) 2061 2446 brd->ports[i].ioaddr = ioaddress + 8 * i; 2062 2447 2063 2448 /* vector */ ··· 1919 2606 /* irq */ 1920 2607 brd->irq = pdev->irq; 1921 2608 1922 - brd->chip_flag = CheckIsMoxaMust(brd->ports[0].ioaddr); 1923 - brd->uart_type = PORT_16550A; 1924 - brd->vector_mask = 0; 2609 + mxser_initbrd(brd, ent->driver_data & MXSER_HIGHBAUD); 1925 2610 1926 - for (i = 0; i < brd->info->nports; i++) { 1927 - for (j = 0; j < UART_INFO_NUM; j++) { 1928 - if (Gpci_uart_info[j].type == brd->chip_flag) { 1929 - brd->ports[i].max_baud = 1930 - Gpci_uart_info[j].max_baud; 1931 - 1932 - /* exception....CP-102 */ 1933 - if (brd->info->flags & MXSER_HIGHBAUD) 1934 - brd->ports[i].max_baud = 921600; 1935 - break; 1936 - } 1937 - } 2611 + retval = devm_request_irq(&pdev->dev, brd->irq, mxser_interrupt, 2612 + IRQF_SHARED, "mxser", brd); 2613 + if (retval) { 2614 + dev_err(&pdev->dev, "request irq failed"); 2615 + goto err_relbrd; 1938 2616 } 1939 2617 1940 - if (brd->chip_flag == MOXA_MUST_MU860_HWID) { 1941 - for (i = 0; i < brd->info->nports; i++) { 1942 - if (i < 4) 1943 - brd->ports[i].opmode_ioaddr = ioaddress + 4; 1944 - else 1945 - brd->ports[i].opmode_ioaddr = ioaddress + 0x0c; 1946 - } 1947 - outb(0, ioaddress + 4); /* default set to RS232 mode */ 1948 - outb(0, ioaddress + 0x0c); /* default set to RS232 mode */ 1949 - } 1950 - 1951 - for (i = 0; i < brd->info->nports; i++) { 1952 - brd->vector_mask |= (1 << i); 1953 - brd->ports[i].baud_base = 921600; 1954 - } 1955 - 1956 - /* mxser_initbrd will hook ISR. */ 1957 - retval = mxser_initbrd(brd); 1958 - if (retval) 1959 - goto err_rel3; 1960 - 1961 - for (i = 0; i < brd->info->nports; i++) { 2618 + for (i = 0; i < nports; i++) { 1962 2619 tty_dev = tty_port_register_device(&brd->ports[i].port, 1963 - mxvar_sdriver, brd->idx + i, &pdev->dev); 2620 + mxvar_sdriver, base + i, &pdev->dev); 1964 2621 if (IS_ERR(tty_dev)) { 1965 2622 retval = PTR_ERR(tty_dev); 1966 2623 for (; i > 0; i--) 1967 2624 tty_unregister_device(mxvar_sdriver, 1968 - brd->idx + i - 1); 2625 + base + i - 1); 1969 2626 goto err_relbrd; 1970 2627 } 1971 2628 } ··· 1944 2661 1945 2662 return 0; 1946 2663 err_relbrd: 1947 - for (i = 0; i < brd->info->nports; i++) 2664 + for (i = 0; i < nports; i++) 1948 2665 tty_port_destroy(&brd->ports[i].port); 1949 - free_irq(brd->irq, brd); 1950 - err_rel3: 1951 - pci_release_region(pdev, 3); 1952 2666 err_zero: 1953 - brd->info = NULL; 1954 - pci_release_region(pdev, 2); 1955 - err_dis: 1956 - pci_disable_device(pdev); 2667 + __clear_bit(brd->idx, mxser_boards); 1957 2668 err: 1958 2669 return retval; 1959 - #else 1960 - return -ENODEV; 1961 - #endif 1962 2670 } 1963 2671 1964 2672 static void mxser_remove(struct pci_dev *pdev) 1965 2673 { 1966 - #ifdef CONFIG_PCI 1967 2674 struct mxser_board *brd = pci_get_drvdata(pdev); 2675 + unsigned int i, base = brd->idx * MXSER_PORTS_PER_BOARD; 1968 2676 1969 - mxser_board_remove(brd); 2677 + for (i = 0; i < brd->nports; i++) { 2678 + tty_unregister_device(mxvar_sdriver, base + i); 2679 + tty_port_destroy(&brd->ports[i].port); 2680 + } 1970 2681 1971 - pci_release_region(pdev, 2); 1972 - pci_release_region(pdev, 3); 1973 - pci_disable_device(pdev); 1974 - brd->info = NULL; 1975 - #endif 2682 + __clear_bit(brd->idx, mxser_boards); 1976 2683 } 1977 2684 1978 2685 static struct pci_driver mxser_driver = { ··· 1974 2701 1975 2702 static int __init mxser_module_init(void) 1976 2703 { 1977 - struct mxser_board *brd; 1978 - struct device *tty_dev; 1979 - unsigned int b, i, m; 1980 2704 int retval; 1981 2705 1982 - mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1); 2706 + mxvar_sdriver = alloc_tty_driver(MXSER_PORTS); 1983 2707 if (!mxvar_sdriver) 1984 2708 return -ENOMEM; 1985 - 1986 - printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", 1987 - MXSER_VERSION); 1988 2709 1989 2710 /* Initialize the tty_driver structure */ 1990 2711 mxvar_sdriver->name = "ttyMI"; ··· 1998 2731 goto err_put; 1999 2732 } 2000 2733 2001 - /* Start finding ISA boards here */ 2002 - for (m = 0, b = 0; b < MXSER_BOARDS; b++) { 2003 - if (!ioaddr[b]) 2004 - continue; 2005 - 2006 - brd = &mxser_boards[m]; 2007 - retval = mxser_get_ISA_conf(ioaddr[b], brd); 2008 - if (retval <= 0) { 2009 - brd->info = NULL; 2010 - continue; 2011 - } 2012 - 2013 - printk(KERN_INFO "mxser: found MOXA %s board (CAP=0x%lx)\n", 2014 - brd->info->name, ioaddr[b]); 2015 - 2016 - /* mxser_initbrd will hook ISR. */ 2017 - if (mxser_initbrd(brd) < 0) { 2018 - mxser_release_ISA_res(brd); 2019 - brd->info = NULL; 2020 - continue; 2021 - } 2022 - 2023 - brd->idx = m * MXSER_PORTS_PER_BOARD; 2024 - for (i = 0; i < brd->info->nports; i++) { 2025 - tty_dev = tty_port_register_device(&brd->ports[i].port, 2026 - mxvar_sdriver, brd->idx + i, NULL); 2027 - if (IS_ERR(tty_dev)) { 2028 - for (; i > 0; i--) 2029 - tty_unregister_device(mxvar_sdriver, 2030 - brd->idx + i - 1); 2031 - for (i = 0; i < brd->info->nports; i++) 2032 - tty_port_destroy(&brd->ports[i].port); 2033 - free_irq(brd->irq, brd); 2034 - mxser_release_ISA_res(brd); 2035 - brd->info = NULL; 2036 - break; 2037 - } 2038 - } 2039 - if (brd->info == NULL) 2040 - continue; 2041 - 2042 - m++; 2043 - } 2044 - 2045 2734 retval = pci_register_driver(&mxser_driver); 2046 2735 if (retval) { 2047 2736 printk(KERN_ERR "mxser: can't register pci driver\n"); 2048 - if (!m) { 2049 - retval = -ENODEV; 2050 - goto err_unr; 2051 - } /* else: we have some ISA cards under control */ 2737 + goto err_unr; 2052 2738 } 2053 2739 2054 2740 return 0; ··· 2014 2794 2015 2795 static void __exit mxser_module_exit(void) 2016 2796 { 2017 - unsigned int i; 2018 - 2019 2797 pci_unregister_driver(&mxser_driver); 2020 - 2021 - for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */ 2022 - if (mxser_boards[i].info != NULL) 2023 - mxser_board_remove(&mxser_boards[i]); 2024 2798 tty_unregister_driver(mxvar_sdriver); 2025 2799 put_tty_driver(mxvar_sdriver); 2026 - 2027 - for (i = 0; i < MXSER_BOARDS; i++) 2028 - if (mxser_boards[i].info != NULL) 2029 - mxser_release_ISA_res(&mxser_boards[i]); 2030 2800 } 2031 2801 2032 2802 module_init(mxser_module_init);
-151
drivers/tty/mxser.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _MXSER_H 3 - #define _MXSER_H 4 - 5 - /* 6 - * Semi-public control interfaces 7 - */ 8 - 9 - /* 10 - * MOXA ioctls 11 - */ 12 - 13 - #define MOXA 0x400 14 - #define MOXA_GETDATACOUNT (MOXA + 23) 15 - #define MOXA_DIAGNOSE (MOXA + 50) 16 - #define MOXA_CHKPORTENABLE (MOXA + 60) 17 - #define MOXA_HighSpeedOn (MOXA + 61) 18 - #define MOXA_GET_MAJOR (MOXA + 63) 19 - #define MOXA_GETMSTATUS (MOXA + 65) 20 - #define MOXA_SET_OP_MODE (MOXA + 66) 21 - #define MOXA_GET_OP_MODE (MOXA + 67) 22 - 23 - #define RS232_MODE 0 24 - #define RS485_2WIRE_MODE 1 25 - #define RS422_MODE 2 26 - #define RS485_4WIRE_MODE 3 27 - #define OP_MODE_MASK 3 28 - 29 - #define MOXA_SDS_RSTICOUNTER (MOXA + 69) 30 - #define MOXA_ASPP_OQUEUE (MOXA + 70) 31 - #define MOXA_ASPP_MON (MOXA + 73) 32 - #define MOXA_ASPP_LSTATUS (MOXA + 74) 33 - #define MOXA_ASPP_MON_EXT (MOXA + 75) 34 - #define MOXA_SET_BAUD_METHOD (MOXA + 76) 35 - 36 - /* --------------------------------------------------- */ 37 - 38 - #define NPPI_NOTIFY_PARITY 0x01 39 - #define NPPI_NOTIFY_FRAMING 0x02 40 - #define NPPI_NOTIFY_HW_OVERRUN 0x04 41 - #define NPPI_NOTIFY_SW_OVERRUN 0x08 42 - #define NPPI_NOTIFY_BREAK 0x10 43 - 44 - #define NPPI_NOTIFY_CTSHOLD 0x01 /* Tx hold by CTS low */ 45 - #define NPPI_NOTIFY_DSRHOLD 0x02 /* Tx hold by DSR low */ 46 - #define NPPI_NOTIFY_XOFFHOLD 0x08 /* Tx hold by Xoff received */ 47 - #define NPPI_NOTIFY_XOFFXENT 0x10 /* Xoff Sent */ 48 - 49 - /* follow just for Moxa Must chip define. */ 50 - /* */ 51 - /* when LCR register (offset 0x03) write following value, */ 52 - /* the Must chip will enter enchance mode. And write value */ 53 - /* on EFR (offset 0x02) bit 6,7 to change bank. */ 54 - #define MOXA_MUST_ENTER_ENCHANCE 0xBF 55 - 56 - /* when enhance mode enable, access on general bank register */ 57 - #define MOXA_MUST_GDL_REGISTER 0x07 58 - #define MOXA_MUST_GDL_MASK 0x7F 59 - #define MOXA_MUST_GDL_HAS_BAD_DATA 0x80 60 - 61 - #define MOXA_MUST_LSR_RERR 0x80 /* error in receive FIFO */ 62 - /* enchance register bank select and enchance mode setting register */ 63 - /* when LCR register equal to 0xBF */ 64 - #define MOXA_MUST_EFR_REGISTER 0x02 65 - /* enchance mode enable */ 66 - #define MOXA_MUST_EFR_EFRB_ENABLE 0x10 67 - /* enchance reister bank set 0, 1, 2 */ 68 - #define MOXA_MUST_EFR_BANK0 0x00 69 - #define MOXA_MUST_EFR_BANK1 0x40 70 - #define MOXA_MUST_EFR_BANK2 0x80 71 - #define MOXA_MUST_EFR_BANK3 0xC0 72 - #define MOXA_MUST_EFR_BANK_MASK 0xC0 73 - 74 - /* set XON1 value register, when LCR=0xBF and change to bank0 */ 75 - #define MOXA_MUST_XON1_REGISTER 0x04 76 - 77 - /* set XON2 value register, when LCR=0xBF and change to bank0 */ 78 - #define MOXA_MUST_XON2_REGISTER 0x05 79 - 80 - /* set XOFF1 value register, when LCR=0xBF and change to bank0 */ 81 - #define MOXA_MUST_XOFF1_REGISTER 0x06 82 - 83 - /* set XOFF2 value register, when LCR=0xBF and change to bank0 */ 84 - #define MOXA_MUST_XOFF2_REGISTER 0x07 85 - 86 - #define MOXA_MUST_RBRTL_REGISTER 0x04 87 - #define MOXA_MUST_RBRTH_REGISTER 0x05 88 - #define MOXA_MUST_RBRTI_REGISTER 0x06 89 - #define MOXA_MUST_THRTL_REGISTER 0x07 90 - #define MOXA_MUST_ENUM_REGISTER 0x04 91 - #define MOXA_MUST_HWID_REGISTER 0x05 92 - #define MOXA_MUST_ECR_REGISTER 0x06 93 - #define MOXA_MUST_CSR_REGISTER 0x07 94 - 95 - /* good data mode enable */ 96 - #define MOXA_MUST_FCR_GDA_MODE_ENABLE 0x20 97 - /* only good data put into RxFIFO */ 98 - #define MOXA_MUST_FCR_GDA_ONLY_ENABLE 0x10 99 - 100 - /* enable CTS interrupt */ 101 - #define MOXA_MUST_IER_ECTSI 0x80 102 - /* enable RTS interrupt */ 103 - #define MOXA_MUST_IER_ERTSI 0x40 104 - /* enable Xon/Xoff interrupt */ 105 - #define MOXA_MUST_IER_XINT 0x20 106 - /* enable GDA interrupt */ 107 - #define MOXA_MUST_IER_EGDAI 0x10 108 - 109 - #define MOXA_MUST_RECV_ISR (UART_IER_RDI | MOXA_MUST_IER_EGDAI) 110 - 111 - /* GDA interrupt pending */ 112 - #define MOXA_MUST_IIR_GDA 0x1C 113 - #define MOXA_MUST_IIR_RDA 0x04 114 - #define MOXA_MUST_IIR_RTO 0x0C 115 - #define MOXA_MUST_IIR_LSR 0x06 116 - 117 - /* received Xon/Xoff or specical interrupt pending */ 118 - #define MOXA_MUST_IIR_XSC 0x10 119 - 120 - /* RTS/CTS change state interrupt pending */ 121 - #define MOXA_MUST_IIR_RTSCTS 0x20 122 - #define MOXA_MUST_IIR_MASK 0x3E 123 - 124 - #define MOXA_MUST_MCR_XON_FLAG 0x40 125 - #define MOXA_MUST_MCR_XON_ANY 0x80 126 - #define MOXA_MUST_MCR_TX_XON 0x08 127 - 128 - /* software flow control on chip mask value */ 129 - #define MOXA_MUST_EFR_SF_MASK 0x0F 130 - /* send Xon1/Xoff1 */ 131 - #define MOXA_MUST_EFR_SF_TX1 0x08 132 - /* send Xon2/Xoff2 */ 133 - #define MOXA_MUST_EFR_SF_TX2 0x04 134 - /* send Xon1,Xon2/Xoff1,Xoff2 */ 135 - #define MOXA_MUST_EFR_SF_TX12 0x0C 136 - /* don't send Xon/Xoff */ 137 - #define MOXA_MUST_EFR_SF_TX_NO 0x00 138 - /* Tx software flow control mask */ 139 - #define MOXA_MUST_EFR_SF_TX_MASK 0x0C 140 - /* don't receive Xon/Xoff */ 141 - #define MOXA_MUST_EFR_SF_RX_NO 0x00 142 - /* receive Xon1/Xoff1 */ 143 - #define MOXA_MUST_EFR_SF_RX1 0x02 144 - /* receive Xon2/Xoff2 */ 145 - #define MOXA_MUST_EFR_SF_RX2 0x01 146 - /* receive Xon1,Xon2/Xoff1,Xoff2 */ 147 - #define MOXA_MUST_EFR_SF_RX12 0x03 148 - /* Rx software flow control mask */ 149 - #define MOXA_MUST_EFR_SF_RX_MASK 0x03 150 - 151 - #endif
+19 -15
drivers/tty/n_gsm.c
··· 512 512 */ 513 513 514 514 /** 515 - * gsm_stuff_packet - bytestuff a packet 515 + * gsm_stuff_frame - bytestuff a packet 516 516 * @input: input buffer 517 517 * @output: output buffer 518 518 * @len: length of input ··· 1594 1594 } 1595 1595 1596 1596 /** 1597 - * gsm_dlci_control - data arrived on control channel 1597 + * gsm_dlci_command - data arrived on control channel 1598 1598 * @dlci: channel 1599 1599 * @data: block of bytes received 1600 1600 * @len: length of received block ··· 2424 2424 } 2425 2425 2426 2426 static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp, 2427 - char *fp, int count) 2427 + const char *fp, int count) 2428 2428 { 2429 2429 struct gsm_mux *gsm = tty->disc_data; 2430 2430 char flags = TTY_NORMAL; ··· 2557 2557 * @file: file object 2558 2558 * @buf: userspace buffer pointer 2559 2559 * @nr: size of I/O 2560 + * @cookie: unused 2561 + * @offset: unused 2560 2562 * 2561 2563 * Perform reads for the line discipline. We are guaranteed that the 2562 2564 * line discipline will not be closed under us but we may get multiple ··· 2859 2857 /* Line discipline for real tty */ 2860 2858 static struct tty_ldisc_ops tty_ldisc_packet = { 2861 2859 .owner = THIS_MODULE, 2860 + .num = N_GSM0710, 2862 2861 .name = "n_gsm", 2863 2862 .open = gsmld_open, 2864 2863 .close = gsmld_close, ··· 3058 3055 return sent; 3059 3056 } 3060 3057 3061 - static int gsmtty_write_room(struct tty_struct *tty) 3058 + static unsigned int gsmtty_write_room(struct tty_struct *tty) 3062 3059 { 3063 3060 struct gsm_dlci *dlci = tty->driver_data; 3064 3061 if (dlci->state == DLCI_CLOSED) ··· 3066 3063 return TX_SIZE - kfifo_len(&dlci->fifo); 3067 3064 } 3068 3065 3069 - static int gsmtty_chars_in_buffer(struct tty_struct *tty) 3066 + static unsigned int gsmtty_chars_in_buffer(struct tty_struct *tty) 3070 3067 { 3071 3068 struct gsm_dlci *dlci = tty->driver_data; 3072 3069 if (dlci->state == DLCI_CLOSED) ··· 3245 3242 static int __init gsm_init(void) 3246 3243 { 3247 3244 /* Fill in our line protocol discipline, and register it */ 3248 - int status = tty_register_ldisc(N_GSM0710, &tty_ldisc_packet); 3245 + int status = tty_register_ldisc(&tty_ldisc_packet); 3249 3246 if (status != 0) { 3250 3247 pr_err("n_gsm: can't register line discipline (err = %d)\n", 3251 3248 status); ··· 3254 3251 3255 3252 gsm_tty_driver = alloc_tty_driver(256); 3256 3253 if (!gsm_tty_driver) { 3257 - tty_unregister_ldisc(N_GSM0710); 3258 3254 pr_err("gsm_init: tty allocation failed.\n"); 3259 - return -EINVAL; 3255 + status = -ENOMEM; 3256 + goto err_unreg_ldisc; 3260 3257 } 3261 3258 gsm_tty_driver->driver_name = "gsmtty"; 3262 3259 gsm_tty_driver->name = "gsmtty"; ··· 3272 3269 tty_set_operations(gsm_tty_driver, &gsmtty_ops); 3273 3270 3274 3271 if (tty_register_driver(gsm_tty_driver)) { 3275 - put_tty_driver(gsm_tty_driver); 3276 - tty_unregister_ldisc(N_GSM0710); 3277 3272 pr_err("gsm_init: tty registration failed.\n"); 3278 - return -EBUSY; 3273 + status = -EBUSY; 3274 + goto err_put_driver; 3279 3275 } 3280 3276 pr_debug("gsm_init: loaded as %d,%d.\n", 3281 3277 gsm_tty_driver->major, gsm_tty_driver->minor_start); 3282 3278 return 0; 3279 + err_put_driver: 3280 + put_tty_driver(gsm_tty_driver); 3281 + err_unreg_ldisc: 3282 + tty_unregister_ldisc(&tty_ldisc_packet); 3283 + return status; 3283 3284 } 3284 3285 3285 3286 static void __exit gsm_exit(void) 3286 3287 { 3287 - int status = tty_unregister_ldisc(N_GSM0710); 3288 - if (status != 0) 3289 - pr_err("n_gsm: can't unregister line discipline (err = %d)\n", 3290 - status); 3288 + tty_unregister_ldisc(&tty_ldisc_packet); 3291 3289 tty_unregister_driver(gsm_tty_driver); 3292 3290 put_tty_driver(gsm_tty_driver); 3293 3291 }
+7 -11
drivers/tty/n_hdlc.c
··· 358 358 * interpreted as one HDLC frame. 359 359 */ 360 360 static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data, 361 - char *flags, int count) 361 + const char *flags, int count) 362 362 { 363 363 register struct n_hdlc *n_hdlc = tty->disc_data; 364 364 register struct n_hdlc_buf *buf; ··· 411 411 * n_hdlc_tty_read - Called to retrieve one frame of data (if available) 412 412 * @tty: pointer to tty instance data 413 413 * @file: pointer to open file object 414 - * @buf: pointer to returned data buffer 414 + * @kbuf: pointer to returned data buffer 415 415 * @nr: size of returned data buffer 416 + * @cookie: stored rbuf from previous run 417 + * @offset: offset into the data buffer 416 418 * 417 419 * Returns the number of bytes returned or error code. 418 420 */ ··· 790 788 791 789 static struct tty_ldisc_ops n_hdlc_ldisc = { 792 790 .owner = THIS_MODULE, 791 + .num = N_HDLC, 793 792 .name = "hdlc", 794 793 .open = n_hdlc_tty_open, 795 794 .close = n_hdlc_tty_close, ··· 810 807 /* range check maxframe arg */ 811 808 maxframe = clamp(maxframe, 4096, MAX_HDLC_FRAME_SIZE); 812 809 813 - status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc); 810 + status = tty_register_ldisc(&n_hdlc_ldisc); 814 811 if (!status) 815 812 pr_info("N_HDLC line discipline registered with maxframe=%d\n", 816 813 maxframe); ··· 824 821 825 822 static void __exit n_hdlc_exit(void) 826 823 { 827 - /* Release tty registration of line discipline */ 828 - int status = tty_unregister_ldisc(N_HDLC); 829 - 830 - if (status) 831 - pr_err("N_HDLC: can't unregister line discipline (err = %d)\n", 832 - status); 833 - else 834 - pr_info("N_HDLC: line discipline unregistered\n"); 824 + tty_unregister_ldisc(&n_hdlc_ldisc); 835 825 } 836 826 837 827 module_init(n_hdlc_init);
+4 -3
drivers/tty/n_null.c
··· 33 33 } 34 34 35 35 static void n_null_receivebuf(struct tty_struct *tty, 36 - const unsigned char *cp, char *fp, 36 + const unsigned char *cp, const char *fp, 37 37 int cnt) 38 38 { 39 39 } 40 40 41 41 static struct tty_ldisc_ops null_ldisc = { 42 42 .owner = THIS_MODULE, 43 + .num = N_NULL, 43 44 .name = "n_null", 44 45 .open = n_null_open, 45 46 .close = n_null_close, ··· 51 50 52 51 static int __init n_null_init(void) 53 52 { 54 - BUG_ON(tty_register_ldisc(N_NULL, &null_ldisc)); 53 + BUG_ON(tty_register_ldisc(&null_ldisc)); 55 54 return 0; 56 55 } 57 56 58 57 static void __exit n_null_exit(void) 59 58 { 60 - tty_unregister_ldisc(N_NULL); 59 + tty_unregister_ldisc(&null_ldisc); 61 60 } 62 61 63 62 module_init(n_null_init);
-1283
drivers/tty/n_r3964.c
··· 1 - // SPDX-License-Identifier: GPL-1.0+ 2 - /* r3964 linediscipline for linux 3 - * 4 - * ----------------------------------------------------------- 5 - * Copyright by 6 - * Philips Automation Projects 7 - * Kassel (Germany) 8 - * ----------------------------------------------------------- 9 - * Author: 10 - * L. Haag 11 - * 12 - * $Log: n_r3964.c,v $ 13 - * Revision 1.10 2001/03/18 13:02:24 dwmw2 14 - * Fix timer usage, use spinlocks properly. 15 - * 16 - * Revision 1.9 2001/03/18 12:52:14 dwmw2 17 - * Merge changes in 2.4.2 18 - * 19 - * Revision 1.8 2000/03/23 14:14:54 dwmw2 20 - * Fix race in sleeping in r3964_read() 21 - * 22 - * Revision 1.7 1999/28/08 11:41:50 dwmw2 23 - * Port to 2.3 kernel 24 - * 25 - * Revision 1.6 1998/09/30 00:40:40 dwmw2 26 - * Fixed compilation on 2.0.x kernels 27 - * Updated to newly registered tty-ldisc number 9 28 - * 29 - * Revision 1.5 1998/09/04 21:57:36 dwmw2 30 - * Signal handling bug fixes, port to 2.1.x. 31 - * 32 - * Revision 1.4 1998/04/02 20:26:59 lhaag 33 - * select, blocking, ... 34 - * 35 - * Revision 1.3 1998/02/12 18:58:43 root 36 - * fixed some memory leaks 37 - * calculation of checksum characters 38 - * 39 - * Revision 1.2 1998/02/07 13:03:34 root 40 - * ioctl read_telegram 41 - * 42 - * Revision 1.1 1998/02/06 19:21:03 root 43 - * Initial revision 44 - * 45 - * 46 - */ 47 - 48 - #include <linux/module.h> 49 - #include <linux/kernel.h> 50 - #include <linux/sched.h> 51 - #include <linux/types.h> 52 - #include <linux/fcntl.h> 53 - #include <linux/interrupt.h> 54 - #include <linux/ptrace.h> 55 - #include <linux/ioport.h> 56 - #include <linux/in.h> 57 - #include <linux/slab.h> 58 - #include <linux/tty.h> 59 - #include <linux/errno.h> 60 - #include <linux/string.h> /* used in new tty drivers */ 61 - #include <linux/signal.h> /* used in new tty drivers */ 62 - #include <linux/ioctl.h> 63 - #include <linux/n_r3964.h> 64 - #include <linux/poll.h> 65 - #include <linux/init.h> 66 - #include <linux/uaccess.h> 67 - 68 - /*#define DEBUG_QUEUE*/ 69 - 70 - /* Log successful handshake and protocol operations */ 71 - /*#define DEBUG_PROTO_S*/ 72 - 73 - /* Log handshake and protocol errors: */ 74 - /*#define DEBUG_PROTO_E*/ 75 - 76 - /* Log Linediscipline operations (open, close, read, write...): */ 77 - /*#define DEBUG_LDISC*/ 78 - 79 - /* Log module and memory operations (init, cleanup; kmalloc, kfree): */ 80 - /*#define DEBUG_MODUL*/ 81 - 82 - /* Macro helpers for debug output: */ 83 - #define TRACE(format, args...) printk("r3964: " format "\n" , ## args) 84 - 85 - #ifdef DEBUG_MODUL 86 - #define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args) 87 - #else 88 - #define TRACE_M(fmt, arg...) do {} while (0) 89 - #endif 90 - #ifdef DEBUG_PROTO_S 91 - #define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args) 92 - #else 93 - #define TRACE_PS(fmt, arg...) do {} while (0) 94 - #endif 95 - #ifdef DEBUG_PROTO_E 96 - #define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args) 97 - #else 98 - #define TRACE_PE(fmt, arg...) do {} while (0) 99 - #endif 100 - #ifdef DEBUG_LDISC 101 - #define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args) 102 - #else 103 - #define TRACE_L(fmt, arg...) do {} while (0) 104 - #endif 105 - #ifdef DEBUG_QUEUE 106 - #define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args) 107 - #else 108 - #define TRACE_Q(fmt, arg...) do {} while (0) 109 - #endif 110 - static void add_tx_queue(struct r3964_info *, struct r3964_block_header *); 111 - static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code); 112 - static void put_char(struct r3964_info *pInfo, unsigned char ch); 113 - static void trigger_transmit(struct r3964_info *pInfo); 114 - static void retry_transmit(struct r3964_info *pInfo); 115 - static void transmit_block(struct r3964_info *pInfo); 116 - static void receive_char(struct r3964_info *pInfo, const unsigned char c); 117 - static void receive_error(struct r3964_info *pInfo, const char flag); 118 - static void on_timeout(struct timer_list *t); 119 - static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg); 120 - static int read_telegram(struct r3964_info *pInfo, struct pid *pid, 121 - unsigned char __user * buf); 122 - static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, 123 - int error_code, struct r3964_block_header *pBlock); 124 - static struct r3964_message *remove_msg(struct r3964_info *pInfo, 125 - struct r3964_client_info *pClient); 126 - static void remove_client_block(struct r3964_info *pInfo, 127 - struct r3964_client_info *pClient); 128 - 129 - static int r3964_open(struct tty_struct *tty); 130 - static void r3964_close(struct tty_struct *tty); 131 - static ssize_t r3964_read(struct tty_struct *tty, struct file *file, 132 - void *cookie, unsigned char *buf, size_t nr); 133 - static ssize_t r3964_write(struct tty_struct *tty, struct file *file, 134 - const unsigned char *buf, size_t nr); 135 - static int r3964_ioctl(struct tty_struct *tty, struct file *file, 136 - unsigned int cmd, unsigned long arg); 137 - #ifdef CONFIG_COMPAT 138 - static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file, 139 - unsigned int cmd, unsigned long arg); 140 - #endif 141 - static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old); 142 - static __poll_t r3964_poll(struct tty_struct *tty, struct file *file, 143 - struct poll_table_struct *wait); 144 - static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, 145 - char *fp, int count); 146 - 147 - static struct tty_ldisc_ops tty_ldisc_N_R3964 = { 148 - .owner = THIS_MODULE, 149 - .name = "R3964", 150 - .open = r3964_open, 151 - .close = r3964_close, 152 - .read = r3964_read, 153 - .write = r3964_write, 154 - .ioctl = r3964_ioctl, 155 - #ifdef CONFIG_COMPAT 156 - .compat_ioctl = r3964_compat_ioctl, 157 - #endif 158 - .set_termios = r3964_set_termios, 159 - .poll = r3964_poll, 160 - .receive_buf = r3964_receive_buf, 161 - }; 162 - 163 - static void dump_block(const unsigned char *block, unsigned int length) 164 - { 165 - unsigned int i, j; 166 - char linebuf[16 * 3 + 1]; 167 - 168 - for (i = 0; i < length; i += 16) { 169 - for (j = 0; (j < 16) && (j + i < length); j++) { 170 - sprintf(linebuf + 3 * j, "%02x ", block[i + j]); 171 - } 172 - linebuf[3 * j] = '\0'; 173 - TRACE_PS("%s", linebuf); 174 - } 175 - } 176 - 177 - /************************************************************* 178 - * Driver initialisation 179 - *************************************************************/ 180 - 181 - /************************************************************* 182 - * Module support routines 183 - *************************************************************/ 184 - 185 - static void __exit r3964_exit(void) 186 - { 187 - int status; 188 - 189 - TRACE_M("cleanup_module()"); 190 - 191 - status = tty_unregister_ldisc(N_R3964); 192 - 193 - if (status != 0) { 194 - printk(KERN_ERR "r3964: error unregistering linediscipline: " 195 - "%d\n", status); 196 - } else { 197 - TRACE_L("linediscipline successfully unregistered"); 198 - } 199 - } 200 - 201 - static int __init r3964_init(void) 202 - { 203 - int status; 204 - 205 - printk("r3964: Philips r3964 Driver $Revision: 1.10 $\n"); 206 - 207 - /* 208 - * Register the tty line discipline 209 - */ 210 - 211 - status = tty_register_ldisc(N_R3964, &tty_ldisc_N_R3964); 212 - if (status == 0) { 213 - TRACE_L("line discipline %d registered", N_R3964); 214 - TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, 215 - tty_ldisc_N_R3964.num); 216 - TRACE_L("open=%p", tty_ldisc_N_R3964.open); 217 - TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964); 218 - } else { 219 - printk(KERN_ERR "r3964: error registering line discipline: " 220 - "%d\n", status); 221 - } 222 - return status; 223 - } 224 - 225 - module_init(r3964_init); 226 - module_exit(r3964_exit); 227 - 228 - /************************************************************* 229 - * Protocol implementation routines 230 - *************************************************************/ 231 - 232 - static void add_tx_queue(struct r3964_info *pInfo, 233 - struct r3964_block_header *pHeader) 234 - { 235 - unsigned long flags; 236 - 237 - spin_lock_irqsave(&pInfo->lock, flags); 238 - 239 - pHeader->next = NULL; 240 - 241 - if (pInfo->tx_last == NULL) { 242 - pInfo->tx_first = pInfo->tx_last = pHeader; 243 - } else { 244 - pInfo->tx_last->next = pHeader; 245 - pInfo->tx_last = pHeader; 246 - } 247 - 248 - spin_unlock_irqrestore(&pInfo->lock, flags); 249 - 250 - TRACE_Q("add_tx_queue %p, length %d, tx_first = %p", 251 - pHeader, pHeader->length, pInfo->tx_first); 252 - } 253 - 254 - static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) 255 - { 256 - struct r3964_block_header *pHeader; 257 - unsigned long flags; 258 - #ifdef DEBUG_QUEUE 259 - struct r3964_block_header *pDump; 260 - #endif 261 - 262 - pHeader = pInfo->tx_first; 263 - 264 - if (pHeader == NULL) 265 - return; 266 - 267 - #ifdef DEBUG_QUEUE 268 - printk("r3964: remove_from_tx_queue: %p, length %u - ", 269 - pHeader, pHeader->length); 270 - for (pDump = pHeader; pDump; pDump = pDump->next) 271 - printk("%p ", pDump); 272 - printk("\n"); 273 - #endif 274 - 275 - if (pHeader->owner) { 276 - if (error_code) { 277 - add_msg(pHeader->owner, R3964_MSG_ACK, 0, 278 - error_code, NULL); 279 - } else { 280 - add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length, 281 - error_code, NULL); 282 - } 283 - wake_up_interruptible(&pInfo->tty->read_wait); 284 - } 285 - 286 - spin_lock_irqsave(&pInfo->lock, flags); 287 - 288 - pInfo->tx_first = pHeader->next; 289 - if (pInfo->tx_first == NULL) { 290 - pInfo->tx_last = NULL; 291 - } 292 - 293 - spin_unlock_irqrestore(&pInfo->lock, flags); 294 - 295 - kfree(pHeader); 296 - TRACE_M("remove_from_tx_queue - kfree %p", pHeader); 297 - 298 - TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p", 299 - pInfo->tx_first, pInfo->tx_last); 300 - } 301 - 302 - static void add_rx_queue(struct r3964_info *pInfo, 303 - struct r3964_block_header *pHeader) 304 - { 305 - unsigned long flags; 306 - 307 - spin_lock_irqsave(&pInfo->lock, flags); 308 - 309 - pHeader->next = NULL; 310 - 311 - if (pInfo->rx_last == NULL) { 312 - pInfo->rx_first = pInfo->rx_last = pHeader; 313 - } else { 314 - pInfo->rx_last->next = pHeader; 315 - pInfo->rx_last = pHeader; 316 - } 317 - pInfo->blocks_in_rx_queue++; 318 - 319 - spin_unlock_irqrestore(&pInfo->lock, flags); 320 - 321 - TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d", 322 - pHeader, pHeader->length, 323 - pInfo->rx_first, pInfo->blocks_in_rx_queue); 324 - } 325 - 326 - static void remove_from_rx_queue(struct r3964_info *pInfo, 327 - struct r3964_block_header *pHeader) 328 - { 329 - unsigned long flags; 330 - struct r3964_block_header *pFind; 331 - 332 - if (pHeader == NULL) 333 - return; 334 - 335 - TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", 336 - pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue); 337 - TRACE_Q("remove_from_rx_queue: %p, length %u", 338 - pHeader, pHeader->length); 339 - 340 - spin_lock_irqsave(&pInfo->lock, flags); 341 - 342 - if (pInfo->rx_first == pHeader) { 343 - /* Remove the first block in the linked list: */ 344 - pInfo->rx_first = pHeader->next; 345 - 346 - if (pInfo->rx_first == NULL) { 347 - pInfo->rx_last = NULL; 348 - } 349 - pInfo->blocks_in_rx_queue--; 350 - } else { 351 - /* Find block to remove: */ 352 - for (pFind = pInfo->rx_first; pFind; pFind = pFind->next) { 353 - if (pFind->next == pHeader) { 354 - /* Got it. */ 355 - pFind->next = pHeader->next; 356 - pInfo->blocks_in_rx_queue--; 357 - if (pFind->next == NULL) { 358 - /* Oh, removed the last one! */ 359 - pInfo->rx_last = pFind; 360 - } 361 - break; 362 - } 363 - } 364 - } 365 - 366 - spin_unlock_irqrestore(&pInfo->lock, flags); 367 - 368 - kfree(pHeader); 369 - TRACE_M("remove_from_rx_queue - kfree %p", pHeader); 370 - 371 - TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", 372 - pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue); 373 - } 374 - 375 - static void put_char(struct r3964_info *pInfo, unsigned char ch) 376 - { 377 - struct tty_struct *tty = pInfo->tty; 378 - /* FIXME: put_char should not be called from an IRQ */ 379 - tty_put_char(tty, ch); 380 - pInfo->bcc ^= ch; 381 - } 382 - 383 - static void flush(struct r3964_info *pInfo) 384 - { 385 - struct tty_struct *tty = pInfo->tty; 386 - 387 - if (tty == NULL || tty->ops->flush_chars == NULL) 388 - return; 389 - tty->ops->flush_chars(tty); 390 - } 391 - 392 - static void trigger_transmit(struct r3964_info *pInfo) 393 - { 394 - unsigned long flags; 395 - 396 - spin_lock_irqsave(&pInfo->lock, flags); 397 - 398 - if ((pInfo->state == R3964_IDLE) && (pInfo->tx_first != NULL)) { 399 - pInfo->state = R3964_TX_REQUEST; 400 - pInfo->nRetry = 0; 401 - pInfo->flags &= ~R3964_ERROR; 402 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ); 403 - 404 - spin_unlock_irqrestore(&pInfo->lock, flags); 405 - 406 - TRACE_PS("trigger_transmit - sent STX"); 407 - 408 - put_char(pInfo, STX); 409 - flush(pInfo); 410 - 411 - pInfo->bcc = 0; 412 - } else { 413 - spin_unlock_irqrestore(&pInfo->lock, flags); 414 - } 415 - } 416 - 417 - static void retry_transmit(struct r3964_info *pInfo) 418 - { 419 - if (pInfo->nRetry < R3964_MAX_RETRIES) { 420 - TRACE_PE("transmission failed. Retry #%d", pInfo->nRetry); 421 - pInfo->bcc = 0; 422 - put_char(pInfo, STX); 423 - flush(pInfo); 424 - pInfo->state = R3964_TX_REQUEST; 425 - pInfo->nRetry++; 426 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ); 427 - } else { 428 - TRACE_PE("transmission failed after %d retries", 429 - R3964_MAX_RETRIES); 430 - 431 - remove_from_tx_queue(pInfo, R3964_TX_FAIL); 432 - 433 - put_char(pInfo, NAK); 434 - flush(pInfo); 435 - pInfo->state = R3964_IDLE; 436 - 437 - trigger_transmit(pInfo); 438 - } 439 - } 440 - 441 - static void transmit_block(struct r3964_info *pInfo) 442 - { 443 - struct tty_struct *tty = pInfo->tty; 444 - struct r3964_block_header *pBlock = pInfo->tx_first; 445 - int room = 0; 446 - 447 - if (tty == NULL || pBlock == NULL) { 448 - return; 449 - } 450 - 451 - room = tty_write_room(tty); 452 - 453 - TRACE_PS("transmit_block %p, room %d, length %d", 454 - pBlock, room, pBlock->length); 455 - 456 - while (pInfo->tx_position < pBlock->length) { 457 - if (room < 2) 458 - break; 459 - 460 - if (pBlock->data[pInfo->tx_position] == DLE) { 461 - /* send additional DLE char: */ 462 - put_char(pInfo, DLE); 463 - } 464 - put_char(pInfo, pBlock->data[pInfo->tx_position++]); 465 - 466 - room--; 467 - } 468 - 469 - if ((pInfo->tx_position == pBlock->length) && (room >= 3)) { 470 - put_char(pInfo, DLE); 471 - put_char(pInfo, ETX); 472 - if (pInfo->flags & R3964_BCC) { 473 - put_char(pInfo, pInfo->bcc); 474 - } 475 - pInfo->state = R3964_WAIT_FOR_TX_ACK; 476 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ); 477 - } 478 - flush(pInfo); 479 - } 480 - 481 - static void on_receive_block(struct r3964_info *pInfo) 482 - { 483 - unsigned int length; 484 - struct r3964_client_info *pClient; 485 - struct r3964_block_header *pBlock; 486 - 487 - length = pInfo->rx_position; 488 - 489 - /* compare byte checksum characters: */ 490 - if (pInfo->flags & R3964_BCC) { 491 - if (pInfo->bcc != pInfo->last_rx) { 492 - TRACE_PE("checksum error - got %x but expected %x", 493 - pInfo->last_rx, pInfo->bcc); 494 - pInfo->flags |= R3964_CHECKSUM; 495 - } 496 - } 497 - 498 - /* check for errors (parity, overrun,...): */ 499 - if (pInfo->flags & R3964_ERROR) { 500 - TRACE_PE("on_receive_block - transmission failed error %x", 501 - pInfo->flags & R3964_ERROR); 502 - 503 - put_char(pInfo, NAK); 504 - flush(pInfo); 505 - if (pInfo->nRetry < R3964_MAX_RETRIES) { 506 - pInfo->state = R3964_WAIT_FOR_RX_REPEAT; 507 - pInfo->nRetry++; 508 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC); 509 - } else { 510 - TRACE_PE("on_receive_block - failed after max retries"); 511 - pInfo->state = R3964_IDLE; 512 - } 513 - return; 514 - } 515 - 516 - /* received block; submit DLE: */ 517 - put_char(pInfo, DLE); 518 - flush(pInfo); 519 - del_timer_sync(&pInfo->tmr); 520 - TRACE_PS(" rx success: got %d chars", length); 521 - 522 - /* prepare struct r3964_block_header: */ 523 - pBlock = kmalloc(length + sizeof(struct r3964_block_header), 524 - GFP_KERNEL); 525 - TRACE_M("on_receive_block - kmalloc %p", pBlock); 526 - 527 - if (pBlock == NULL) 528 - return; 529 - 530 - pBlock->length = length; 531 - pBlock->data = ((unsigned char *)pBlock) + 532 - sizeof(struct r3964_block_header); 533 - pBlock->locks = 0; 534 - pBlock->next = NULL; 535 - pBlock->owner = NULL; 536 - 537 - memcpy(pBlock->data, pInfo->rx_buf, length); 538 - 539 - /* queue block into rx_queue: */ 540 - add_rx_queue(pInfo, pBlock); 541 - 542 - /* notify attached client processes: */ 543 - for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) { 544 - if (pClient->sig_flags & R3964_SIG_DATA) { 545 - add_msg(pClient, R3964_MSG_DATA, length, R3964_OK, 546 - pBlock); 547 - } 548 - } 549 - wake_up_interruptible(&pInfo->tty->read_wait); 550 - 551 - pInfo->state = R3964_IDLE; 552 - 553 - trigger_transmit(pInfo); 554 - } 555 - 556 - static void receive_char(struct r3964_info *pInfo, const unsigned char c) 557 - { 558 - switch (pInfo->state) { 559 - case R3964_TX_REQUEST: 560 - if (c == DLE) { 561 - TRACE_PS("TX_REQUEST - got DLE"); 562 - 563 - pInfo->state = R3964_TRANSMITTING; 564 - pInfo->tx_position = 0; 565 - 566 - transmit_block(pInfo); 567 - } else if (c == STX) { 568 - if (pInfo->nRetry == 0) { 569 - TRACE_PE("TX_REQUEST - init conflict"); 570 - if (pInfo->priority == R3964_SLAVE) { 571 - goto start_receiving; 572 - } 573 - } else { 574 - TRACE_PE("TX_REQUEST - secondary init " 575 - "conflict!? Switching to SLAVE mode " 576 - "for next rx."); 577 - goto start_receiving; 578 - } 579 - } else { 580 - TRACE_PE("TX_REQUEST - char != DLE: %x", c); 581 - retry_transmit(pInfo); 582 - } 583 - break; 584 - case R3964_TRANSMITTING: 585 - if (c == NAK) { 586 - TRACE_PE("TRANSMITTING - got NAK"); 587 - retry_transmit(pInfo); 588 - } else { 589 - TRACE_PE("TRANSMITTING - got invalid char"); 590 - 591 - pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY; 592 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 593 - } 594 - break; 595 - case R3964_WAIT_FOR_TX_ACK: 596 - if (c == DLE) { 597 - TRACE_PS("WAIT_FOR_TX_ACK - got DLE"); 598 - remove_from_tx_queue(pInfo, R3964_OK); 599 - 600 - pInfo->state = R3964_IDLE; 601 - trigger_transmit(pInfo); 602 - } else { 603 - retry_transmit(pInfo); 604 - } 605 - break; 606 - case R3964_WAIT_FOR_RX_REPEAT: 607 - case R3964_IDLE: 608 - if (c == STX) { 609 - /* Prevent rx_queue from overflow: */ 610 - if (pInfo->blocks_in_rx_queue >= 611 - R3964_MAX_BLOCKS_IN_RX_QUEUE) { 612 - TRACE_PE("IDLE - got STX but no space in " 613 - "rx_queue!"); 614 - pInfo->state = R3964_WAIT_FOR_RX_BUF; 615 - mod_timer(&pInfo->tmr, 616 - jiffies + R3964_TO_NO_BUF); 617 - break; 618 - } 619 - start_receiving: 620 - /* Ok, start receiving: */ 621 - TRACE_PS("IDLE - got STX"); 622 - pInfo->rx_position = 0; 623 - pInfo->last_rx = 0; 624 - pInfo->flags &= ~R3964_ERROR; 625 - pInfo->state = R3964_RECEIVING; 626 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 627 - pInfo->nRetry = 0; 628 - put_char(pInfo, DLE); 629 - flush(pInfo); 630 - pInfo->bcc = 0; 631 - } 632 - break; 633 - case R3964_RECEIVING: 634 - if (pInfo->rx_position < RX_BUF_SIZE) { 635 - pInfo->bcc ^= c; 636 - 637 - if (c == DLE) { 638 - if (pInfo->last_rx == DLE) { 639 - pInfo->last_rx = 0; 640 - goto char_to_buf; 641 - } 642 - pInfo->last_rx = DLE; 643 - break; 644 - } else if ((c == ETX) && (pInfo->last_rx == DLE)) { 645 - if (pInfo->flags & R3964_BCC) { 646 - pInfo->state = R3964_WAIT_FOR_BCC; 647 - mod_timer(&pInfo->tmr, 648 - jiffies + R3964_TO_ZVZ); 649 - } else { 650 - on_receive_block(pInfo); 651 - } 652 - } else { 653 - pInfo->last_rx = c; 654 - char_to_buf: 655 - pInfo->rx_buf[pInfo->rx_position++] = c; 656 - mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 657 - } 658 - } 659 - /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */ 660 - break; 661 - case R3964_WAIT_FOR_BCC: 662 - pInfo->last_rx = c; 663 - on_receive_block(pInfo); 664 - break; 665 - } 666 - } 667 - 668 - static void receive_error(struct r3964_info *pInfo, const char flag) 669 - { 670 - switch (flag) { 671 - case TTY_NORMAL: 672 - break; 673 - case TTY_BREAK: 674 - TRACE_PE("received break"); 675 - pInfo->flags |= R3964_BREAK; 676 - break; 677 - case TTY_PARITY: 678 - TRACE_PE("parity error"); 679 - pInfo->flags |= R3964_PARITY; 680 - break; 681 - case TTY_FRAME: 682 - TRACE_PE("frame error"); 683 - pInfo->flags |= R3964_FRAME; 684 - break; 685 - case TTY_OVERRUN: 686 - TRACE_PE("frame overrun"); 687 - pInfo->flags |= R3964_OVERRUN; 688 - break; 689 - default: 690 - TRACE_PE("receive_error - unknown flag %d", flag); 691 - pInfo->flags |= R3964_UNKNOWN; 692 - break; 693 - } 694 - } 695 - 696 - static void on_timeout(struct timer_list *t) 697 - { 698 - struct r3964_info *pInfo = from_timer(pInfo, t, tmr); 699 - 700 - switch (pInfo->state) { 701 - case R3964_TX_REQUEST: 702 - TRACE_PE("TX_REQUEST - timeout"); 703 - retry_transmit(pInfo); 704 - break; 705 - case R3964_WAIT_ZVZ_BEFORE_TX_RETRY: 706 - put_char(pInfo, NAK); 707 - flush(pInfo); 708 - retry_transmit(pInfo); 709 - break; 710 - case R3964_WAIT_FOR_TX_ACK: 711 - TRACE_PE("WAIT_FOR_TX_ACK - timeout"); 712 - retry_transmit(pInfo); 713 - break; 714 - case R3964_WAIT_FOR_RX_BUF: 715 - TRACE_PE("WAIT_FOR_RX_BUF - timeout"); 716 - put_char(pInfo, NAK); 717 - flush(pInfo); 718 - pInfo->state = R3964_IDLE; 719 - break; 720 - case R3964_RECEIVING: 721 - TRACE_PE("RECEIVING - timeout after %d chars", 722 - pInfo->rx_position); 723 - put_char(pInfo, NAK); 724 - flush(pInfo); 725 - pInfo->state = R3964_IDLE; 726 - break; 727 - case R3964_WAIT_FOR_RX_REPEAT: 728 - TRACE_PE("WAIT_FOR_RX_REPEAT - timeout"); 729 - pInfo->state = R3964_IDLE; 730 - break; 731 - case R3964_WAIT_FOR_BCC: 732 - TRACE_PE("WAIT_FOR_BCC - timeout"); 733 - put_char(pInfo, NAK); 734 - flush(pInfo); 735 - pInfo->state = R3964_IDLE; 736 - break; 737 - } 738 - } 739 - 740 - static struct r3964_client_info *findClient(struct r3964_info *pInfo, 741 - struct pid *pid) 742 - { 743 - struct r3964_client_info *pClient; 744 - 745 - for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) { 746 - if (pClient->pid == pid) { 747 - return pClient; 748 - } 749 - } 750 - return NULL; 751 - } 752 - 753 - static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) 754 - { 755 - struct r3964_client_info *pClient; 756 - struct r3964_client_info **ppClient; 757 - struct r3964_message *pMsg; 758 - 759 - if ((arg & R3964_SIG_ALL) == 0) { 760 - /* Remove client from client list */ 761 - for (ppClient = &pInfo->firstClient; *ppClient; 762 - ppClient = &(*ppClient)->next) { 763 - pClient = *ppClient; 764 - 765 - if (pClient->pid == pid) { 766 - TRACE_PS("removing client %d from client list", 767 - pid_nr(pid)); 768 - *ppClient = pClient->next; 769 - while (pClient->msg_count) { 770 - pMsg = remove_msg(pInfo, pClient); 771 - if (pMsg) { 772 - kfree(pMsg); 773 - TRACE_M("enable_signals - msg " 774 - "kfree %p", pMsg); 775 - } 776 - } 777 - put_pid(pClient->pid); 778 - kfree(pClient); 779 - TRACE_M("enable_signals - kfree %p", pClient); 780 - return 0; 781 - } 782 - } 783 - return -EINVAL; 784 - } else { 785 - pClient = findClient(pInfo, pid); 786 - if (pClient) { 787 - /* update signal options */ 788 - pClient->sig_flags = arg; 789 - } else { 790 - /* add client to client list */ 791 - pClient = kmalloc(sizeof(struct r3964_client_info), 792 - GFP_KERNEL); 793 - TRACE_M("enable_signals - kmalloc %p", pClient); 794 - if (pClient == NULL) 795 - return -ENOMEM; 796 - 797 - TRACE_PS("add client %d to client list", pid_nr(pid)); 798 - spin_lock_init(&pClient->lock); 799 - pClient->sig_flags = arg; 800 - pClient->pid = get_pid(pid); 801 - pClient->next = pInfo->firstClient; 802 - pClient->first_msg = NULL; 803 - pClient->last_msg = NULL; 804 - pClient->next_block_to_read = NULL; 805 - pClient->msg_count = 0; 806 - pInfo->firstClient = pClient; 807 - } 808 - } 809 - 810 - return 0; 811 - } 812 - 813 - static int read_telegram(struct r3964_info *pInfo, struct pid *pid, 814 - unsigned char __user * buf) 815 - { 816 - struct r3964_client_info *pClient; 817 - struct r3964_block_header *block; 818 - 819 - if (!buf) { 820 - return -EINVAL; 821 - } 822 - 823 - pClient = findClient(pInfo, pid); 824 - if (pClient == NULL) { 825 - return -EINVAL; 826 - } 827 - 828 - block = pClient->next_block_to_read; 829 - if (!block) { 830 - return 0; 831 - } else { 832 - if (copy_to_user(buf, block->data, block->length)) 833 - return -EFAULT; 834 - 835 - remove_client_block(pInfo, pClient); 836 - return block->length; 837 - } 838 - 839 - return -EINVAL; 840 - } 841 - 842 - static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, 843 - int error_code, struct r3964_block_header *pBlock) 844 - { 845 - struct r3964_message *pMsg; 846 - unsigned long flags; 847 - 848 - if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) { 849 - queue_the_message: 850 - 851 - pMsg = kmalloc(sizeof(struct r3964_message), 852 - error_code ? GFP_ATOMIC : GFP_KERNEL); 853 - TRACE_M("add_msg - kmalloc %p", pMsg); 854 - if (pMsg == NULL) { 855 - return; 856 - } 857 - 858 - spin_lock_irqsave(&pClient->lock, flags); 859 - 860 - pMsg->msg_id = msg_id; 861 - pMsg->arg = arg; 862 - pMsg->error_code = error_code; 863 - pMsg->block = pBlock; 864 - pMsg->next = NULL; 865 - 866 - if (pClient->last_msg == NULL) { 867 - pClient->first_msg = pClient->last_msg = pMsg; 868 - } else { 869 - pClient->last_msg->next = pMsg; 870 - pClient->last_msg = pMsg; 871 - } 872 - 873 - pClient->msg_count++; 874 - 875 - if (pBlock != NULL) { 876 - pBlock->locks++; 877 - } 878 - spin_unlock_irqrestore(&pClient->lock, flags); 879 - } else { 880 - if ((pClient->last_msg->msg_id == R3964_MSG_ACK) 881 - && (pClient->last_msg->error_code == R3964_OVERFLOW)) { 882 - pClient->last_msg->arg++; 883 - TRACE_PE("add_msg - inc prev OVERFLOW-msg"); 884 - } else { 885 - msg_id = R3964_MSG_ACK; 886 - arg = 0; 887 - error_code = R3964_OVERFLOW; 888 - pBlock = NULL; 889 - TRACE_PE("add_msg - queue OVERFLOW-msg"); 890 - goto queue_the_message; 891 - } 892 - } 893 - /* Send SIGIO signal to client process: */ 894 - if (pClient->sig_flags & R3964_USE_SIGIO) { 895 - kill_pid(pClient->pid, SIGIO, 1); 896 - } 897 - } 898 - 899 - static struct r3964_message *remove_msg(struct r3964_info *pInfo, 900 - struct r3964_client_info *pClient) 901 - { 902 - struct r3964_message *pMsg = NULL; 903 - unsigned long flags; 904 - 905 - if (pClient->first_msg) { 906 - spin_lock_irqsave(&pClient->lock, flags); 907 - 908 - pMsg = pClient->first_msg; 909 - pClient->first_msg = pMsg->next; 910 - if (pClient->first_msg == NULL) { 911 - pClient->last_msg = NULL; 912 - } 913 - 914 - pClient->msg_count--; 915 - if (pMsg->block) { 916 - remove_client_block(pInfo, pClient); 917 - pClient->next_block_to_read = pMsg->block; 918 - } 919 - spin_unlock_irqrestore(&pClient->lock, flags); 920 - } 921 - return pMsg; 922 - } 923 - 924 - static void remove_client_block(struct r3964_info *pInfo, 925 - struct r3964_client_info *pClient) 926 - { 927 - struct r3964_block_header *block; 928 - 929 - TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid)); 930 - 931 - block = pClient->next_block_to_read; 932 - if (block) { 933 - block->locks--; 934 - if (block->locks == 0) { 935 - remove_from_rx_queue(pInfo, block); 936 - } 937 - } 938 - pClient->next_block_to_read = NULL; 939 - } 940 - 941 - /************************************************************* 942 - * Line discipline routines 943 - *************************************************************/ 944 - 945 - static int r3964_open(struct tty_struct *tty) 946 - { 947 - struct r3964_info *pInfo; 948 - 949 - TRACE_L("open"); 950 - TRACE_L("tty=%p, PID=%d, disc_data=%p", 951 - tty, current->pid, tty->disc_data); 952 - 953 - pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL); 954 - TRACE_M("r3964_open - info kmalloc %p", pInfo); 955 - 956 - if (!pInfo) { 957 - printk(KERN_ERR "r3964: failed to alloc info structure\n"); 958 - return -ENOMEM; 959 - } 960 - 961 - pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); 962 - TRACE_M("r3964_open - rx_buf kmalloc %p", pInfo->rx_buf); 963 - 964 - if (!pInfo->rx_buf) { 965 - printk(KERN_ERR "r3964: failed to alloc receive buffer\n"); 966 - kfree(pInfo); 967 - TRACE_M("r3964_open - info kfree %p", pInfo); 968 - return -ENOMEM; 969 - } 970 - 971 - pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL); 972 - TRACE_M("r3964_open - tx_buf kmalloc %p", pInfo->tx_buf); 973 - 974 - if (!pInfo->tx_buf) { 975 - printk(KERN_ERR "r3964: failed to alloc transmit buffer\n"); 976 - kfree(pInfo->rx_buf); 977 - TRACE_M("r3964_open - rx_buf kfree %p", pInfo->rx_buf); 978 - kfree(pInfo); 979 - TRACE_M("r3964_open - info kfree %p", pInfo); 980 - return -ENOMEM; 981 - } 982 - 983 - spin_lock_init(&pInfo->lock); 984 - mutex_init(&pInfo->read_lock); 985 - pInfo->tty = tty; 986 - pInfo->priority = R3964_MASTER; 987 - pInfo->rx_first = pInfo->rx_last = NULL; 988 - pInfo->tx_first = pInfo->tx_last = NULL; 989 - pInfo->rx_position = 0; 990 - pInfo->tx_position = 0; 991 - pInfo->last_rx = 0; 992 - pInfo->blocks_in_rx_queue = 0; 993 - pInfo->firstClient = NULL; 994 - pInfo->state = R3964_IDLE; 995 - pInfo->flags = R3964_DEBUG; 996 - pInfo->nRetry = 0; 997 - 998 - tty->disc_data = pInfo; 999 - tty->receive_room = 65536; 1000 - 1001 - timer_setup(&pInfo->tmr, on_timeout, 0); 1002 - 1003 - return 0; 1004 - } 1005 - 1006 - static void r3964_close(struct tty_struct *tty) 1007 - { 1008 - struct r3964_info *pInfo = tty->disc_data; 1009 - struct r3964_client_info *pClient, *pNext; 1010 - struct r3964_message *pMsg; 1011 - struct r3964_block_header *pHeader, *pNextHeader; 1012 - unsigned long flags; 1013 - 1014 - TRACE_L("close"); 1015 - 1016 - /* 1017 - * Make sure that our task queue isn't activated. If it 1018 - * is, take it out of the linked list. 1019 - */ 1020 - del_timer_sync(&pInfo->tmr); 1021 - 1022 - /* Remove client-structs and message queues: */ 1023 - pClient = pInfo->firstClient; 1024 - while (pClient) { 1025 - pNext = pClient->next; 1026 - while (pClient->msg_count) { 1027 - pMsg = remove_msg(pInfo, pClient); 1028 - if (pMsg) { 1029 - kfree(pMsg); 1030 - TRACE_M("r3964_close - msg kfree %p", pMsg); 1031 - } 1032 - } 1033 - put_pid(pClient->pid); 1034 - kfree(pClient); 1035 - TRACE_M("r3964_close - client kfree %p", pClient); 1036 - pClient = pNext; 1037 - } 1038 - /* Remove jobs from tx_queue: */ 1039 - spin_lock_irqsave(&pInfo->lock, flags); 1040 - pHeader = pInfo->tx_first; 1041 - pInfo->tx_first = pInfo->tx_last = NULL; 1042 - spin_unlock_irqrestore(&pInfo->lock, flags); 1043 - 1044 - while (pHeader) { 1045 - pNextHeader = pHeader->next; 1046 - kfree(pHeader); 1047 - pHeader = pNextHeader; 1048 - } 1049 - 1050 - /* Free buffers: */ 1051 - kfree(pInfo->rx_buf); 1052 - TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf); 1053 - kfree(pInfo->tx_buf); 1054 - TRACE_M("r3964_close - tx_buf kfree %p", pInfo->tx_buf); 1055 - kfree(pInfo); 1056 - TRACE_M("r3964_close - info kfree %p", pInfo); 1057 - } 1058 - 1059 - static ssize_t r3964_read(struct tty_struct *tty, struct file *file, 1060 - unsigned char *kbuf, size_t nr, 1061 - void **cookie, unsigned long offset) 1062 - { 1063 - struct r3964_info *pInfo = tty->disc_data; 1064 - struct r3964_client_info *pClient; 1065 - struct r3964_message *pMsg; 1066 - struct r3964_client_message theMsg; 1067 - int ret; 1068 - 1069 - TRACE_L("read()"); 1070 - 1071 - /* 1072 - * Internal serialization of reads. 1073 - */ 1074 - if (file->f_flags & O_NONBLOCK) { 1075 - if (!mutex_trylock(&pInfo->read_lock)) 1076 - return -EAGAIN; 1077 - } else { 1078 - if (mutex_lock_interruptible(&pInfo->read_lock)) 1079 - return -ERESTARTSYS; 1080 - } 1081 - 1082 - pClient = findClient(pInfo, task_pid(current)); 1083 - if (pClient) { 1084 - pMsg = remove_msg(pInfo, pClient); 1085 - if (pMsg == NULL) { 1086 - /* no messages available. */ 1087 - if (tty_io_nonblock(tty, file)) { 1088 - ret = -EAGAIN; 1089 - goto unlock; 1090 - } 1091 - /* block until there is a message: */ 1092 - wait_event_interruptible(tty->read_wait, 1093 - (pMsg = remove_msg(pInfo, pClient))); 1094 - } 1095 - 1096 - /* If we still haven't got a message, we must have been signalled */ 1097 - 1098 - if (!pMsg) { 1099 - ret = -EINTR; 1100 - goto unlock; 1101 - } 1102 - 1103 - /* deliver msg to client process: */ 1104 - theMsg.msg_id = pMsg->msg_id; 1105 - theMsg.arg = pMsg->arg; 1106 - theMsg.error_code = pMsg->error_code; 1107 - ret = sizeof(struct r3964_client_message); 1108 - 1109 - kfree(pMsg); 1110 - TRACE_M("r3964_read - msg kfree %p", pMsg); 1111 - 1112 - memcpy(kbuf, &theMsg, ret); 1113 - 1114 - TRACE_PS("read - return %d", ret); 1115 - goto unlock; 1116 - } 1117 - ret = -EPERM; 1118 - unlock: 1119 - mutex_unlock(&pInfo->read_lock); 1120 - return ret; 1121 - } 1122 - 1123 - static ssize_t r3964_write(struct tty_struct *tty, struct file *file, 1124 - const unsigned char *data, size_t count) 1125 - { 1126 - struct r3964_info *pInfo = tty->disc_data; 1127 - struct r3964_block_header *pHeader; 1128 - struct r3964_client_info *pClient; 1129 - unsigned char *new_data; 1130 - 1131 - TRACE_L("write request, %d characters", count); 1132 - /* 1133 - * Verify the pointers 1134 - */ 1135 - 1136 - if (!pInfo) 1137 - return -EIO; 1138 - 1139 - /* 1140 - * Ensure that the caller does not wish to send too much. 1141 - */ 1142 - if (count > R3964_MTU) { 1143 - if (pInfo->flags & R3964_DEBUG) { 1144 - TRACE_L(KERN_WARNING "r3964_write: truncating user " 1145 - "packet from %u to mtu %d", count, R3964_MTU); 1146 - } 1147 - count = R3964_MTU; 1148 - } 1149 - /* 1150 - * Allocate a buffer for the data and copy it from the buffer with header prepended 1151 - */ 1152 - new_data = kmalloc(count + sizeof(struct r3964_block_header), 1153 - GFP_KERNEL); 1154 - TRACE_M("r3964_write - kmalloc %p", new_data); 1155 - if (new_data == NULL) { 1156 - if (pInfo->flags & R3964_DEBUG) { 1157 - printk(KERN_ERR "r3964_write: no memory\n"); 1158 - } 1159 - return -ENOSPC; 1160 - } 1161 - 1162 - pHeader = (struct r3964_block_header *)new_data; 1163 - pHeader->data = new_data + sizeof(struct r3964_block_header); 1164 - pHeader->length = count; 1165 - pHeader->locks = 0; 1166 - pHeader->owner = NULL; 1167 - 1168 - pClient = findClient(pInfo, task_pid(current)); 1169 - if (pClient) { 1170 - pHeader->owner = pClient; 1171 - } 1172 - 1173 - memcpy(pHeader->data, data, count); /* We already verified this */ 1174 - 1175 - if (pInfo->flags & R3964_DEBUG) { 1176 - dump_block(pHeader->data, count); 1177 - } 1178 - 1179 - /* 1180 - * Add buffer to transmit-queue: 1181 - */ 1182 - add_tx_queue(pInfo, pHeader); 1183 - trigger_transmit(pInfo); 1184 - 1185 - return 0; 1186 - } 1187 - 1188 - static int r3964_ioctl(struct tty_struct *tty, struct file *file, 1189 - unsigned int cmd, unsigned long arg) 1190 - { 1191 - struct r3964_info *pInfo = tty->disc_data; 1192 - if (pInfo == NULL) 1193 - return -EINVAL; 1194 - switch (cmd) { 1195 - case R3964_ENABLE_SIGNALS: 1196 - return enable_signals(pInfo, task_pid(current), arg); 1197 - case R3964_SETPRIORITY: 1198 - if (arg < R3964_MASTER || arg > R3964_SLAVE) 1199 - return -EINVAL; 1200 - pInfo->priority = arg & 0xff; 1201 - return 0; 1202 - case R3964_USE_BCC: 1203 - if (arg) 1204 - pInfo->flags |= R3964_BCC; 1205 - else 1206 - pInfo->flags &= ~R3964_BCC; 1207 - return 0; 1208 - case R3964_READ_TELEGRAM: 1209 - return read_telegram(pInfo, task_pid(current), 1210 - (unsigned char __user *)arg); 1211 - default: 1212 - return -ENOIOCTLCMD; 1213 - } 1214 - } 1215 - 1216 - #ifdef CONFIG_COMPAT 1217 - static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file, 1218 - unsigned int cmd, unsigned long arg) 1219 - { 1220 - switch (cmd) { 1221 - case R3964_ENABLE_SIGNALS: 1222 - case R3964_SETPRIORITY: 1223 - case R3964_USE_BCC: 1224 - return r3964_ioctl(tty, file, cmd, arg); 1225 - default: 1226 - return -ENOIOCTLCMD; 1227 - } 1228 - } 1229 - #endif 1230 - 1231 - static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old) 1232 - { 1233 - TRACE_L("set_termios"); 1234 - } 1235 - 1236 - /* Called without the kernel lock held - fine */ 1237 - static __poll_t r3964_poll(struct tty_struct *tty, struct file *file, 1238 - struct poll_table_struct *wait) 1239 - { 1240 - struct r3964_info *pInfo = tty->disc_data; 1241 - struct r3964_client_info *pClient; 1242 - struct r3964_message *pMsg = NULL; 1243 - unsigned long flags; 1244 - __poll_t result = EPOLLOUT; 1245 - 1246 - TRACE_L("POLL"); 1247 - 1248 - pClient = findClient(pInfo, task_pid(current)); 1249 - if (pClient) { 1250 - poll_wait(file, &tty->read_wait, wait); 1251 - spin_lock_irqsave(&pInfo->lock, flags); 1252 - pMsg = pClient->first_msg; 1253 - spin_unlock_irqrestore(&pInfo->lock, flags); 1254 - if (pMsg) 1255 - result |= EPOLLIN | EPOLLRDNORM; 1256 - } else { 1257 - result = -EINVAL; 1258 - } 1259 - return result; 1260 - } 1261 - 1262 - static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1263 - char *fp, int count) 1264 - { 1265 - struct r3964_info *pInfo = tty->disc_data; 1266 - const unsigned char *p; 1267 - char *f, flags = TTY_NORMAL; 1268 - int i; 1269 - 1270 - for (i = count, p = cp, f = fp; i; i--, p++) { 1271 - if (f) 1272 - flags = *f++; 1273 - if (flags == TTY_NORMAL) { 1274 - receive_char(pInfo, *p); 1275 - } else { 1276 - receive_error(pInfo, flags); 1277 - } 1278 - 1279 - } 1280 - } 1281 - 1282 - MODULE_LICENSE("GPL"); 1283 - MODULE_ALIAS_LDISC(N_R3964);
+66 -131
drivers/tty/n_tty.c
··· 342 342 { 343 343 unsigned long flags; 344 344 345 - if (tty->link->packet) { 346 - spin_lock_irqsave(&tty->ctrl_lock, flags); 347 - tty->ctrl_status |= TIOCPKT_FLUSHREAD; 348 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 345 + if (tty->link->ctrl.packet) { 346 + spin_lock_irqsave(&tty->ctrl.lock, flags); 347 + tty->ctrl.pktstatus |= TIOCPKT_FLUSHREAD; 348 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 349 349 wake_up_interruptible(&tty->link->read_wait); 350 350 } 351 351 } ··· 361 361 * Holds termios_rwsem to exclude producer/consumer while 362 362 * buffer indices are reset. 363 363 * 364 - * Locking: ctrl_lock, exclusive termios_rwsem 364 + * Locking: ctrl.lock, exclusive termios_rwsem 365 365 */ 366 366 367 367 static void n_tty_flush_buffer(struct tty_struct *tty) ··· 1103 1103 * buffer is 'output'. The signal is processed first to alert any current 1104 1104 * readers or writers to discontinue and exit their i/o loops. 1105 1105 * 1106 - * Locking: ctrl_lock 1106 + * Locking: ctrl.lock 1107 1107 */ 1108 1108 1109 1109 static void __isig(int sig, struct tty_struct *tty) ··· 1245 1245 commit_echoes(tty); 1246 1246 } else 1247 1247 process_echoes(tty); 1248 - return; 1249 1248 } 1250 1249 1251 1250 /** ··· 1259 1260 * n_tty_receive_buf()/producer path: 1260 1261 * caller holds non-exclusive termios_rwsem 1261 1262 * publishes canon_head if canonical mode is active 1262 - * 1263 - * Returns 1 if LNEXT was received, else returns 0 1264 1263 */ 1265 - 1266 - static int 1267 - n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) 1264 + static void n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) 1268 1265 { 1269 1266 struct n_tty_data *ldata = tty->disc_data; 1270 1267 ··· 1268 1273 if (c == START_CHAR(tty)) { 1269 1274 start_tty(tty); 1270 1275 process_echoes(tty); 1271 - return 0; 1276 + return; 1272 1277 } 1273 1278 if (c == STOP_CHAR(tty)) { 1274 1279 stop_tty(tty); 1275 - return 0; 1280 + return; 1276 1281 } 1277 1282 } 1278 1283 1279 1284 if (L_ISIG(tty)) { 1280 1285 if (c == INTR_CHAR(tty)) { 1281 1286 n_tty_receive_signal_char(tty, SIGINT, c); 1282 - return 0; 1287 + return; 1283 1288 } else if (c == QUIT_CHAR(tty)) { 1284 1289 n_tty_receive_signal_char(tty, SIGQUIT, c); 1285 - return 0; 1290 + return; 1286 1291 } else if (c == SUSP_CHAR(tty)) { 1287 1292 n_tty_receive_signal_char(tty, SIGTSTP, c); 1288 - return 0; 1293 + return; 1289 1294 } 1290 1295 } 1291 1296 1292 - if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { 1297 + if (tty->flow.stopped && !tty->flow.tco_stopped && I_IXON(tty) && I_IXANY(tty)) { 1293 1298 start_tty(tty); 1294 1299 process_echoes(tty); 1295 1300 } 1296 1301 1297 1302 if (c == '\r') { 1298 1303 if (I_IGNCR(tty)) 1299 - return 0; 1304 + return; 1300 1305 if (I_ICRNL(tty)) 1301 1306 c = '\n'; 1302 1307 } else if (c == '\n' && I_INLCR(tty)) ··· 1307 1312 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { 1308 1313 eraser(c, tty); 1309 1314 commit_echoes(tty); 1310 - return 0; 1315 + return; 1311 1316 } 1312 1317 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { 1313 1318 ldata->lnext = 1; ··· 1319 1324 commit_echoes(tty); 1320 1325 } 1321 1326 } 1322 - return 1; 1327 + return; 1323 1328 } 1324 1329 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) { 1325 1330 size_t tail = ldata->canon_head; ··· 1332 1337 tail++; 1333 1338 } 1334 1339 commit_echoes(tty); 1335 - return 0; 1340 + return; 1336 1341 } 1337 1342 if (c == '\n') { 1338 1343 if (L_ECHO(tty) || L_ECHONL(tty)) { ··· 1370 1375 smp_store_release(&ldata->canon_head, ldata->read_head); 1371 1376 kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1372 1377 wake_up_interruptible_poll(&tty->read_wait, EPOLLIN); 1373 - return 0; 1378 + return; 1374 1379 } 1375 1380 } 1376 1381 ··· 1392 1397 put_tty_queue(c, ldata); 1393 1398 1394 1399 put_tty_queue(c, ldata); 1395 - return 0; 1396 1400 } 1397 1401 1398 - static inline void 1399 - n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c) 1402 + static void n_tty_receive_char(struct tty_struct *tty, unsigned char c) 1400 1403 { 1401 1404 struct n_tty_data *ldata = tty->disc_data; 1402 1405 1403 - if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { 1406 + if (tty->flow.stopped && !tty->flow.tco_stopped && I_IXON(tty) && I_IXANY(tty)) { 1404 1407 start_tty(tty); 1405 1408 process_echoes(tty); 1406 1409 } ··· 1416 1423 put_tty_queue(c, ldata); 1417 1424 } 1418 1425 1419 - static void n_tty_receive_char(struct tty_struct *tty, unsigned char c) 1420 - { 1421 - n_tty_receive_char_inline(tty, c); 1422 - } 1423 - 1424 - static inline void 1425 - n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c) 1426 - { 1427 - struct n_tty_data *ldata = tty->disc_data; 1428 - 1429 - if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { 1430 - start_tty(tty); 1431 - process_echoes(tty); 1432 - } 1433 - if (L_ECHO(tty)) { 1434 - finish_erasing(ldata); 1435 - /* Record the column of first canon char. */ 1436 - if (ldata->canon_head == ldata->read_head) 1437 - echo_set_canon_col(ldata); 1438 - echo_char(c, tty); 1439 - commit_echoes(tty); 1440 - } 1441 - put_tty_queue(c, ldata); 1442 - } 1443 - 1444 1426 static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c) 1445 1427 { 1446 1428 if (I_ISTRIP(tty)) ··· 1427 1459 if (c == STOP_CHAR(tty)) 1428 1460 stop_tty(tty); 1429 1461 else if (c == START_CHAR(tty) || 1430 - (tty->stopped && !tty->flow_stopped && I_IXANY(tty) && 1462 + (tty->flow.stopped && !tty->flow.tco_stopped && I_IXANY(tty) && 1431 1463 c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && 1432 1464 c != SUSP_CHAR(tty))) { 1433 1465 start_tty(tty); ··· 1474 1506 1475 1507 static void 1476 1508 n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp, 1477 - char *fp, int count) 1509 + const char *fp, int count) 1478 1510 { 1479 1511 struct n_tty_data *ldata = tty->disc_data; 1480 1512 size_t n, head; ··· 1494 1526 1495 1527 static void 1496 1528 n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, 1497 - char *fp, int count) 1529 + const char *fp, int count) 1498 1530 { 1499 1531 struct n_tty_data *ldata = tty->disc_data; 1500 1532 char flag = TTY_NORMAL; ··· 1511 1543 1512 1544 static void 1513 1545 n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, 1514 - char *fp, int count) 1546 + const char *fp, int count) 1515 1547 { 1516 1548 char flag = TTY_NORMAL; 1517 1549 ··· 1523 1555 } 1524 1556 } 1525 1557 1526 - static void 1527 - n_tty_receive_buf_standard(struct tty_struct *tty, const unsigned char *cp, 1528 - char *fp, int count) 1558 + static void n_tty_receive_buf_standard(struct tty_struct *tty, 1559 + const unsigned char *cp, const char *fp, int count) 1529 1560 { 1530 1561 struct n_tty_data *ldata = tty->disc_data; 1531 1562 char flag = TTY_NORMAL; 1532 1563 1533 1564 while (count--) { 1565 + unsigned char c = *cp++; 1566 + 1534 1567 if (fp) 1535 1568 flag = *fp++; 1536 - if (likely(flag == TTY_NORMAL)) { 1537 - unsigned char c = *cp++; 1538 1569 1539 - if (I_ISTRIP(tty)) 1540 - c &= 0x7f; 1541 - if (I_IUCLC(tty) && L_IEXTEN(tty)) 1542 - c = tolower(c); 1543 - if (L_EXTPROC(tty)) { 1544 - put_tty_queue(c, ldata); 1545 - continue; 1546 - } 1547 - if (!test_bit(c, ldata->char_map)) 1548 - n_tty_receive_char_inline(tty, c); 1549 - else if (n_tty_receive_char_special(tty, c) && count) { 1550 - if (fp) 1551 - flag = *fp++; 1552 - n_tty_receive_char_lnext(tty, *cp++, flag); 1553 - count--; 1554 - } 1555 - } else 1556 - n_tty_receive_char_flagged(tty, *cp++, flag); 1557 - } 1558 - } 1570 + if (ldata->lnext) { 1571 + n_tty_receive_char_lnext(tty, c, flag); 1572 + continue; 1573 + } 1559 1574 1560 - static void 1561 - n_tty_receive_buf_fast(struct tty_struct *tty, const unsigned char *cp, 1562 - char *fp, int count) 1563 - { 1564 - struct n_tty_data *ldata = tty->disc_data; 1565 - char flag = TTY_NORMAL; 1575 + if (unlikely(flag != TTY_NORMAL)) { 1576 + n_tty_receive_char_flagged(tty, c, flag); 1577 + continue; 1578 + } 1566 1579 1567 - while (count--) { 1568 - if (fp) 1569 - flag = *fp++; 1570 - if (likely(flag == TTY_NORMAL)) { 1571 - unsigned char c = *cp++; 1580 + if (I_ISTRIP(tty)) 1581 + c &= 0x7f; 1582 + if (I_IUCLC(tty) && L_IEXTEN(tty)) 1583 + c = tolower(c); 1584 + if (L_EXTPROC(tty)) { 1585 + put_tty_queue(c, ldata); 1586 + continue; 1587 + } 1572 1588 1573 - if (!test_bit(c, ldata->char_map)) 1574 - n_tty_receive_char_fast(tty, c); 1575 - else if (n_tty_receive_char_special(tty, c) && count) { 1576 - if (fp) 1577 - flag = *fp++; 1578 - n_tty_receive_char_lnext(tty, *cp++, flag); 1579 - count--; 1580 - } 1581 - } else 1582 - n_tty_receive_char_flagged(tty, *cp++, flag); 1589 + if (test_bit(c, ldata->char_map)) 1590 + n_tty_receive_char_special(tty, c); 1591 + else 1592 + n_tty_receive_char(tty, c); 1583 1593 } 1584 1594 } 1585 1595 1586 1596 static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, 1587 - char *fp, int count) 1597 + const char *fp, int count) 1588 1598 { 1589 1599 struct n_tty_data *ldata = tty->disc_data; 1590 1600 bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty)); ··· 1574 1628 else if (tty->closing && !L_EXTPROC(tty)) 1575 1629 n_tty_receive_buf_closing(tty, cp, fp, count); 1576 1630 else { 1577 - if (ldata->lnext) { 1578 - char flag = TTY_NORMAL; 1579 - 1580 - if (fp) 1581 - flag = *fp++; 1582 - n_tty_receive_char_lnext(tty, *cp++, flag); 1583 - count--; 1584 - } 1585 - 1586 - if (!preops && !I_PARMRK(tty)) 1587 - n_tty_receive_buf_fast(tty, cp, fp, count); 1588 - else 1589 - n_tty_receive_buf_standard(tty, cp, fp, count); 1631 + n_tty_receive_buf_standard(tty, cp, fp, count); 1590 1632 1591 1633 flush_echoes(tty); 1592 1634 if (tty->ops->flush_chars) ··· 1629 1695 */ 1630 1696 static int 1631 1697 n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, 1632 - char *fp, int count, int flow) 1698 + const char *fp, int count, int flow) 1633 1699 { 1634 1700 struct n_tty_data *ldata = tty->disc_data; 1635 1701 int room, n, rcvd = 0, overflow; ··· 1698 1764 } 1699 1765 1700 1766 static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1701 - char *fp, int count) 1767 + const char *fp, int count) 1702 1768 { 1703 1769 n_tty_receive_buf_common(tty, cp, fp, count, 0); 1704 1770 } 1705 1771 1706 1772 static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, 1707 - char *fp, int count) 1773 + const char *fp, int count) 1708 1774 { 1709 1775 return n_tty_receive_buf_common(tty, cp, fp, count, 1); 1710 1776 } ··· 1797 1863 * Fix tty hang when I_IXON(tty) is cleared, but the tty 1798 1864 * been stopped by STOP_CHAR(tty) before it. 1799 1865 */ 1800 - if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) { 1866 + if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow.tco_stopped) { 1801 1867 start_tty(tty); 1802 1868 process_echoes(tty); 1803 1869 } ··· 2025 2091 * 2026 2092 * Locking: redirected write test is safe 2027 2093 * current->signal->tty check is safe 2028 - * ctrl_lock to safely reference tty->pgrp 2094 + * ctrl.lock to safely reference tty->ctrl.pgrp 2029 2095 */ 2030 2096 2031 2097 static int job_control(struct tty_struct *tty, struct file *file) ··· 2072 2138 int minimum, time; 2073 2139 ssize_t retval = 0; 2074 2140 long timeout; 2075 - int packet; 2141 + bool packet; 2076 2142 size_t tail; 2077 2143 2078 2144 /* ··· 2128 2194 } 2129 2195 } 2130 2196 2131 - packet = tty->packet; 2197 + packet = tty->ctrl.packet; 2132 2198 tail = ldata->read_tail; 2133 2199 2134 2200 add_wait_queue(&tty->read_wait, &wait); 2135 2201 while (nr) { 2136 2202 /* First test for status change. */ 2137 - if (packet && tty->link->ctrl_status) { 2203 + if (packet && tty->link->ctrl.pktstatus) { 2138 2204 unsigned char cs; 2139 2205 if (kb != kbuf) 2140 2206 break; 2141 - spin_lock_irq(&tty->link->ctrl_lock); 2142 - cs = tty->link->ctrl_status; 2143 - tty->link->ctrl_status = 0; 2144 - spin_unlock_irq(&tty->link->ctrl_lock); 2207 + spin_lock_irq(&tty->link->ctrl.lock); 2208 + cs = tty->link->ctrl.pktstatus; 2209 + tty->link->ctrl.pktstatus = 0; 2210 + spin_unlock_irq(&tty->link->ctrl.lock); 2145 2211 *kb++ = cs; 2146 2212 nr--; 2147 2213 break; ··· 2368 2434 if (input_available_p(tty, 1)) 2369 2435 mask |= EPOLLIN | EPOLLRDNORM; 2370 2436 } 2371 - if (tty->packet && tty->link->ctrl_status) 2437 + if (tty->ctrl.packet && tty->link->ctrl.pktstatus) 2372 2438 mask |= EPOLLPRI | EPOLLIN | EPOLLRDNORM; 2373 2439 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) 2374 2440 mask |= EPOLLHUP; ··· 2424 2490 2425 2491 static struct tty_ldisc_ops n_tty_ops = { 2426 2492 .owner = THIS_MODULE, 2493 + .num = N_TTY, 2427 2494 .name = "n_tty", 2428 2495 .open = n_tty_open, 2429 2496 .close = n_tty_close, ··· 2450 2515 { 2451 2516 *ops = n_tty_ops; 2452 2517 ops->owner = NULL; 2453 - ops->refcount = ops->flags = 0; 2518 + ops->flags = 0; 2454 2519 } 2455 2520 EXPORT_SYMBOL_GPL(n_tty_inherit_ops); 2456 2521 2457 2522 void __init n_tty_init(void) 2458 2523 { 2459 - tty_register_ldisc(N_TTY, &n_tty_ops); 2524 + tty_register_ldisc(&n_tty_ops); 2460 2525 }
+12 -14
drivers/tty/nozomi.c
··· 1378 1378 NOZOMI_NAME, dc); 1379 1379 if (unlikely(ret)) { 1380 1380 dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq); 1381 - goto err_free_kfifo; 1381 + goto err_free_all_kfifo; 1382 1382 } 1383 1383 1384 1384 DBG1("base_addr: %p", dc->base_addr); ··· 1416 1416 return 0; 1417 1417 1418 1418 err_free_tty: 1419 - for (i = 0; i < MAX_PORT; ++i) { 1419 + for (i--; i >= 0; i--) { 1420 1420 tty_unregister_device(ntty_driver, dc->index_start + i); 1421 1421 tty_port_destroy(&dc->port[i].port); 1422 1422 } 1423 + free_irq(pdev->irq, dc); 1424 + err_free_all_kfifo: 1425 + i = MAX_PORT; 1423 1426 err_free_kfifo: 1424 - for (i = 0; i < MAX_PORT; i++) 1427 + for (i--; i >= PORT_MDM; i--) 1425 1428 kfifo_free(&dc->port[i].fifo_ul); 1426 1429 err_free_sbuf: 1427 1430 kfree(dc->send_buf); ··· 1639 1636 * If the port is unplugged report lots of room and let the bits 1640 1637 * dribble away so we don't block anything. 1641 1638 */ 1642 - static int ntty_write_room(struct tty_struct *tty) 1639 + static unsigned int ntty_write_room(struct tty_struct *tty) 1643 1640 { 1644 1641 struct port *port = tty->driver_data; 1645 - int room = 4096; 1642 + unsigned int room = 4096; 1646 1643 const struct nozomi *dc = get_dc_by_tty(tty); 1647 1644 1648 1645 if (dc) ··· 1779 1776 } 1780 1777 1781 1778 /* Returns number of chars in buffer, called by tty layer */ 1782 - static s32 ntty_chars_in_buffer(struct tty_struct *tty) 1779 + static unsigned int ntty_chars_in_buffer(struct tty_struct *tty) 1783 1780 { 1784 1781 struct port *port = tty->driver_data; 1785 1782 struct nozomi *dc = get_dc_by_tty(tty); 1786 - s32 rval = 0; 1787 1783 1788 - if (unlikely(!dc || !port)) { 1789 - goto exit_in_buffer; 1790 - } 1784 + if (unlikely(!dc || !port)) 1785 + return 0; 1791 1786 1792 - rval = kfifo_len(&port->fifo_ul); 1793 - 1794 - exit_in_buffer: 1795 - return rval; 1787 + return kfifo_len(&port->fifo_ul); 1796 1788 } 1797 1789 1798 1790 static const struct tty_port_operations noz_tty_port_ops = {
+36 -53
drivers/tty/pty.c
··· 57 57 set_bit(TTY_IO_ERROR, &tty->flags); 58 58 wake_up_interruptible(&tty->read_wait); 59 59 wake_up_interruptible(&tty->write_wait); 60 - spin_lock_irq(&tty->ctrl_lock); 61 - tty->packet = 0; 62 - spin_unlock_irq(&tty->ctrl_lock); 60 + spin_lock_irq(&tty->ctrl.lock); 61 + tty->ctrl.packet = false; 62 + spin_unlock_irq(&tty->ctrl.lock); 63 63 /* Review - krefs on tty_link ?? */ 64 64 if (!tty->link) 65 65 return; ··· 113 113 struct tty_struct *to = tty->link; 114 114 unsigned long flags; 115 115 116 - if (tty->stopped) 116 + if (tty->flow.stopped) 117 117 return 0; 118 118 119 119 if (c > 0) { ··· 136 136 * the other device. 137 137 */ 138 138 139 - static int pty_write_room(struct tty_struct *tty) 139 + static unsigned int pty_write_room(struct tty_struct *tty) 140 140 { 141 - if (tty->stopped) 141 + if (tty->flow.stopped) 142 142 return 0; 143 143 return tty_buffer_space_avail(tty->link->port); 144 - } 145 - 146 - /** 147 - * pty_chars_in_buffer - characters currently in our tx queue 148 - * @tty: our tty 149 - * 150 - * Report how much we have in the transmit queue. As everything is 151 - * instantly at the other end this is easy to implement. 152 - */ 153 - 154 - static int pty_chars_in_buffer(struct tty_struct *tty) 155 - { 156 - return 0; 157 144 } 158 145 159 146 /* Set the lock flag on a pty */ ··· 172 185 if (get_user(pktmode, arg)) 173 186 return -EFAULT; 174 187 175 - spin_lock_irq(&tty->ctrl_lock); 188 + spin_lock_irq(&tty->ctrl.lock); 176 189 if (pktmode) { 177 - if (!tty->packet) { 178 - tty->link->ctrl_status = 0; 190 + if (!tty->ctrl.packet) { 191 + tty->link->ctrl.pktstatus = 0; 179 192 smp_mb(); 180 - tty->packet = 1; 193 + tty->ctrl.packet = true; 181 194 } 182 195 } else 183 - tty->packet = 0; 184 - spin_unlock_irq(&tty->ctrl_lock); 196 + tty->ctrl.packet = false; 197 + spin_unlock_irq(&tty->ctrl.lock); 185 198 186 199 return 0; 187 200 } ··· 189 202 /* Get the packet mode of a pty */ 190 203 static int pty_get_pktmode(struct tty_struct *tty, int __user *arg) 191 204 { 192 - int pktmode = tty->packet; 205 + int pktmode = tty->ctrl.packet; 193 206 194 207 return put_user(pktmode, arg); 195 208 } ··· 219 232 return; 220 233 221 234 tty_buffer_flush(to, NULL); 222 - if (to->packet) { 223 - spin_lock_irq(&tty->ctrl_lock); 224 - tty->ctrl_status |= TIOCPKT_FLUSHWRITE; 235 + if (to->ctrl.packet) { 236 + spin_lock_irq(&tty->ctrl.lock); 237 + tty->ctrl.pktstatus |= TIOCPKT_FLUSHWRITE; 225 238 wake_up_interruptible(&to->read_wait); 226 - spin_unlock_irq(&tty->ctrl_lock); 239 + spin_unlock_irq(&tty->ctrl.lock); 227 240 } 228 241 } 229 242 ··· 253 266 struct ktermios *old_termios) 254 267 { 255 268 /* See if packet mode change of state. */ 256 - if (tty->link && tty->link->packet) { 269 + if (tty->link && tty->link->ctrl.packet) { 257 270 int extproc = (old_termios->c_lflag & EXTPROC) | L_EXTPROC(tty); 258 271 int old_flow = ((old_termios->c_iflag & IXON) && 259 272 (old_termios->c_cc[VSTOP] == '\023') && ··· 262 275 STOP_CHAR(tty) == '\023' && 263 276 START_CHAR(tty) == '\021'); 264 277 if ((old_flow != new_flow) || extproc) { 265 - spin_lock_irq(&tty->ctrl_lock); 278 + spin_lock_irq(&tty->ctrl.lock); 266 279 if (old_flow != new_flow) { 267 - tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); 280 + tty->ctrl.pktstatus &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); 268 281 if (new_flow) 269 - tty->ctrl_status |= TIOCPKT_DOSTOP; 282 + tty->ctrl.pktstatus |= TIOCPKT_DOSTOP; 270 283 else 271 - tty->ctrl_status |= TIOCPKT_NOSTOP; 284 + tty->ctrl.pktstatus |= TIOCPKT_NOSTOP; 272 285 } 273 286 if (extproc) 274 - tty->ctrl_status |= TIOCPKT_IOCTL; 275 - spin_unlock_irq(&tty->ctrl_lock); 287 + tty->ctrl.pktstatus |= TIOCPKT_IOCTL; 288 + spin_unlock_irq(&tty->ctrl.lock); 276 289 wake_up_interruptible(&tty->link->read_wait); 277 290 } 278 291 } ··· 282 295 } 283 296 284 297 /** 285 - * pty_do_resize - resize event 298 + * pty_resize - resize event 286 299 * @tty: tty being resized 287 300 * @ws: window size being set. 288 301 * ··· 333 346 { 334 347 unsigned long flags; 335 348 336 - if (tty->link && tty->link->packet) { 337 - spin_lock_irqsave(&tty->ctrl_lock, flags); 338 - tty->ctrl_status &= ~TIOCPKT_STOP; 339 - tty->ctrl_status |= TIOCPKT_START; 340 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 349 + if (tty->link && tty->link->ctrl.packet) { 350 + spin_lock_irqsave(&tty->ctrl.lock, flags); 351 + tty->ctrl.pktstatus &= ~TIOCPKT_STOP; 352 + tty->ctrl.pktstatus |= TIOCPKT_START; 353 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 341 354 wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN); 342 355 } 343 356 } ··· 346 359 { 347 360 unsigned long flags; 348 361 349 - if (tty->link && tty->link->packet) { 350 - spin_lock_irqsave(&tty->ctrl_lock, flags); 351 - tty->ctrl_status &= ~TIOCPKT_START; 352 - tty->ctrl_status |= TIOCPKT_STOP; 353 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 362 + if (tty->link && tty->link->ctrl.packet) { 363 + spin_lock_irqsave(&tty->ctrl.lock, flags); 364 + tty->ctrl.pktstatus &= ~TIOCPKT_START; 365 + tty->ctrl.pktstatus |= TIOCPKT_STOP; 366 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 354 367 wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN); 355 368 } 356 369 } ··· 512 525 .write = pty_write, 513 526 .write_room = pty_write_room, 514 527 .flush_buffer = pty_flush_buffer, 515 - .chars_in_buffer = pty_chars_in_buffer, 516 528 .unthrottle = pty_unthrottle, 517 529 .ioctl = pty_bsd_ioctl, 518 530 .compat_ioctl = pty_bsd_compat_ioctl, ··· 527 541 .write = pty_write, 528 542 .write_room = pty_write_room, 529 543 .flush_buffer = pty_flush_buffer, 530 - .chars_in_buffer = pty_chars_in_buffer, 531 544 .unthrottle = pty_unthrottle, 532 545 .set_termios = pty_set_termios, 533 546 .cleanup = pty_cleanup, ··· 611 626 */ 612 627 int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags) 613 628 { 614 - int fd = -1; 629 + int fd; 615 630 struct file *filp; 616 631 int retval = -EINVAL; 617 632 struct path path; ··· 761 776 .write = pty_write, 762 777 .write_room = pty_write_room, 763 778 .flush_buffer = pty_flush_buffer, 764 - .chars_in_buffer = pty_chars_in_buffer, 765 779 .unthrottle = pty_unthrottle, 766 780 .ioctl = pty_unix98_ioctl, 767 781 .compat_ioctl = pty_unix98_compat_ioctl, ··· 778 794 .write = pty_write, 779 795 .write_room = pty_write_room, 780 796 .flush_buffer = pty_flush_buffer, 781 - .chars_in_buffer = pty_chars_in_buffer, 782 797 .unthrottle = pty_unthrottle, 783 798 .set_termios = pty_set_termios, 784 799 .start = pty_start,
+1 -1
drivers/tty/serdev/core.c
··· 798 798 EXPORT_SYMBOL_GPL(serdev_controller_remove); 799 799 800 800 /** 801 - * serdev_driver_register() - Register client driver with serdev core 801 + * __serdev_device_driver_register() - Register client driver with serdev core 802 802 * @sdrv: client driver to be associated with client-device. 803 803 * @owner: client driver owner to set. 804 804 *
+29 -25
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 34 34 35 35 struct aspeed_vuart { 36 36 struct device *dev; 37 - void __iomem *regs; 38 37 struct clk *clk; 39 38 int line; 40 39 struct timer_list unthrottle_timer; ··· 63 64 * different system (though most of them use 3f8/4). 64 65 */ 65 66 67 + static inline u8 aspeed_vuart_readb(struct aspeed_vuart *vuart, u8 reg) 68 + { 69 + return readb(vuart->port->port.membase + reg); 70 + } 71 + 72 + static inline void aspeed_vuart_writeb(struct aspeed_vuart *vuart, u8 val, u8 reg) 73 + { 74 + writeb(val, vuart->port->port.membase + reg); 75 + } 76 + 66 77 static ssize_t lpc_address_show(struct device *dev, 67 78 struct device_attribute *attr, char *buf) 68 79 { 69 80 struct aspeed_vuart *vuart = dev_get_drvdata(dev); 70 81 u16 addr; 71 82 72 - addr = (readb(vuart->regs + ASPEED_VUART_ADDRH) << 8) | 73 - (readb(vuart->regs + ASPEED_VUART_ADDRL)); 83 + addr = (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRH) << 8) | 84 + (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRL)); 74 85 75 86 return snprintf(buf, PAGE_SIZE - 1, "0x%x\n", addr); 76 87 } ··· 90 81 if (addr > U16_MAX) 91 82 return -EINVAL; 92 83 93 - writeb(addr >> 8, vuart->regs + ASPEED_VUART_ADDRH); 94 - writeb(addr >> 0, vuart->regs + ASPEED_VUART_ADDRL); 84 + aspeed_vuart_writeb(vuart, addr >> 8, ASPEED_VUART_ADDRH); 85 + aspeed_vuart_writeb(vuart, addr >> 0, ASPEED_VUART_ADDRL); 95 86 96 87 return 0; 97 88 } ··· 120 111 struct aspeed_vuart *vuart = dev_get_drvdata(dev); 121 112 u8 reg; 122 113 123 - reg = readb(vuart->regs + ASPEED_VUART_GCRB); 114 + reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRB); 124 115 reg &= ASPEED_VUART_GCRB_HOST_SIRQ_MASK; 125 116 reg >>= ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT; 126 117 ··· 137 128 sirq <<= ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT; 138 129 sirq &= ASPEED_VUART_GCRB_HOST_SIRQ_MASK; 139 130 140 - reg = readb(vuart->regs + ASPEED_VUART_GCRB); 131 + reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRB); 141 132 reg &= ~ASPEED_VUART_GCRB_HOST_SIRQ_MASK; 142 133 reg |= sirq; 143 - writeb(reg, vuart->regs + ASPEED_VUART_GCRB); 134 + aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRB); 144 135 145 136 return 0; 146 137 } ··· 168 159 struct aspeed_vuart *vuart = dev_get_drvdata(dev); 169 160 u8 reg; 170 161 171 - reg = readb(vuart->regs + ASPEED_VUART_GCRA); 162 + reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA); 172 163 reg &= ASPEED_VUART_GCRA_HOST_SIRQ_POLARITY; 173 164 174 165 return snprintf(buf, PAGE_SIZE - 1, "%u\n", reg ? 1 : 0); ··· 177 168 static void aspeed_vuart_set_sirq_polarity(struct aspeed_vuart *vuart, 178 169 bool polarity) 179 170 { 180 - u8 reg = readb(vuart->regs + ASPEED_VUART_GCRA); 171 + u8 reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA); 181 172 182 173 if (polarity) 183 174 reg |= ASPEED_VUART_GCRA_HOST_SIRQ_POLARITY; 184 175 else 185 176 reg &= ~ASPEED_VUART_GCRA_HOST_SIRQ_POLARITY; 186 177 187 - writeb(reg, vuart->regs + ASPEED_VUART_GCRA); 178 + aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRA); 188 179 } 189 180 190 181 static ssize_t sirq_polarity_store(struct device *dev, ··· 219 210 220 211 static void aspeed_vuart_set_enabled(struct aspeed_vuart *vuart, bool enabled) 221 212 { 222 - u8 reg = readb(vuart->regs + ASPEED_VUART_GCRA); 213 + u8 reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA); 223 214 224 215 if (enabled) 225 216 reg |= ASPEED_VUART_GCRA_VUART_EN; 226 217 else 227 218 reg &= ~ASPEED_VUART_GCRA_VUART_EN; 228 219 229 - writeb(reg, vuart->regs + ASPEED_VUART_GCRA); 220 + aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRA); 230 221 } 231 222 232 223 static void aspeed_vuart_set_host_tx_discard(struct aspeed_vuart *vuart, ··· 234 225 { 235 226 u8 reg; 236 227 237 - reg = readb(vuart->regs + ASPEED_VUART_GCRA); 228 + reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA); 238 229 239 230 /* If the DISABLE_HOST_TX_DISCARD bit is set, discard is disabled */ 240 231 if (!discard) ··· 242 233 else 243 234 reg &= ~ASPEED_VUART_GCRA_DISABLE_HOST_TX_DISCARD; 244 235 245 - writeb(reg, vuart->regs + ASPEED_VUART_GCRA); 236 + aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRA); 246 237 } 247 238 248 239 static int aspeed_vuart_startup(struct uart_port *uart_port) ··· 329 320 { 330 321 struct uart_8250_port *up = up_to_u8250p(port); 331 322 unsigned int iir, lsr; 332 - int space, count; 323 + unsigned int space, count; 333 324 334 325 iir = serial_port_in(port, UART_IIR); 335 326 ··· 348 339 struct aspeed_vuart *vuart = port->private_data; 349 340 __aspeed_vuart_set_throttle(up, true); 350 341 351 - if (!timer_pending(&vuart->unthrottle_timer)) { 352 - vuart->port = up; 342 + if (!timer_pending(&vuart->unthrottle_timer)) 353 343 mod_timer(&vuart->unthrottle_timer, 354 344 jiffies + unthrottle_timeout); 355 - } 356 345 357 346 } else { 358 - count = min(space, 256); 347 + count = min(space, 256U); 359 348 360 349 do { 361 350 serial8250_read_char(up, lsr); ··· 428 421 timer_setup(&vuart->unthrottle_timer, aspeed_vuart_unthrottle_exp, 0); 429 422 430 423 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 431 - vuart->regs = devm_ioremap_resource(&pdev->dev, res); 432 - if (IS_ERR(vuart->regs)) 433 - return PTR_ERR(vuart->regs); 434 424 435 425 memset(&port, 0, sizeof(port)); 436 426 port.port.private_data = vuart; 437 - port.port.membase = vuart->regs; 438 427 port.port.mapbase = res->start; 439 428 port.port.mapsize = resource_size(res); 440 429 port.port.startup = aspeed_vuart_startup; ··· 488 485 port.port.iotype = UPIO_MEM; 489 486 port.port.type = PORT_16550A; 490 487 port.port.uartclk = clk; 491 - port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF 488 + port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 492 489 | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST; 493 490 494 491 if (of_property_read_bool(np, "no-loopback-test")) ··· 505 502 goto err_clk_disable; 506 503 507 504 vuart->line = rc; 505 + vuart->port = serial8250_get_port(vuart->line); 508 506 509 507 rc = of_parse_phandle_with_fixed_args( 510 508 np, "aspeed,sirq-polarity-sense", 2, 0,
+9 -18
drivers/tty/serial/8250/8250_core.c
··· 172 172 static int serial_link_irq_chain(struct uart_8250_port *up) 173 173 { 174 174 struct hlist_head *h; 175 - struct hlist_node *n; 176 175 struct irq_info *i; 177 176 int ret; 178 177 ··· 179 180 180 181 h = &irq_lists[up->port.irq % NR_IRQ_HASH]; 181 182 182 - hlist_for_each(n, h) { 183 - i = hlist_entry(n, struct irq_info, node); 183 + hlist_for_each_entry(i, h, node) 184 184 if (i->irq == up->port.irq) 185 185 break; 186 - } 187 186 188 - if (n == NULL) { 187 + if (i == NULL) { 189 188 i = kzalloc(sizeof(struct irq_info), GFP_KERNEL); 190 189 if (i == NULL) { 191 190 mutex_unlock(&hash_mutex); ··· 217 220 218 221 static void serial_unlink_irq_chain(struct uart_8250_port *up) 219 222 { 220 - /* 221 - * yes, some broken gcc emit "warning: 'i' may be used uninitialized" 222 - * but no, we are not going to take a patch that assigns NULL below. 223 - */ 224 223 struct irq_info *i; 225 - struct hlist_node *n; 226 224 struct hlist_head *h; 227 225 228 226 mutex_lock(&hash_mutex); 229 227 230 228 h = &irq_lists[up->port.irq % NR_IRQ_HASH]; 231 229 232 - hlist_for_each(n, h) { 233 - i = hlist_entry(n, struct irq_info, node); 230 + hlist_for_each_entry(i, h, node) 234 231 if (i->irq == up->port.irq) 235 232 break; 236 - } 237 233 238 - BUG_ON(n == NULL); 234 + BUG_ON(i == NULL); 239 235 BUG_ON(i->head == NULL); 240 236 241 237 if (list_empty(i->head)) ··· 321 331 * hardware interrupt, we use a timer-based system. The original 322 332 * driver used to do this with IRQ0. 323 333 */ 324 - if (!port->irq) { 334 + if (!port->irq) 325 335 mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); 326 - } else 336 + else 327 337 retval = serial_link_irq_chain(up); 328 338 329 339 return retval; ··· 752 762 if (!console_suspend_enabled && uart_console(port) && 753 763 port->type != PORT_8250) { 754 764 unsigned char canary = 0xa5; 765 + 755 766 serial_out(up, UART_SCR, canary); 756 767 if (serial_in(up, UART_SCR) == canary) 757 768 up->canary = canary; ··· 906 915 */ 907 916 static DEFINE_MUTEX(serial_mutex); 908 917 909 - static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port) 918 + static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_port *port) 910 919 { 911 920 int i; 912 921 ··· 971 980 * 972 981 * On success the port is ready to use and the line number is returned. 973 982 */ 974 - int serial8250_register_8250_port(struct uart_8250_port *up) 983 + int serial8250_register_8250_port(const struct uart_8250_port *up) 975 984 { 976 985 struct uart_8250_port *uart; 977 986 int ret = -ENOSPC;
+12 -8
drivers/tty/serial/8250/8250_exar.c
··· 501 501 {} 502 502 }; 503 503 504 + static const struct exar8250_platform *exar_get_platform(void) 505 + { 506 + const struct dmi_system_id *dmi_match; 507 + 508 + dmi_match = dmi_first_match(exar_platforms); 509 + if (dmi_match) 510 + return dmi_match->driver_data; 511 + 512 + return &exar8250_default_platform; 513 + } 514 + 504 515 static int 505 516 pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev, 506 517 struct uart_8250_port *port, int idx) 507 518 { 508 - const struct exar8250_platform *platform; 509 - const struct dmi_system_id *dmi_match; 519 + const struct exar8250_platform *platform = exar_get_platform(); 510 520 unsigned int offset = idx * 0x400; 511 521 unsigned int baud = 7812500; 512 522 u8 __iomem *p; 513 523 int ret; 514 - 515 - dmi_match = dmi_first_match(exar_platforms); 516 - if (dmi_match) 517 - platform = dmi_match->driver_data; 518 - else 519 - platform = &exar8250_default_platform; 520 524 521 525 port->port.uartclk = baud * 16; 522 526 port->port.rs485_config = platform->rs485_config;
+4
drivers/tty/serial/8250/8250_of.c
··· 192 192 u32 tx_threshold; 193 193 int ret; 194 194 195 + if (IS_ENABLED(CONFIG_SERIAL_8250_BCM7271) && 196 + of_device_is_compatible(ofdev->dev.of_node, "brcm,bcm7271-uart")) 197 + return -ENODEV; 198 + 195 199 port_type = (unsigned long)of_device_get_match_data(&ofdev->dev); 196 200 if (port_type == PORT_UNKNOWN) 197 201 return -EINVAL;
+20 -2
drivers/tty/serial/8250/8250_omap.c
··· 43 43 #define UART_ERRATA_CLOCK_DISABLE (1 << 3) 44 44 #define UART_HAS_EFR2 BIT(4) 45 45 #define UART_HAS_RHR_IT_DIS BIT(5) 46 + #define UART_RX_TIMEOUT_QUIRK BIT(6) 46 47 47 48 #define OMAP_UART_FCR_RX_TRIG 6 48 49 #define OMAP_UART_FCR_TX_TRIG 4 ··· 104 103 /* Enhanced features register 2 */ 105 104 #define UART_OMAP_EFR2 0x23 106 105 #define UART_OMAP_EFR2_TIMEOUT_BEHAVE BIT(6) 106 + 107 + /* RX FIFO occupancy indicator */ 108 + #define UART_OMAP_RX_LVL 0x64 107 109 108 110 struct omap8250_priv { 109 111 int line; ··· 615 611 static irqreturn_t omap8250_irq(int irq, void *dev_id) 616 612 { 617 613 struct uart_port *port = dev_id; 614 + struct omap8250_priv *priv = port->private_data; 618 615 struct uart_8250_port *up = up_to_u8250p(port); 619 616 unsigned int iir; 620 617 int ret; ··· 630 625 serial8250_rpm_get(up); 631 626 iir = serial_port_in(port, UART_IIR); 632 627 ret = serial8250_handle_irq(port, iir); 628 + 629 + /* 630 + * On K3 SoCs, it is observed that RX TIMEOUT is signalled after 631 + * FIFO has been drained, in which case a dummy read of RX FIFO 632 + * is required to clear RX TIMEOUT condition. 633 + */ 634 + if (priv->habit & UART_RX_TIMEOUT_QUIRK && 635 + (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT && 636 + serial_port_in(port, UART_OMAP_RX_LVL) == 0) { 637 + serial_port_in(port, UART_RX); 638 + } 639 + 633 640 serial8250_rpm_put(up); 634 641 635 642 return IRQ_RETVAL(ret); ··· 830 813 poll_count--) 831 814 cpu_relax(); 832 815 833 - if (!poll_count) 816 + if (poll_count == -1) 834 817 dev_err(p->port.dev, "teardown incomplete\n"); 835 818 } 836 819 } ··· 1235 1218 1236 1219 static struct omap8250_platdata am654_platdata = { 1237 1220 .dma_params = &am654_dma, 1238 - .habit = UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS, 1221 + .habit = UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS | 1222 + UART_RX_TIMEOUT_QUIRK, 1239 1223 }; 1240 1224 1241 1225 static struct omap8250_platdata am33xx_platdata = {
+102 -70
drivers/tty/serial/8250/8250_pci.c
··· 2851 2851 pbn_b0_2_1843200, 2852 2852 pbn_b0_4_1843200, 2853 2853 2854 - pbn_b0_1_4000000, 2854 + pbn_b0_1_3906250, 2855 2855 2856 2856 pbn_b0_bt_1_115200, 2857 2857 pbn_b0_bt_2_115200, ··· 2931 2931 pbn_plx_romulus, 2932 2932 pbn_endrun_2_4000000, 2933 2933 pbn_oxsemi, 2934 - pbn_oxsemi_1_4000000, 2935 - pbn_oxsemi_2_4000000, 2936 - pbn_oxsemi_4_4000000, 2937 - pbn_oxsemi_8_4000000, 2934 + pbn_oxsemi_1_3906250, 2935 + pbn_oxsemi_2_3906250, 2936 + pbn_oxsemi_4_3906250, 2937 + pbn_oxsemi_8_3906250, 2938 2938 pbn_intel_i960, 2939 2939 pbn_sgi_ioc3, 2940 2940 pbn_computone_4, ··· 2972 2972 pbn_sunix_pci_4s, 2973 2973 pbn_sunix_pci_8s, 2974 2974 pbn_sunix_pci_16s, 2975 + pbn_titan_1_4000000, 2976 + pbn_titan_2_4000000, 2977 + pbn_titan_4_4000000, 2978 + pbn_titan_8_4000000, 2975 2979 pbn_moxa8250_2p, 2976 2980 pbn_moxa8250_4p, 2977 2981 pbn_moxa8250_8p, ··· 3081 3077 .uart_offset = 8, 3082 3078 }, 3083 3079 3084 - [pbn_b0_1_4000000] = { 3080 + [pbn_b0_1_3906250] = { 3085 3081 .flags = FL_BASE0, 3086 3082 .num_ports = 1, 3087 - .base_baud = 4000000, 3083 + .base_baud = 3906250, 3088 3084 .uart_offset = 8, 3089 3085 }, 3090 3086 ··· 3479 3475 .base_baud = 115200, 3480 3476 .uart_offset = 8, 3481 3477 }, 3482 - [pbn_oxsemi_1_4000000] = { 3478 + [pbn_oxsemi_1_3906250] = { 3483 3479 .flags = FL_BASE0, 3484 3480 .num_ports = 1, 3485 - .base_baud = 4000000, 3481 + .base_baud = 3906250, 3486 3482 .uart_offset = 0x200, 3487 3483 .first_offset = 0x1000, 3488 3484 }, 3489 - [pbn_oxsemi_2_4000000] = { 3485 + [pbn_oxsemi_2_3906250] = { 3490 3486 .flags = FL_BASE0, 3491 3487 .num_ports = 2, 3492 - .base_baud = 4000000, 3488 + .base_baud = 3906250, 3493 3489 .uart_offset = 0x200, 3494 3490 .first_offset = 0x1000, 3495 3491 }, 3496 - [pbn_oxsemi_4_4000000] = { 3492 + [pbn_oxsemi_4_3906250] = { 3497 3493 .flags = FL_BASE0, 3498 3494 .num_ports = 4, 3499 - .base_baud = 4000000, 3495 + .base_baud = 3906250, 3500 3496 .uart_offset = 0x200, 3501 3497 .first_offset = 0x1000, 3502 3498 }, 3503 - [pbn_oxsemi_8_4000000] = { 3499 + [pbn_oxsemi_8_3906250] = { 3504 3500 .flags = FL_BASE0, 3505 3501 .num_ports = 8, 3506 - .base_baud = 4000000, 3502 + .base_baud = 3906250, 3507 3503 .uart_offset = 0x200, 3508 3504 .first_offset = 0x1000, 3509 3505 }, ··· 3762 3758 .num_ports = 16, 3763 3759 .base_baud = 921600, 3764 3760 .uart_offset = 0x8, 3761 + }, 3762 + [pbn_titan_1_4000000] = { 3763 + .flags = FL_BASE0, 3764 + .num_ports = 1, 3765 + .base_baud = 4000000, 3766 + .uart_offset = 0x200, 3767 + .first_offset = 0x1000, 3768 + }, 3769 + [pbn_titan_2_4000000] = { 3770 + .flags = FL_BASE0, 3771 + .num_ports = 2, 3772 + .base_baud = 4000000, 3773 + .uart_offset = 0x200, 3774 + .first_offset = 0x1000, 3775 + }, 3776 + [pbn_titan_4_4000000] = { 3777 + .flags = FL_BASE0, 3778 + .num_ports = 4, 3779 + .base_baud = 4000000, 3780 + .uart_offset = 0x200, 3781 + .first_offset = 0x1000, 3782 + }, 3783 + [pbn_titan_8_4000000] = { 3784 + .flags = FL_BASE0, 3785 + .num_ports = 8, 3786 + .base_baud = 4000000, 3787 + .uart_offset = 0x200, 3788 + .first_offset = 0x1000, 3765 3789 }, 3766 3790 [pbn_moxa8250_2p] = { 3767 3791 .flags = FL_BASE1, ··· 4510 4478 */ 4511 4479 { PCI_VENDOR_ID_OXSEMI, 0xc101, /* OXPCIe952 1 Legacy UART */ 4512 4480 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4513 - pbn_b0_1_4000000 }, 4481 + pbn_b0_1_3906250 }, 4514 4482 { PCI_VENDOR_ID_OXSEMI, 0xc105, /* OXPCIe952 1 Legacy UART */ 4515 4483 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4516 - pbn_b0_1_4000000 }, 4484 + pbn_b0_1_3906250 }, 4517 4485 { PCI_VENDOR_ID_OXSEMI, 0xc11b, /* OXPCIe952 1 Native UART */ 4518 4486 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4519 - pbn_oxsemi_1_4000000 }, 4487 + pbn_oxsemi_1_3906250 }, 4520 4488 { PCI_VENDOR_ID_OXSEMI, 0xc11f, /* OXPCIe952 1 Native UART */ 4521 4489 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4522 - pbn_oxsemi_1_4000000 }, 4490 + pbn_oxsemi_1_3906250 }, 4523 4491 { PCI_VENDOR_ID_OXSEMI, 0xc120, /* OXPCIe952 1 Legacy UART */ 4524 4492 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4525 - pbn_b0_1_4000000 }, 4493 + pbn_b0_1_3906250 }, 4526 4494 { PCI_VENDOR_ID_OXSEMI, 0xc124, /* OXPCIe952 1 Legacy UART */ 4527 4495 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4528 - pbn_b0_1_4000000 }, 4496 + pbn_b0_1_3906250 }, 4529 4497 { PCI_VENDOR_ID_OXSEMI, 0xc138, /* OXPCIe952 1 Native UART */ 4530 4498 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4531 - pbn_oxsemi_1_4000000 }, 4499 + pbn_oxsemi_1_3906250 }, 4532 4500 { PCI_VENDOR_ID_OXSEMI, 0xc13d, /* OXPCIe952 1 Native UART */ 4533 4501 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4534 - pbn_oxsemi_1_4000000 }, 4502 + pbn_oxsemi_1_3906250 }, 4535 4503 { PCI_VENDOR_ID_OXSEMI, 0xc140, /* OXPCIe952 1 Legacy UART */ 4536 4504 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4537 - pbn_b0_1_4000000 }, 4505 + pbn_b0_1_3906250 }, 4538 4506 { PCI_VENDOR_ID_OXSEMI, 0xc141, /* OXPCIe952 1 Legacy UART */ 4539 4507 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4540 - pbn_b0_1_4000000 }, 4508 + pbn_b0_1_3906250 }, 4541 4509 { PCI_VENDOR_ID_OXSEMI, 0xc144, /* OXPCIe952 1 Legacy UART */ 4542 4510 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4543 - pbn_b0_1_4000000 }, 4511 + pbn_b0_1_3906250 }, 4544 4512 { PCI_VENDOR_ID_OXSEMI, 0xc145, /* OXPCIe952 1 Legacy UART */ 4545 4513 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4546 - pbn_b0_1_4000000 }, 4514 + pbn_b0_1_3906250 }, 4547 4515 { PCI_VENDOR_ID_OXSEMI, 0xc158, /* OXPCIe952 2 Native UART */ 4548 4516 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4549 - pbn_oxsemi_2_4000000 }, 4517 + pbn_oxsemi_2_3906250 }, 4550 4518 { PCI_VENDOR_ID_OXSEMI, 0xc15d, /* OXPCIe952 2 Native UART */ 4551 4519 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4552 - pbn_oxsemi_2_4000000 }, 4520 + pbn_oxsemi_2_3906250 }, 4553 4521 { PCI_VENDOR_ID_OXSEMI, 0xc208, /* OXPCIe954 4 Native UART */ 4554 4522 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4555 - pbn_oxsemi_4_4000000 }, 4523 + pbn_oxsemi_4_3906250 }, 4556 4524 { PCI_VENDOR_ID_OXSEMI, 0xc20d, /* OXPCIe954 4 Native UART */ 4557 4525 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4558 - pbn_oxsemi_4_4000000 }, 4526 + pbn_oxsemi_4_3906250 }, 4559 4527 { PCI_VENDOR_ID_OXSEMI, 0xc308, /* OXPCIe958 8 Native UART */ 4560 4528 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4561 - pbn_oxsemi_8_4000000 }, 4529 + pbn_oxsemi_8_3906250 }, 4562 4530 { PCI_VENDOR_ID_OXSEMI, 0xc30d, /* OXPCIe958 8 Native UART */ 4563 4531 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4564 - pbn_oxsemi_8_4000000 }, 4532 + pbn_oxsemi_8_3906250 }, 4565 4533 { PCI_VENDOR_ID_OXSEMI, 0xc40b, /* OXPCIe200 1 Native UART */ 4566 4534 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4567 - pbn_oxsemi_1_4000000 }, 4535 + pbn_oxsemi_1_3906250 }, 4568 4536 { PCI_VENDOR_ID_OXSEMI, 0xc40f, /* OXPCIe200 1 Native UART */ 4569 4537 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4570 - pbn_oxsemi_1_4000000 }, 4538 + pbn_oxsemi_1_3906250 }, 4571 4539 { PCI_VENDOR_ID_OXSEMI, 0xc41b, /* OXPCIe200 1 Native UART */ 4572 4540 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4573 - pbn_oxsemi_1_4000000 }, 4541 + pbn_oxsemi_1_3906250 }, 4574 4542 { PCI_VENDOR_ID_OXSEMI, 0xc41f, /* OXPCIe200 1 Native UART */ 4575 4543 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4576 - pbn_oxsemi_1_4000000 }, 4544 + pbn_oxsemi_1_3906250 }, 4577 4545 { PCI_VENDOR_ID_OXSEMI, 0xc42b, /* OXPCIe200 1 Native UART */ 4578 4546 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4579 - pbn_oxsemi_1_4000000 }, 4547 + pbn_oxsemi_1_3906250 }, 4580 4548 { PCI_VENDOR_ID_OXSEMI, 0xc42f, /* OXPCIe200 1 Native UART */ 4581 4549 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4582 - pbn_oxsemi_1_4000000 }, 4550 + pbn_oxsemi_1_3906250 }, 4583 4551 { PCI_VENDOR_ID_OXSEMI, 0xc43b, /* OXPCIe200 1 Native UART */ 4584 4552 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4585 - pbn_oxsemi_1_4000000 }, 4553 + pbn_oxsemi_1_3906250 }, 4586 4554 { PCI_VENDOR_ID_OXSEMI, 0xc43f, /* OXPCIe200 1 Native UART */ 4587 4555 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4588 - pbn_oxsemi_1_4000000 }, 4556 + pbn_oxsemi_1_3906250 }, 4589 4557 { PCI_VENDOR_ID_OXSEMI, 0xc44b, /* OXPCIe200 1 Native UART */ 4590 4558 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4591 - pbn_oxsemi_1_4000000 }, 4559 + pbn_oxsemi_1_3906250 }, 4592 4560 { PCI_VENDOR_ID_OXSEMI, 0xc44f, /* OXPCIe200 1 Native UART */ 4593 4561 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4594 - pbn_oxsemi_1_4000000 }, 4562 + pbn_oxsemi_1_3906250 }, 4595 4563 { PCI_VENDOR_ID_OXSEMI, 0xc45b, /* OXPCIe200 1 Native UART */ 4596 4564 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4597 - pbn_oxsemi_1_4000000 }, 4565 + pbn_oxsemi_1_3906250 }, 4598 4566 { PCI_VENDOR_ID_OXSEMI, 0xc45f, /* OXPCIe200 1 Native UART */ 4599 4567 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4600 - pbn_oxsemi_1_4000000 }, 4568 + pbn_oxsemi_1_3906250 }, 4601 4569 { PCI_VENDOR_ID_OXSEMI, 0xc46b, /* OXPCIe200 1 Native UART */ 4602 4570 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4603 - pbn_oxsemi_1_4000000 }, 4571 + pbn_oxsemi_1_3906250 }, 4604 4572 { PCI_VENDOR_ID_OXSEMI, 0xc46f, /* OXPCIe200 1 Native UART */ 4605 4573 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4606 - pbn_oxsemi_1_4000000 }, 4574 + pbn_oxsemi_1_3906250 }, 4607 4575 { PCI_VENDOR_ID_OXSEMI, 0xc47b, /* OXPCIe200 1 Native UART */ 4608 4576 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4609 - pbn_oxsemi_1_4000000 }, 4577 + pbn_oxsemi_1_3906250 }, 4610 4578 { PCI_VENDOR_ID_OXSEMI, 0xc47f, /* OXPCIe200 1 Native UART */ 4611 4579 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4612 - pbn_oxsemi_1_4000000 }, 4580 + pbn_oxsemi_1_3906250 }, 4613 4581 { PCI_VENDOR_ID_OXSEMI, 0xc48b, /* OXPCIe200 1 Native UART */ 4614 4582 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4615 - pbn_oxsemi_1_4000000 }, 4583 + pbn_oxsemi_1_3906250 }, 4616 4584 { PCI_VENDOR_ID_OXSEMI, 0xc48f, /* OXPCIe200 1 Native UART */ 4617 4585 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4618 - pbn_oxsemi_1_4000000 }, 4586 + pbn_oxsemi_1_3906250 }, 4619 4587 { PCI_VENDOR_ID_OXSEMI, 0xc49b, /* OXPCIe200 1 Native UART */ 4620 4588 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4621 - pbn_oxsemi_1_4000000 }, 4589 + pbn_oxsemi_1_3906250 }, 4622 4590 { PCI_VENDOR_ID_OXSEMI, 0xc49f, /* OXPCIe200 1 Native UART */ 4623 4591 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4624 - pbn_oxsemi_1_4000000 }, 4592 + pbn_oxsemi_1_3906250 }, 4625 4593 { PCI_VENDOR_ID_OXSEMI, 0xc4ab, /* OXPCIe200 1 Native UART */ 4626 4594 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4627 - pbn_oxsemi_1_4000000 }, 4595 + pbn_oxsemi_1_3906250 }, 4628 4596 { PCI_VENDOR_ID_OXSEMI, 0xc4af, /* OXPCIe200 1 Native UART */ 4629 4597 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4630 - pbn_oxsemi_1_4000000 }, 4598 + pbn_oxsemi_1_3906250 }, 4631 4599 { PCI_VENDOR_ID_OXSEMI, 0xc4bb, /* OXPCIe200 1 Native UART */ 4632 4600 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4633 - pbn_oxsemi_1_4000000 }, 4601 + pbn_oxsemi_1_3906250 }, 4634 4602 { PCI_VENDOR_ID_OXSEMI, 0xc4bf, /* OXPCIe200 1 Native UART */ 4635 4603 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4636 - pbn_oxsemi_1_4000000 }, 4604 + pbn_oxsemi_1_3906250 }, 4637 4605 { PCI_VENDOR_ID_OXSEMI, 0xc4cb, /* OXPCIe200 1 Native UART */ 4638 4606 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4639 - pbn_oxsemi_1_4000000 }, 4607 + pbn_oxsemi_1_3906250 }, 4640 4608 { PCI_VENDOR_ID_OXSEMI, 0xc4cf, /* OXPCIe200 1 Native UART */ 4641 4609 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4642 - pbn_oxsemi_1_4000000 }, 4610 + pbn_oxsemi_1_3906250 }, 4643 4611 /* 4644 4612 * Mainpine Inc. IQ Express "Rev3" utilizing OxSemi Tornado 4645 4613 */ 4646 4614 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 1 Port V.34 Super-G3 Fax */ 4647 4615 PCI_VENDOR_ID_MAINPINE, 0x4001, 0, 0, 4648 - pbn_oxsemi_1_4000000 }, 4616 + pbn_oxsemi_1_3906250 }, 4649 4617 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 2 Port V.34 Super-G3 Fax */ 4650 4618 PCI_VENDOR_ID_MAINPINE, 0x4002, 0, 0, 4651 - pbn_oxsemi_2_4000000 }, 4619 + pbn_oxsemi_2_3906250 }, 4652 4620 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 4 Port V.34 Super-G3 Fax */ 4653 4621 PCI_VENDOR_ID_MAINPINE, 0x4004, 0, 0, 4654 - pbn_oxsemi_4_4000000 }, 4622 + pbn_oxsemi_4_3906250 }, 4655 4623 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 8 Port V.34 Super-G3 Fax */ 4656 4624 PCI_VENDOR_ID_MAINPINE, 0x4008, 0, 0, 4657 - pbn_oxsemi_8_4000000 }, 4625 + pbn_oxsemi_8_3906250 }, 4658 4626 4659 4627 /* 4660 4628 * Digi/IBM PCIe 2-port Async EIA-232 Adapter utilizing OxSemi Tornado 4661 4629 */ 4662 4630 { PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_2_OX_IBM, 4663 4631 PCI_SUBVENDOR_ID_IBM, PCI_ANY_ID, 0, 0, 4664 - pbn_oxsemi_2_4000000 }, 4632 + pbn_oxsemi_2_3906250 }, 4665 4633 4666 4634 /* 4667 4635 * SBS Technologies, Inc. P-Octal and PMC-OCTPRO cards, ··· 4735 4703 pbn_b0_4_921600 }, 4736 4704 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_100E, 4737 4705 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4738 - pbn_oxsemi_1_4000000 }, 4706 + pbn_titan_1_4000000 }, 4739 4707 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200E, 4740 4708 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4741 - pbn_oxsemi_2_4000000 }, 4709 + pbn_titan_2_4000000 }, 4742 4710 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400E, 4743 4711 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4744 - pbn_oxsemi_4_4000000 }, 4712 + pbn_titan_4_4000000 }, 4745 4713 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800E, 4746 4714 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4747 - pbn_oxsemi_8_4000000 }, 4715 + pbn_titan_8_4000000 }, 4748 4716 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200EI, 4749 4717 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4750 - pbn_oxsemi_2_4000000 }, 4718 + pbn_titan_2_4000000 }, 4751 4719 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200EISI, 4752 4720 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4753 - pbn_oxsemi_2_4000000 }, 4721 + pbn_titan_2_4000000 }, 4754 4722 { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200V3, 4755 4723 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4756 4724 pbn_b0_bt_2_921600 },
+48 -9
drivers/tty/serial/8250/8250_port.c
··· 2512 2512 unsigned int baud, 2513 2513 unsigned int *frac) 2514 2514 { 2515 + upf_t magic_multiplier = port->flags & UPF_MAGIC_MULTIPLIER; 2515 2516 struct uart_8250_port *up = up_to_u8250p(port); 2516 2517 unsigned int quot; 2517 2518 2518 2519 /* 2519 - * Handle magic divisors for baud rates above baud_base on 2520 - * SMSC SuperIO chips. 2520 + * Handle magic divisors for baud rates above baud_base on SMSC 2521 + * Super I/O chips. We clamp custom rates from clk/6 and clk/12 2522 + * up to clk/4 (0x8001) and clk/8 (0x8002) respectively. These 2523 + * magic divisors actually reprogram the baud rate generator's 2524 + * reference clock derived from chips's 14.318MHz clock input. 2521 2525 * 2526 + * Documentation claims that with these magic divisors the base 2527 + * frequencies of 7.3728MHz and 3.6864MHz are used respectively 2528 + * for the extra baud rates of 460800bps and 230400bps rather 2529 + * than the usual base frequency of 1.8462MHz. However empirical 2530 + * evidence contradicts that. 2531 + * 2532 + * Instead bit 7 of the DLM register (bit 15 of the divisor) is 2533 + * effectively used as a clock prescaler selection bit for the 2534 + * base frequency of 7.3728MHz, always used. If set to 0, then 2535 + * the base frequency is divided by 4 for use by the Baud Rate 2536 + * Generator, for the usual arrangement where the value of 1 of 2537 + * the divisor produces the baud rate of 115200bps. Conversely, 2538 + * if set to 1 and high-speed operation has been enabled with the 2539 + * Serial Port Mode Register in the Device Configuration Space, 2540 + * then the base frequency is supplied directly to the Baud Rate 2541 + * Generator, so for the divisor values of 0x8001, 0x8002, 0x8003, 2542 + * 0x8004, etc. the respective baud rates produced are 460800bps, 2543 + * 230400bps, 153600bps, 115200bps, etc. 2544 + * 2545 + * In all cases only low 15 bits of the divisor are used to divide 2546 + * the baud base and therefore 32767 is the maximum divisor value 2547 + * possible, even though documentation says that the programmable 2548 + * Baud Rate Generator is capable of dividing the internal PLL 2549 + * clock by any divisor from 1 to 65535. 2522 2550 */ 2523 - if ((port->flags & UPF_MAGIC_MULTIPLIER) && 2524 - baud == (port->uartclk/4)) 2551 + if (magic_multiplier && baud >= port->uartclk / 6) 2525 2552 quot = 0x8001; 2526 - else if ((port->flags & UPF_MAGIC_MULTIPLIER) && 2527 - baud == (port->uartclk/8)) 2553 + else if (magic_multiplier && baud >= port->uartclk / 12) 2528 2554 quot = 0x8002; 2529 2555 else if (up->port.type == PORT_NPCM) 2530 2556 quot = npcm_get_divisor(up, baud); ··· 2655 2629 struct ktermios *old) 2656 2630 { 2657 2631 unsigned int tolerance = port->uartclk / 100; 2632 + unsigned int min; 2633 + unsigned int max; 2634 + 2635 + /* 2636 + * Handle magic divisors for baud rates above baud_base on SMSC 2637 + * Super I/O chips. Enable custom rates of clk/4 and clk/8, but 2638 + * disable divisor values beyond 32767, which are unavailable. 2639 + */ 2640 + if (port->flags & UPF_MAGIC_MULTIPLIER) { 2641 + min = port->uartclk / 16 / UART_DIV_MAX >> 1; 2642 + max = (port->uartclk + tolerance) / 4; 2643 + } else { 2644 + min = port->uartclk / 16 / UART_DIV_MAX; 2645 + max = (port->uartclk + tolerance) / 16; 2646 + } 2658 2647 2659 2648 /* 2660 2649 * Ask the core to calculate the divisor for us. ··· 2677 2636 * slower than nominal still match standard baud rates without 2678 2637 * causing transmission errors. 2679 2638 */ 2680 - return uart_get_baud_rate(port, termios, old, 2681 - port->uartclk / 16 / UART_DIV_MAX, 2682 - (port->uartclk + tolerance) / 16); 2639 + return uart_get_baud_rate(port, termios, old, min, max); 2683 2640 } 2684 2641 2685 2642 /*
+11 -2
drivers/tty/serial/8250/serial_cs.c
··· 306 306 static int serial_probe(struct pcmcia_device *link) 307 307 { 308 308 struct serial_info *info; 309 + int ret; 309 310 310 311 dev_dbg(&link->dev, "serial_attach()\n"); 311 312 ··· 321 320 if (do_sound) 322 321 link->config_flags |= CONF_ENABLE_SPKR; 323 322 324 - return serial_config(link); 323 + ret = serial_config(link); 324 + if (ret) 325 + goto free_info; 326 + 327 + return 0; 328 + 329 + free_info: 330 + kfree(info); 331 + return ret; 325 332 } 326 333 327 334 static void serial_detach(struct pcmcia_device *link) ··· 786 777 PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e), 787 778 PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a), 788 779 PCMCIA_DEVICE_PROD_ID12("Option International", "V34bis GSM/PSTN Data/Fax Modem", 0x9d7cd6f5, 0x5cb8bf41), 780 + PCMCIA_DEVICE_PROD_ID12("Option International", "GSM-Ready 56K/ISDN", 0x9d7cd6f5, 0xb23844aa), 789 781 PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), 790 782 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), 791 783 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d), ··· 814 804 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "cis/COMpad4.cis"), 815 805 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "cis/COMpad2.cis"), 816 806 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "cis/RS-COM-2P.cis"), 817 - PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "cis/GLOBETROTTER.cis"), 818 807 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL100 1.00.", 0x19ca78af, 0xf964f42b), 819 808 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL100", 0x19ca78af, 0x71d98e83), 820 809 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL232 1.00.", 0x19ca78af, 0x69fb7490),
+1
drivers/tty/serial/Kconfig
··· 1553 1553 bool "LiteUART serial port console support" 1554 1554 depends on SERIAL_LITEUART=y 1555 1555 select SERIAL_CORE_CONSOLE 1556 + select SERIAL_EARLYCON 1556 1557 help 1557 1558 Say 'Y' or 'M' here if you wish to use the FPGA-based LiteUART serial 1558 1559 controller from LiteX SoC builder as the system console
+1 -1
drivers/tty/serial/amba-pl011.c
··· 1062 1062 struct tty_port *port = &uap->port.state->port; 1063 1063 struct pl011_dmarx_data *dmarx = &uap->dmarx; 1064 1064 struct dma_chan *rxchan = uap->dmarx.chan; 1065 - unsigned long flags = 0; 1065 + unsigned long flags; 1066 1066 unsigned int dmataken = 0; 1067 1067 unsigned int size = 0; 1068 1068 struct pl011_sgbuf *sgbuf;
+1 -1
drivers/tty/serial/arc_uart.c
··· 149 149 /* 150 150 * Driver internal routine, used by both tty(serial core) as well as tx-isr 151 151 * -Called under spinlock in either cases 152 - * -also tty->stopped has already been checked 152 + * -also tty->flow.stopped has already been checked 153 153 * = by uart_start( ) before calling us 154 154 * = tx_ist checks that too before calling 155 155 */
+1 -1
drivers/tty/serial/atmel_serial.c
··· 30 30 #include <linux/irq.h> 31 31 #include <linux/suspend.h> 32 32 #include <linux/mm.h> 33 + #include <linux/io.h> 33 34 34 35 #include <asm/div64.h> 35 - #include <asm/io.h> 36 36 #include <asm/ioctls.h> 37 37 38 38 #define PDC_BUFFER_SIZE 512
+1 -18
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 524 524 scval = 0; 525 525 526 526 /* byte size */ 527 - switch (termios->c_cflag & CSIZE) { 528 - case CS5: 529 - bits = 5; 530 - break; 531 - case CS6: 532 - bits = 6; 533 - break; 534 - case CS7: 535 - bits = 7; 536 - break; 537 - case CS8: 538 - bits = 8; 539 - break; 540 - /* Never happens, but GCC is too dumb to figure it out */ 541 - default: 542 - bits = 8; 543 - break; 544 - } 527 + bits = tty_get_char_size(termios->c_cflag); 545 528 sbits = bits - 5; 546 529 547 530 if (termios->c_cflag & CSTOPB) {
+2 -2
drivers/tty/serial/dz.c
··· 47 47 #include <linux/tty_flip.h> 48 48 49 49 #include <linux/atomic.h> 50 + #include <linux/io.h> 50 51 #include <asm/bootinfo.h> 51 - #include <asm/io.h> 52 52 53 53 #include <asm/dec/interrupts.h> 54 54 #include <asm/dec/kn01.h> ··· 115 115 * rs_stop () and rs_start () 116 116 * 117 117 * These routines are called before setting or resetting 118 - * tty->stopped. They enable or disable transmitter interrupts, 118 + * tty->flow.stopped. They enable or disable transmitter interrupts, 119 119 * as necessary. 120 120 * ------------------------------------------------------------ 121 121 */
+75 -60
drivers/tty/serial/fsl_lpuart.c
··· 824 824 825 825 static void lpuart_txint(struct lpuart_port *sport) 826 826 { 827 - unsigned long flags; 828 - 829 - spin_lock_irqsave(&sport->port.lock, flags); 827 + spin_lock(&sport->port.lock); 830 828 lpuart_transmit_buffer(sport); 831 - spin_unlock_irqrestore(&sport->port.lock, flags); 829 + spin_unlock(&sport->port.lock); 832 830 } 833 831 834 832 static void lpuart_rxint(struct lpuart_port *sport) 835 833 { 836 834 unsigned int flg, ignored = 0, overrun = 0; 837 835 struct tty_port *port = &sport->port.state->port; 838 - unsigned long flags; 839 836 unsigned char rx, sr; 840 837 841 - spin_lock_irqsave(&sport->port.lock, flags); 838 + spin_lock(&sport->port.lock); 842 839 843 840 while (!(readb(sport->port.membase + UARTSFIFO) & UARTSFIFO_RXEMPT)) { 844 841 flg = TTY_NORMAL; ··· 847 850 sr = readb(sport->port.membase + UARTSR1); 848 851 rx = readb(sport->port.membase + UARTDR); 849 852 850 - if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) 853 + if (uart_prepare_sysrq_char(&sport->port, rx)) 851 854 continue; 852 855 853 856 if (sr & (UARTSR1_PE | UARTSR1_OR | UARTSR1_FE)) { ··· 893 896 writeb(UARTSFIFO_RXOF, sport->port.membase + UARTSFIFO); 894 897 } 895 898 896 - spin_unlock_irqrestore(&sport->port.lock, flags); 899 + uart_unlock_and_check_sysrq(&sport->port); 897 900 898 901 tty_flip_buffer_push(port); 899 902 } 900 903 901 904 static void lpuart32_txint(struct lpuart_port *sport) 902 905 { 903 - unsigned long flags; 904 - 905 - spin_lock_irqsave(&sport->port.lock, flags); 906 + spin_lock(&sport->port.lock); 906 907 lpuart32_transmit_buffer(sport); 907 - spin_unlock_irqrestore(&sport->port.lock, flags); 908 + spin_unlock(&sport->port.lock); 908 909 } 909 910 910 911 static void lpuart32_rxint(struct lpuart_port *sport) 911 912 { 912 913 unsigned int flg, ignored = 0; 913 914 struct tty_port *port = &sport->port.state->port; 914 - unsigned long flags; 915 915 unsigned long rx, sr; 916 + bool is_break; 916 917 917 - spin_lock_irqsave(&sport->port.lock, flags); 918 + spin_lock(&sport->port.lock); 918 919 919 920 while (!(lpuart32_read(&sport->port, UARTFIFO) & UARTFIFO_RXEMPT)) { 920 921 flg = TTY_NORMAL; ··· 923 928 */ 924 929 sr = lpuart32_read(&sport->port, UARTSTAT); 925 930 rx = lpuart32_read(&sport->port, UARTDATA); 926 - rx &= 0x3ff; 931 + rx &= UARTDATA_MASK; 927 932 928 - if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) 933 + /* 934 + * The LPUART can't distinguish between a break and a framing error, 935 + * thus we assume it is a break if the received data is zero. 936 + */ 937 + is_break = (sr & UARTSTAT_FE) && !rx; 938 + 939 + if (is_break && uart_handle_break(&sport->port)) 940 + continue; 941 + 942 + if (uart_prepare_sysrq_char(&sport->port, rx)) 929 943 continue; 930 944 931 945 if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) { 932 - if (sr & UARTSTAT_PE) 933 - sport->port.icount.parity++; 934 - else if (sr & UARTSTAT_FE) 946 + if (sr & UARTSTAT_PE) { 947 + if (is_break) 948 + sport->port.icount.brk++; 949 + else 950 + sport->port.icount.parity++; 951 + } else if (sr & UARTSTAT_FE) { 935 952 sport->port.icount.frame++; 953 + } 936 954 937 955 if (sr & UARTSTAT_OR) 938 956 sport->port.icount.overrun++; ··· 958 950 959 951 sr &= sport->port.read_status_mask; 960 952 961 - if (sr & UARTSTAT_PE) 962 - flg = TTY_PARITY; 963 - else if (sr & UARTSTAT_FE) 953 + if (sr & UARTSTAT_PE) { 954 + if (is_break) 955 + flg = TTY_BREAK; 956 + else 957 + flg = TTY_PARITY; 958 + } else if (sr & UARTSTAT_FE) { 964 959 flg = TTY_FRAME; 960 + } 965 961 966 962 if (sr & UARTSTAT_OR) 967 963 flg = TTY_OVERRUN; 968 - 969 - sport->port.sysrq = 0; 970 964 } 971 965 972 966 tty_insert_flip_char(port, rx, flg); 973 967 } 974 968 975 969 out: 976 - spin_unlock_irqrestore(&sport->port.lock, flags); 970 + uart_unlock_and_check_sysrq(&sport->port); 977 971 978 972 tty_flip_buffer_push(port); 979 973 } ··· 1403 1393 1404 1394 static unsigned int lpuart_get_mctrl(struct uart_port *port) 1405 1395 { 1406 - unsigned int temp = 0; 1407 - unsigned char reg; 1396 + unsigned int mctrl = 0; 1397 + u8 reg; 1408 1398 1409 - reg = readb(port->membase + UARTMODEM); 1410 - if (reg & UARTMODEM_TXCTSE) 1411 - temp |= TIOCM_CTS; 1399 + reg = readb(port->membase + UARTCR1); 1400 + if (reg & UARTCR1_LOOPS) 1401 + mctrl |= TIOCM_LOOP; 1412 1402 1413 - if (reg & UARTMODEM_RXRTSE) 1414 - temp |= TIOCM_RTS; 1415 - 1416 - return temp; 1403 + return mctrl; 1417 1404 } 1418 1405 1419 1406 static unsigned int lpuart32_get_mctrl(struct uart_port *port) 1420 1407 { 1421 - unsigned int temp = 0; 1422 - unsigned long reg; 1408 + unsigned int mctrl = 0; 1409 + u32 reg; 1423 1410 1424 - reg = lpuart32_read(port, UARTMODIR); 1425 - if (reg & UARTMODIR_TXCTSE) 1426 - temp |= TIOCM_CTS; 1411 + reg = lpuart32_read(port, UARTCTRL); 1412 + if (reg & UARTCTRL_LOOPS) 1413 + mctrl |= TIOCM_LOOP; 1427 1414 1428 - if (reg & UARTMODIR_RXRTSE) 1429 - temp |= TIOCM_RTS; 1430 - 1431 - return temp; 1415 + return mctrl; 1432 1416 } 1433 1417 1434 1418 static void lpuart_set_mctrl(struct uart_port *port, unsigned int mctrl) 1435 1419 { 1436 - unsigned char temp; 1437 - struct lpuart_port *sport = container_of(port, 1438 - struct lpuart_port, port); 1420 + u8 reg; 1439 1421 1440 - /* Make sure RXRTSE bit is not set when RS485 is enabled */ 1441 - if (!(sport->port.rs485.flags & SER_RS485_ENABLED)) { 1442 - temp = readb(sport->port.membase + UARTMODEM) & 1443 - ~(UARTMODEM_RXRTSE | UARTMODEM_TXCTSE); 1422 + reg = readb(port->membase + UARTCR1); 1444 1423 1445 - if (mctrl & TIOCM_RTS) 1446 - temp |= UARTMODEM_RXRTSE; 1424 + /* for internal loopback we need LOOPS=1 and RSRC=0 */ 1425 + reg &= ~(UARTCR1_LOOPS | UARTCR1_RSRC); 1426 + if (mctrl & TIOCM_LOOP) 1427 + reg |= UARTCR1_LOOPS; 1447 1428 1448 - if (mctrl & TIOCM_CTS) 1449 - temp |= UARTMODEM_TXCTSE; 1450 - 1451 - writeb(temp, port->membase + UARTMODEM); 1452 - } 1429 + writeb(reg, port->membase + UARTCR1); 1453 1430 } 1454 1431 1455 1432 static void lpuart32_set_mctrl(struct uart_port *port, unsigned int mctrl) 1456 1433 { 1434 + u32 reg; 1457 1435 1436 + reg = lpuart32_read(port, UARTCTRL); 1437 + 1438 + /* for internal loopback we need LOOPS=1 and RSRC=0 */ 1439 + reg &= ~(UARTCTRL_LOOPS | UARTCTRL_RSRC); 1440 + if (mctrl & TIOCM_LOOP) 1441 + reg |= UARTCTRL_LOOPS; 1442 + 1443 + lpuart32_write(port, reg, UARTCTRL); 1458 1444 } 1459 1445 1460 1446 static void lpuart_break_ctl(struct uart_port *port, int break_state) ··· 1587 1581 u32 uartbaud; 1588 1582 int ret; 1589 1583 1584 + if (uart_console(&sport->port)) 1585 + goto err; 1586 + 1590 1587 if (!sport->dma_tx_chan) 1591 1588 goto err; 1592 1589 ··· 1619 1610 int ret; 1620 1611 unsigned char cr3; 1621 1612 1613 + if (uart_console(&sport->port)) 1614 + goto err; 1615 + 1622 1616 if (!sport->dma_rx_chan) 1623 1617 goto err; 1624 1618 ··· 1637 1625 sport->lpuart_dma_rx_use = true; 1638 1626 rx_dma_timer_init(sport); 1639 1627 1640 - if (sport->port.has_sysrq) { 1628 + if (sport->port.has_sysrq && !lpuart_is_32(sport)) { 1641 1629 cr3 = readb(sport->port.membase + UARTCR3); 1642 1630 cr3 |= UARTCR3_FEIE; 1643 1631 writeb(cr3, sport->port.membase + UARTCR3); ··· 2290 2278 unsigned long flags; 2291 2279 int locked = 1; 2292 2280 2293 - if (sport->port.sysrq || oops_in_progress) 2281 + if (oops_in_progress) 2294 2282 locked = spin_trylock_irqsave(&sport->port.lock, flags); 2295 2283 else 2296 2284 spin_lock_irqsave(&sport->port.lock, flags); ··· 2320 2308 unsigned long flags; 2321 2309 int locked = 1; 2322 2310 2323 - if (sport->port.sysrq || oops_in_progress) 2311 + if (oops_in_progress) 2324 2312 locked = spin_trylock_irqsave(&sport->port.lock, flags); 2325 2313 else 2326 2314 spin_lock_irqsave(&sport->port.lock, flags); ··· 2426 2414 2427 2415 bd = lpuart32_read(&sport->port, UARTBAUD); 2428 2416 bd &= UARTBAUD_SBR_MASK; 2417 + if (!bd) 2418 + return; 2419 + 2429 2420 sbr = bd; 2430 2421 uartclk = lpuart_get_baud_clk_rate(sport); 2431 2422 /*
+1 -1
drivers/tty/serial/icom.c
··· 37 37 #include <linux/firmware.h> 38 38 #include <linux/bitops.h> 39 39 40 - #include <asm/io.h> 40 + #include <linux/io.h> 41 41 #include <asm/irq.h> 42 42 #include <linux/uaccess.h> 43 43
+19 -8
drivers/tty/serial/imx.c
··· 225 225 struct scatterlist rx_sgl, tx_sgl[2]; 226 226 void *rx_buf; 227 227 struct circ_buf rx_ring; 228 + unsigned int rx_buf_size; 229 + unsigned int rx_period_length; 228 230 unsigned int rx_periods; 229 231 dma_cookie_t rx_cookie; 230 232 unsigned int tx_bytes; ··· 1185 1183 } 1186 1184 } 1187 1185 1188 - /* RX DMA buffer periods */ 1189 - #define RX_DMA_PERIODS 16 1190 - #define RX_BUF_SIZE (RX_DMA_PERIODS * PAGE_SIZE / 4) 1191 - 1192 1186 static int imx_uart_start_rx_dma(struct imx_port *sport) 1193 1187 { 1194 1188 struct scatterlist *sgl = &sport->rx_sgl; ··· 1195 1197 1196 1198 sport->rx_ring.head = 0; 1197 1199 sport->rx_ring.tail = 0; 1198 - sport->rx_periods = RX_DMA_PERIODS; 1199 1200 1200 - sg_init_one(sgl, sport->rx_buf, RX_BUF_SIZE); 1201 + sg_init_one(sgl, sport->rx_buf, sport->rx_buf_size); 1201 1202 ret = dma_map_sg(dev, sgl, 1, DMA_FROM_DEVICE); 1202 1203 if (ret == 0) { 1203 1204 dev_err(dev, "DMA mapping error for RX.\n"); ··· 1313 1316 goto err; 1314 1317 } 1315 1318 1316 - sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL); 1319 + sport->rx_buf_size = sport->rx_period_length * sport->rx_periods; 1320 + sport->rx_buf = kzalloc(sport->rx_buf_size, GFP_KERNEL); 1317 1321 if (!sport->rx_buf) { 1318 1322 ret = -ENOMEM; 1319 1323 goto err; ··· 1973 1975 { 1974 1976 struct imx_port *sport = imx_uart_ports[co->index]; 1975 1977 struct imx_port_ucrs old_ucr; 1978 + unsigned long flags; 1976 1979 unsigned int ucr1; 1977 - unsigned long flags = 0; 1978 1980 int locked = 1; 1979 1981 1980 1982 if (sport->port.sysrq) ··· 2177 2179 return HRTIMER_NORESTART; 2178 2180 } 2179 2181 2182 + /* Default RX DMA buffer configuration */ 2183 + #define RX_DMA_PERIODS 16 2184 + #define RX_DMA_PERIOD_LEN (PAGE_SIZE / 4) 2185 + 2180 2186 static int imx_uart_probe(struct platform_device *pdev) 2181 2187 { 2182 2188 struct device_node *np = pdev->dev.of_node; 2183 2189 struct imx_port *sport; 2184 2190 void __iomem *base; 2191 + u32 dma_buf_conf[2]; 2185 2192 int ret = 0; 2186 2193 u32 ucr1; 2187 2194 struct resource *res; ··· 2220 2217 2221 2218 if (of_get_property(np, "fsl,inverted-rx", NULL)) 2222 2219 sport->inverted_rx = 1; 2220 + 2221 + if (!of_property_read_u32_array(np, "fsl,dma-info", dma_buf_conf, 2)) { 2222 + sport->rx_period_length = dma_buf_conf[0]; 2223 + sport->rx_periods = dma_buf_conf[1]; 2224 + } else { 2225 + sport->rx_period_length = RX_DMA_PERIOD_LEN; 2226 + sport->rx_periods = RX_DMA_PERIODS; 2227 + } 2223 2228 2224 2229 if (sport->port.line >= ARRAY_SIZE(imx_uart_ports)) { 2225 2230 dev_err(&pdev->dev, "serial%d out of range\n",
+1 -1
drivers/tty/serial/ip22zilog.c
··· 31 31 #include <linux/spinlock.h> 32 32 #include <linux/init.h> 33 33 34 - #include <asm/io.h> 34 + #include <linux/io.h> 35 35 #include <asm/irq.h> 36 36 #include <asm/sgialib.h> 37 37 #include <asm/sgi/ioc.h>
+2 -2
drivers/tty/serial/kgdb_nmi.c
··· 115 115 static int kgdb_nmi_poll_one_knock(void) 116 116 { 117 117 static int n; 118 - int c = -1; 118 + int c; 119 119 const char *magic = kgdb_nmi_magic; 120 120 size_t m = strlen(magic); 121 121 bool printch = false; ··· 298 298 tty_port_hangup(&priv->port); 299 299 } 300 300 301 - static int kgdb_nmi_tty_write_room(struct tty_struct *tty) 301 + static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty) 302 302 { 303 303 /* Actually, we can handle any amount as we use polled writes. */ 304 304 return 2048;
+21
drivers/tty/serial/liteuart.c
··· 370 370 return 0; 371 371 } 372 372 console_initcall(liteuart_console_init); 373 + 374 + static void early_liteuart_write(struct console *console, const char *s, 375 + unsigned int count) 376 + { 377 + struct earlycon_device *device = console->data; 378 + struct uart_port *port = &device->port; 379 + 380 + uart_console_write(port, s, count, liteuart_putchar); 381 + } 382 + 383 + static int __init early_liteuart_setup(struct earlycon_device *device, 384 + const char *options) 385 + { 386 + if (!device->port.membase) 387 + return -ENODEV; 388 + 389 + device->con->write = early_liteuart_write; 390 + return 0; 391 + } 392 + 393 + OF_EARLYCON_DECLARE(liteuart, "litex,liteuart", early_liteuart_setup); 373 394 #endif /* CONFIG_SERIAL_LITEUART_CONSOLE */ 374 395 375 396 static int __init liteuart_init(void)
+26 -14
drivers/tty/serial/max310x.c
··· 552 552 return 1; 553 553 } 554 554 555 - static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s, 555 + static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s, 556 556 unsigned long freq, bool xtal) 557 557 { 558 558 unsigned int div, clksrc, pllcfg = 0; ··· 618 618 } 619 619 } 620 620 621 - return (int)bestfreq; 621 + return bestfreq; 622 622 } 623 623 624 624 static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len) ··· 1253 1253 static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype, 1254 1254 struct regmap *regmap, int irq) 1255 1255 { 1256 - int i, ret, fmin, fmax, freq, uartclk; 1256 + int i, ret, fmin, fmax, freq; 1257 1257 struct max310x_port *s; 1258 - bool xtal = false; 1258 + u32 uartclk = 0; 1259 + bool xtal; 1259 1260 1260 1261 if (IS_ERR(regmap)) 1261 1262 return PTR_ERR(regmap); ··· 1268 1267 return -ENOMEM; 1269 1268 } 1270 1269 1270 + /* Always ask for fixed clock rate from a property. */ 1271 + device_property_read_u32(dev, "clock-frequency", &uartclk); 1272 + 1271 1273 s->clk = devm_clk_get_optional(dev, "osc"); 1272 1274 if (IS_ERR(s->clk)) 1273 1275 return PTR_ERR(s->clk); 1274 1276 if (s->clk) { 1275 - fmin = 500000; 1276 - fmax = 35000000; 1277 + xtal = false; 1277 1278 } else { 1278 1279 s->clk = devm_clk_get_optional(dev, "xtal"); 1279 1280 if (IS_ERR(s->clk)) 1280 1281 return PTR_ERR(s->clk); 1281 - if (s->clk) { 1282 - fmin = 1000000; 1283 - fmax = 4000000; 1284 - xtal = true; 1285 - } else { 1286 - dev_err(dev, "Cannot get clock\n"); 1287 - return -EINVAL; 1288 - } 1282 + 1283 + xtal = true; 1289 1284 } 1290 1285 1291 1286 ret = clk_prepare_enable(s->clk); ··· 1289 1292 return ret; 1290 1293 1291 1294 freq = clk_get_rate(s->clk); 1295 + if (freq == 0) 1296 + freq = uartclk; 1297 + if (freq == 0) { 1298 + dev_err(dev, "Cannot get clock rate\n"); 1299 + return -EINVAL; 1300 + } 1301 + 1302 + if (xtal) { 1303 + fmin = 1000000; 1304 + fmax = 4000000; 1305 + } else { 1306 + fmin = 500000; 1307 + fmax = 35000000; 1308 + } 1309 + 1292 1310 /* Check frequency limits */ 1293 1311 if (freq < fmin || freq > fmax) { 1294 1312 ret = -ERANGE;
+6 -2
drivers/tty/serial/meson_uart.c
··· 715 715 { 716 716 struct resource *res_mem, *res_irq; 717 717 struct uart_port *port; 718 + u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */ 718 719 int ret = 0; 719 - int id = -1; 720 720 721 721 if (pdev->dev.of_node) 722 722 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); 723 723 724 724 if (pdev->id < 0) { 725 + int id; 726 + 725 727 for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) { 726 728 if (!meson_ports[id]) { 727 729 pdev->id = id; ··· 742 740 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 743 741 if (!res_irq) 744 742 return -ENODEV; 743 + 744 + of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); 745 745 746 746 if (meson_ports[pdev->id]) { 747 747 dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); ··· 774 770 port->type = PORT_MESON; 775 771 port->x_char = 0; 776 772 port->ops = &meson_uart_ops; 777 - port->fifosize = 64; 773 + port->fifosize = fifosize; 778 774 779 775 meson_ports[pdev->id] = port; 780 776 platform_set_drvdata(pdev, port);
+1 -1
drivers/tty/serial/mux.c
··· 21 21 #include <linux/console.h> 22 22 #include <linux/delay.h> /* for udelay */ 23 23 #include <linux/device.h> 24 - #include <asm/io.h> 24 + #include <linux/io.h> 25 25 #include <asm/irq.h> 26 26 #include <asm/parisc-device.h> 27 27
+12 -9
drivers/tty/serial/mvebu-uart.c
··· 128 128 struct uart_port *port; 129 129 struct clk *clk; 130 130 int irq[UART_IRQ_COUNT]; 131 - unsigned char __iomem *nb; 132 131 struct mvebu_uart_driver_data *data; 133 132 #if defined(CONFIG_PM) 134 133 struct mvebu_uart_pm_regs pm_regs; ··· 444 445 445 446 static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) 446 447 { 447 - struct mvebu_uart *mvuart = to_mvuart(port); 448 448 unsigned int d_divisor, m_divisor; 449 449 u32 brdv, osamp; 450 450 451 - if (IS_ERR(mvuart->clk)) 452 - return -PTR_ERR(mvuart->clk); 451 + if (!port->uartclk) 452 + return -EOPNOTSUPP; 453 453 454 454 /* 455 455 * The baudrate is derived from the UART clock thanks to two divisors: ··· 461 463 * makes use of D to configure the desired baudrate. 462 464 */ 463 465 m_divisor = OSAMP_DEFAULT_DIVISOR; 464 - d_divisor = DIV_ROUND_UP(port->uartclk, baud * m_divisor); 466 + d_divisor = DIV_ROUND_CLOSEST(port->uartclk, baud * m_divisor); 465 467 466 468 brdv = readl(port->membase + UART_BRDV); 467 469 brdv &= ~BRDV_BAUD_MASK; ··· 480 482 struct ktermios *old) 481 483 { 482 484 unsigned long flags; 483 - unsigned int baud; 485 + unsigned int baud, min_baud, max_baud; 484 486 485 487 spin_lock_irqsave(&port->lock, flags); 486 488 ··· 499 501 port->ignore_status_mask |= STAT_RX_RDY(port) | STAT_BRK_ERR; 500 502 501 503 /* 504 + * Maximal divisor is 1023 * 16 when using default (x16) scheme. 502 505 * Maximum achievable frequency with simple baudrate divisor is 230400. 503 506 * Since the error per bit frame would be of more than 15%, achieving 504 507 * higher frequencies would require to implement the fractional divisor 505 508 * feature. 506 509 */ 507 - baud = uart_get_baud_rate(port, termios, old, 0, 230400); 510 + min_baud = DIV_ROUND_UP(port->uartclk, 1023 * 16); 511 + max_baud = 230400; 512 + 513 + baud = uart_get_baud_rate(port, termios, old, min_baud, max_baud); 508 514 if (mvebu_uart_baud_rate_set(port, baud)) { 509 515 /* No clock available, baudrate cannot be changed */ 510 516 if (old) 511 - baud = uart_get_baud_rate(port, old, NULL, 0, 230400); 517 + baud = uart_get_baud_rate(port, old, NULL, 518 + min_baud, max_baud); 512 519 } else { 513 520 tty_termios_encode_baud_rate(termios, baud, baud); 514 521 uart_update_timeout(port, termios->c_cflag, baud); ··· 620 617 621 618 static void mvebu_uart_putc_early_write(struct console *con, 622 619 const char *s, 623 - unsigned n) 620 + unsigned int n) 624 621 { 625 622 struct earlycon_device *dev = con->data; 626 623
+4 -22
drivers/tty/serial/mxs-auart.c
··· 87 87 #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8) 88 88 #define AUART_LINECTRL_SPS (1 << 7) 89 89 #define AUART_LINECTRL_WLEN_MASK 0x00000060 90 - #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5) 90 + #define AUART_LINECTRL_WLEN(v) ((((v) - 5) & 0x3) << 5) 91 91 #define AUART_LINECTRL_FEN (1 << 4) 92 92 #define AUART_LINECTRL_STP2 (1 << 3) 93 93 #define AUART_LINECTRL_EPS (1 << 2) ··· 962 962 struct ktermios *old) 963 963 { 964 964 struct mxs_auart_port *s = to_auart_port(u); 965 - u32 bm, ctrl, ctrl2, div; 965 + u32 ctrl, ctrl2, div; 966 966 unsigned int cflag, baud, baud_min, baud_max; 967 967 968 968 cflag = termios->c_cflag; ··· 970 970 ctrl = AUART_LINECTRL_FEN; 971 971 ctrl2 = mxs_read(s, REG_CTRL2); 972 972 973 - /* byte size */ 974 - switch (cflag & CSIZE) { 975 - case CS5: 976 - bm = 0; 977 - break; 978 - case CS6: 979 - bm = 1; 980 - break; 981 - case CS7: 982 - bm = 2; 983 - break; 984 - case CS8: 985 - bm = 3; 986 - break; 987 - default: 988 - return; 989 - } 990 - 991 - ctrl |= AUART_LINECTRL_WLEN(bm); 973 + ctrl |= AUART_LINECTRL_WLEN(tty_get_char_size(cflag)); 992 974 993 975 /* parity */ 994 976 if (cflag & PARENB) { ··· 1385 1403 *parity = 'o'; 1386 1404 } 1387 1405 1388 - if ((lcr_h & AUART_LINECTRL_WLEN_MASK) == AUART_LINECTRL_WLEN(2)) 1406 + if ((lcr_h & AUART_LINECTRL_WLEN_MASK) == AUART_LINECTRL_WLEN(7)) 1389 1407 *bits = 7; 1390 1408 else 1391 1409 *bits = 8;
+5 -5
drivers/tty/serial/omap-serial.c
··· 626 626 static unsigned int serial_omap_tx_empty(struct uart_port *port) 627 627 { 628 628 struct uart_omap_port *up = to_uart_omap_port(port); 629 - unsigned long flags = 0; 629 + unsigned long flags; 630 630 unsigned int ret = 0; 631 631 632 632 pm_runtime_get_sync(up->dev); ··· 704 704 static void serial_omap_break_ctl(struct uart_port *port, int break_state) 705 705 { 706 706 struct uart_omap_port *up = to_uart_omap_port(port); 707 - unsigned long flags = 0; 707 + unsigned long flags; 708 708 709 709 dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line); 710 710 pm_runtime_get_sync(up->dev); ··· 722 722 static int serial_omap_startup(struct uart_port *port) 723 723 { 724 724 struct uart_omap_port *up = to_uart_omap_port(port); 725 - unsigned long flags = 0; 725 + unsigned long flags; 726 726 int retval; 727 727 728 728 /* ··· 797 797 static void serial_omap_shutdown(struct uart_port *port) 798 798 { 799 799 struct uart_omap_port *up = to_uart_omap_port(port); 800 - unsigned long flags = 0; 800 + unsigned long flags; 801 801 802 802 dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line); 803 803 ··· 845 845 { 846 846 struct uart_omap_port *up = to_uart_omap_port(port); 847 847 unsigned char cval = 0; 848 - unsigned long flags = 0; 848 + unsigned long flags; 849 849 unsigned int baud, quot; 850 850 851 851 switch (termios->c_cflag & CSIZE) {
+1 -1
drivers/tty/serial/pmac_zilog.c
··· 47 47 #include <linux/of_address.h> 48 48 #include <linux/of_irq.h> 49 49 #include <asm/sections.h> 50 - #include <asm/io.h> 50 + #include <linux/io.h> 51 51 #include <asm/irq.h> 52 52 53 53 #ifdef CONFIG_PPC_PMAC
+5 -17
drivers/tty/serial/qcom_geni_serial.c
··· 1050 1050 } 1051 1051 1052 1052 /* bits per char */ 1053 - switch (termios->c_cflag & CSIZE) { 1054 - case CS5: 1055 - bits_per_char = 5; 1056 - break; 1057 - case CS6: 1058 - bits_per_char = 6; 1059 - break; 1060 - case CS7: 1061 - bits_per_char = 7; 1062 - break; 1063 - case CS8: 1064 - default: 1065 - bits_per_char = 8; 1066 - break; 1067 - } 1053 + bits_per_char = tty_get_char_size(termios->c_cflag); 1068 1054 1069 1055 /* stop bits */ 1070 1056 if (termios->c_cflag & CSTOPB) ··· 1324 1338 static int qcom_geni_serial_probe(struct platform_device *pdev) 1325 1339 { 1326 1340 int ret = 0; 1327 - int line = -1; 1341 + int line; 1328 1342 struct qcom_geni_serial_port *port; 1329 1343 struct uart_port *uport; 1330 1344 struct resource *res; ··· 1340 1354 line = of_alias_get_id(pdev->dev.of_node, "serial"); 1341 1355 } else { 1342 1356 drv = &qcom_geni_uart_driver; 1343 - line = of_alias_get_id(pdev->dev.of_node, "hsuart"); 1357 + line = of_alias_get_id(pdev->dev.of_node, "serial"); 1358 + if (line == -ENODEV) /* compat with non-standard aliases */ 1359 + line = of_alias_get_id(pdev->dev.of_node, "hsuart"); 1344 1360 } 1345 1361 1346 1362 port = get_port_from_line(line, console);
+1 -2
drivers/tty/serial/samsung_tty.c
··· 2220 2220 default: 2221 2221 dev_warn(&pdev->dev, "unsupported reg-io-width (%d)\n", 2222 2222 prop); 2223 - ret = -EINVAL; 2224 - break; 2223 + return -EINVAL; 2225 2224 } 2226 2225 } 2227 2226 }
+1 -1
drivers/tty/serial/sb1250-duart.c
··· 34 34 #include <linux/types.h> 35 35 36 36 #include <linux/refcount.h> 37 - #include <asm/io.h> 37 + #include <linux/io.h> 38 38 39 39 #include <asm/sibyte/sb1250.h> 40 40 #include <asm/sibyte/sb1250_uart.h>
+13 -13
drivers/tty/serial/sc16is7xx.c
··· 1208 1208 /* Always ask for fixed clock rate from a property. */ 1209 1209 device_property_read_u32(dev, "clock-frequency", &uartclk); 1210 1210 1211 - s->clk = devm_clk_get(dev, NULL); 1212 - if (IS_ERR(s->clk)) { 1211 + s->clk = devm_clk_get_optional(dev, NULL); 1212 + if (IS_ERR(s->clk)) 1213 + return PTR_ERR(s->clk); 1214 + 1215 + ret = clk_prepare_enable(s->clk); 1216 + if (ret) 1217 + return ret; 1218 + 1219 + freq = clk_get_rate(s->clk); 1220 + if (freq == 0) { 1213 1221 if (uartclk) 1214 1222 freq = uartclk; 1215 1223 if (pfreq) ··· 1225 1217 if (freq) 1226 1218 dev_dbg(dev, "Clock frequency: %luHz\n", freq); 1227 1219 else 1228 - return PTR_ERR(s->clk); 1229 - } else { 1230 - ret = clk_prepare_enable(s->clk); 1231 - if (ret) 1232 - return ret; 1233 - 1234 - freq = clk_get_rate(s->clk); 1220 + return -EINVAL; 1235 1221 } 1236 1222 1237 1223 s->regmap = regmap; ··· 1360 1358 kthread_stop(s->kworker_task); 1361 1359 1362 1360 out_clk: 1363 - if (!IS_ERR(s->clk)) 1364 - clk_disable_unprepare(s->clk); 1361 + clk_disable_unprepare(s->clk); 1365 1362 1366 1363 return ret; 1367 1364 } ··· 1384 1383 kthread_flush_worker(&s->kworker); 1385 1384 kthread_stop(s->kworker_task); 1386 1385 1387 - if (!IS_ERR(s->clk)) 1388 - clk_disable_unprepare(s->clk); 1386 + clk_disable_unprepare(s->clk); 1389 1387 1390 1388 return 0; 1391 1389 }
+18 -40
drivers/tty/serial/serial_core.c
··· 184 184 int init_hw) 185 185 { 186 186 struct uart_port *uport = uart_port_check(state); 187 + unsigned long flags; 187 188 unsigned long page; 188 - unsigned long flags = 0; 189 189 int retval = 0; 190 190 191 191 if (uport->type == PORT_UNKNOWN) ··· 275 275 { 276 276 struct uart_port *uport = uart_port_check(state); 277 277 struct tty_port *port = &state->port; 278 - unsigned long flags = 0; 278 + unsigned long flags; 279 279 char *xmit_buf = NULL; 280 280 281 281 /* ··· 334 334 uart_update_timeout(struct uart_port *port, unsigned int cflag, 335 335 unsigned int baud) 336 336 { 337 - unsigned int bits; 337 + unsigned int size; 338 338 339 - /* byte size and parity */ 340 - switch (cflag & CSIZE) { 341 - case CS5: 342 - bits = 7; 343 - break; 344 - case CS6: 345 - bits = 8; 346 - break; 347 - case CS7: 348 - bits = 9; 349 - break; 350 - default: 351 - bits = 10; 352 - break; /* CS8 */ 353 - } 354 - 355 - if (cflag & CSTOPB) 356 - bits++; 357 - if (cflag & PARENB) 358 - bits++; 359 - 360 - /* 361 - * The total number of bits to be transmitted in the fifo. 362 - */ 363 - bits = bits * port->fifosize; 339 + size = tty_get_frame_size(cflag) * port->fifosize; 364 340 365 341 /* 366 342 * Figure the timeout to send the above number of bits. 367 343 * Add .02 seconds of slop 368 344 */ 369 - port->timeout = (HZ * bits) / baud + HZ/50; 345 + port->timeout = (HZ * size) / baud + HZ/50; 370 346 } 371 347 372 348 EXPORT_SYMBOL(uart_update_timeout); ··· 592 616 return ret; 593 617 } 594 618 595 - static int uart_write_room(struct tty_struct *tty) 619 + static unsigned int uart_write_room(struct tty_struct *tty) 596 620 { 597 621 struct uart_state *state = tty->driver_data; 598 622 struct uart_port *port; 599 623 unsigned long flags; 600 - int ret; 624 + unsigned int ret; 601 625 602 626 port = uart_port_lock(state, flags); 603 627 ret = uart_circ_chars_free(&state->xmit); ··· 605 629 return ret; 606 630 } 607 631 608 - static int uart_chars_in_buffer(struct tty_struct *tty) 632 + static unsigned int uart_chars_in_buffer(struct tty_struct *tty) 609 633 { 610 634 struct uart_state *state = tty->driver_data; 611 635 struct uart_port *port; 612 636 unsigned long flags; 613 - int ret; 637 + unsigned int ret; 614 638 615 639 port = uart_port_lock(state, flags); 616 640 ret = uart_circ_chars_pending(&state->xmit); ··· 3005 3029 /* 3006 3030 * Are the two ports equivalent? 3007 3031 */ 3008 - int uart_match_port(struct uart_port *port1, struct uart_port *port2) 3032 + bool uart_match_port(const struct uart_port *port1, 3033 + const struct uart_port *port2) 3009 3034 { 3010 3035 if (port1->iotype != port2->iotype) 3011 - return 0; 3036 + return false; 3012 3037 3013 3038 switch (port1->iotype) { 3014 3039 case UPIO_PORT: 3015 - return (port1->iobase == port2->iobase); 3040 + return port1->iobase == port2->iobase; 3016 3041 case UPIO_HUB6: 3017 - return (port1->iobase == port2->iobase) && 3018 - (port1->hub6 == port2->hub6); 3042 + return port1->iobase == port2->iobase && 3043 + port1->hub6 == port2->hub6; 3019 3044 case UPIO_MEM: 3020 3045 case UPIO_MEM16: 3021 3046 case UPIO_MEM32: 3022 3047 case UPIO_MEM32BE: 3023 3048 case UPIO_AU: 3024 3049 case UPIO_TSI: 3025 - return (port1->mapbase == port2->mapbase); 3050 + return port1->mapbase == port2->mapbase; 3026 3051 } 3027 - return 0; 3052 + 3053 + return false; 3028 3054 } 3029 3055 EXPORT_SYMBOL(uart_match_port); 3030 3056
+1 -1
drivers/tty/serial/serial_txx9.c
··· 24 24 #include <linux/tty.h> 25 25 #include <linux/tty_flip.h> 26 26 27 - #include <asm/io.h> 27 + #include <linux/io.h> 28 28 29 29 static char *serial_version = "1.11"; 30 30 static char *serial_name = "TX39/49 Serial driver";
+19 -22
drivers/tty/serial/sh-sci.c
··· 289 289 }, 290 290 291 291 /* 292 - * The "SCIFA" that is in RZ/T and RZ/A2. 292 + * The "SCIFA" that is in RZ/A2, RZ/G2L and RZ/T. 293 293 * It looks like a normal SCIF with FIFO data, but with a 294 294 * compressed address space. Also, the break out of interrupts 295 295 * are different: ERI/BRI, RXI, TXI, TEI, DRI. ··· 306 306 [SCFDR] = { 0x0E, 16 }, 307 307 [SCSPTR] = { 0x10, 16 }, 308 308 [SCLSR] = { 0x12, 16 }, 309 + [SEMR] = { 0x14, 8 }, 309 310 }, 310 311 .fifosize = 16, 311 312 .overrun_reg = SCLSR, ··· 611 610 ctrl &= ~SCSCR_TIE; 612 611 613 612 serial_port_out(port, SCSCR, ctrl); 613 + 614 + #ifdef CONFIG_SERIAL_SH_SCI_DMA 615 + if (to_sci_port(port)->chan_tx && 616 + !dma_submit_error(to_sci_port(port)->cookie_tx)) { 617 + dmaengine_terminate_async(to_sci_port(port)->chan_tx); 618 + to_sci_port(port)->cookie_tx = -EINVAL; 619 + } 620 + #endif 614 621 } 615 622 616 623 static void sci_start_rx(struct uart_port *port) ··· 848 839 sci_stop_tx(port); 849 840 850 841 } 851 - 852 - /* On SH3, SCIF may read end-of-break as a space->mark char */ 853 - #define STEPFN(c) ({int __c = (c); (((__c-1)|(__c)) == -1); }) 854 842 855 843 static void sci_receive_chars(struct uart_port *port) 856 844 { ··· 2500 2494 uart_update_timeout(port, termios->c_cflag, baud); 2501 2495 2502 2496 /* byte size and parity */ 2503 - switch (termios->c_cflag & CSIZE) { 2504 - case CS5: 2505 - bits = 7; 2506 - break; 2507 - case CS6: 2508 - bits = 8; 2509 - break; 2510 - case CS7: 2511 - bits = 9; 2512 - break; 2513 - default: 2514 - bits = 10; 2515 - break; 2516 - } 2497 + bits = tty_get_frame_size(termios->c_cflag); 2517 2498 2518 - if (termios->c_cflag & CSTOPB) 2519 - bits++; 2520 - if (termios->c_cflag & PARENB) 2521 - bits++; 2499 + if (sci_getreg(port, SEMR)->size) 2500 + serial_port_out(port, SEMR, 0); 2522 2501 2523 2502 if (best_clk >= 0) { 2524 2503 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) ··· 3161 3170 .compatible = "renesas,scif-r7s9210", 3162 3171 .data = SCI_OF_DATA(PORT_SCIF, SCIx_RZ_SCIFA_REGTYPE), 3163 3172 }, 3173 + { 3174 + .compatible = "renesas,scif-r9a07g044", 3175 + .data = SCI_OF_DATA(PORT_SCIF, SCIx_RZ_SCIFA_REGTYPE), 3176 + }, 3164 3177 /* Family-specific types */ 3165 3178 { 3166 3179 .compatible = "renesas,rcar-gen1-scif", ··· 3447 3452 port_cfg.regtype = SCIx_RZ_SCIFA_REGTYPE; 3448 3453 return early_console_setup(device, PORT_SCIF); 3449 3454 } 3455 + 3450 3456 static int __init scifa_early_console_setup(struct earlycon_device *device, 3451 3457 const char *opt) 3452 3458 { ··· 3467 3471 OF_EARLYCON_DECLARE(sci, "renesas,sci", sci_early_console_setup); 3468 3472 OF_EARLYCON_DECLARE(scif, "renesas,scif", scif_early_console_setup); 3469 3473 OF_EARLYCON_DECLARE(scif, "renesas,scif-r7s9210", rzscifa_early_console_setup); 3474 + OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a07g044", rzscifa_early_console_setup); 3470 3475 OF_EARLYCON_DECLARE(scifa, "renesas,scifa", scifa_early_console_setup); 3471 3476 OF_EARLYCON_DECLARE(scifb, "renesas,scifb", scifb_early_console_setup); 3472 3477 OF_EARLYCON_DECLARE(hscif, "renesas,hscif", hscif_early_console_setup);
+1
drivers/tty/serial/sh-sci.h
··· 31 31 SCCKS, /* BRG Clock Select Register */ 32 32 HSRTRGR, /* Rx FIFO Data Count Trigger Register */ 33 33 HSTTRGR, /* Tx FIFO Data Count Trigger Register */ 34 + SEMR, /* Serial extended mode register */ 34 35 35 36 SCIx_NR_REGS, 36 37 };
+2 -2
drivers/tty/serial/st-asc.c
··· 65 65 /* ASC_RXBUF */ 66 66 #define ASC_RXBUF_PE 0x100 67 67 #define ASC_RXBUF_FE 0x200 68 - /** 68 + /* 69 69 * Some of status comes from higher bits of the character and some come from 70 70 * the status register. Combining both of them in to single status using dummy 71 71 * bits. ··· 478 478 unsigned int oldstate) 479 479 { 480 480 struct asc_port *ascport = to_asc_port(port); 481 - unsigned long flags = 0; 481 + unsigned long flags; 482 482 u32 ctl; 483 483 484 484 switch (state) {
+80 -119
drivers/tty/serial/stm32-usart.c
··· 718 718 free_irq(port->irq, port); 719 719 } 720 720 721 - static unsigned int stm32_usart_get_databits(struct ktermios *termios) 722 - { 723 - unsigned int bits; 724 - 725 - tcflag_t cflag = termios->c_cflag; 726 - 727 - switch (cflag & CSIZE) { 728 - /* 729 - * CSIZE settings are not necessarily supported in hardware. 730 - * CSIZE unsupported configurations are handled here to set word length 731 - * to 8 bits word as default configuration and to print debug message. 732 - */ 733 - case CS5: 734 - bits = 5; 735 - break; 736 - case CS6: 737 - bits = 6; 738 - break; 739 - case CS7: 740 - bits = 7; 741 - break; 742 - /* default including CS8 */ 743 - default: 744 - bits = 8; 745 - break; 746 - } 747 - 748 - return bits; 749 - } 750 - 751 721 static void stm32_usart_set_termios(struct uart_port *port, 752 722 struct ktermios *termios, 753 723 struct ktermios *old) ··· 775 805 if (cflag & CSTOPB) 776 806 cr2 |= USART_CR2_STOP_2B; 777 807 778 - bits = stm32_usart_get_databits(termios); 808 + bits = tty_get_char_size(cflag); 779 809 stm32_port->rdr_mask = (BIT(bits) - 1); 780 810 781 811 if (cflag & PARENB) { ··· 950 980 struct stm32_port, port); 951 981 const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; 952 982 const struct stm32_usart_config *cfg = &stm32port->info->cfg; 953 - unsigned long flags = 0; 983 + unsigned long flags; 954 984 955 985 switch (state) { 956 986 case UART_PM_STATE_ON: ··· 1152 1182 MODULE_DEVICE_TABLE(of, stm32_match); 1153 1183 #endif 1154 1184 1185 + static void stm32_usart_of_dma_rx_remove(struct stm32_port *stm32port, 1186 + struct platform_device *pdev) 1187 + { 1188 + if (stm32port->rx_buf) 1189 + dma_free_coherent(&pdev->dev, RX_BUF_L, stm32port->rx_buf, 1190 + stm32port->rx_dma_buf); 1191 + } 1192 + 1155 1193 static int stm32_usart_of_dma_rx_probe(struct stm32_port *stm32port, 1156 1194 struct platform_device *pdev) 1157 1195 { ··· 1177 1199 if (uart_console(port)) 1178 1200 return -ENODEV; 1179 1201 1180 - /* Request DMA RX channel */ 1181 - stm32port->rx_ch = dma_request_slave_channel(dev, "rx"); 1182 - if (!stm32port->rx_ch) { 1183 - dev_info(dev, "rx dma alloc failed\n"); 1184 - return -ENODEV; 1185 - } 1186 1202 stm32port->rx_buf = dma_alloc_coherent(&pdev->dev, RX_BUF_L, 1187 1203 &stm32port->rx_dma_buf, 1188 1204 GFP_KERNEL); 1189 - if (!stm32port->rx_buf) { 1190 - ret = -ENOMEM; 1191 - goto alloc_err; 1192 - } 1205 + if (!stm32port->rx_buf) 1206 + return -ENOMEM; 1193 1207 1194 1208 /* Configure DMA channel */ 1195 1209 memset(&config, 0, sizeof(config)); ··· 1191 1221 ret = dmaengine_slave_config(stm32port->rx_ch, &config); 1192 1222 if (ret < 0) { 1193 1223 dev_err(dev, "rx dma channel config failed\n"); 1194 - ret = -ENODEV; 1195 - goto config_err; 1224 + stm32_usart_of_dma_rx_remove(stm32port, pdev); 1225 + return ret; 1196 1226 } 1197 1227 1198 1228 /* Prepare a DMA cyclic transaction */ ··· 1202 1232 DMA_PREP_INTERRUPT); 1203 1233 if (!desc) { 1204 1234 dev_err(dev, "rx dma prep cyclic failed\n"); 1205 - ret = -ENODEV; 1206 - goto config_err; 1235 + stm32_usart_of_dma_rx_remove(stm32port, pdev); 1236 + return -ENODEV; 1207 1237 } 1208 1238 1209 1239 /* No callback as dma buffer is drained on usart interrupt */ ··· 1214 1244 ret = dma_submit_error(dmaengine_submit(desc)); 1215 1245 if (ret) { 1216 1246 dmaengine_terminate_sync(stm32port->rx_ch); 1217 - goto config_err; 1247 + stm32_usart_of_dma_rx_remove(stm32port, pdev); 1248 + return ret; 1218 1249 } 1219 1250 1220 1251 /* Issue pending DMA requests */ 1221 1252 dma_async_issue_pending(stm32port->rx_ch); 1222 1253 1223 1254 return 0; 1255 + } 1224 1256 1225 - config_err: 1226 - dma_free_coherent(&pdev->dev, 1227 - RX_BUF_L, stm32port->rx_buf, 1228 - stm32port->rx_dma_buf); 1229 - 1230 - alloc_err: 1231 - dma_release_channel(stm32port->rx_ch); 1232 - stm32port->rx_ch = NULL; 1233 - 1234 - return ret; 1257 + static void stm32_usart_of_dma_tx_remove(struct stm32_port *stm32port, 1258 + struct platform_device *pdev) 1259 + { 1260 + if (stm32port->tx_buf) 1261 + dma_free_coherent(&pdev->dev, TX_BUF_L, stm32port->tx_buf, 1262 + stm32port->tx_dma_buf); 1235 1263 } 1236 1264 1237 1265 static int stm32_usart_of_dma_tx_probe(struct stm32_port *stm32port, ··· 1243 1275 1244 1276 stm32port->tx_dma_busy = false; 1245 1277 1246 - /* Request DMA TX channel */ 1247 - stm32port->tx_ch = dma_request_slave_channel(dev, "tx"); 1248 - if (!stm32port->tx_ch) { 1249 - dev_info(dev, "tx dma alloc failed\n"); 1250 - return -ENODEV; 1251 - } 1252 1278 stm32port->tx_buf = dma_alloc_coherent(&pdev->dev, TX_BUF_L, 1253 1279 &stm32port->tx_dma_buf, 1254 1280 GFP_KERNEL); 1255 - if (!stm32port->tx_buf) { 1256 - ret = -ENOMEM; 1257 - goto alloc_err; 1258 - } 1281 + if (!stm32port->tx_buf) 1282 + return -ENOMEM; 1259 1283 1260 1284 /* Configure DMA channel */ 1261 1285 memset(&config, 0, sizeof(config)); ··· 1257 1297 ret = dmaengine_slave_config(stm32port->tx_ch, &config); 1258 1298 if (ret < 0) { 1259 1299 dev_err(dev, "tx dma channel config failed\n"); 1260 - ret = -ENODEV; 1261 - goto config_err; 1300 + stm32_usart_of_dma_tx_remove(stm32port, pdev); 1301 + return ret; 1262 1302 } 1263 1303 1264 1304 return 0; 1265 - 1266 - config_err: 1267 - dma_free_coherent(&pdev->dev, 1268 - TX_BUF_L, stm32port->tx_buf, 1269 - stm32port->tx_dma_buf); 1270 - 1271 - alloc_err: 1272 - dma_release_channel(stm32port->tx_ch); 1273 - stm32port->tx_ch = NULL; 1274 - 1275 - return ret; 1276 1305 } 1277 1306 1278 1307 static int stm32_usart_serial_probe(struct platform_device *pdev) ··· 1285 1336 device_set_wakeup_capable(&pdev->dev, true); 1286 1337 ret = dev_pm_set_wake_irq(&pdev->dev, stm32port->port.irq); 1287 1338 if (ret) 1288 - goto err_nowup; 1339 + goto err_deinit_port; 1289 1340 } 1290 1341 1291 - ret = stm32_usart_of_dma_rx_probe(stm32port, pdev); 1292 - if (ret) 1293 - dev_info(&pdev->dev, "interrupt mode used for rx (no dma)\n"); 1342 + stm32port->rx_ch = dma_request_chan(&pdev->dev, "rx"); 1343 + if (PTR_ERR(stm32port->rx_ch) == -EPROBE_DEFER) { 1344 + ret = -EPROBE_DEFER; 1345 + goto err_wakeirq; 1346 + } 1347 + /* Fall back in interrupt mode for any non-deferral error */ 1348 + if (IS_ERR(stm32port->rx_ch)) 1349 + stm32port->rx_ch = NULL; 1294 1350 1295 - ret = stm32_usart_of_dma_tx_probe(stm32port, pdev); 1296 - if (ret) 1297 - dev_info(&pdev->dev, "interrupt mode used for tx (no dma)\n"); 1351 + stm32port->tx_ch = dma_request_chan(&pdev->dev, "tx"); 1352 + if (PTR_ERR(stm32port->tx_ch) == -EPROBE_DEFER) { 1353 + ret = -EPROBE_DEFER; 1354 + goto err_dma_rx; 1355 + } 1356 + /* Fall back in interrupt mode for any non-deferral error */ 1357 + if (IS_ERR(stm32port->tx_ch)) 1358 + stm32port->tx_ch = NULL; 1359 + 1360 + if (stm32port->rx_ch && stm32_usart_of_dma_rx_probe(stm32port, pdev)) { 1361 + /* Fall back in interrupt mode */ 1362 + dma_release_channel(stm32port->rx_ch); 1363 + stm32port->rx_ch = NULL; 1364 + } 1365 + 1366 + if (stm32port->tx_ch && stm32_usart_of_dma_tx_probe(stm32port, pdev)) { 1367 + /* Fall back in interrupt mode */ 1368 + dma_release_channel(stm32port->tx_ch); 1369 + stm32port->tx_ch = NULL; 1370 + } 1371 + 1372 + if (!stm32port->rx_ch) 1373 + dev_info(&pdev->dev, "interrupt mode for rx (no dma)\n"); 1374 + if (!stm32port->tx_ch) 1375 + dev_info(&pdev->dev, "interrupt mode for tx (no dma)\n"); 1298 1376 1299 1377 platform_set_drvdata(pdev, &stm32port->port); 1300 1378 ··· 1342 1366 pm_runtime_set_suspended(&pdev->dev); 1343 1367 pm_runtime_put_noidle(&pdev->dev); 1344 1368 1345 - if (stm32port->rx_ch) { 1346 - dmaengine_terminate_async(stm32port->rx_ch); 1347 - dma_release_channel(stm32port->rx_ch); 1348 - } 1349 - 1350 - if (stm32port->rx_dma_buf) 1351 - dma_free_coherent(&pdev->dev, 1352 - RX_BUF_L, stm32port->rx_buf, 1353 - stm32port->rx_dma_buf); 1354 - 1355 1369 if (stm32port->tx_ch) { 1356 - dmaengine_terminate_async(stm32port->tx_ch); 1370 + stm32_usart_of_dma_tx_remove(stm32port, pdev); 1357 1371 dma_release_channel(stm32port->tx_ch); 1358 1372 } 1359 1373 1360 - if (stm32port->tx_dma_buf) 1361 - dma_free_coherent(&pdev->dev, 1362 - TX_BUF_L, stm32port->tx_buf, 1363 - stm32port->tx_dma_buf); 1374 + if (stm32port->rx_ch) 1375 + stm32_usart_of_dma_rx_remove(stm32port, pdev); 1364 1376 1377 + err_dma_rx: 1378 + if (stm32port->rx_ch) 1379 + dma_release_channel(stm32port->rx_ch); 1380 + 1381 + err_wakeirq: 1365 1382 if (stm32port->wakeup_src) 1366 1383 dev_pm_clear_wake_irq(&pdev->dev); 1367 1384 1368 - err_nowup: 1385 + err_deinit_port: 1369 1386 if (stm32port->wakeup_src) 1370 1387 device_set_wakeup_capable(&pdev->dev, false); 1371 1388 ··· 1385 1416 1386 1417 stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 1387 1418 1388 - if (stm32_port->rx_ch) { 1389 - dmaengine_terminate_async(stm32_port->rx_ch); 1390 - dma_release_channel(stm32_port->rx_ch); 1391 - } 1392 - 1393 - if (stm32_port->rx_dma_buf) 1394 - dma_free_coherent(&pdev->dev, 1395 - RX_BUF_L, stm32_port->rx_buf, 1396 - stm32_port->rx_dma_buf); 1397 - 1398 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 1399 - 1400 1419 if (stm32_port->tx_ch) { 1401 1420 dmaengine_terminate_async(stm32_port->tx_ch); 1421 + stm32_usart_of_dma_tx_remove(stm32_port, pdev); 1402 1422 dma_release_channel(stm32_port->tx_ch); 1403 1423 } 1404 1424 1405 - if (stm32_port->tx_dma_buf) 1406 - dma_free_coherent(&pdev->dev, 1407 - TX_BUF_L, stm32_port->tx_buf, 1408 - stm32_port->tx_dma_buf); 1425 + if (stm32_port->rx_ch) { 1426 + dmaengine_terminate_async(stm32_port->rx_ch); 1427 + stm32_usart_of_dma_rx_remove(stm32_port, pdev); 1428 + dma_release_channel(stm32_port->rx_ch); 1429 + } 1430 + 1431 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 1409 1432 1410 1433 if (stm32_port->wakeup_src) { 1411 1434 dev_pm_clear_wake_irq(&pdev->dev);
+1 -1
drivers/tty/serial/sunsab.c
··· 35 35 #include <linux/init.h> 36 36 #include <linux/of_device.h> 37 37 38 - #include <asm/io.h> 38 + #include <linux/io.h> 39 39 #include <asm/irq.h> 40 40 #include <asm/prom.h> 41 41 #include <asm/setup.h>
+1 -1
drivers/tty/serial/sunsu.c
··· 39 39 #include <linux/delay.h> 40 40 #include <linux/of_device.h> 41 41 42 - #include <asm/io.h> 42 + #include <linux/io.h> 43 43 #include <asm/irq.h> 44 44 #include <asm/prom.h> 45 45 #include <asm/setup.h>
+1 -1
drivers/tty/serial/sunzilog.c
··· 35 35 #include <linux/init.h> 36 36 #include <linux/of_device.h> 37 37 38 - #include <asm/io.h> 38 + #include <linux/io.h> 39 39 #include <asm/irq.h> 40 40 #include <asm/prom.h> 41 41 #include <asm/setup.h>
+15 -11
drivers/tty/serial/tegra-tcu.c
··· 195 195 return err; 196 196 } 197 197 198 - tcu->rx = mbox_request_channel_byname(&tcu->rx_client, "rx"); 199 - if (IS_ERR(tcu->rx)) { 200 - err = PTR_ERR(tcu->rx); 201 - dev_err(&pdev->dev, "failed to get rx mailbox: %d\n", err); 202 - goto free_tx; 203 - } 204 - 205 198 #if IS_ENABLED(CONFIG_SERIAL_TEGRA_TCU_CONSOLE) 206 199 /* setup the console */ 207 200 strcpy(tcu->console.name, "ttyTCU"); ··· 219 226 if (err) { 220 227 dev_err(&pdev->dev, "failed to register UART driver: %d\n", 221 228 err); 222 - goto free_rx; 229 + goto free_tx; 223 230 } 224 231 225 232 /* setup the port */ ··· 239 246 goto unregister_uart; 240 247 } 241 248 249 + /* 250 + * Request RX channel after creating port to ensure tcu->port 251 + * is ready for any immediate incoming bytes. 252 + */ 253 + tcu->rx = mbox_request_channel_byname(&tcu->rx_client, "rx"); 254 + if (IS_ERR(tcu->rx)) { 255 + err = PTR_ERR(tcu->rx); 256 + dev_err(&pdev->dev, "failed to get rx mailbox: %d\n", err); 257 + goto remove_uart_port; 258 + } 259 + 242 260 platform_set_drvdata(pdev, tcu); 243 261 #if IS_ENABLED(CONFIG_SERIAL_TEGRA_TCU_CONSOLE) 244 262 register_console(&tcu->console); ··· 257 253 258 254 return 0; 259 255 256 + remove_uart_port: 257 + uart_remove_one_port(&tcu->driver, &tcu->port); 260 258 unregister_uart: 261 259 uart_unregister_driver(&tcu->driver); 262 - free_rx: 263 - mbox_free_channel(tcu->rx); 264 260 free_tx: 265 261 mbox_free_channel(tcu->tx); 266 262 ··· 274 270 #if IS_ENABLED(CONFIG_SERIAL_TEGRA_TCU_CONSOLE) 275 271 unregister_console(&tcu->console); 276 272 #endif 273 + mbox_free_channel(tcu->rx); 277 274 uart_remove_one_port(&tcu->driver, &tcu->port); 278 275 uart_unregister_driver(&tcu->driver); 279 - mbox_free_channel(tcu->rx); 280 276 mbox_free_channel(tcu->tx); 281 277 282 278 return 0;
+6 -21
drivers/tty/serial/uartlite.c
··· 505 505 506 506 static int ulite_console_setup(struct console *co, char *options) 507 507 { 508 - struct uart_port *port; 508 + struct uart_port *port = NULL; 509 509 int baud = 9600; 510 510 int bits = 8; 511 511 int parity = 'n'; 512 512 int flow = 'n'; 513 513 514 - 515 - port = console_port; 514 + if (co->index >= 0 && co->index < ULITE_NR_UARTS) 515 + port = ulite_ports + co->index; 516 516 517 517 /* Has the device been initialized yet? */ 518 - if (!port->mapbase) { 518 + if (!port || !port->mapbase) { 519 519 pr_debug("console on ttyUL%i not present\n", co->index); 520 520 return -ENODEV; 521 521 } 522 + 523 + console_port = port; 522 524 523 525 /* not initialized yet? */ 524 526 if (!port->membase) { ··· 657 655 658 656 dev_set_drvdata(dev, port); 659 657 660 - #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE 661 - /* 662 - * If console hasn't been found yet try to assign this port 663 - * because it is required to be assigned for console setup function. 664 - * If register_console() don't assign value, then console_port pointer 665 - * is cleanup. 666 - */ 667 - if (ulite_uart_driver.cons->index == -1) 668 - console_port = port; 669 - #endif 670 - 671 658 /* Register the port */ 672 659 rc = uart_add_one_port(&ulite_uart_driver, port); 673 660 if (rc) { ··· 665 674 dev_set_drvdata(dev, NULL); 666 675 return rc; 667 676 } 668 - 669 - #ifdef CONFIG_SERIAL_UARTLITE_CONSOLE 670 - /* This is not port which is used for console that's why clean it up */ 671 - if (ulite_uart_driver.cons->index == -1) 672 - console_port = NULL; 673 - #endif 674 677 675 678 return 0; 676 679 }
+1 -1
drivers/tty/serial/vr41xx_siu.c
··· 20 20 #include <linux/tty.h> 21 21 #include <linux/tty_flip.h> 22 22 23 - #include <asm/io.h> 23 + #include <linux/io.h> 24 24 #include <asm/vr41xx/siu.h> 25 25 #include <asm/vr41xx/vr41xx.h> 26 26
+6 -6
drivers/tty/serial/xilinx_uartps.c
··· 484 484 485 485 #ifdef CONFIG_COMMON_CLK 486 486 /** 487 - * cdns_uart_clk_notitifer_cb - Clock notifier callback 487 + * cdns_uart_clk_notifier_cb - Clock notifier callback 488 488 * @nb: Notifier block 489 489 * @event: Notify event 490 490 * @data: Notifier data ··· 497 497 struct uart_port *port; 498 498 int locked = 0; 499 499 struct clk_notifier_data *ndata = data; 500 - unsigned long flags = 0; 501 500 struct cdns_uart *cdns_uart = to_cdns_uart(nb); 501 + unsigned long flags; 502 502 503 503 port = cdns_uart->port; 504 504 if (port->suspended) ··· 1149 1149 } 1150 1150 1151 1151 static void cdns_early_write(struct console *con, const char *s, 1152 - unsigned n) 1152 + unsigned int n) 1153 1153 { 1154 1154 struct earlycon_device *dev = con->data; 1155 1155 ··· 1210 1210 unsigned int count) 1211 1211 { 1212 1212 struct uart_port *port = console_port; 1213 - unsigned long flags = 0; 1213 + unsigned long flags; 1214 1214 unsigned int imr, ctrl; 1215 1215 int locked = 1; 1216 1216 ··· 1308 1308 may_wake = device_may_wakeup(device); 1309 1309 1310 1310 if (console_suspend_enabled && uart_console(port) && may_wake) { 1311 - unsigned long flags = 0; 1311 + unsigned long flags; 1312 1312 1313 1313 spin_lock_irqsave(&port->lock, flags); 1314 1314 /* Empty the receive FIFO 1st before making changes */ ··· 1339 1339 { 1340 1340 struct uart_port *port = dev_get_drvdata(device); 1341 1341 struct cdns_uart *cdns_uart = port->private_data; 1342 - unsigned long flags = 0; 1342 + unsigned long flags; 1343 1343 u32 ctrl_reg; 1344 1344 int may_wake; 1345 1345
+8 -5
drivers/tty/tty_baudrate.c
··· 147 147 int iclose = ibaud/50, oclose = obaud/50; 148 148 int ibinput = 0; 149 149 150 - if (obaud == 0) /* CD dropped */ 150 + if (obaud == 0) /* CD dropped */ 151 151 ibaud = 0; /* Clear ibaud to be sure */ 152 152 153 153 termios->c_ispeed = ibaud; ··· 159 159 #endif 160 160 #ifdef BOTHER 161 161 /* If the user asked for a precise weird speed give a precise weird 162 - answer. If they asked for a Bfoo speed they may have problems 163 - digesting non-exact replies so fuzz a bit */ 162 + * answer. If they asked for a Bfoo speed they may have problems 163 + * digesting non-exact replies so fuzz a bit. 164 + */ 164 165 165 166 if ((termios->c_cflag & CBAUD) == BOTHER) { 166 167 oclose = 0; ··· 192 191 if (ibaud - iclose <= baud_table[i] && 193 192 ibaud + iclose >= baud_table[i]) { 194 193 /* For the case input == output don't set IBAUD bits 195 - if the user didn't do so */ 194 + * if the user didn't do so. 195 + */ 196 196 if (ofound == i && !ibinput) 197 197 ifound = i; 198 198 #ifdef IBSHIFT ··· 213 211 if (ofound == -1) 214 212 termios->c_cflag |= BOTHER; 215 213 /* Set exact input bits only if the input and output differ or the 216 - user already did */ 214 + * user already did. 215 + */ 217 216 if (ifound == -1 && (ibaud != obaud || ibinput)) 218 217 termios->c_cflag |= (BOTHER << IBSHIFT); 219 218 #else
+19 -9
drivers/tty/tty_buffer.c
··· 32 32 * We default to dicing tty buffer allocations to this many characters 33 33 * in order to avoid multiple page allocations. We know the size of 34 34 * tty_buffer itself but it must also be taken into account that the 35 - * the buffer is 256 byte aligned. See tty_buffer_find for the allocation 36 - * logic this must match 35 + * buffer is 256 byte aligned. See tty_buffer_find for the allocation 36 + * logic this must match. 37 37 */ 38 38 39 39 #define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF) ··· 88 88 * pre-allocate if memory guarantee is required). 89 89 */ 90 90 91 - int tty_buffer_space_avail(struct tty_port *port) 91 + unsigned int tty_buffer_space_avail(struct tty_port *port) 92 92 { 93 93 int space = port->buf.mem_limit - atomic_read(&port->buf.mem_used); 94 + 94 95 return max(space, 0); 95 96 } 96 97 EXPORT_SYMBOL_GPL(tty_buffer_space_avail); ··· 170 169 } 171 170 172 171 /* Should possibly check if this fails for the largest buffer we 173 - have queued and recycle that ? */ 172 + * have queued and recycle that ? 173 + */ 174 174 if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit) 175 175 return NULL; 176 176 p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); ··· 244 242 } 245 243 246 244 /** 247 - * tty_buffer_request_room - grow tty buffer if needed 245 + * __tty_buffer_request_room - grow tty buffer if needed 248 246 * @port: tty port 249 247 * @size: size desired 250 248 * @flags: buffer flags if new buffer allocated (default = 0) ··· 314 312 const unsigned char *chars, char flag, size_t size) 315 313 { 316 314 int copied = 0; 315 + 317 316 do { 318 317 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 319 318 int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; 320 319 int space = __tty_buffer_request_room(port, goal, flags); 321 320 struct tty_buffer *tb = port->buf.tail; 321 + 322 322 if (unlikely(space == 0)) 323 323 break; 324 324 memcpy(char_buf_ptr(tb, tb->used), chars, space); ··· 330 326 copied += space; 331 327 chars += space; 332 328 /* There is a small chance that we need to split the data over 333 - several buffers. If this is the case we must loop */ 329 + * several buffers. If this is the case we must loop. 330 + */ 334 331 } while (unlikely(size > copied)); 335 332 return copied; 336 333 } ··· 353 348 const unsigned char *chars, const char *flags, size_t size) 354 349 { 355 350 int copied = 0; 351 + 356 352 do { 357 353 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 358 354 int space = tty_buffer_request_room(port, goal); 359 355 struct tty_buffer *tb = port->buf.tail; 356 + 360 357 if (unlikely(space == 0)) 361 358 break; 362 359 memcpy(char_buf_ptr(tb, tb->used), chars, space); ··· 368 361 chars += space; 369 362 flags += space; 370 363 /* There is a small chance that we need to split the data over 371 - several buffers. If this is the case we must loop */ 364 + * several buffers. If this is the case we must loop. 365 + */ 372 366 } while (unlikely(size > copied)); 373 367 return copied; 374 368 } ··· 439 431 size_t size) 440 432 { 441 433 int space = __tty_buffer_request_room(port, size, TTYB_NORMAL); 434 + 442 435 if (likely(space)) { 443 436 struct tty_buffer *tb = port->buf.tail; 437 + 444 438 *chars = char_buf_ptr(tb, tb->used); 445 439 if (~tb->flags & TTYB_NORMAL) 446 440 memset(flag_buf_ptr(tb, tb->used), TTY_NORMAL, space); ··· 465 455 * Returns the number of bytes processed 466 456 */ 467 457 int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 468 - char *f, int count) 458 + const char *f, int count) 469 459 { 470 460 if (ld->ops->receive_buf2) 471 461 count = ld->ops->receive_buf2(ld->tty, p, f, count); ··· 482 472 receive_buf(struct tty_port *port, struct tty_buffer *head, int count) 483 473 { 484 474 unsigned char *p = char_buf_ptr(head, head->read); 485 - char *f = NULL; 475 + const char *f = NULL; 486 476 int n; 487 477 488 478 if (~head->flags & TTYB_NORMAL)
+99 -99
drivers/tty/tty_io.c
··· 33 33 * -- Nick Holloway <alfie@dcs.warwick.ac.uk>, 27th May 1993. 34 34 * 35 35 * Rewrote canonical mode and added more termios flags. 36 - * -- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94 36 + * -- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94 37 37 * 38 38 * Reorganized FASYNC support so mouse code can share it. 39 39 * -- ctm@ardi.com, 9Sep95 ··· 131 131 .c_ospeed = 38400, 132 132 /* .c_line = N_TTY, */ 133 133 }; 134 - 135 134 EXPORT_SYMBOL(tty_std_termios); 136 135 137 136 /* This list gets poked at by procfs and various bits of boot up code. This 138 - could do with some rationalisation such as pulling the tty proc function 139 - into this file */ 137 + * could do with some rationalisation such as pulling the tty proc function 138 + * into this file. 139 + */ 140 140 141 141 LIST_HEAD(tty_drivers); /* linked list of tty drivers */ 142 142 ··· 248 248 return "NULL tty"; 249 249 return tty->name; 250 250 } 251 - 252 251 EXPORT_SYMBOL(tty_name); 253 252 254 253 const char *tty_driver_name(const struct tty_struct *tty) ··· 319 320 320 321 list_for_each_entry(p, &tty_drivers, tty_drivers) { 321 322 dev_t base = MKDEV(p->major, p->minor_start); 323 + 322 324 if (device < base || device >= base + p->num) 323 325 continue; 324 326 *index = device - base; ··· 537 537 } 538 538 wake_up_interruptible_poll(&tty->write_wait, EPOLLOUT); 539 539 } 540 - 541 540 EXPORT_SYMBOL_GPL(tty_wakeup); 542 541 543 542 /** ··· 612 613 set_bit(TTY_HUPPING, &tty->flags); 613 614 614 615 /* inuse_filps is protected by the single tty lock, 615 - this really needs to change if we want to flush the 616 - workqueue with the lock held */ 616 + * this really needs to change if we want to flush the 617 + * workqueue with the lock held. 618 + */ 617 619 check_tty_count(tty, "tty_hangup"); 618 620 619 621 spin_lock(&tty->files_lock); ··· 638 638 639 639 tty_ldisc_hangup(tty, cons_filp != NULL); 640 640 641 - spin_lock_irq(&tty->ctrl_lock); 641 + spin_lock_irq(&tty->ctrl.lock); 642 642 clear_bit(TTY_THROTTLED, &tty->flags); 643 643 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 644 - put_pid(tty->session); 645 - put_pid(tty->pgrp); 646 - tty->session = NULL; 647 - tty->pgrp = NULL; 648 - tty->ctrl_status = 0; 649 - spin_unlock_irq(&tty->ctrl_lock); 644 + put_pid(tty->ctrl.session); 645 + put_pid(tty->ctrl.pgrp); 646 + tty->ctrl.session = NULL; 647 + tty->ctrl.pgrp = NULL; 648 + tty->ctrl.pktstatus = 0; 649 + spin_unlock_irq(&tty->ctrl.lock); 650 650 651 651 /* 652 652 * If one of the devices matches a console pointer, we ··· 694 694 tty_debug_hangup(tty, "hangup\n"); 695 695 schedule_work(&tty->hangup_work); 696 696 } 697 - 698 697 EXPORT_SYMBOL(tty_hangup); 699 698 700 699 /** ··· 710 711 tty_debug_hangup(tty, "vhangup\n"); 711 712 __tty_hangup(tty, 0); 712 713 } 713 - 714 714 EXPORT_SYMBOL(tty_vhangup); 715 715 716 716 ··· 759 761 { 760 762 return (filp && filp->f_op == &hung_up_tty_fops); 761 763 } 762 - 763 764 EXPORT_SYMBOL(tty_hung_up_p); 765 + 766 + void __stop_tty(struct tty_struct *tty) 767 + { 768 + if (tty->flow.stopped) 769 + return; 770 + tty->flow.stopped = true; 771 + if (tty->ops->stop) 772 + tty->ops->stop(tty); 773 + } 764 774 765 775 /** 766 776 * stop_tty - propagate flow control ··· 784 778 * but not always. 785 779 * 786 780 * Locking: 787 - * flow_lock 781 + * flow.lock 788 782 */ 789 - 790 - void __stop_tty(struct tty_struct *tty) 791 - { 792 - if (tty->stopped) 793 - return; 794 - tty->stopped = 1; 795 - if (tty->ops->stop) 796 - tty->ops->stop(tty); 797 - } 798 - 799 783 void stop_tty(struct tty_struct *tty) 800 784 { 801 785 unsigned long flags; 802 786 803 - spin_lock_irqsave(&tty->flow_lock, flags); 787 + spin_lock_irqsave(&tty->flow.lock, flags); 804 788 __stop_tty(tty); 805 - spin_unlock_irqrestore(&tty->flow_lock, flags); 789 + spin_unlock_irqrestore(&tty->flow.lock, flags); 806 790 } 807 791 EXPORT_SYMBOL(stop_tty); 792 + 793 + void __start_tty(struct tty_struct *tty) 794 + { 795 + if (!tty->flow.stopped || tty->flow.tco_stopped) 796 + return; 797 + tty->flow.stopped = false; 798 + if (tty->ops->start) 799 + tty->ops->start(tty); 800 + tty_wakeup(tty); 801 + } 808 802 809 803 /** 810 804 * start_tty - propagate flow control ··· 815 809 * start method is invoked and the line discipline woken. 816 810 * 817 811 * Locking: 818 - * flow_lock 812 + * flow.lock 819 813 */ 820 - 821 - void __start_tty(struct tty_struct *tty) 822 - { 823 - if (!tty->stopped || tty->flow_stopped) 824 - return; 825 - tty->stopped = 0; 826 - if (tty->ops->start) 827 - tty->ops->start(tty); 828 - tty_wakeup(tty); 829 - } 830 - 831 814 void start_tty(struct tty_struct *tty) 832 815 { 833 816 unsigned long flags; 834 817 835 - spin_lock_irqsave(&tty->flow_lock, flags); 818 + spin_lock_irqsave(&tty->flow.lock, flags); 836 819 __start_tty(tty); 837 - spin_unlock_irqrestore(&tty->flow_lock, flags); 820 + spin_unlock_irqrestore(&tty->flow.lock, flags); 838 821 } 839 822 EXPORT_SYMBOL(start_tty); 840 823 ··· 909 914 910 915 /** 911 916 * tty_read - read method for tty device files 912 - * @file: pointer to tty file 913 - * @buf: user buffer 914 - * @count: size of user buffer 915 - * @ppos: unused 917 + * @iocb: kernel I/O control block 918 + * @to: destination for the data read 916 919 * 917 920 * Perform the read system call function on this terminal device. Checks 918 921 * for hung up devices before calling the line discipline method. ··· 934 941 return -EIO; 935 942 936 943 /* We want to wait for the line discipline to sort out in this 937 - situation */ 944 + * situation. 945 + */ 938 946 ld = tty_ldisc_ref_wait(tty); 939 947 if (!ld) 940 948 return hung_up_tty_read(iocb, to); ··· 1027 1033 /* Do the write .. */ 1028 1034 for (;;) { 1029 1035 size_t size = count; 1036 + 1030 1037 if (size > chunk) 1031 1038 size = chunk; 1032 1039 ··· 1086 1091 tty_unlock(tty); 1087 1092 tty_write_unlock(tty); 1088 1093 } 1089 - return; 1090 1094 } 1091 - 1092 - 1093 - /** 1094 - * tty_write - write method for tty device file 1095 - * @file: tty file pointer 1096 - * @buf: user data to write 1097 - * @count: bytes to write 1098 - * @ppos: unused 1099 - * 1100 - * Write data to a tty device via the line discipline. 1101 - * 1102 - * Locking: 1103 - * Locks the line discipline as required 1104 - * Writes to the tty driver are serialized by the atomic_write_lock 1105 - * and are then processed in chunks to the device. The line discipline 1106 - * write method will not be invoked in parallel for each device. 1107 - */ 1108 1095 1109 1096 static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_iter *from) 1110 1097 { 1111 1098 struct tty_struct *tty = file_tty(file); 1112 - struct tty_ldisc *ld; 1099 + struct tty_ldisc *ld; 1113 1100 ssize_t ret; 1114 1101 1115 1102 if (tty_paranoia_check(tty, file_inode(file), "tty_write")) 1116 1103 return -EIO; 1117 1104 if (!tty || !tty->ops->write || tty_io_error(tty)) 1118 - return -EIO; 1105 + return -EIO; 1119 1106 /* Short term debug to catch buggy drivers */ 1120 1107 if (tty->ops->write_room == NULL) 1121 1108 tty_err(tty, "missing write_room method\n"); ··· 1112 1135 return ret; 1113 1136 } 1114 1137 1138 + /** 1139 + * tty_write - write method for tty device file 1140 + * @iocb: kernel I/O control block 1141 + * @from: iov_iter with data to write 1142 + * 1143 + * Write data to a tty device via the line discipline. 1144 + * 1145 + * Locking: 1146 + * Locks the line discipline as required 1147 + * Writes to the tty driver are serialized by the atomic_write_lock 1148 + * and are then processed in chunks to the device. The line 1149 + * discipline write method will not be invoked in parallel for 1150 + * each device. 1151 + */ 1115 1152 static ssize_t tty_write(struct kiocb *iocb, struct iov_iter *from) 1116 1153 { 1117 1154 return file_tty_write(iocb->ki_filp, iocb, from); ··· 1141 1150 spin_unlock(&redirect_lock); 1142 1151 1143 1152 /* 1144 - * We know the redirected tty is just another tty, we can can 1153 + * We know the redirected tty is just another tty, we can 1145 1154 * call file_tty_write() directly with that file pointer. 1146 1155 */ 1147 1156 if (p) { 1148 1157 ssize_t res; 1158 + 1149 1159 res = file_tty_write(p, iocb, iter); 1150 1160 fput(p); 1151 1161 return res; ··· 1164 1172 1165 1173 int tty_send_xchar(struct tty_struct *tty, char ch) 1166 1174 { 1167 - int was_stopped = tty->stopped; 1175 + bool was_stopped = tty->flow.stopped; 1168 1176 1169 1177 if (tty->ops->send_xchar) { 1170 1178 down_read(&tty->termios_rwsem); ··· 1551 1559 list_del_init(&tty->tty_files); 1552 1560 spin_unlock(&tty->files_lock); 1553 1561 1554 - put_pid(tty->pgrp); 1555 - put_pid(tty->session); 1562 + put_pid(tty->ctrl.pgrp); 1563 + put_pid(tty->ctrl.session); 1556 1564 free_tty_struct(tty); 1557 1565 } 1558 1566 ··· 1561 1569 struct tty_struct *tty = container_of(kref, struct tty_struct, kref); 1562 1570 1563 1571 /* The hangup queue is now free so we can reuse it rather than 1564 - waste a chunk of memory for each port */ 1572 + * waste a chunk of memory for each port. 1573 + */ 1565 1574 INIT_WORK(&tty->hangup_work, release_one_tty); 1566 1575 schedule_work(&tty->hangup_work); 1567 1576 } ··· 1854 1861 */ 1855 1862 if (!tty->count) { 1856 1863 read_lock(&tasklist_lock); 1857 - session_clear_tty(tty->session); 1864 + session_clear_tty(tty->ctrl.session); 1858 1865 if (o_tty) 1859 - session_clear_tty(o_tty->session); 1866 + session_clear_tty(o_tty->ctrl.session); 1860 1867 read_unlock(&tasklist_lock); 1861 1868 } 1862 1869 ··· 1867 1874 tty_unlock(tty); 1868 1875 1869 1876 /* At this point, the tty->count == 0 should ensure a dead tty 1870 - cannot be re-opened by a racing opener */ 1877 + * cannot be re-opened by a racing opener. 1878 + */ 1871 1879 1872 1880 if (!final) 1873 1881 return 0; ··· 1922 1928 * @index: index for the device in the @return driver 1923 1929 * @return: driver for this inode (with increased refcount) 1924 1930 * 1925 - * If @return is not erroneous, the caller is responsible to decrement the 1926 - * refcount by tty_driver_kref_put. 1931 + * If @return is not erroneous, the caller is responsible to decrement the 1932 + * refcount by tty_driver_kref_put. 1927 1933 * 1928 1934 * Locking: tty_mutex protects get_tty_driver 1929 1935 */ ··· 1936 1942 #ifdef CONFIG_VT 1937 1943 case MKDEV(TTY_MAJOR, 0): { 1938 1944 extern struct tty_driver *console_driver; 1945 + 1939 1946 driver = tty_driver_kref_get(console_driver); 1940 1947 *index = fg_console; 1941 1948 break; ··· 1944 1949 #endif 1945 1950 case MKDEV(TTYAUX_MAJOR, 1): { 1946 1951 struct tty_driver *console_driver = console_device(index); 1952 + 1947 1953 if (console_driver) { 1948 1954 driver = tty_driver_kref_get(console_driver); 1949 1955 if (driver && filp) { ··· 2246 2250 enum pid_type type; 2247 2251 struct pid *pid; 2248 2252 2249 - spin_lock_irqsave(&tty->ctrl_lock, flags); 2250 - if (tty->pgrp) { 2251 - pid = tty->pgrp; 2253 + spin_lock_irqsave(&tty->ctrl.lock, flags); 2254 + if (tty->ctrl.pgrp) { 2255 + pid = tty->ctrl.pgrp; 2252 2256 type = PIDTYPE_PGID; 2253 2257 } else { 2254 2258 pid = task_pid(current); 2255 2259 type = PIDTYPE_TGID; 2256 2260 } 2257 2261 get_pid(pid); 2258 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 2262 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 2259 2263 __f_setown(filp, pid, type, 0); 2260 2264 put_pid(pid); 2261 2265 retval = 0; ··· 2332 2336 err = copy_to_user(arg, &tty->winsize, sizeof(*arg)); 2333 2337 mutex_unlock(&tty->winsize_mutex); 2334 2338 2335 - return err ? -EFAULT: 0; 2339 + return err ? -EFAULT : 0; 2336 2340 } 2337 2341 2338 2342 /** ··· 2377 2381 * 2378 2382 * Locking: 2379 2383 * Driver dependent. The default do_resize method takes the 2380 - * tty termios mutex and ctrl_lock. The console takes its own lock 2384 + * tty termios mutex and ctrl.lock. The console takes its own lock 2381 2385 * then calls into the default method. 2382 2386 */ 2383 2387 2384 2388 static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg) 2385 2389 { 2386 2390 struct winsize tmp_ws; 2391 + 2387 2392 if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) 2388 2393 return -EFAULT; 2389 2394 ··· 2409 2412 return -EPERM; 2410 2413 if (file->f_op->write_iter == redirected_tty_write) { 2411 2414 struct file *f; 2415 + 2412 2416 spin_lock(&redirect_lock); 2413 2417 f = redirect; 2414 2418 redirect = NULL; ··· 2732 2734 case TIOCGEXCL: 2733 2735 { 2734 2736 int excl = test_bit(TTY_EXCLUSIVE, &tty->flags); 2737 + 2735 2738 return put_user(excl, (int __user *)p); 2736 2739 } 2737 2740 case TIOCGETD: ··· 2747 2748 case TIOCGDEV: 2748 2749 { 2749 2750 unsigned int ret = new_encode_dev(tty_devnum(real_tty)); 2751 + 2750 2752 return put_user(ret, (unsigned int __user *)p); 2751 2753 } 2752 2754 /* ··· 3006 3006 return 0; 3007 3007 return file_tty(file) != t ? 0 : fd + 1; 3008 3008 } 3009 - 3009 + 3010 3010 /* 3011 3011 * This implements the "Secure Attention Key" --- the idea is to 3012 3012 * prevent trojan horses by killing all processes associated with this ··· 3039 3039 if (!tty) 3040 3040 return; 3041 3041 3042 - spin_lock_irqsave(&tty->ctrl_lock, flags); 3043 - session = get_pid(tty->session); 3044 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 3042 + spin_lock_irqsave(&tty->ctrl.lock, flags); 3043 + session = get_pid(tty->ctrl.session); 3044 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 3045 3045 3046 3046 tty_ldisc_flush(tty); 3047 3047 ··· 3096 3096 return; 3097 3097 schedule_work(&tty->SAK_work); 3098 3098 } 3099 - 3100 3099 EXPORT_SYMBOL(do_SAK); 3101 3100 3102 3101 /* Must put_device() after it's unused! */ 3103 3102 static struct device *tty_get_device(struct tty_struct *tty) 3104 3103 { 3105 3104 dev_t devt = tty_devnum(tty); 3105 + 3106 3106 return class_find_device_by_devt(tty_class, devt); 3107 3107 } 3108 3108 ··· 3129 3129 kfree(tty); 3130 3130 return NULL; 3131 3131 } 3132 - tty->session = NULL; 3133 - tty->pgrp = NULL; 3132 + tty->ctrl.session = NULL; 3133 + tty->ctrl.pgrp = NULL; 3134 3134 mutex_init(&tty->legacy_mutex); 3135 3135 mutex_init(&tty->throttle_mutex); 3136 3136 init_rwsem(&tty->termios_rwsem); ··· 3140 3140 init_waitqueue_head(&tty->read_wait); 3141 3141 INIT_WORK(&tty->hangup_work, do_tty_hangup); 3142 3142 mutex_init(&tty->atomic_write_lock); 3143 - spin_lock_init(&tty->ctrl_lock); 3144 - spin_lock_init(&tty->flow_lock); 3143 + spin_lock_init(&tty->ctrl.lock); 3144 + spin_lock_init(&tty->flow.lock); 3145 3145 spin_lock_init(&tty->files_lock); 3146 3146 INIT_LIST_HEAD(&tty->tty_files); 3147 3147 INIT_WORK(&tty->SAK_work, do_SAK_work); ··· 3317 3317 EXPORT_SYMBOL_GPL(tty_register_device_attr); 3318 3318 3319 3319 /** 3320 - * tty_unregister_device - unregister a tty device 3321 - * @driver: the tty driver that describes the tty device 3322 - * @index: the index in the tty driver for this tty device 3320 + * tty_unregister_device - unregister a tty device 3321 + * @driver: the tty driver that describes the tty device 3322 + * @index: the index in the tty driver for this tty device 3323 3323 * 3324 - * If a tty device is registered with a call to tty_register_device() then 3324 + * If a tty device is registered with a call to tty_register_device() then 3325 3325 * this function must be called when the tty device is gone. 3326 3326 * 3327 3327 * Locking: ??
+60 -36
drivers/tty/tty_ioctl.c
··· 54 54 * to be no queue on the device. 55 55 */ 56 56 57 - int tty_chars_in_buffer(struct tty_struct *tty) 57 + unsigned int tty_chars_in_buffer(struct tty_struct *tty) 58 58 { 59 59 if (tty->ops->chars_in_buffer) 60 60 return tty->ops->chars_in_buffer(tty); ··· 73 73 * returned and data may be lost as there will be no flow control. 74 74 */ 75 75 76 - int tty_write_room(struct tty_struct *tty) 76 + unsigned int tty_write_room(struct tty_struct *tty) 77 77 { 78 78 if (tty->ops->write_room) 79 79 return tty->ops->write_room(tty); ··· 95 95 tty->ops->flush_buffer(tty); 96 96 } 97 97 EXPORT_SYMBOL(tty_driver_flush_buffer); 98 - 99 - /** 100 - * tty_throttle - flow control 101 - * @tty: terminal 102 - * 103 - * Indicate that a tty should stop transmitting data down the stack. 104 - * Takes the termios rwsem to protect against parallel throttle/unthrottle 105 - * and also to ensure the driver can consistently reference its own 106 - * termios data at this point when implementing software flow control. 107 - */ 108 - 109 - void tty_throttle(struct tty_struct *tty) 110 - { 111 - down_write(&tty->termios_rwsem); 112 - /* check TTY_THROTTLED first so it indicates our state */ 113 - if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && 114 - tty->ops->throttle) 115 - tty->ops->throttle(tty); 116 - tty->flow_change = 0; 117 - up_write(&tty->termios_rwsem); 118 - } 119 - EXPORT_SYMBOL(tty_throttle); 120 98 121 99 /** 122 100 * tty_unthrottle - flow control ··· 124 146 * tty_throttle_safe - flow control 125 147 * @tty: terminal 126 148 * 127 - * Similar to tty_throttle() but will only attempt throttle 128 - * if tty->flow_change is TTY_THROTTLE_SAFE. Prevents an accidental 129 - * throttle due to race conditions when throttling is conditional 130 - * on factors evaluated prior to throttling. 149 + * Indicate that a tty should stop transmitting data down the stack. 150 + * tty_throttle_safe will only attempt throttle if tty->flow_change is 151 + * TTY_THROTTLE_SAFE. Prevents an accidental throttle due to race 152 + * conditions when throttling is conditional on factors evaluated prior to 153 + * throttling. 131 154 * 132 155 * Returns 0 if tty is throttled (or was already throttled) 133 156 */ ··· 278 299 return 0; 279 300 } 280 301 EXPORT_SYMBOL(tty_termios_hw_change); 302 + 303 + /** 304 + * tty_get_char_size - get size of a character 305 + * @cflag: termios cflag value 306 + * 307 + * Get the size (in bits) of a character depending on @cflag's %CSIZE 308 + * setting. 309 + */ 310 + unsigned char tty_get_char_size(unsigned int cflag) 311 + { 312 + switch (cflag & CSIZE) { 313 + case CS5: 314 + return 5; 315 + case CS6: 316 + return 6; 317 + case CS7: 318 + return 7; 319 + case CS8: 320 + default: 321 + return 8; 322 + } 323 + } 324 + EXPORT_SYMBOL_GPL(tty_get_char_size); 325 + 326 + /** 327 + * tty_get_frame_size - get size of a frame 328 + * @cflag: termios cflag value 329 + * 330 + * Get the size (in bits) of a frame depending on @cflag's %CSIZE, %CSTOPB, 331 + * and %PARENB setting. The result is a sum of character size, start and 332 + * stop bits -- one bit each -- second stop bit (if set), and parity bit 333 + * (if set). 334 + */ 335 + unsigned char tty_get_frame_size(unsigned int cflag) 336 + { 337 + unsigned char bits = 2 + tty_get_char_size(cflag); 338 + 339 + if (cflag & CSTOPB) 340 + bits++; 341 + if (cflag & PARENB) 342 + bits++; 343 + 344 + return bits; 345 + } 346 + EXPORT_SYMBOL_GPL(tty_get_frame_size); 281 347 282 348 /** 283 349 * tty_set_termios - update termios values ··· 870 846 return retval; 871 847 switch (arg) { 872 848 case TCOOFF: 873 - spin_lock_irq(&tty->flow_lock); 874 - if (!tty->flow_stopped) { 875 - tty->flow_stopped = 1; 849 + spin_lock_irq(&tty->flow.lock); 850 + if (!tty->flow.tco_stopped) { 851 + tty->flow.tco_stopped = true; 876 852 __stop_tty(tty); 877 853 } 878 - spin_unlock_irq(&tty->flow_lock); 854 + spin_unlock_irq(&tty->flow.lock); 879 855 break; 880 856 case TCOON: 881 - spin_lock_irq(&tty->flow_lock); 882 - if (tty->flow_stopped) { 883 - tty->flow_stopped = 0; 857 + spin_lock_irq(&tty->flow.lock); 858 + if (tty->flow.tco_stopped) { 859 + tty->flow.tco_stopped = false; 884 860 __start_tty(tty); 885 861 } 886 - spin_unlock_irq(&tty->flow_lock); 862 + spin_unlock_irq(&tty->flow.lock); 887 863 break; 888 864 case TCIOFF: 889 865 if (STOP_CHAR(tty) != __DISABLED_CHAR)
+45 -43
drivers/tty/tty_jobctrl.c
··· 20 20 } 21 21 22 22 /** 23 - * tty_check_change - check for POSIX terminal changes 23 + * __tty_check_change - check for POSIX terminal changes 24 24 * @tty: tty to check 25 25 * @sig: signal to send 26 26 * ··· 28 28 * not in the foreground, send a SIGTTOU. If the signal is blocked or 29 29 * ignored, go ahead and perform the operation. (POSIX 7.2) 30 30 * 31 - * Locking: ctrl_lock 31 + * Locking: ctrl.lock 32 32 */ 33 33 int __tty_check_change(struct tty_struct *tty, int sig) 34 34 { ··· 42 42 rcu_read_lock(); 43 43 pgrp = task_pgrp(current); 44 44 45 - spin_lock_irqsave(&tty->ctrl_lock, flags); 46 - tty_pgrp = tty->pgrp; 47 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 45 + spin_lock_irqsave(&tty->ctrl.lock, flags); 46 + tty_pgrp = tty->ctrl.pgrp; 47 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 48 48 49 49 if (tty_pgrp && pgrp != tty_pgrp) { 50 50 if (is_ignored(sig)) { ··· 85 85 } 86 86 87 87 /** 88 - * proc_set_tty - set the controlling terminal 88 + * __proc_set_tty - set the controlling terminal 89 89 * @tty: tty structure 90 90 * 91 91 * Only callable by the session leader and only if it does not already have ··· 99 99 { 100 100 unsigned long flags; 101 101 102 - spin_lock_irqsave(&tty->ctrl_lock, flags); 102 + spin_lock_irqsave(&tty->ctrl.lock, flags); 103 103 /* 104 104 * The session and fg pgrp references will be non-NULL if 105 105 * tiocsctty() is stealing the controlling tty 106 106 */ 107 - put_pid(tty->session); 108 - put_pid(tty->pgrp); 109 - tty->pgrp = get_pid(task_pgrp(current)); 110 - tty->session = get_pid(task_session(current)); 111 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 107 + put_pid(tty->ctrl.session); 108 + put_pid(tty->ctrl.pgrp); 109 + tty->ctrl.pgrp = get_pid(task_pgrp(current)); 110 + tty->ctrl.session = get_pid(task_session(current)); 111 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 112 112 if (current->signal->tty) { 113 113 tty_debug(tty, "current tty %s not NULL!!\n", 114 114 current->signal->tty->name); ··· 135 135 spin_lock_irq(&current->sighand->siglock); 136 136 if (current->signal->leader && 137 137 !current->signal->tty && 138 - tty->session == NULL) { 138 + tty->ctrl.session == NULL) { 139 139 /* 140 140 * Don't let a process that only has write access to the tty 141 141 * obtain the privileges associated with having a tty as ··· 200 200 struct pid *tty_pgrp = NULL; 201 201 202 202 read_lock(&tasklist_lock); 203 - if (tty->session) { 204 - do_each_pid_task(tty->session, PIDTYPE_SID, p) { 203 + if (tty->ctrl.session) { 204 + do_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p) { 205 205 spin_lock_irq(&p->sighand->siglock); 206 206 if (p->signal->tty == tty) { 207 207 p->signal->tty = NULL; ··· 218 218 __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p); 219 219 __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p); 220 220 put_pid(p->signal->tty_old_pgrp); /* A noop */ 221 - spin_lock(&tty->ctrl_lock); 222 - tty_pgrp = get_pid(tty->pgrp); 223 - if (tty->pgrp) 224 - p->signal->tty_old_pgrp = get_pid(tty->pgrp); 225 - spin_unlock(&tty->ctrl_lock); 221 + spin_lock(&tty->ctrl.lock); 222 + tty_pgrp = get_pid(tty->ctrl.pgrp); 223 + if (tty->ctrl.pgrp) 224 + p->signal->tty_old_pgrp = 225 + get_pid(tty->ctrl.pgrp); 226 + spin_unlock(&tty->ctrl.lock); 226 227 spin_unlock_irq(&p->sighand->siglock); 227 - } while_each_pid_task(tty->session, PIDTYPE_SID, p); 228 + } while_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p); 228 229 } 229 230 read_unlock(&tasklist_lock); 230 231 ··· 310 309 unsigned long flags; 311 310 312 311 tty_lock(tty); 313 - spin_lock_irqsave(&tty->ctrl_lock, flags); 314 - put_pid(tty->session); 315 - put_pid(tty->pgrp); 316 - tty->session = NULL; 317 - tty->pgrp = NULL; 318 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 312 + spin_lock_irqsave(&tty->ctrl.lock, flags); 313 + put_pid(tty->ctrl.session); 314 + put_pid(tty->ctrl.pgrp); 315 + tty->ctrl.session = NULL; 316 + tty->ctrl.pgrp = NULL; 317 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 319 318 tty_unlock(tty); 320 319 tty_kref_put(tty); 321 320 } ··· 364 363 tty_lock(tty); 365 364 read_lock(&tasklist_lock); 366 365 367 - if (current->signal->leader && (task_session(current) == tty->session)) 366 + if (current->signal->leader && 367 + task_session(current) == tty->ctrl.session) 368 368 goto unlock; 369 369 370 370 /* ··· 377 375 goto unlock; 378 376 } 379 377 380 - if (tty->session) { 378 + if (tty->ctrl.session) { 381 379 /* 382 380 * This tty is already the controlling 383 381 * tty for another session group! ··· 386 384 /* 387 385 * Steal it away 388 386 */ 389 - session_clear_tty(tty->session); 387 + session_clear_tty(tty->ctrl.session); 390 388 } else { 391 389 ret = -EPERM; 392 390 goto unlock; ··· 418 416 unsigned long flags; 419 417 struct pid *pgrp; 420 418 421 - spin_lock_irqsave(&tty->ctrl_lock, flags); 422 - pgrp = get_pid(tty->pgrp); 423 - spin_unlock_irqrestore(&tty->ctrl_lock, flags); 419 + spin_lock_irqsave(&tty->ctrl.lock, flags); 420 + pgrp = get_pid(tty->ctrl.pgrp); 421 + spin_unlock_irqrestore(&tty->ctrl.lock, flags); 424 422 425 423 return pgrp; 426 424 } ··· 501 499 if (pgrp_nr < 0) 502 500 return -EINVAL; 503 501 504 - spin_lock_irq(&real_tty->ctrl_lock); 502 + spin_lock_irq(&real_tty->ctrl.lock); 505 503 if (!current->signal->tty || 506 504 (current->signal->tty != real_tty) || 507 - (real_tty->session != task_session(current))) { 505 + (real_tty->ctrl.session != task_session(current))) { 508 506 retval = -ENOTTY; 509 507 goto out_unlock_ctrl; 510 508 } ··· 517 515 if (session_of_pgrp(pgrp) != task_session(current)) 518 516 goto out_unlock; 519 517 retval = 0; 520 - put_pid(real_tty->pgrp); 521 - real_tty->pgrp = get_pid(pgrp); 518 + put_pid(real_tty->ctrl.pgrp); 519 + real_tty->ctrl.pgrp = get_pid(pgrp); 522 520 out_unlock: 523 521 rcu_read_unlock(); 524 522 out_unlock_ctrl: 525 - spin_unlock_irq(&real_tty->ctrl_lock); 523 + spin_unlock_irq(&real_tty->ctrl.lock); 526 524 return retval; 527 525 } 528 526 ··· 547 545 if (tty == real_tty && current->signal->tty != real_tty) 548 546 return -ENOTTY; 549 547 550 - spin_lock_irqsave(&real_tty->ctrl_lock, flags); 551 - if (!real_tty->session) 548 + spin_lock_irqsave(&real_tty->ctrl.lock, flags); 549 + if (!real_tty->ctrl.session) 552 550 goto err; 553 - sid = pid_vnr(real_tty->session); 554 - spin_unlock_irqrestore(&real_tty->ctrl_lock, flags); 551 + sid = pid_vnr(real_tty->ctrl.session); 552 + spin_unlock_irqrestore(&real_tty->ctrl.lock, flags); 555 553 556 554 return put_user(sid, p); 557 555 558 556 err: 559 - spin_unlock_irqrestore(&real_tty->ctrl_lock, flags); 557 + spin_unlock_irqrestore(&real_tty->ctrl.lock, flags); 560 558 return -ENOTTY; 561 559 } 562 560
+7 -22
drivers/tty/tty_ldisc.c
··· 48 48 49 49 /** 50 50 * tty_register_ldisc - install a line discipline 51 - * @disc: ldisc number 52 51 * @new_ldisc: pointer to the ldisc object 53 52 * 54 53 * Installs a new line discipline into the kernel. The discipline ··· 58 59 * takes tty_ldiscs_lock to guard against ldisc races 59 60 */ 60 61 61 - int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc) 62 + int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc) 62 63 { 63 64 unsigned long flags; 64 65 int ret = 0; 65 66 66 - if (disc < N_TTY || disc >= NR_LDISCS) 67 + if (new_ldisc->num < N_TTY || new_ldisc->num >= NR_LDISCS) 67 68 return -EINVAL; 68 69 69 70 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags); 70 - tty_ldiscs[disc] = new_ldisc; 71 - new_ldisc->num = disc; 72 - new_ldisc->refcount = 0; 71 + tty_ldiscs[new_ldisc->num] = new_ldisc; 73 72 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags); 74 73 75 74 return ret; ··· 76 79 77 80 /** 78 81 * tty_unregister_ldisc - unload a line discipline 79 - * @disc: ldisc number 82 + * @ldisc: ldisc number 80 83 * 81 84 * Remove a line discipline from the kernel providing it is not 82 85 * currently in use. ··· 85 88 * takes tty_ldiscs_lock to guard against ldisc races 86 89 */ 87 90 88 - int tty_unregister_ldisc(int disc) 91 + void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc) 89 92 { 90 93 unsigned long flags; 91 - int ret = 0; 92 - 93 - if (disc < N_TTY || disc >= NR_LDISCS) 94 - return -EINVAL; 95 94 96 95 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags); 97 - if (tty_ldiscs[disc]->refcount) 98 - ret = -EBUSY; 99 - else 100 - tty_ldiscs[disc] = NULL; 96 + tty_ldiscs[ldisc->num] = NULL; 101 97 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags); 102 - 103 - return ret; 104 98 } 105 99 EXPORT_SYMBOL(tty_unregister_ldisc); 106 100 ··· 105 117 ldops = tty_ldiscs[disc]; 106 118 if (ldops) { 107 119 ret = ERR_PTR(-EAGAIN); 108 - if (try_module_get(ldops->owner)) { 109 - ldops->refcount++; 120 + if (try_module_get(ldops->owner)) 110 121 ret = ldops; 111 - } 112 122 } 113 123 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags); 114 124 return ret; ··· 117 131 unsigned long flags; 118 132 119 133 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags); 120 - ldops->refcount--; 121 134 module_put(ldops->owner); 122 135 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags); 123 136 }
+11 -7
drivers/tty/tty_port.c
··· 468 468 DEFINE_WAIT(wait); 469 469 470 470 /* if non-blocking mode is set we can pass directly to open unless 471 - the port has just hung up or is in another error state */ 471 + * the port has just hung up or is in another error state. 472 + */ 472 473 if (tty_io_error(tty)) { 473 474 tty_port_set_active(port, 1); 474 475 return 0; ··· 486 485 do_clocal = 1; 487 486 488 487 /* Block waiting until we can proceed. We may need to wait for the 489 - carrier, but we must also wait for any close that is in progress 490 - before the next open may complete */ 488 + * carrier, but we must also wait for any close that is in progress 489 + * before the next open may complete. 490 + */ 491 491 492 492 retval = 0; 493 493 ··· 505 503 506 504 prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); 507 505 /* Check for a hangup or uninitialised port. 508 - Return accordingly */ 506 + * Return accordingly. 507 + */ 509 508 if (tty_hung_up_p(filp) || !tty_port_initialized(port)) { 510 509 if (port->flags & ASYNC_HUP_NOTIFY) 511 510 retval = -EAGAIN; ··· 533 530 finish_wait(&port->open_wait, &wait); 534 531 535 532 /* Update counts. A parallel hangup will have set count to zero and 536 - we must not mess that up further */ 533 + * we must not mess that up further. 534 + */ 537 535 spin_lock_irqsave(&port->lock, flags); 538 536 if (!tty_hung_up_p(filp)) 539 537 port->count++; ··· 591 587 592 588 if (tty_port_initialized(port)) { 593 589 /* Don't block on a stalled port, just pull the chain */ 594 - if (tty->flow_stopped) 590 + if (tty->flow.tco_stopped) 595 591 tty_driver_flush_buffer(tty); 596 592 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) 597 593 tty_wait_until_sent(tty, port->closing_wait); ··· 692 688 clear_bit(TTY_IO_ERROR, &tty->flags); 693 689 if (port->ops->activate) { 694 690 int retval = port->ops->activate(port, tty); 691 + 695 692 if (retval) { 696 693 mutex_unlock(&port->mutex); 697 694 return retval; ··· 703 698 mutex_unlock(&port->mutex); 704 699 return tty_port_block_til_ready(port, tty, filp); 705 700 } 706 - 707 701 EXPORT_SYMBOL(tty_port_open);
+1 -1
drivers/tty/ttynull.c
··· 35 35 return count; 36 36 } 37 37 38 - static int ttynull_write_room(struct tty_struct *tty) 38 + static unsigned int ttynull_write_room(struct tty_struct *tty) 39 39 { 40 40 return 65536; 41 41 }
+12 -12
drivers/tty/vcc.c
··· 473 473 474 474 static struct tty_port_operations vcc_port_ops = { 0 }; 475 475 476 - static ssize_t vcc_sysfs_domain_show(struct device *dev, 477 - struct device_attribute *attr, 478 - char *buf) 476 + static ssize_t domain_show(struct device *dev, 477 + struct device_attribute *attr, 478 + char *buf) 479 479 { 480 480 struct vcc_port *port; 481 481 int rv; ··· 505 505 return rv; 506 506 } 507 507 508 - static ssize_t vcc_sysfs_break_store(struct device *dev, 509 - struct device_attribute *attr, 510 - const char *buf, size_t count) 508 + static ssize_t break_store(struct device *dev, 509 + struct device_attribute *attr, 510 + const char *buf, size_t count) 511 511 { 512 512 struct vcc_port *port; 513 513 unsigned long flags; ··· 530 530 return rv; 531 531 } 532 532 533 - static DEVICE_ATTR(domain, 0400, vcc_sysfs_domain_show, NULL); 534 - static DEVICE_ATTR(break, 0200, NULL, vcc_sysfs_break_store); 533 + static DEVICE_ATTR_ADMIN_RO(domain); 534 + static DEVICE_ATTR_WO(break); 535 535 536 536 static struct attribute *vcc_sysfs_entries[] = { 537 537 &dev_attr_domain.attr, ··· 868 868 return total_sent ? total_sent : rv; 869 869 } 870 870 871 - static int vcc_write_room(struct tty_struct *tty) 871 + static unsigned int vcc_write_room(struct tty_struct *tty) 872 872 { 873 873 struct vcc_port *port; 874 - u64 num; 874 + unsigned int num; 875 875 876 876 port = vcc_get_ne(tty->index); 877 877 if (unlikely(!port)) { ··· 886 886 return num; 887 887 } 888 888 889 - static int vcc_chars_in_buffer(struct tty_struct *tty) 889 + static unsigned int vcc_chars_in_buffer(struct tty_struct *tty) 890 890 { 891 891 struct vcc_port *port; 892 - u64 num; 892 + unsigned int num; 893 893 894 894 port = vcc_get_ne(tty->index); 895 895 if (unlikely(!port)) {
+1 -1
drivers/tty/vt/keyboard.c
··· 515 515 * these routines are also activated by ^S/^Q. 516 516 * (And SCROLLOCK can also be set by the ioctl KDSKBLED.) 517 517 */ 518 - if (tty->stopped) 518 + if (tty->flow.stopped) 519 519 start_tty(tty); 520 520 else 521 521 stop_tty(tty);
+10 -10
drivers/tty/vt/selection.c
··· 33 33 #include <linux/sched/signal.h> 34 34 35 35 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */ 36 - #define isspace(c) ((c) == ' ') 36 + #define is_space_on_vt(c) ((c) == ' ') 37 37 38 38 /* FIXME: all this needs locking */ 39 39 static struct vc_selection { ··· 109 109 } 110 110 111 111 /** 112 - * set loadlut - load the LUT table 112 + * sel_loadlut() - load the LUT table 113 113 * @p: user table 114 114 * 115 115 * Load the LUT table from user space. The caller must hold the console ··· 209 209 bp += store_utf8(c, bp); 210 210 else 211 211 *bp++ = c; 212 - if (!isspace(c)) 212 + if (!is_space_on_vt(c)) 213 213 obp = bp; 214 214 if (!((i + 2) % vc->vc_size_row)) { 215 215 /* strip trailing blanks from line and add newline, ··· 238 238 new_sel_end = pe; 239 239 break; 240 240 case TIOCL_SELWORD: /* word-by-word selection */ 241 - spc = isspace(sel_pos(ps, unicode)); 241 + spc = is_space_on_vt(sel_pos(ps, unicode)); 242 242 for (new_sel_start = ps; ; ps -= 2) { 243 - if ((spc && !isspace(sel_pos(ps, unicode))) || 243 + if ((spc && !is_space_on_vt(sel_pos(ps, unicode))) || 244 244 (!spc && !inword(sel_pos(ps, unicode)))) 245 245 break; 246 246 new_sel_start = ps; ··· 248 248 break; 249 249 } 250 250 251 - spc = isspace(sel_pos(pe, unicode)); 251 + spc = is_space_on_vt(sel_pos(pe, unicode)); 252 252 for (new_sel_end = pe; ; pe += 2) { 253 - if ((spc && !isspace(sel_pos(pe, unicode))) || 253 + if ((spc && !is_space_on_vt(sel_pos(pe, unicode))) || 254 254 (!spc && !inword(sel_pos(pe, unicode)))) 255 255 break; 256 256 new_sel_end = pe; ··· 276 276 /* select to end of line if on trailing space */ 277 277 if (new_sel_end > new_sel_start && 278 278 !atedge(new_sel_end, vc->vc_size_row) && 279 - isspace(sel_pos(new_sel_end, unicode))) { 279 + is_space_on_vt(sel_pos(new_sel_end, unicode))) { 280 280 for (pe = new_sel_end + 2; ; pe += 2) 281 - if (!isspace(sel_pos(pe, unicode)) || 281 + if (!is_space_on_vt(sel_pos(pe, unicode)) || 282 282 atedge(pe, vc->vc_size_row)) 283 283 break; 284 - if (isspace(sel_pos(pe, unicode))) 284 + if (is_space_on_vt(sel_pos(pe, unicode))) 285 285 new_sel_end = pe; 286 286 } 287 287 if (vc_sel.start == -1) /* no current selection */
+5 -13
drivers/tty/vt/vt.c
··· 1189 1189 * information and perform any necessary signal handling. 1190 1190 * 1191 1191 * Caller must hold the console semaphore. Takes the termios rwsem and 1192 - * ctrl_lock of the tty IFF a tty is passed. 1192 + * ctrl.lock of the tty IFF a tty is passed. 1193 1193 */ 1194 1194 1195 1195 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, ··· 1355 1355 * the actual work. 1356 1356 * 1357 1357 * Takes the console sem and the called methods then take the tty 1358 - * termios_rwsem and the tty ctrl_lock in that order. 1358 + * termios_rwsem and the tty ctrl.lock in that order. 1359 1359 */ 1360 1360 static int vt_resize(struct tty_struct *tty, struct winsize *ws) 1361 1361 { ··· 2888 2888 2889 2889 param.vc = vc; 2890 2890 2891 - while (!tty->stopped && count) { 2891 + while (!tty->flow.stopped && count) { 2892 2892 int orig = *buf; 2893 2893 buf++; 2894 2894 n++; ··· 3260 3260 3261 3261 static int con_put_char(struct tty_struct *tty, unsigned char ch) 3262 3262 { 3263 - if (in_interrupt()) 3264 - return 0; /* n_r3964 calls put_char() from interrupt context */ 3265 3263 return do_con_write(tty, &ch, 1); 3266 3264 } 3267 3265 3268 - static int con_write_room(struct tty_struct *tty) 3266 + static unsigned int con_write_room(struct tty_struct *tty) 3269 3267 { 3270 - if (tty->stopped) 3268 + if (tty->flow.stopped) 3271 3269 return 0; 3272 3270 return 32768; /* No limit, really; we're not buffering */ 3273 - } 3274 - 3275 - static int con_chars_in_buffer(struct tty_struct *tty) 3276 - { 3277 - return 0; /* we're not buffering */ 3278 3271 } 3279 3272 3280 3273 /* ··· 3516 3523 .write_room = con_write_room, 3517 3524 .put_char = con_put_char, 3518 3525 .flush_chars = con_flush_chars, 3519 - .chars_in_buffer = con_chars_in_buffer, 3520 3526 .ioctl = vt_ioctl, 3521 3527 #ifdef CONFIG_COMPAT 3522 3528 .compat_ioctl = vt_compat_ioctl,
+4 -17
drivers/usb/class/cdc-acm.c
··· 838 838 return count; 839 839 } 840 840 841 - static int acm_tty_write_room(struct tty_struct *tty) 841 + static unsigned int acm_tty_write_room(struct tty_struct *tty) 842 842 { 843 843 struct acm *acm = tty->driver_data; 844 844 /* ··· 848 848 return acm_wb_is_avail(acm) ? acm->writesize : 0; 849 849 } 850 850 851 - static int acm_tty_chars_in_buffer(struct tty_struct *tty) 851 + static unsigned int acm_tty_chars_in_buffer(struct tty_struct *tty) 852 852 { 853 853 struct acm *acm = tty->driver_data; 854 854 /* ··· 1056 1056 newline.bParityType = termios->c_cflag & PARENB ? 1057 1057 (termios->c_cflag & PARODD ? 1 : 2) + 1058 1058 (termios->c_cflag & CMSPAR ? 2 : 0) : 0; 1059 - switch (termios->c_cflag & CSIZE) { 1060 - case CS5: 1061 - newline.bDataBits = 5; 1062 - break; 1063 - case CS6: 1064 - newline.bDataBits = 6; 1065 - break; 1066 - case CS7: 1067 - newline.bDataBits = 7; 1068 - break; 1069 - case CS8: 1070 - default: 1071 - newline.bDataBits = 8; 1072 - break; 1073 - } 1059 + newline.bDataBits = tty_get_char_size(termios->c_cflag); 1060 + 1074 1061 /* FIXME: Needs to clear unsupported bits in the termios */ 1075 1062 acm->clocal = ((termios->c_cflag & CLOCAL) != 0); 1076 1063
+6 -6
drivers/usb/gadget/function/u_serial.c
··· 774 774 spin_unlock_irqrestore(&port->port_lock, flags); 775 775 } 776 776 777 - static int gs_write_room(struct tty_struct *tty) 777 + static unsigned int gs_write_room(struct tty_struct *tty) 778 778 { 779 779 struct gs_port *port = tty->driver_data; 780 780 unsigned long flags; 781 - int room = 0; 781 + unsigned int room = 0; 782 782 783 783 spin_lock_irqsave(&port->port_lock, flags); 784 784 if (port->port_usb) 785 785 room = kfifo_avail(&port->port_write_buf); 786 786 spin_unlock_irqrestore(&port->port_lock, flags); 787 787 788 - pr_vdebug("gs_write_room: (%d,%p) room=%d\n", 788 + pr_vdebug("gs_write_room: (%d,%p) room=%u\n", 789 789 port->port_num, tty, room); 790 790 791 791 return room; 792 792 } 793 793 794 - static int gs_chars_in_buffer(struct tty_struct *tty) 794 + static unsigned int gs_chars_in_buffer(struct tty_struct *tty) 795 795 { 796 796 struct gs_port *port = tty->driver_data; 797 797 unsigned long flags; 798 - int chars = 0; 798 + unsigned int chars; 799 799 800 800 spin_lock_irqsave(&port->port_lock, flags); 801 801 chars = kfifo_len(&port->port_write_buf); 802 802 spin_unlock_irqrestore(&port->port_lock, flags); 803 803 804 - pr_vdebug("gs_chars_in_buffer: (%d,%p) chars=%d\n", 804 + pr_vdebug("gs_chars_in_buffer: (%d,%p) chars=%u\n", 805 805 port->port_num, tty, chars); 806 806 807 807 return chars;
+4 -4
drivers/usb/host/xhci-dbgtty.c
··· 240 240 spin_unlock_irqrestore(&port->port_lock, flags); 241 241 } 242 242 243 - static int dbc_tty_write_room(struct tty_struct *tty) 243 + static unsigned int dbc_tty_write_room(struct tty_struct *tty) 244 244 { 245 245 struct dbc_port *port = tty->driver_data; 246 246 unsigned long flags; 247 - int room = 0; 247 + unsigned int room; 248 248 249 249 spin_lock_irqsave(&port->port_lock, flags); 250 250 room = kfifo_avail(&port->write_fifo); ··· 253 253 return room; 254 254 } 255 255 256 - static int dbc_tty_chars_in_buffer(struct tty_struct *tty) 256 + static unsigned int dbc_tty_chars_in_buffer(struct tty_struct *tty) 257 257 { 258 258 struct dbc_port *port = tty->driver_data; 259 259 unsigned long flags; 260 - int chars = 0; 260 + unsigned int chars; 261 261 262 262 spin_lock_irqsave(&port->port_lock, flags); 263 263 chars = kfifo_len(&port->write_fifo);
+1 -19
drivers/usb/serial/belkin_sa.c
··· 356 356 357 357 /* set the number of data bits */ 358 358 if ((cflag & CSIZE) != (old_cflag & CSIZE)) { 359 - switch (cflag & CSIZE) { 360 - case CS5: 361 - urb_value = BELKIN_SA_DATA_BITS(5); 362 - break; 363 - case CS6: 364 - urb_value = BELKIN_SA_DATA_BITS(6); 365 - break; 366 - case CS7: 367 - urb_value = BELKIN_SA_DATA_BITS(7); 368 - break; 369 - case CS8: 370 - urb_value = BELKIN_SA_DATA_BITS(8); 371 - break; 372 - default: 373 - dev_dbg(&port->dev, 374 - "CSIZE was not CS5-CS8, using default of 8\n"); 375 - urb_value = BELKIN_SA_DATA_BITS(8); 376 - break; 377 - } 359 + urb_value = BELKIN_SA_DATA_BITS(tty_get_char_size(cflag)); 378 360 if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) 379 361 dev_err(&port->dev, "Set data bits error\n"); 380 362 }
+3 -18
drivers/usb/serial/cypress_m8.c
··· 326 326 327 327 /* fill the feature_buffer with new configuration */ 328 328 put_unaligned_le32(new_baudrate, feature_buffer); 329 - feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */ 329 + feature_buffer[4] |= data_bits - 5; /* assign data bits in 2 bit space ( max 3 ) */ 330 330 /* 1 bit gap */ 331 331 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */ 332 332 feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */ ··· 887 887 } else 888 888 parity_enable = parity_type = 0; 889 889 890 - switch (cflag & CSIZE) { 891 - case CS5: 892 - data_bits = 0; 893 - break; 894 - case CS6: 895 - data_bits = 1; 896 - break; 897 - case CS7: 898 - data_bits = 2; 899 - break; 900 - case CS8: 901 - data_bits = 3; 902 - break; 903 - default: 904 - dev_err(dev, "%s - CSIZE was set, but not CS5-CS8\n", __func__); 905 - data_bits = 3; 906 - } 890 + data_bits = tty_get_char_size(cflag); 891 + 907 892 spin_lock_irqsave(&priv->lock, flags); 908 893 oldlines = priv->line_control; 909 894 if ((cflag & CBAUD) == B0) {
+1 -14
drivers/usb/serial/pl2303.c
··· 789 789 790 790 pl2303_get_line_request(port, buf); 791 791 792 - switch (C_CSIZE(tty)) { 793 - case CS5: 794 - buf[6] = 5; 795 - break; 796 - case CS6: 797 - buf[6] = 6; 798 - break; 799 - case CS7: 800 - buf[6] = 7; 801 - break; 802 - default: 803 - case CS8: 804 - buf[6] = 8; 805 - } 792 + buf[6] = tty_get_char_size(tty->termios.c_cflag); 806 793 dev_dbg(&port->dev, "data bits = %d\n", buf[6]); 807 794 808 795 /* For reference buf[0]:buf[3] baud rate value */
+2 -2
drivers/usb/serial/usb-serial.c
··· 376 376 return retval; 377 377 } 378 378 379 - static int serial_write_room(struct tty_struct *tty) 379 + static unsigned int serial_write_room(struct tty_struct *tty) 380 380 { 381 381 struct usb_serial_port *port = tty->driver_data; 382 382 ··· 385 385 return port->serial->type->write_room(tty); 386 386 } 387 387 388 - static int serial_chars_in_buffer(struct tty_struct *tty) 388 + static unsigned int serial_chars_in_buffer(struct tty_struct *tty) 389 389 { 390 390 struct usb_serial_port *port = tty->driver_data; 391 391 struct usb_serial *serial = port->serial;
+1 -8
drivers/usb/serial/whiteheat.c
··· 625 625 626 626 port_settings.port = port->port_number + 1; 627 627 628 - /* get the byte size */ 629 - switch (cflag & CSIZE) { 630 - case CS5: port_settings.bits = 5; break; 631 - case CS6: port_settings.bits = 6; break; 632 - case CS7: port_settings.bits = 7; break; 633 - default: 634 - case CS8: port_settings.bits = 8; break; 635 - } 628 + port_settings.bits = tty_get_char_size(cflag); 636 629 dev_dbg(dev, "%s - data bits = %d\n", __func__, port_settings.bits); 637 630 638 631 /* determine the parity */
-175
include/linux/n_r3964.h
··· 1 - /* r3964 linediscipline for linux 2 - * 3 - * ----------------------------------------------------------- 4 - * Copyright by 5 - * Philips Automation Projects 6 - * Kassel (Germany) 7 - * ----------------------------------------------------------- 8 - * This software may be used and distributed according to the terms of 9 - * the GNU General Public License, incorporated herein by reference. 10 - * 11 - * Author: 12 - * L. Haag 13 - * 14 - * $Log: r3964.h,v $ 15 - * Revision 1.4 2005/12/21 19:54:24 Kurt Huwig <kurt huwig de> 16 - * Fixed HZ usage on 2.6 kernels 17 - * Removed unnecessary include 18 - * 19 - * Revision 1.3 2001/03/18 13:02:24 dwmw2 20 - * Fix timer usage, use spinlocks properly. 21 - * 22 - * Revision 1.2 2001/03/18 12:53:15 dwmw2 23 - * Merge changes in 2.4.2 24 - * 25 - * Revision 1.1.1.1 1998/10/13 16:43:14 dwmw2 26 - * This'll screw the version control 27 - * 28 - * Revision 1.6 1998/09/30 00:40:38 dwmw2 29 - * Updated to use kernel's N_R3964 if available 30 - * 31 - * Revision 1.4 1998/04/02 20:29:44 lhaag 32 - * select, blocking, ... 33 - * 34 - * Revision 1.3 1998/02/12 18:58:43 root 35 - * fixed some memory leaks 36 - * calculation of checksum characters 37 - * 38 - * Revision 1.2 1998/02/07 13:03:17 root 39 - * ioctl read_telegram 40 - * 41 - * Revision 1.1 1998/02/06 19:19:43 root 42 - * Initial revision 43 - * 44 - * 45 - */ 46 - #ifndef __LINUX_N_R3964_H__ 47 - #define __LINUX_N_R3964_H__ 48 - 49 - 50 - #include <linux/param.h> 51 - #include <uapi/linux/n_r3964.h> 52 - 53 - /* 54 - * Common ascii handshake characters: 55 - */ 56 - 57 - #define STX 0x02 58 - #define ETX 0x03 59 - #define DLE 0x10 60 - #define NAK 0x15 61 - 62 - /* 63 - * Timeouts (from milliseconds to jiffies) 64 - */ 65 - 66 - #define R3964_TO_QVZ ((550)*HZ/1000) 67 - #define R3964_TO_ZVZ ((220)*HZ/1000) 68 - #define R3964_TO_NO_BUF ((400)*HZ/1000) 69 - #define R3964_NO_TX_ROOM ((100)*HZ/1000) 70 - #define R3964_TO_RX_PANIC ((4000)*HZ/1000) 71 - #define R3964_MAX_RETRIES 5 72 - 73 - 74 - enum { R3964_IDLE, 75 - R3964_TX_REQUEST, R3964_TRANSMITTING, 76 - R3964_WAIT_ZVZ_BEFORE_TX_RETRY, R3964_WAIT_FOR_TX_ACK, 77 - R3964_WAIT_FOR_RX_BUF, 78 - R3964_RECEIVING, R3964_WAIT_FOR_BCC, R3964_WAIT_FOR_RX_REPEAT 79 - }; 80 - 81 - /* 82 - * All open file-handles are 'clients' and are stored in a linked list: 83 - */ 84 - 85 - struct r3964_message; 86 - 87 - struct r3964_client_info { 88 - spinlock_t lock; 89 - struct pid *pid; 90 - unsigned int sig_flags; 91 - 92 - struct r3964_client_info *next; 93 - 94 - struct r3964_message *first_msg; 95 - struct r3964_message *last_msg; 96 - struct r3964_block_header *next_block_to_read; 97 - int msg_count; 98 - }; 99 - 100 - 101 - 102 - struct r3964_block_header; 103 - 104 - /* internal version of client_message: */ 105 - struct r3964_message { 106 - int msg_id; 107 - int arg; 108 - int error_code; 109 - struct r3964_block_header *block; 110 - struct r3964_message *next; 111 - }; 112 - 113 - /* 114 - * Header of received block in rx_buf/tx_buf: 115 - */ 116 - 117 - struct r3964_block_header 118 - { 119 - unsigned int length; /* length in chars without header */ 120 - unsigned char *data; /* usually data is located 121 - immediately behind this struct */ 122 - unsigned int locks; /* only used in rx_buffer */ 123 - 124 - struct r3964_block_header *next; 125 - struct r3964_client_info *owner; /* =NULL in rx_buffer */ 126 - }; 127 - 128 - /* 129 - * If rx_buf hasn't enough space to store R3964_MTU chars, 130 - * we will reject all incoming STX-requests by sending NAK. 131 - */ 132 - 133 - #define RX_BUF_SIZE 4000 134 - #define TX_BUF_SIZE 4000 135 - #define R3964_MAX_BLOCKS_IN_RX_QUEUE 100 136 - 137 - #define R3964_PARITY 0x0001 138 - #define R3964_FRAME 0x0002 139 - #define R3964_OVERRUN 0x0004 140 - #define R3964_UNKNOWN 0x0008 141 - #define R3964_BREAK 0x0010 142 - #define R3964_CHECKSUM 0x0020 143 - #define R3964_ERROR 0x003f 144 - #define R3964_BCC 0x4000 145 - #define R3964_DEBUG 0x8000 146 - 147 - 148 - struct r3964_info { 149 - spinlock_t lock; 150 - struct tty_struct *tty; 151 - unsigned char priority; 152 - unsigned char *rx_buf; /* ring buffer */ 153 - unsigned char *tx_buf; 154 - 155 - struct r3964_block_header *rx_first; 156 - struct r3964_block_header *rx_last; 157 - struct r3964_block_header *tx_first; 158 - struct r3964_block_header *tx_last; 159 - unsigned int tx_position; 160 - unsigned int rx_position; 161 - unsigned char last_rx; 162 - unsigned char bcc; 163 - unsigned int blocks_in_rx_queue; 164 - 165 - struct mutex read_lock; /* serialize r3964_read */ 166 - 167 - struct r3964_client_info *firstClient; 168 - unsigned int state; 169 - unsigned int flags; 170 - 171 - struct timer_list tmr; 172 - int nRetry; 173 - }; 174 - 175 - #endif
+1 -1
include/linux/serial_8250.h
··· 146 146 return container_of(up, struct uart_8250_port, port); 147 147 } 148 148 149 - int serial8250_register_8250_port(struct uart_8250_port *); 149 + int serial8250_register_8250_port(const struct uart_8250_port *); 150 150 void serial8250_unregister_port(int line); 151 151 void serial8250_suspend_port(int line); 152 152 void serial8250_resume_port(int line);
+3 -2
include/linux/serial_core.h
··· 408 408 void uart_unregister_driver(struct uart_driver *uart); 409 409 int uart_add_one_port(struct uart_driver *reg, struct uart_port *port); 410 410 int uart_remove_one_port(struct uart_driver *reg, struct uart_port *port); 411 - int uart_match_port(struct uart_port *port1, struct uart_port *port2); 411 + bool uart_match_port(const struct uart_port *port1, 412 + const struct uart_port *port2); 412 413 413 414 /* 414 415 * Power Management ··· 429 428 static inline int uart_tx_stopped(struct uart_port *port) 430 429 { 431 430 struct tty_struct *tty = port->state->port.tty; 432 - if ((tty && tty->stopped) || port->hw_stopped) 431 + if ((tty && tty->flow.stopped) || port->hw_stopped) 433 432 return 1; 434 433 return 0; 435 434 }
+46 -32
include/linux/tty.h
··· 243 243 #define TTY_PORT_KOPENED 5 /* device exclusively opened by 244 244 kernel */ 245 245 246 - /* 247 - * Where all of the state associated with a tty is kept while the tty 248 - * is open. Since the termios state should be kept even if the tty 249 - * has been closed --- for things like the baud rate, etc --- it is 250 - * not stored here, but rather a pointer to the real state is stored 251 - * here. Possible the winsize structure should have the same 252 - * treatment, but (1) the default 80x24 is usually right and (2) it's 253 - * most often used by a windowing system, which will set the correct 254 - * size each time the window is created or resized anyway. 255 - * - TYT, 9/14/92 256 - */ 257 - 258 246 struct tty_operations; 259 247 248 + /** 249 + * struct tty_struct - state associated with a tty while open 250 + * 251 + * @flow.lock: lock for flow members 252 + * @flow.stopped: tty stopped/started by tty_stop/tty_start 253 + * @flow.tco_stopped: tty stopped/started by TCOOFF/TCOON ioctls (it has 254 + * precedense over @flow.stopped) 255 + * @flow.unused: alignment for Alpha, so that no members other than @flow.* are 256 + * modified by the same 64b word store. The @flow's __aligned is 257 + * there for the very same reason. 258 + * @ctrl.lock: lock for ctrl members 259 + * @ctrl.pgrp: process group of this tty (setpgrp(2)) 260 + * @ctrl.session: session of this tty (setsid(2)). Writes are protected by both 261 + * @ctrl.lock and legacy mutex, readers must use at least one of 262 + * them. 263 + * @ctrl.pktstatus: packet mode status (bitwise OR of TIOCPKT_* constants) 264 + * @ctrl.packet: packet mode enabled 265 + * 266 + * All of the state associated with a tty while the tty is open. Persistent 267 + * storage for tty devices is referenced here as @port in struct tty_port. 268 + */ 260 269 struct tty_struct { 261 270 int magic; 262 271 struct kref kref; ··· 283 274 struct mutex throttle_mutex; 284 275 struct rw_semaphore termios_rwsem; 285 276 struct mutex winsize_mutex; 286 - spinlock_t ctrl_lock; 287 - spinlock_t flow_lock; 288 277 /* Termios values are protected by the termios rwsem */ 289 278 struct ktermios termios, termios_locked; 290 279 char name[64]; 291 - struct pid *pgrp; /* Protected by ctrl lock */ 292 - /* 293 - * Writes protected by both ctrl lock and legacy mutex, readers must use 294 - * at least one of them. 295 - */ 296 - struct pid *session; 297 280 unsigned long flags; 298 281 int count; 299 282 struct winsize winsize; /* winsize_mutex */ 300 - unsigned long stopped:1, /* flow_lock */ 301 - flow_stopped:1, 302 - unused:BITS_PER_LONG - 2; 283 + 284 + struct { 285 + spinlock_t lock; 286 + bool stopped; 287 + bool tco_stopped; 288 + unsigned long unused[0]; 289 + } __aligned(sizeof(unsigned long)) flow; 290 + 291 + struct { 292 + spinlock_t lock; 293 + struct pid *pgrp; 294 + struct pid *session; 295 + unsigned char pktstatus; 296 + bool packet; 297 + unsigned long unused[0]; 298 + } __aligned(sizeof(unsigned long)) ctrl; 299 + 303 300 int hw_stopped; 304 - unsigned long ctrl_status:8, /* ctrl_lock */ 305 - packet:1, 306 - unused_ctrl:BITS_PER_LONG - 9; 307 301 unsigned int receive_room; /* Bytes free for queue */ 308 302 int flow_change; 309 303 ··· 458 446 extern void tty_write_message(struct tty_struct *tty, char *msg); 459 447 extern int tty_send_xchar(struct tty_struct *tty, char ch); 460 448 extern int tty_put_char(struct tty_struct *tty, unsigned char c); 461 - extern int tty_chars_in_buffer(struct tty_struct *tty); 462 - extern int tty_write_room(struct tty_struct *tty); 449 + extern unsigned int tty_chars_in_buffer(struct tty_struct *tty); 450 + extern unsigned int tty_write_room(struct tty_struct *tty); 463 451 extern void tty_driver_flush_buffer(struct tty_struct *tty); 464 - extern void tty_throttle(struct tty_struct *tty); 465 452 extern void tty_unthrottle(struct tty_struct *tty); 466 453 extern int tty_throttle_safe(struct tty_struct *tty); 467 454 extern int tty_unthrottle_safe(struct tty_struct *tty); ··· 494 483 { 495 484 return tty_termios_baud_rate(&tty->termios); 496 485 } 486 + 487 + unsigned char tty_get_char_size(unsigned int cflag); 488 + unsigned char tty_get_frame_size(unsigned int cflag); 497 489 498 490 extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 499 491 extern int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); ··· 638 624 return port->count + port->blocked_open; 639 625 } 640 626 641 - extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc); 642 - extern int tty_unregister_ldisc(int disc); 627 + extern int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc); 628 + extern void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc); 643 629 extern int tty_set_ldisc(struct tty_struct *tty, int disc); 644 630 extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 645 - char *f, int count); 631 + const char *f, int count); 646 632 647 633 /* n_tty.c */ 648 634 extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops);
+6 -6
include/linux/tty_driver.h
··· 89 89 * 90 90 * Note: Do not call this function directly, call tty_driver_flush_chars 91 91 * 92 - * int (*write_room)(struct tty_struct *tty); 92 + * unsigned int (*write_room)(struct tty_struct *tty); 93 93 * 94 94 * This routine returns the numbers of characters the tty driver 95 95 * will accept for queuing to be written. This number is subject ··· 136 136 * the line discipline are close to full, and it should somehow 137 137 * signal that no more characters should be sent to the tty. 138 138 * 139 - * Optional: Always invoke via tty_throttle(), called under the 139 + * Optional: Always invoke via tty_throttle_safe(), called under the 140 140 * termios lock. 141 141 * 142 142 * void (*unthrottle)(struct tty_struct * tty); ··· 153 153 * This routine notifies the tty driver that it should stop 154 154 * outputting characters to the tty device. 155 155 * 156 - * Called with ->flow_lock held. Serialized with start() method. 156 + * Called with ->flow.lock held. Serialized with start() method. 157 157 * 158 158 * Optional: 159 159 * ··· 164 164 * This routine notifies the tty driver that it resume sending 165 165 * characters to the tty device. 166 166 * 167 - * Called with ->flow_lock held. Serialized with stop() method. 167 + * Called with ->flow.lock held. Serialized with stop() method. 168 168 * 169 169 * Optional: 170 170 * ··· 256 256 const unsigned char *buf, int count); 257 257 int (*put_char)(struct tty_struct *tty, unsigned char ch); 258 258 void (*flush_chars)(struct tty_struct *tty); 259 - int (*write_room)(struct tty_struct *tty); 260 - int (*chars_in_buffer)(struct tty_struct *tty); 259 + unsigned int (*write_room)(struct tty_struct *tty); 260 + unsigned int (*chars_in_buffer)(struct tty_struct *tty); 261 261 int (*ioctl)(struct tty_struct *tty, 262 262 unsigned int cmd, unsigned long arg); 263 263 long (*compat_ioctl)(struct tty_struct *tty,
+3 -1
include/linux/tty_flip.h
··· 2 2 #ifndef _LINUX_TTY_FLIP_H 3 3 #define _LINUX_TTY_FLIP_H 4 4 5 + #include <linux/tty.h> 6 + 5 7 extern int tty_buffer_set_limit(struct tty_port *port, int limit); 6 - extern int tty_buffer_space_avail(struct tty_port *port); 8 + extern unsigned int tty_buffer_space_avail(struct tty_port *port); 7 9 extern int tty_buffer_request_room(struct tty_port *port, size_t size); 8 10 extern int tty_insert_flip_string_flags(struct tty_port *port, 9 11 const unsigned char *chars, const char *flags, size_t size);
+2 -4
include/linux/tty_ldisc.h
··· 201 201 * The following routines are called from below. 202 202 */ 203 203 void (*receive_buf)(struct tty_struct *, const unsigned char *cp, 204 - char *fp, int count); 204 + const char *fp, int count); 205 205 void (*write_wakeup)(struct tty_struct *); 206 206 void (*dcd_change)(struct tty_struct *, unsigned int); 207 207 int (*receive_buf2)(struct tty_struct *, const unsigned char *cp, 208 - char *fp, int count); 208 + const char *fp, int count); 209 209 210 210 struct module *owner; 211 - 212 - int refcount; 213 211 }; 214 212 215 213 struct tty_ldisc {
-1
include/linux/vt_kern.h
··· 166 166 void vt_set_kbd_mode_bit(int console, int bit); 167 167 void vt_clr_kbd_mode_bit(int console, int bit); 168 168 void vt_set_led_state(int console, int leds); 169 - void vt_set_led_state(int console, int leds); 170 169 void vt_kbd_con_start(int console); 171 170 void vt_kbd_con_stop(int console); 172 171
-99
include/uapi/linux/n_r3964.h
··· 1 - /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ 2 - /* r3964 linediscipline for linux 3 - * 4 - * ----------------------------------------------------------- 5 - * Copyright by 6 - * Philips Automation Projects 7 - * Kassel (Germany) 8 - * ----------------------------------------------------------- 9 - * This software may be used and distributed according to the terms of 10 - * the GNU General Public License, incorporated herein by reference. 11 - * 12 - * Author: 13 - * L. Haag 14 - * 15 - * $Log: r3964.h,v $ 16 - * Revision 1.4 2005/12/21 19:54:24 Kurt Huwig <kurt huwig de> 17 - * Fixed HZ usage on 2.6 kernels 18 - * Removed unnecessary include 19 - * 20 - * Revision 1.3 2001/03/18 13:02:24 dwmw2 21 - * Fix timer usage, use spinlocks properly. 22 - * 23 - * Revision 1.2 2001/03/18 12:53:15 dwmw2 24 - * Merge changes in 2.4.2 25 - * 26 - * Revision 1.1.1.1 1998/10/13 16:43:14 dwmw2 27 - * This'll screw the version control 28 - * 29 - * Revision 1.6 1998/09/30 00:40:38 dwmw2 30 - * Updated to use kernel's N_R3964 if available 31 - * 32 - * Revision 1.4 1998/04/02 20:29:44 lhaag 33 - * select, blocking, ... 34 - * 35 - * Revision 1.3 1998/02/12 18:58:43 root 36 - * fixed some memory leaks 37 - * calculation of checksum characters 38 - * 39 - * Revision 1.2 1998/02/07 13:03:17 root 40 - * ioctl read_telegram 41 - * 42 - * Revision 1.1 1998/02/06 19:19:43 root 43 - * Initial revision 44 - * 45 - * 46 - */ 47 - 48 - #ifndef _UAPI__LINUX_N_R3964_H__ 49 - #define _UAPI__LINUX_N_R3964_H__ 50 - 51 - /* line disciplines for r3964 protocol */ 52 - 53 - 54 - /* 55 - * Ioctl-commands 56 - */ 57 - 58 - #define R3964_ENABLE_SIGNALS 0x5301 59 - #define R3964_SETPRIORITY 0x5302 60 - #define R3964_USE_BCC 0x5303 61 - #define R3964_READ_TELEGRAM 0x5304 62 - 63 - /* Options for R3964_SETPRIORITY */ 64 - #define R3964_MASTER 0 65 - #define R3964_SLAVE 1 66 - 67 - /* Options for R3964_ENABLE_SIGNALS */ 68 - #define R3964_SIG_ACK 0x0001 69 - #define R3964_SIG_DATA 0x0002 70 - #define R3964_SIG_ALL 0x000f 71 - #define R3964_SIG_NONE 0x0000 72 - #define R3964_USE_SIGIO 0x1000 73 - 74 - /* 75 - * r3964 operation states: 76 - */ 77 - 78 - /* types for msg_id: */ 79 - enum {R3964_MSG_ACK=1, R3964_MSG_DATA }; 80 - 81 - #define R3964_MAX_MSG_COUNT 32 82 - 83 - /* error codes for client messages */ 84 - #define R3964_OK 0 /* no error. */ 85 - #define R3964_TX_FAIL -1 /* transmission error, block NOT sent */ 86 - #define R3964_OVERFLOW -2 /* msg queue overflow */ 87 - 88 - /* the client gets this struct when calling read(fd,...): */ 89 - struct r3964_client_message { 90 - int msg_id; 91 - int arg; 92 - int error_code; 93 - }; 94 - 95 - #define R3964_MTU 256 96 - 97 - 98 - 99 - #endif /* _UAPI__LINUX_N_R3964_H__ */
+2 -2
net/bluetooth/rfcomm/tty.c
··· 809 809 return sent; 810 810 } 811 811 812 - static int rfcomm_tty_write_room(struct tty_struct *tty) 812 + static unsigned int rfcomm_tty_write_room(struct tty_struct *tty) 813 813 { 814 814 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 815 815 int room = 0; ··· 1012 1012 rfcomm_dlc_unthrottle(dev->dlc); 1013 1013 } 1014 1014 1015 - static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) 1015 + static unsigned int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) 1016 1016 { 1017 1017 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1018 1018
+4 -3
net/nfc/nci/uart.c
··· 308 308 * Return Value: None 309 309 */ 310 310 static void nci_uart_tty_receive(struct tty_struct *tty, const u8 *data, 311 - char *flags, int count) 311 + const char *flags, int count) 312 312 { 313 313 struct nci_uart *nu = (void *)tty->disc_data; 314 314 ··· 442 442 443 443 static struct tty_ldisc_ops nci_uart_ldisc = { 444 444 .owner = THIS_MODULE, 445 + .num = N_NCI, 445 446 .name = "n_nci", 446 447 .open = nci_uart_tty_open, 447 448 .close = nci_uart_tty_close, ··· 457 456 458 457 static int __init nci_uart_init(void) 459 458 { 460 - return tty_register_ldisc(N_NCI, &nci_uart_ldisc); 459 + return tty_register_ldisc(&nci_uart_ldisc); 461 460 } 462 461 463 462 static void __exit nci_uart_exit(void) 464 463 { 465 - tty_unregister_ldisc(N_NCI); 464 + tty_unregister_ldisc(&nci_uart_ldisc); 466 465 } 467 466 468 467 module_init(nci_uart_init);
+2 -2
sound/soc/codecs/cx20442.c
··· 259 259 } 260 260 261 261 /* Line discipline .receive_buf() */ 262 - static void v253_receive(struct tty_struct *tty, 263 - const unsigned char *cp, char *fp, int count) 262 + static void v253_receive(struct tty_struct *tty, const unsigned char *cp, 263 + const char *fp, int count) 264 264 { 265 265 struct snd_soc_component *component = tty->disc_data; 266 266 struct cx20442_priv *cx20442;
+5 -6
sound/soc/ti/ams-delta.c
··· 337 337 } 338 338 339 339 /* Line discipline .receive_buf() */ 340 - static void cx81801_receive(struct tty_struct *tty, 341 - const unsigned char *cp, char *fp, int count) 340 + static void cx81801_receive(struct tty_struct *tty, const unsigned char *cp, 341 + const char *fp, int count) 342 342 { 343 343 struct snd_soc_component *component = tty->disc_data; 344 344 const unsigned char *c; ··· 396 396 397 397 static struct tty_ldisc_ops cx81801_ops = { 398 398 .name = "cx81801", 399 + .num = N_V253, 399 400 .owner = THIS_MODULE, 400 401 .open = cx81801_open, 401 402 .close = cx81801_close, ··· 504 503 } 505 504 506 505 /* Register optional line discipline for over the modem control */ 507 - ret = tty_register_ldisc(N_V253, &cx81801_ops); 506 + ret = tty_register_ldisc(&cx81801_ops); 508 507 if (ret) { 509 508 dev_warn(card->dev, 510 509 "Failed to register line discipline, " ··· 583 582 { 584 583 struct snd_soc_card *card = platform_get_drvdata(pdev); 585 584 586 - if (tty_unregister_ldisc(N_V253) != 0) 587 - dev_warn(&pdev->dev, 588 - "failed to unregister V253 line discipline\n"); 585 + tty_unregister_ldisc(&cx81801_ops); 589 586 590 587 snd_soc_unregister_card(card); 591 588 card->dev = NULL;