Merge 5.13-rc4 into tty-next
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 31 May 2021 07:44:28 +0000 (09:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 31 May 2021 07:44:28 +0000 (09:44 +0200)
We need the tty/serial fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
137 files changed:
Documentation/admin-guide/kernel-parameters.txt
Documentation/devicetree/bindings/serial/8250.yaml
Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
Documentation/devicetree/bindings/serial/brcm,bcm7271-uart.yaml
Documentation/devicetree/bindings/serial/ingenic,uart.yaml
Documentation/devicetree/bindings/serial/pl011.yaml
Documentation/devicetree/bindings/serial/qca,ar9330-uart.yaml
Documentation/devicetree/bindings/serial/renesas,em-uart.yaml
Documentation/devicetree/bindings/serial/renesas,scif.yaml
Documentation/devicetree/bindings/serial/samsung_uart.yaml
Documentation/devicetree/bindings/serial/serial.yaml
Documentation/devicetree/bindings/serial/sifive-serial.yaml
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
Documentation/networking/caif/caif.rst
MAINTAINERS
arch/alpha/kernel/srmcons.c
arch/m68k/emu/nfcon.c
arch/parisc/kernel/pdc_cons.c
arch/powerpc/configs/ppc6xx_defconfig
arch/um/drivers/line.c
arch/um/drivers/line.h
arch/um/drivers/ssl.c
arch/um/drivers/stdio_console.c
arch/xtensa/platforms/iss/console.c
drivers/accessibility/speakup/spk_ttyio.c
drivers/bluetooth/hci_ldisc.c
drivers/char/Kconfig
drivers/char/pcmcia/synclink_cs.c
drivers/char/ttyprintk.c
drivers/input/serio/serport.c
drivers/ipack/devices/ipoctal.c
drivers/isdn/capi/capi.c
drivers/misc/bcm-vk/bcm_vk_tty.c
drivers/misc/ti-st/st_core.c
drivers/mmc/core/sdio_uart.c
drivers/net/caif/caif_serial.c
drivers/net/can/slcan.c
drivers/net/hamradio/6pack.c
drivers/net/hamradio/mkiss.c
drivers/net/ppp/ppp_async.c
drivers/net/ppp/ppp_synctty.c
drivers/net/slip/slip.c
drivers/net/usb/hso.c
drivers/pps/clients/pps-ldisc.c
drivers/s390/char/con3215.c
drivers/s390/char/sclp_rw.c
drivers/s390/char/sclp_rw.h
drivers/s390/char/sclp_tty.c
drivers/s390/char/sclp_vt220.c
drivers/s390/char/tty3270.c
drivers/staging/fwserial/fwserial.c
drivers/staging/gdm724x/gdm_tty.c
drivers/staging/greybus/uart.c
drivers/tty/Makefile
drivers/tty/amiserial.c
drivers/tty/ehv_bytechan.c
drivers/tty/goldfish.c
drivers/tty/hvc/hvc_console.c
drivers/tty/hvc/hvc_iucv.c
drivers/tty/hvc/hvcs.c
drivers/tty/hvc/hvsi.c
drivers/tty/ipwireless/tty.c
drivers/tty/mips_ejtag_fdc.c
drivers/tty/moxa.c
drivers/tty/mxser.c
drivers/tty/n_gsm.c
drivers/tty/n_hdlc.c
drivers/tty/n_null.c
drivers/tty/n_r3964.c [deleted file]
drivers/tty/n_tty.c
drivers/tty/nozomi.c
drivers/tty/pty.c
drivers/tty/serdev/core.c
drivers/tty/serial/8250/8250_aspeed_vuart.c
drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/8250/8250_of.c
drivers/tty/serial/8250/8250_omap.c
drivers/tty/serial/8250/serial_cs.c
drivers/tty/serial/Kconfig
drivers/tty/serial/amba-pl011.c
drivers/tty/serial/arc_uart.c
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/dz.c
drivers/tty/serial/fsl_lpuart.c
drivers/tty/serial/icom.c
drivers/tty/serial/imx.c
drivers/tty/serial/ip22zilog.c
drivers/tty/serial/kgdb_nmi.c
drivers/tty/serial/liteuart.c
drivers/tty/serial/max310x.c
drivers/tty/serial/meson_uart.c
drivers/tty/serial/mux.c
drivers/tty/serial/omap-serial.c
drivers/tty/serial/pmac_zilog.c
drivers/tty/serial/qcom_geni_serial.c
drivers/tty/serial/samsung_tty.c
drivers/tty/serial/sb1250-duart.c
drivers/tty/serial/sc16is7xx.c
drivers/tty/serial/serial_core.c
drivers/tty/serial/serial_txx9.c
drivers/tty/serial/st-asc.c
drivers/tty/serial/stm32-usart.c
drivers/tty/serial/sunsab.c
drivers/tty/serial/sunsu.c
drivers/tty/serial/sunzilog.c
drivers/tty/serial/vr41xx_siu.c
drivers/tty/serial/xilinx_uartps.c
drivers/tty/synclink_gt.c
drivers/tty/tty_baudrate.c
drivers/tty/tty_buffer.c
drivers/tty/tty_io.c
drivers/tty/tty_ioctl.c
drivers/tty/tty_jobctrl.c
drivers/tty/tty_ldisc.c
drivers/tty/tty_port.c
drivers/tty/ttynull.c
drivers/tty/vcc.c
drivers/tty/vt/keyboard.c
drivers/tty/vt/selection.c
drivers/tty/vt/vt.c
drivers/usb/class/cdc-acm.c
drivers/usb/gadget/function/u_serial.c
drivers/usb/host/xhci-dbgtty.c
drivers/usb/serial/usb-serial.c
include/linux/n_r3964.h [deleted file]
include/linux/serial_8250.h
include/linux/serial_core.h
include/linux/tty.h
include/linux/tty_driver.h
include/linux/tty_flip.h
include/linux/tty_ldisc.h
include/uapi/linux/n_r3964.h [deleted file]
net/bluetooth/rfcomm/tty.c
net/nfc/nci/uart.c
sound/soc/codecs/cx20442.c
sound/soc/ti/ams-delta.c

index cb89dbd..17bdf5d 100644 (file)
                        the driver will use only 32-bit accessors to read/write
                        the device registers.
 
+               liteuart,<addr>
+                       Start an early console on a litex serial port at the
+                       specified address. The serial port must already be
+                       setup and configured. Options are not yet supported.
+
                meson,<addr>
                        Start an early, polled-mode console on a meson serial
                        port at the specified address. The serial port must
index 41f57c4..a0bf061 100644 (file)
@@ -10,7 +10,7 @@ maintainers:
   - devicetree@vger.kernel.org
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
   - if:
       anyOf:
         - required:
index 75ebc99..7487aa6 100644 (file)
@@ -55,6 +55,11 @@ properties:
       - const: pclk
       - const: baud
 
+  fifo-size:
+    description: The fifo size supported by the UART channel.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [64, 128]
+
 required:
   - compatible
   - reg
index 46c6274..6d17658 100644 (file)
@@ -10,7 +10,7 @@ maintainers:
   - Al Cooper <alcooperx@gmail.com>
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
 description: |+
   The Broadcom UART is based on the basic 8250 UART but with
index 7748d8c..b432d4d 100644 (file)
@@ -10,7 +10,7 @@ maintainers:
   - Paul Cercueil <paul@crapouillou.net>
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
 properties:
   $nodename:
index 1f8e9f2..5ea00f8 100644 (file)
@@ -10,7 +10,7 @@ maintainers:
   - Rob Herring <robh@kernel.org>
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
 # Need a custom select here or 'arm,primecell' will match on lots of nodes
 select:
@@ -24,12 +24,9 @@ select:
 
 properties:
   compatible:
-    oneOf:
-      - items:
-          - const: arm,pl011
-          - const: arm,primecell
-      - items:
-          - const: arm,primecell
+    items:
+      - const: arm,pl011
+      - const: arm,primecell
 
   reg:
     maxItems: 1
@@ -103,7 +100,7 @@ dependencies:
   poll-rate-ms: [ auto-poll ]
   poll-timeout-ms: [ auto-poll ]
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
index a344369..a644e5a 100644 (file)
@@ -10,7 +10,7 @@ maintainers:
   - Oleksij Rempel <o.rempel@pengutronix.de>
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
 properties:
   compatible:
@@ -35,7 +35,7 @@ required:
   - clocks
   - clock-names
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
index 82aefdb..e98ec48 100644 (file)
@@ -35,7 +35,7 @@ required:
   - clocks
   - clock-names
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
index 22d7682..6b8731f 100644 (file)
@@ -64,6 +64,10 @@ properties:
           - const: renesas,rcar-gen3-scif # R-Car Gen3 and RZ/G2
           - const: renesas,scif           # generic SCIF compatible UART
 
+      - items:
+          - enum:
+              - renesas,scif-r9a07g044      # RZ/G2{L,LC}
+
   reg:
     maxItems: 1
 
index 97ec8a0..0c24e7b 100644 (file)
@@ -82,7 +82,7 @@ required:
 unevaluatedProperties: false
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
   - if:
       properties:
index 2fdf4ed..c75ba3f 100644 (file)
@@ -23,6 +23,8 @@ properties:
   $nodename:
     pattern: "^serial(@.*)?$"
 
+  label: true
+
   cts-gpios:
     maxItems: 1
     description:
index 5fa94da..09aae43 100644 (file)
@@ -12,7 +12,7 @@ maintainers:
   - Palmer Dabbelt <palmer@sifive.com>
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
 properties:
   compatible:
@@ -49,7 +49,7 @@ required:
   - interrupts
   - clocks
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
index 87ef1e2..b49fda5 100644 (file)
@@ -10,7 +10,7 @@ maintainers:
   - Rob Herring <robh@kernel.org>
 
 allOf:
-  - $ref: /schemas/serial.yaml#
+  - $ref: serial.yaml#
 
 properties:
   compatible:
@@ -23,6 +23,7 @@ properties:
       - items:
           - enum:
               - rockchip,px30-uart
+              - rockchip,rk1808-uart
               - rockchip,rk3036-uart
               - rockchip,rk3066-uart
               - rockchip,rk3188-uart
@@ -31,6 +32,7 @@ properties:
               - rockchip,rk3328-uart
               - rockchip,rk3368-uart
               - rockchip,rk3399-uart
+              - rockchip,rk3568-uart
               - rockchip,rv1108-uart
           - const: snps,dw-apb-uart
       - items:
index 71a6426..f50f4ca 100644 (file)
@@ -112,8 +112,7 @@ required:
   - interrupts
   - clocks
 
-additionalProperties:
-  type: object
+unevaluatedProperties: false
 
 examples:
   - |
index 81a1437..d922d41 100644 (file)
@@ -69,9 +69,9 @@ There are debugfs parameters provided for serial communication.
 
   - 0x01 - tty->warned is on.
   - 0x04 - tty->packed is on.
-  - 0x08 - tty->flow_stopped is on.
+  - 0x08 - tty->flow.tco_stopped is on.
   - 0x10 - tty->hw_stopped is on.
-  - 0x20 - tty->stopped is on.
+  - 0x20 - tty->flow.stopped is on.
 
 * last_tx_msg: Binary blob Prints the last transmitted frame.
 
index 503fd21..4fdd308 100644 (file)
@@ -18561,9 +18561,13 @@ T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
 F:     Documentation/driver-api/serial/
 F:     drivers/tty/
 F:     drivers/tty/serial/serial_core.c
+F:     include/linux/selection.h
 F:     include/linux/serial.h
 F:     include/linux/serial_core.h
-F:     include/linux/tty.h
+F:     include/linux/sysrq.h
+F:     include/linux/tty*.h
+F:     include/linux/vt.h
+F:     include/linux/vt_*.h
 F:     include/uapi/linux/serial.h
 F:     include/uapi/linux/serial_core.h
 F:     include/uapi/linux/tty.h
index 438b10c..fc03471 100644 (file)
@@ -142,18 +142,12 @@ srmcons_write(struct tty_struct *tty,
        return count;
 }
 
-static int
+static unsigned int
 srmcons_write_room(struct tty_struct *tty)
 {
        return 512;
 }
 
-static int
-srmcons_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0;
-}
-
 static int
 srmcons_open(struct tty_struct *tty, struct file *filp)
 {
@@ -200,7 +194,6 @@ static const struct tty_operations srmcons_ops = {
        .close          = srmcons_close,
        .write          = srmcons_write,
        .write_room     = srmcons_write_room,
-       .chars_in_buffer= srmcons_chars_in_buffer,
 };
 
 static int __init
index 57e8c8f..92636c8 100644 (file)
@@ -85,7 +85,7 @@ static int nfcon_tty_put_char(struct tty_struct *tty, unsigned char ch)
        return 1;
 }
 
-static int nfcon_tty_write_room(struct tty_struct *tty)
+static unsigned int nfcon_tty_write_room(struct tty_struct *tty)
 {
        return 64;
 }
index 7ed404c..39ccad0 100644 (file)
@@ -103,22 +103,16 @@ static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *bu
        return count;
 }
 
-static int pdc_console_tty_write_room(struct tty_struct *tty)
+static unsigned int pdc_console_tty_write_room(struct tty_struct *tty)
 {
        return 32768; /* no limit, no buffer used */
 }
 
-static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0; /* no buffer */
-}
-
 static const struct tty_operations pdc_console_tty_ops = {
        .open = pdc_console_tty_open,
        .close = pdc_console_tty_close,
        .write = pdc_console_tty_write,
        .write_room = pdc_console_tty_write_room,
-       .chars_in_buffer = pdc_console_tty_chars_in_buffer,
 };
 
 static void pdc_console_poll(struct timer_list *unused)
index 1fd9d12..ee09f7b 100644 (file)
@@ -621,7 +621,6 @@ CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_VIRTIO=m
 CONFIG_NVRAM=y
 CONFIG_DTLK=m
-CONFIG_R3964=m
 CONFIG_CARDMAN_4000=m
 CONFIG_CARDMAN_4040=m
 CONFIG_IPWIRELESS=m
index 1c70a31..fbc623d 100644 (file)
@@ -32,7 +32,7 @@ static irqreturn_t line_interrupt(int irq, void *data)
  *
  * Should be called while holding line->lock (this does not modify data).
  */
-static int write_room(struct line *line)
+static unsigned int write_room(struct line *line)
 {
        int n;
 
@@ -47,11 +47,11 @@ static int write_room(struct line *line)
        return n - 1;
 }
 
-int line_write_room(struct tty_struct *tty)
+unsigned int line_write_room(struct tty_struct *tty)
 {
        struct line *line = tty->driver_data;
        unsigned long flags;
-       int room;
+       unsigned int room;
 
        spin_lock_irqsave(&line->lock, flags);
        room = write_room(line);
@@ -60,11 +60,11 @@ int line_write_room(struct tty_struct *tty)
        return room;
 }
 
-int line_chars_in_buffer(struct tty_struct *tty)
+unsigned int line_chars_in_buffer(struct tty_struct *tty)
 {
        struct line *line = tty->driver_data;
        unsigned long flags;
-       int ret;
+       unsigned int ret;
 
        spin_lock_irqsave(&line->lock, flags);
        /* write_room subtracts 1 for the needed NULL, so we readd it.*/
@@ -211,11 +211,6 @@ out_up:
        return ret;
 }
 
-void line_set_termios(struct tty_struct *tty, struct ktermios * old)
-{
-       /* nothing */
-}
-
 void line_throttle(struct tty_struct *tty)
 {
        struct line *line = tty->driver_data;
index 01d21e7..bdb16b9 100644 (file)
@@ -66,11 +66,10 @@ extern int line_setup(char **conf, unsigned nlines, char **def,
                      char *init, char *name);
 extern int line_write(struct tty_struct *tty, const unsigned char *buf,
                      int len);
-extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
-extern int line_chars_in_buffer(struct tty_struct *tty);
+extern unsigned int line_chars_in_buffer(struct tty_struct *tty);
 extern void line_flush_buffer(struct tty_struct *tty);
 extern void line_flush_chars(struct tty_struct *tty);
-extern int line_write_room(struct tty_struct *tty);
+extern unsigned int line_write_room(struct tty_struct *tty);
 extern void line_throttle(struct tty_struct *tty);
 extern void line_unthrottle(struct tty_struct *tty);
 
index 6476b28..41eae2e 100644 (file)
@@ -99,7 +99,6 @@ static const struct tty_operations ssl_ops = {
        .chars_in_buffer        = line_chars_in_buffer,
        .flush_buffer           = line_flush_buffer,
        .flush_chars            = line_flush_chars,
-       .set_termios            = line_set_termios,
        .throttle               = line_throttle,
        .unthrottle             = line_unthrottle,
        .install                = ssl_install,
index 37b1279..e8b762f 100644 (file)
@@ -106,7 +106,6 @@ static const struct tty_operations console_ops = {
        .chars_in_buffer        = line_chars_in_buffer,
        .flush_buffer           = line_flush_buffer,
        .flush_chars            = line_flush_chars,
-       .set_termios            = line_set_termios,
        .throttle               = line_throttle,
        .unthrottle             = line_unthrottle,
        .hangup                 = line_hangup,
index a3dda25..2118448 100644 (file)
@@ -100,18 +100,12 @@ static void rs_flush_chars(struct tty_struct *tty)
 {
 }
 
-static int rs_write_room(struct tty_struct *tty)
+static unsigned int rs_write_room(struct tty_struct *tty)
 {
        /* Let's say iss can always accept 2K characters.. */
        return 2 * 1024;
 }
 
-static int rs_chars_in_buffer(struct tty_struct *tty)
-{
-       /* the iss doesn't buffer characters */
-       return 0;
-}
-
 static void rs_hangup(struct tty_struct *tty)
 {
        /* Stub, once again.. */
@@ -135,7 +129,6 @@ static const struct tty_operations serial_ops = {
        .put_char = rs_put_char,
        .flush_chars = rs_flush_chars,
        .write_room = rs_write_room,
-       .chars_in_buffer = rs_chars_in_buffer,
        .hangup = rs_hangup,
        .wait_until_sent = rs_wait_until_sent,
        .proc_show = rs_proc_show,
index 2e39fcf..0d1f397 100644 (file)
@@ -72,7 +72,8 @@ static void spk_ttyio_ldisc_close(struct tty_struct *tty)
 }
 
 static int spk_ttyio_receive_buf2(struct tty_struct *tty,
-                                 const unsigned char *cp, char *fp, int count)
+                                 const unsigned char *cp,
+                                 const char *fp, int count)
 {
        struct spk_ldisc_data *ldisc_data = tty->disc_data;
        struct spk_synth *synth = ldisc_data->synth;
@@ -104,6 +105,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty,
 
 static struct tty_ldisc_ops spk_ttyio_ldisc_ops = {
        .owner          = THIS_MODULE,
+       .num            = N_SPEAKUP,
        .name           = "speakup_ldisc",
        .open           = spk_ttyio_ldisc_open,
        .close          = spk_ttyio_ldisc_close,
@@ -211,14 +213,13 @@ static int spk_ttyio_initialise_ldisc(struct spk_synth *synth)
 
 void spk_ttyio_register_ldisc(void)
 {
-       if (tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops))
+       if (tty_register_ldisc(&spk_ttyio_ldisc_ops))
                pr_warn("speakup: Error registering line discipline. Most synths won't work.\n");
 }
 
 void spk_ttyio_unregister_ldisc(void)
 {
-       if (tty_unregister_ldisc(N_SPEAKUP))
-               pr_warn("speakup: Couldn't unregister ldisc\n");
+       tty_unregister_ldisc(&spk_ttyio_ldisc_ops);
 }
 
 static int spk_ttyio_out(struct spk_synth *in_synth, const char ch)
index 71a4ca5..5ed2cfa 100644 (file)
@@ -593,7 +593,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
  * Return Value:    None
  */
 static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
-                                char *flags, int count)
+                                const char *flags, int count)
 {
        struct hci_uart *hu = tty->disc_data;
 
@@ -821,6 +821,7 @@ static __poll_t hci_uart_tty_poll(struct tty_struct *tty,
 
 static struct tty_ldisc_ops hci_uart_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_HCI,
        .name           = "n_hci",
        .open           = hci_uart_tty_open,
        .close          = hci_uart_tty_close,
@@ -840,7 +841,7 @@ static int __init hci_uart_init(void)
        BT_INFO("HCI UART driver ver %s", VERSION);
 
        /* Register the tty discipline */
-       err = tty_register_ldisc(N_HCI, &hci_uart_ldisc);
+       err = tty_register_ldisc(&hci_uart_ldisc);
        if (err) {
                BT_ERR("HCI line discipline registration failed. (%d)", err);
                return err;
@@ -882,8 +883,6 @@ static int __init hci_uart_init(void)
 
 static void __exit hci_uart_exit(void)
 {
-       int err;
-
 #ifdef CONFIG_BT_HCIUART_H4
        h4_deinit();
 #endif
@@ -915,10 +914,7 @@ static void __exit hci_uart_exit(void)
        mrvl_deinit();
 #endif
 
-       /* Release tty registration of line discipline */
-       err = tty_unregister_ldisc(N_HCI);
-       if (err)
-               BT_ERR("Can't unregister HCI line discipline (%d)", err);
+       tty_unregister_ldisc(&hci_uart_ldisc);
 }
 
 module_init(hci_uart_init);
index b151e0f..52d0dd4 100644 (file)
@@ -218,19 +218,6 @@ config XILINX_HWICAP
 
          If unsure, say N.
 
-config R3964
-       tristate "Siemens R3964 line discipline"
-       depends on TTY && BROKEN
-       help
-         This driver allows synchronous communication with devices using the
-         Siemens R3964 packet protocol. Unless you are dealing with special
-         hardware like PLCs, you are unlikely to need this.
-
-         To compile this driver as a module, choose M here: the
-         module will be called n_r3964.
-
-         If unsure, say N.
-
 config APPLICOM
        tristate "Applicom intelligent fieldbus card support"
        depends on PCI
index 3287a76..9f7420b 100644 (file)
@@ -985,7 +985,7 @@ static void tx_done(MGSLPC_INFO *info, struct tty_struct *tty)
        else
 #endif
        {
-               if (tty && (tty->stopped || tty->hw_stopped)) {
+               if (tty && (tty->flow.stopped || tty->hw_stopped)) {
                        tx_stop(info);
                        return;
                }
@@ -1005,7 +1005,7 @@ static void tx_ready(MGSLPC_INFO *info, struct tty_struct *tty)
                if (!info->tx_active)
                        return;
        } else {
-               if (tty && (tty->stopped || tty->hw_stopped)) {
+               if (tty && (tty->flow.stopped || tty->hw_stopped)) {
                        tx_stop(info);
                        return;
                }
@@ -1525,7 +1525,7 @@ static void mgslpc_flush_chars(struct tty_struct *tty)
        if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars"))
                return;
 
-       if (info->tx_count <= 0 || tty->stopped ||
+       if (info->tx_count <= 0 || tty->flow.stopped ||
            tty->hw_stopped || !info->tx_buf)
                return;
 
@@ -1594,7 +1594,7 @@ static int mgslpc_write(struct tty_struct * tty,
                ret += c;
        }
 start:
-       if (info->tx_count && !tty->stopped && !tty->hw_stopped) {
+       if (info->tx_count && !tty->flow.stopped && !tty->hw_stopped) {
                spin_lock_irqsave(&info->lock, flags);
                if (!info->tx_active)
                        tx_start(info, tty);
@@ -1609,7 +1609,7 @@ cleanup:
 
 /* Return the count of free bytes in transmit buffer
  */
-static int mgslpc_write_room(struct tty_struct *tty)
+static unsigned int mgslpc_write_room(struct tty_struct *tty)
 {
        MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
        int ret;
@@ -1637,10 +1637,10 @@ static int mgslpc_write_room(struct tty_struct *tty)
 
 /* Return the count of bytes in transmit buffer
  */
-static int mgslpc_chars_in_buffer(struct tty_struct *tty)
+static unsigned int mgslpc_chars_in_buffer(struct tty_struct *tty)
 {
        MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
-       int rc;
+       unsigned int rc;
 
        if (debug_level >= DEBUG_LEVEL_INFO)
                printk("%s(%d):mgslpc_chars_in_buffer(%s)\n",
@@ -1655,7 +1655,7 @@ static int mgslpc_chars_in_buffer(struct tty_struct *tty)
                rc = info->tx_count;
 
        if (debug_level >= DEBUG_LEVEL_INFO)
-               printk("%s(%d):mgslpc_chars_in_buffer(%s)=%d\n",
+               printk("%s(%d):mgslpc_chars_in_buffer(%s)=%u\n",
                         __FILE__, __LINE__, info->device_name, rc);
 
        return rc;
index 93f5d11..230b2c9 100644 (file)
@@ -52,12 +52,7 @@ static void tpk_flush(void)
 
 static int tpk_printk(const unsigned char *buf, int count)
 {
-       int i = tpk_curr;
-
-       if (buf == NULL) {
-               tpk_flush();
-               return i;
-       }
+       int i;
 
        for (i = 0; i < count; i++) {
                if (tpk_curr >= TPK_STR_SIZE) {
@@ -100,12 +95,6 @@ static int tpk_open(struct tty_struct *tty, struct file *filp)
 static void tpk_close(struct tty_struct *tty, struct file *filp)
 {
        struct ttyprintk_port *tpkp = tty->driver_data;
-       unsigned long flags;
-
-       spin_lock_irqsave(&tpkp->spinlock, flags);
-       /* flush tpk_printk buffer */
-       tpk_printk(NULL, 0);
-       spin_unlock_irqrestore(&tpkp->spinlock, flags);
 
        tty_port_close(&tpkp->port, tty, filp);
 }
@@ -120,7 +109,6 @@ static int tpk_write(struct tty_struct *tty,
        unsigned long flags;
        int ret;
 
-
        /* exclusive use of tpk_printk within this tty */
        spin_lock_irqsave(&tpkp->spinlock, flags);
        ret = tpk_printk(buf, count);
@@ -132,40 +120,33 @@ static int tpk_write(struct tty_struct *tty,
 /*
  * TTY operations write_room function.
  */
-static int tpk_write_room(struct tty_struct *tty)
+static unsigned int tpk_write_room(struct tty_struct *tty)
 {
        return TPK_MAX_ROOM;
 }
 
 /*
- * TTY operations ioctl function.
+ * TTY operations hangup function.
  */
-static int tpk_ioctl(struct tty_struct *tty,
-                       unsigned int cmd, unsigned long arg)
+static void tpk_hangup(struct tty_struct *tty)
 {
        struct ttyprintk_port *tpkp = tty->driver_data;
 
-       if (!tpkp)
-               return -EINVAL;
-
-       switch (cmd) {
-       /* Stop TIOCCONS */
-       case TIOCCONS:
-               return -EOPNOTSUPP;
-       default:
-               return -ENOIOCTLCMD;
-       }
-       return 0;
+       tty_port_hangup(&tpkp->port);
 }
 
 /*
- * TTY operations hangup function.
+ * TTY port operations shutdown function.
  */
-static void tpk_hangup(struct tty_struct *tty)
+static void tpk_port_shutdown(struct tty_port *tport)
 {
-       struct ttyprintk_port *tpkp = tty->driver_data;
+       struct ttyprintk_port *tpkp =
+               container_of(tport, struct ttyprintk_port, port);
+       unsigned long flags;
 
-       tty_port_hangup(&tpkp->port);
+       spin_lock_irqsave(&tpkp->spinlock, flags);
+       tpk_flush();
+       spin_unlock_irqrestore(&tpkp->spinlock, flags);
 }
 
 static const struct tty_operations ttyprintk_ops = {
@@ -173,11 +154,12 @@ static const struct tty_operations ttyprintk_ops = {
        .close = tpk_close,
        .write = tpk_write,
        .write_room = tpk_write_room,
-       .ioctl = tpk_ioctl,
        .hangup = tpk_hangup,
 };
 
-static const struct tty_port_operations null_ops = { };
+static const struct tty_port_operations tpk_port_ops = {
+       .shutdown = tpk_port_shutdown,
+};
 
 static struct tty_driver *ttyprintk_driver;
 
@@ -195,7 +177,7 @@ static int __init ttyprintk_init(void)
                return PTR_ERR(ttyprintk_driver);
 
        tty_port_init(&tpk_port.port);
-       tpk_port.port.ops = &null_ops;
+       tpk_port.port.ops = &tpk_port_ops;
 
        ttyprintk_driver->driver_name = "ttyprintk";
        ttyprintk_driver->name = "ttyprintk";
index 33e9d9b..7fbbe00 100644 (file)
@@ -114,7 +114,8 @@ static void serport_ldisc_close(struct tty_struct *tty)
  * 'interrupt' routine.
  */
 
-static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
+static void serport_ldisc_receive(struct tty_struct *tty,
+               const unsigned char *cp, const char *fp, int count)
 {
        struct serport *serport = (struct serport*) tty->disc_data;
        unsigned long flags;
@@ -273,6 +274,7 @@ static void serport_ldisc_write_wakeup(struct tty_struct * tty)
 
 static struct tty_ldisc_ops serport_ldisc = {
        .owner =        THIS_MODULE,
+       .num =          N_MOUSE,
        .name =         "input",
        .open =         serport_ldisc_open,
        .close =        serport_ldisc_close,
@@ -293,7 +295,7 @@ static struct tty_ldisc_ops serport_ldisc = {
 static int __init serport_init(void)
 {
        int retval;
-       retval = tty_register_ldisc(N_MOUSE, &serport_ldisc);
+       retval = tty_register_ldisc(&serport_ldisc);
        if (retval)
                printk(KERN_ERR "serport.c: Error registering line discipline.\n");
 
@@ -302,7 +304,7 @@ static int __init serport_init(void)
 
 static void __exit serport_exit(void)
 {
-       tty_unregister_ldisc(N_MOUSE);
+       tty_unregister_ldisc(&serport_ldisc);
 }
 
 module_init(serport_init);
index 3940714..0a3b89c 100644 (file)
@@ -460,14 +460,14 @@ static int ipoctal_write_tty(struct tty_struct *tty,
        return char_copied;
 }
 
-static int ipoctal_write_room(struct tty_struct *tty)
+static unsigned int ipoctal_write_room(struct tty_struct *tty)
 {
        struct ipoctal_channel *channel = tty->driver_data;
 
        return PAGE_SIZE - channel->nb_bytes;
 }
 
-static int ipoctal_chars_in_buffer(struct tty_struct *tty)
+static unsigned int ipoctal_chars_in_buffer(struct tty_struct *tty)
 {
        struct ipoctal_channel *channel = tty->driver_data;
 
index fdf87ac..d5f9261 100644 (file)
@@ -1158,8 +1158,6 @@ static void capinc_tty_flush_chars(struct tty_struct *tty)
        struct capiminor *mp = tty->driver_data;
        struct sk_buff *skb;
 
-       pr_debug("capinc_tty_flush_chars\n");
-
        spin_lock_bh(&mp->outlock);
        skb = mp->outskb;
        if (skb) {
@@ -1175,18 +1173,18 @@ static void capinc_tty_flush_chars(struct tty_struct *tty)
        handle_minor_recv(mp);
 }
 
-static int capinc_tty_write_room(struct tty_struct *tty)
+static unsigned int capinc_tty_write_room(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
-       int room;
+       unsigned int room;
 
        room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue);
        room *= CAPI_MAX_BLKSIZE;
-       pr_debug("capinc_tty_write_room = %d\n", room);
+       pr_debug("capinc_tty_write_room = %u\n", room);
        return room;
 }
 
-static int capinc_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int capinc_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
 
@@ -1197,15 +1195,9 @@ static int capinc_tty_chars_in_buffer(struct tty_struct *tty)
        return mp->outbytes;
 }
 
-static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
-{
-       pr_debug("capinc_tty_set_termios\n");
-}
-
 static void capinc_tty_throttle(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
-       pr_debug("capinc_tty_throttle\n");
        mp->ttyinstop = 1;
 }
 
@@ -1213,7 +1205,6 @@ static void capinc_tty_unthrottle(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
 
-       pr_debug("capinc_tty_unthrottle\n");
        mp->ttyinstop = 0;
        handle_minor_recv(mp);
 }
@@ -1222,7 +1213,6 @@ static void capinc_tty_stop(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
 
-       pr_debug("capinc_tty_stop\n");
        mp->ttyoutstop = 1;
 }
 
@@ -1230,7 +1220,6 @@ static void capinc_tty_start(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
 
-       pr_debug("capinc_tty_start\n");
        mp->ttyoutstop = 0;
        handle_minor_send(mp);
 }
@@ -1239,26 +1228,9 @@ static void capinc_tty_hangup(struct tty_struct *tty)
 {
        struct capiminor *mp = tty->driver_data;
 
-       pr_debug("capinc_tty_hangup\n");
        tty_port_hangup(&mp->port);
 }
 
-static int capinc_tty_break_ctl(struct tty_struct *tty, int state)
-{
-       pr_debug("capinc_tty_break_ctl(%d)\n", state);
-       return 0;
-}
-
-static void capinc_tty_flush_buffer(struct tty_struct *tty)
-{
-       pr_debug("capinc_tty_flush_buffer\n");
-}
-
-static void capinc_tty_set_ldisc(struct tty_struct *tty)
-{
-       pr_debug("capinc_tty_set_ldisc\n");
-}
-
 static void capinc_tty_send_xchar(struct tty_struct *tty, char ch)
 {
        pr_debug("capinc_tty_send_xchar(%d)\n", ch);
@@ -1272,15 +1244,11 @@ static const struct tty_operations capinc_ops = {
        .flush_chars = capinc_tty_flush_chars,
        .write_room = capinc_tty_write_room,
        .chars_in_buffer = capinc_tty_chars_in_buffer,
-       .set_termios = capinc_tty_set_termios,
        .throttle = capinc_tty_throttle,
        .unthrottle = capinc_tty_unthrottle,
        .stop = capinc_tty_stop,
        .start = capinc_tty_start,
        .hangup = capinc_tty_hangup,
-       .break_ctl = capinc_tty_break_ctl,
-       .flush_buffer = capinc_tty_flush_buffer,
-       .set_ldisc = capinc_tty_set_ldisc,
        .send_xchar = capinc_tty_send_xchar,
        .install = capinc_tty_install,
        .cleanup = capinc_tty_cleanup,
index 4d02692..dae9eee 100644 (file)
@@ -214,7 +214,7 @@ static int bcm_vk_tty_write(struct tty_struct *tty,
        return count;
 }
 
-static int bcm_vk_tty_write_room(struct tty_struct *tty)
+static unsigned int bcm_vk_tty_write_room(struct tty_struct *tty)
 {
        struct bcm_vk *vk = dev_get_drvdata(tty->dev);
 
index 071844b..7f6976a 100644 (file)
@@ -52,13 +52,12 @@ static void remove_channel_from_table(struct st_data_s *st_gdata,
  */
 int st_get_uart_wr_room(struct st_data_s *st_gdata)
 {
-       struct tty_struct *tty;
        if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
                pr_err("tty unavailable to perform write");
                return -1;
        }
-       tty = st_gdata->tty;
-       return tty->ops->write_room(tty);
+
+       return tty_write_room(st_gdata->tty);
 }
 
 /*
@@ -798,7 +797,7 @@ static void st_tty_close(struct tty_struct *tty)
 }
 
 static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
-                          char *tty_flags, int count)
+                          const char *tty_flags, int count)
 {
 #ifdef VERBOSE
        print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
@@ -845,6 +844,7 @@ static void st_tty_flush_buffer(struct tty_struct *tty)
 }
 
 static struct tty_ldisc_ops st_ldisc_ops = {
+       .num = N_TI_WL,
        .name = "n_st",
        .open = st_tty_open,
        .close = st_tty_close,
@@ -860,7 +860,7 @@ int st_core_init(struct st_data_s **core_data)
        struct st_data_s *st_gdata;
        long err;
 
-       err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
+       err = tty_register_ldisc(&st_ldisc_ops);
        if (err) {
                pr_err("error registering %d line discipline %ld",
                           N_TI_WL, err);
@@ -871,11 +871,8 @@ int st_core_init(struct st_data_s **core_data)
        st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
        if (!st_gdata) {
                pr_err("memory allocation failed");
-               err = tty_unregister_ldisc(N_TI_WL);
-               if (err)
-                       pr_err("unable to un-register ldisc %ld", err);
                err = -ENOMEM;
-               return err;
+               goto err_unreg_ldisc;
        }
 
        /* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's
@@ -890,17 +887,18 @@ int st_core_init(struct st_data_s **core_data)
        err = st_ll_init(st_gdata);
        if (err) {
                pr_err("error during st_ll initialization(%ld)", err);
-               kfree(st_gdata);
-               err = tty_unregister_ldisc(N_TI_WL);
-               if (err)
-                       pr_err("unable to un-register ldisc");
-               return err;
+               goto err_free_gdata;
        }
 
        INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup);
 
        *core_data = st_gdata;
        return 0;
+err_free_gdata:
+       kfree(st_gdata);
+err_unreg_ldisc:
+       tty_unregister_ldisc(&st_ldisc_ops);
+       return err;
 }
 
 void st_core_exit(struct st_data_s *st_gdata)
@@ -918,9 +916,7 @@ void st_core_exit(struct st_data_s *st_gdata)
                kfree_skb(st_gdata->rx_skb);
                kfree_skb(st_gdata->tx_skb);
                /* TTY ldisc cleanup */
-               err = tty_unregister_ldisc(N_TI_WL);
-               if (err)
-                       pr_err("unable to un-register ldisc %ld", err);
+               tty_unregister_ldisc(&st_ldisc_ops);
                /* free the global data pointer */
                kfree(st_gdata);
        }
index be40672..c36242b 100644 (file)
@@ -439,7 +439,7 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
        tty = tty_port_tty_get(&port->port);
 
        if (tty == NULL || !kfifo_len(xmit) ||
-                               tty->stopped || tty->hw_stopped) {
+                               tty->flow.stopped || tty->hw_stopped) {
                sdio_uart_stop_tx(port);
                tty_kref_put(tty);
                return;
@@ -797,13 +797,13 @@ static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf,
        return ret;
 }
 
-static int sdio_uart_write_room(struct tty_struct *tty)
+static unsigned int sdio_uart_write_room(struct tty_struct *tty)
 {
        struct sdio_uart_port *port = tty->driver_data;
        return FIFO_SIZE - kfifo_len(&port->xmit_fifo);
 }
 
-static int sdio_uart_chars_in_buffer(struct tty_struct *tty)
+static unsigned int sdio_uart_chars_in_buffer(struct tty_struct *tty)
 {
        struct sdio_uart_port *port = tty->driver_data;
        return kfifo_len(&port->xmit_fifo);
index d174823..205219d 100644 (file)
@@ -87,9 +87,9 @@ static void ldisc_tx_wakeup(struct tty_struct *tty);
 static inline void update_tty_status(struct ser_device *ser)
 {
        ser->tty_status =
-               ser->tty->stopped << 5 |
-               ser->tty->flow_stopped << 3 |
-               ser->tty->packet << 2;
+               ser->tty->flow.stopped << 5 |
+               ser->tty->flow.tco_stopped << 3 |
+               ser->tty->ctrl.packet << 2;
 }
 static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty)
 {
@@ -159,7 +159,7 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)
 #endif
 
 static void ldisc_receive(struct tty_struct *tty, const u8 *data,
-                       char *flags, int count)
+                       const char *flags, int count)
 {
        struct sk_buff *skb = NULL;
        struct ser_device *ser;
@@ -379,6 +379,7 @@ static void ldisc_close(struct tty_struct *tty)
 /* The line discipline structure. */
 static struct tty_ldisc_ops caif_ldisc = {
        .owner =        THIS_MODULE,
+       .num =          N_CAIF,
        .name =         "n_caif",
        .open =         ldisc_open,
        .close =        ldisc_close,
@@ -428,7 +429,7 @@ static int __init caif_ser_init(void)
 {
        int ret;
 
-       ret = tty_register_ldisc(N_CAIF, &caif_ldisc);
+       ret = tty_register_ldisc(&caif_ldisc);
        if (ret < 0)
                pr_err("cannot register CAIF ldisc=%d err=%d\n", N_CAIF, ret);
 
@@ -443,7 +444,7 @@ static void __exit caif_ser_exit(void)
        spin_unlock(&ser_lock);
        ser_release(NULL);
        cancel_work_sync(&ser_release_work);
-       tty_unregister_ldisc(N_CAIF);
+       tty_unregister_ldisc(&caif_ldisc);
        debugfs_remove_recursive(debugfsdir);
 }
 
index 31ba666..d42ec7d 100644 (file)
@@ -467,7 +467,8 @@ static void slc_setup(struct net_device *dev)
  */
 
 static void slcan_receive_buf(struct tty_struct *tty,
-                             const unsigned char *cp, char *fp, int count)
+                             const unsigned char *cp, const char *fp,
+                             int count)
 {
        struct slcan *sl = (struct slcan *) tty->disc_data;
 
@@ -697,6 +698,7 @@ static int slcan_ioctl(struct tty_struct *tty, struct file *file,
 
 static struct tty_ldisc_ops slc_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_SLCAN,
        .name           = "slcan",
        .open           = slcan_open,
        .close          = slcan_close,
@@ -721,7 +723,7 @@ static int __init slcan_init(void)
                return -ENOMEM;
 
        /* Fill in our line protocol discipline, and register it */
-       status = tty_register_ldisc(N_SLCAN, &slc_ldisc);
+       status = tty_register_ldisc(&slc_ldisc);
        if (status)  {
                printk(KERN_ERR "slcan: can't register line discipline\n");
                kfree(slcan_devs);
@@ -782,9 +784,7 @@ static void __exit slcan_exit(void)
        kfree(slcan_devs);
        slcan_devs = NULL;
 
-       i = tty_unregister_ldisc(N_SLCAN);
-       if (i)
-               printk(KERN_ERR "slcan: can't unregister ldisc (err %d)\n", i);
+       tty_unregister_ldisc(&slc_ldisc);
 }
 
 module_init(slcan_init);
index 80f4194..686c38c 100644 (file)
@@ -428,7 +428,7 @@ out:
  * and sent on to some IP layer for further processing.
  */
 static void sixpack_receive_buf(struct tty_struct *tty,
-       const unsigned char *cp, char *fp, int count)
+       const unsigned char *cp, const char *fp, int count)
 {
        struct sixpack *sp;
        int count1;
@@ -744,6 +744,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
 
 static struct tty_ldisc_ops sp_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_6PACK,
        .name           = "6pack",
        .open           = sixpack_open,
        .close          = sixpack_close,
@@ -766,21 +767,16 @@ static int __init sixpack_init_driver(void)
        printk(msg_banner);
 
        /* Register the provided line protocol discipline */
-       if ((status = tty_register_ldisc(N_6PACK, &sp_ldisc)) != 0)
+       status = tty_register_ldisc(&sp_ldisc);
+       if (status)
                printk(msg_regfail, status);
 
        return status;
 }
 
-static const char msg_unregfail[] = KERN_ERR \
-       "6pack: can't unregister line discipline (err = %d)\n";
-
 static void __exit sixpack_exit_driver(void)
 {
-       int ret;
-
-       if ((ret = tty_unregister_ldisc(N_6PACK)))
-               printk(msg_unregfail, ret);
+       tty_unregister_ldisc(&sp_ldisc);
 }
 
 /* encode an AX.25 packet into 6pack */
index 6515422..e3294a0 100644 (file)
@@ -871,7 +871,7 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
  * and sent on to the AX.25 layer for further processing.
  */
 static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-       char *fp, int count)
+       const char *fp, int count)
 {
        struct mkiss *ax = mkiss_get(tty);
 
@@ -933,6 +933,7 @@ out:
 
 static struct tty_ldisc_ops ax_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_AX25,
        .name           = "mkiss",
        .open           = mkiss_open,
        .close          = mkiss_close,
@@ -952,22 +953,16 @@ static int __init mkiss_init_driver(void)
 
        printk(banner);
 
-       status = tty_register_ldisc(N_AX25, &ax_ldisc);
+       status = tty_register_ldisc(&ax_ldisc);
        if (status != 0)
                printk(msg_regfail, status);
 
        return status;
 }
 
-static const char msg_unregfail[] = KERN_ERR \
-       "mkiss: can't unregister line discipline (err = %d)\n";
-
 static void __exit mkiss_exit_driver(void)
 {
-       int ret;
-
-       if ((ret = tty_unregister_ldisc(N_AX25)))
-               printk(msg_unregfail, ret);
+       tty_unregister_ldisc(&ax_ldisc);
 }
 
 MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>");
index 8b41aa3..29a93d6 100644 (file)
@@ -98,7 +98,7 @@ static int ppp_async_send(struct ppp_channel *chan, struct sk_buff *skb);
 static int ppp_async_push(struct asyncppp *ap);
 static void ppp_async_flush_output(struct asyncppp *ap);
 static void ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
-                           char *flags, int count);
+                           const char *flags, int count);
 static int ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd,
                           unsigned long arg);
 static void ppp_async_process(struct tasklet_struct *t);
@@ -340,7 +340,7 @@ ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
 /* May sleep, don't call from interrupt level or with interrupts disabled */
 static void
 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
-                 char *cflags, int count)
+                 const char *cflags, int count)
 {
        struct asyncppp *ap = ap_get(tty);
        unsigned long flags;
@@ -372,6 +372,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty)
 
 static struct tty_ldisc_ops ppp_ldisc = {
        .owner  = THIS_MODULE,
+       .num    = N_PPP,
        .name   = "ppp",
        .open   = ppp_asynctty_open,
        .close  = ppp_asynctty_close,
@@ -389,7 +390,7 @@ ppp_async_init(void)
 {
        int err;
 
-       err = tty_register_ldisc(N_PPP, &ppp_ldisc);
+       err = tty_register_ldisc(&ppp_ldisc);
        if (err != 0)
                printk(KERN_ERR "PPP_async: error %d registering line disc.\n",
                       err);
@@ -829,7 +830,7 @@ process_input_packet(struct asyncppp *ap)
 
 static void
 ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
-               char *flags, int count)
+               const char *flags, int count)
 {
        struct sk_buff *skb;
        int c, i, j, n, s, f;
@@ -1015,8 +1016,7 @@ static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
 
 static void __exit ppp_async_cleanup(void)
 {
-       if (tty_unregister_ldisc(N_PPP) != 0)
-               printk(KERN_ERR "failed to unregister PPP line discipline\n");
+       tty_unregister_ldisc(&ppp_ldisc);
 }
 
 module_init(ppp_async_init);
index 576b6a9..af3e048 100644 (file)
@@ -94,7 +94,7 @@ static void ppp_sync_process(struct tasklet_struct *t);
 static int ppp_sync_push(struct syncppp *ap);
 static void ppp_sync_flush_output(struct syncppp *ap);
 static void ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
-                          char *flags, int count);
+                          const char *flags, int count);
 
 static const struct ppp_channel_ops sync_ops = {
        .start_xmit = ppp_sync_send,
@@ -333,7 +333,7 @@ ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
 /* May sleep, don't call from interrupt level or with interrupts disabled */
 static void
 ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
-                 char *cflags, int count)
+                 const char *cflags, int count)
 {
        struct syncppp *ap = sp_get(tty);
        unsigned long flags;
@@ -365,6 +365,7 @@ ppp_sync_wakeup(struct tty_struct *tty)
 
 static struct tty_ldisc_ops ppp_sync_ldisc = {
        .owner  = THIS_MODULE,
+       .num    = N_SYNC_PPP,
        .name   = "pppsync",
        .open   = ppp_sync_open,
        .close  = ppp_sync_close,
@@ -382,7 +383,7 @@ ppp_sync_init(void)
 {
        int err;
 
-       err = tty_register_ldisc(N_SYNC_PPP, &ppp_sync_ldisc);
+       err = tty_register_ldisc(&ppp_sync_ldisc);
        if (err != 0)
                printk(KERN_ERR "PPP_sync: error %d registering line disc.\n",
                       err);
@@ -665,7 +666,7 @@ ppp_sync_flush_output(struct syncppp *ap)
  */
 static void
 ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
-               char *flags, int count)
+               const char *flags, int count)
 {
        struct sk_buff *skb;
        unsigned char *p;
@@ -726,8 +727,7 @@ err:
 static void __exit
 ppp_sync_cleanup(void)
 {
-       if (tty_unregister_ldisc(N_SYNC_PPP) != 0)
-               printk(KERN_ERR "failed to unregister Sync PPP line discipline\n");
+       tty_unregister_ldisc(&ppp_sync_ldisc);
 }
 
 module_init(ppp_sync_init);
index 1ab124e..dc84cb8 100644 (file)
@@ -685,7 +685,7 @@ static void sl_setup(struct net_device *dev)
  */
 
 static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                                                       char *fp, int count)
+               const char *fp, int count)
 {
        struct slip *sl = tty->disc_data;
 
@@ -1263,6 +1263,7 @@ static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
 static struct tty_ldisc_ops sl_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_SLIP,
        .name           = "slip",
        .open           = slip_open,
        .close          = slip_close,
@@ -1298,7 +1299,7 @@ static int __init slip_init(void)
                return -ENOMEM;
 
        /* Fill in our line protocol discipline, and register it */
-       status = tty_register_ldisc(N_SLIP, &sl_ldisc);
+       status = tty_register_ldisc(&sl_ldisc);
        if (status != 0) {
                printk(KERN_ERR "SLIP: can't register line discipline (err = %d)\n", status);
                kfree(slip_devs);
@@ -1359,9 +1360,7 @@ static void __exit slip_exit(void)
        kfree(slip_devs);
        slip_devs = NULL;
 
-       i = tty_unregister_ldisc(N_SLIP);
-       if (i != 0)
-               printk(KERN_ERR "SLIP: can't unregister line discipline (err = %d)\n", i);
+       tty_unregister_ldisc(&sl_ldisc);
 }
 
 module_init(slip_init);
index 5c779cc..f59e497 100644 (file)
@@ -1357,10 +1357,10 @@ out:
 }
 
 /* how much room is there for writing */
-static int hso_serial_write_room(struct tty_struct *tty)
+static unsigned int hso_serial_write_room(struct tty_struct *tty)
 {
        struct hso_serial *serial = tty->driver_data;
-       int room;
+       unsigned int room;
        unsigned long flags;
 
        spin_lock_irqsave(&serial->serial_lock, flags);
@@ -1404,11 +1404,11 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
 }
 
 /* how many characters in the buffer */
-static int hso_serial_chars_in_buffer(struct tty_struct *tty)
+static unsigned int hso_serial_chars_in_buffer(struct tty_struct *tty)
 {
        struct hso_serial *serial = tty->driver_data;
-       int chars;
        unsigned long flags;
+       unsigned int chars;
 
        /* sanity check */
        if (serial == NULL)
index bf26cc5..d73c4c2 100644 (file)
@@ -112,12 +112,13 @@ static int __init pps_tty_init(void)
 
        /* Init PPS_TTY data */
        pps_ldisc_ops.owner = THIS_MODULE;
+       pps_ldisc_ops.num = N_PPS;
        pps_ldisc_ops.name = "pps_tty";
        pps_ldisc_ops.dcd_change = pps_tty_dcd_change;
        pps_ldisc_ops.open = pps_tty_open;
        pps_ldisc_ops.close = pps_tty_close;
 
-       err = tty_register_ldisc(N_PPS, &pps_ldisc_ops);
+       err = tty_register_ldisc(&pps_ldisc_ops);
        if (err)
                pr_err("can't register PPS line discipline\n");
        else
@@ -128,13 +129,7 @@ static int __init pps_tty_init(void)
 
 static void __exit pps_tty_cleanup(void)
 {
-       int err;
-
-       err = tty_unregister_ldisc(N_PPS);
-       if (err)
-               pr_err("can't unregister PPS line discipline\n");
-       else
-               pr_info("PPS line discipline removed\n");
+       tty_unregister_ldisc(&pps_ldisc_ops);
 }
 
 module_init(pps_tty_init);
index 1fd5bca..8821927 100644 (file)
@@ -924,7 +924,7 @@ static void tty3215_close(struct tty_struct *tty, struct file * filp)
 /*
  * Returns the amount of free space in the output buffer.
  */
-static int tty3215_write_room(struct tty_struct *tty)
+static unsigned int tty3215_write_room(struct tty_struct *tty)
 {
        struct raw3215_info *raw = tty->driver_data;
 
@@ -980,7 +980,7 @@ static void tty3215_flush_chars(struct tty_struct *tty)
 /*
  * Returns the number of characters in the output buffer
  */
-static int tty3215_chars_in_buffer(struct tty_struct *tty)
+static unsigned int tty3215_chars_in_buffer(struct tty_struct *tty)
 {
        struct raw3215_info *raw = tty->driver_data;
 
index d6c84e3..5a1bf6e 100644 (file)
@@ -325,10 +325,10 @@ sclp_buffer_space(struct sclp_buffer *buffer)
 /*
  * Return number of characters in buffer
  */
-int
+unsigned int
 sclp_chars_in_buffer(struct sclp_buffer *buffer)
 {
-       int count;
+       unsigned int count;
 
        count = buffer->char_sum;
        if (buffer->current_line != NULL)
index 93d706e..b4506be 100644 (file)
@@ -86,7 +86,7 @@ void *sclp_unmake_buffer(struct sclp_buffer *);
 int sclp_buffer_space(struct sclp_buffer *);
 int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int);
 int sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int));
-int sclp_chars_in_buffer(struct sclp_buffer *);
+unsigned int sclp_chars_in_buffer(struct sclp_buffer *);
 
 #ifdef CONFIG_SCLP_CONSOLE
 void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event);
index 4456ceb..162127f 100644 (file)
@@ -86,12 +86,12 @@ sclp_tty_close(struct tty_struct *tty, struct file *filp)
  * a string of newlines. Every newline creates a new message which
  * needs 82 bytes.
  */
-static int
+static unsigned int
 sclp_tty_write_room (struct tty_struct *tty)
 {
        unsigned long flags;
        struct list_head *l;
-       int count;
+       unsigned int count;
 
        spin_lock_irqsave(&sclp_tty_lock, flags);
        count = 0;
@@ -280,16 +280,15 @@ sclp_tty_flush_chars(struct tty_struct *tty)
  * characters in the write buffer (will not be written as long as there is a
  * final line feed missing).
  */
-static int
+static unsigned int
 sclp_tty_chars_in_buffer(struct tty_struct *tty)
 {
        unsigned long flags;
        struct list_head *l;
        struct sclp_buffer *t;
-       int count;
+       unsigned int count = 0;
 
        spin_lock_irqsave(&sclp_tty_lock, flags);
-       count = 0;
        if (sclp_ttybuf != NULL)
                count = sclp_chars_in_buffer(sclp_ttybuf);
        list_for_each(l, &sclp_tty_outqueue) {
index 7f4445b..24eb3a0 100644 (file)
@@ -609,12 +609,12 @@ sclp_vt220_flush_chars(struct tty_struct *tty)
  * to change as output buffers get emptied, or if the output flow
  * control is acted.
  */
-static int
+static unsigned int
 sclp_vt220_write_room(struct tty_struct *tty)
 {
        unsigned long flags;
        struct list_head *l;
-       int count;
+       unsigned int count;
 
        spin_lock_irqsave(&sclp_vt220_lock, flags);
        count = 0;
@@ -629,16 +629,15 @@ sclp_vt220_write_room(struct tty_struct *tty)
 /*
  * Return number of buffered chars.
  */
-static int
+static unsigned int
 sclp_vt220_chars_in_buffer(struct tty_struct *tty)
 {
        unsigned long flags;
        struct list_head *l;
        struct sclp_vt220_request *r;
-       int count;
+       unsigned int count = 0;
 
        spin_lock_irqsave(&sclp_vt220_lock, flags);
-       count = 0;
        if (sclp_vt220_current_request != NULL)
                count = sclp_vt220_chars_stored(sclp_vt220_current_request);
        list_for_each(l, &sclp_vt220_outqueue) {
index 307a80f..adc3384 100644 (file)
@@ -1071,7 +1071,7 @@ static void tty3270_cleanup(struct tty_struct *tty)
 /*
  * We always have room.
  */
-static int
+static unsigned int
 tty3270_write_room(struct tty_struct *tty)
 {
        return INT_MAX;
@@ -1640,7 +1640,7 @@ tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty,
        int i_msg, i;
 
        spin_lock_bh(&tp->view.lock);
-       for (i_msg = 0; !tty->stopped && i_msg < count; i_msg++) {
+       for (i_msg = 0; !tty->flow.stopped && i_msg < count; i_msg++) {
                if (tp->esc_state != 0) {
                        /* Continue escape sequence. */
                        tty3270_escape_sequence(tp, buf[i_msg]);
@@ -1756,22 +1756,6 @@ tty3270_flush_chars(struct tty_struct *tty)
        }
 }
 
-/*
- * Returns the number of characters in the output buffer. This is
- * used in tty_wait_until_sent to wait until all characters have
- * appeared on the screen.
- */
-static int
-tty3270_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0;
-}
-
-static void
-tty3270_flush_buffer(struct tty_struct *tty)
-{
-}
-
 /*
  * Check for visible/invisible input switches
  */
@@ -1892,8 +1876,6 @@ static const struct tty_operations tty3270_ops = {
        .put_char = tty3270_put_char,
        .flush_chars = tty3270_flush_chars,
        .write_room = tty3270_write_room,
-       .chars_in_buffer = tty3270_chars_in_buffer,
-       .flush_buffer = tty3270_flush_buffer,
        .throttle = tty3270_throttle,
        .unthrottle = tty3270_unthrottle,
        .hangup = tty3270_hangup,
index 1ee6382..d2b286e 100644 (file)
@@ -722,7 +722,7 @@ static int fwtty_tx(struct fwtty_port *port, bool drain)
 
        /* try to write as many dma transactions out as possible */
        n = -EAGAIN;
-       while (!tty->stopped && !tty->hw_stopped &&
+       while (!tty->flow.stopped && !tty->hw_stopped &&
               !test_bit(STOP_TX, &port->flags)) {
                txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC);
                if (!txn) {
@@ -1113,30 +1113,30 @@ static int fwtty_write(struct tty_struct *tty, const unsigned char *buf, int c)
        return (n < 0) ? 0 : n;
 }
 
-static int fwtty_write_room(struct tty_struct *tty)
+static unsigned int fwtty_write_room(struct tty_struct *tty)
 {
        struct fwtty_port *port = tty->driver_data;
-       int n;
+       unsigned int n;
 
        spin_lock_bh(&port->lock);
        n = dma_fifo_avail(&port->tx_fifo);
        spin_unlock_bh(&port->lock);
 
-       fwtty_dbg(port, "%d\n", n);
+       fwtty_dbg(port, "%u\n", n);
 
        return n;
 }
 
-static int fwtty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int fwtty_chars_in_buffer(struct tty_struct *tty)
 {
        struct fwtty_port *port = tty->driver_data;
-       int n;
+       unsigned int n;
 
        spin_lock_bh(&port->lock);
        n = dma_fifo_level(&port->tx_fifo);
        spin_unlock_bh(&port->lock);
 
-       fwtty_dbg(port, "%d\n", n);
+       fwtty_dbg(port, "%u\n", n);
 
        return n;
 }
index 0ccc8c2..279de2c 100644 (file)
@@ -183,7 +183,7 @@ static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf,
        return len;
 }
 
-static int gdm_tty_write_room(struct tty_struct *tty)
+static unsigned int gdm_tty_write_room(struct tty_struct *tty)
 {
        struct gdm *gdm = tty->driver_data;
 
index b1e63f7..ccfaa0f 100644 (file)
@@ -440,7 +440,7 @@ static int gb_tty_write(struct tty_struct *tty, const unsigned char *buf,
        return count;
 }
 
-static int gb_tty_write_room(struct tty_struct *tty)
+static unsigned int gb_tty_write_room(struct tty_struct *tty)
 {
        struct gb_tty *gb_tty = tty->driver_data;
        unsigned long flags;
@@ -457,11 +457,11 @@ static int gb_tty_write_room(struct tty_struct *tty)
        return room;
 }
 
-static int gb_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int gb_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct gb_tty *gb_tty = tty->driver_data;
        unsigned long flags;
-       int chars;
+       unsigned int chars;
 
        spin_lock_irqsave(&gb_tty->write_lock, flags);
        chars = kfifo_len(&gb_tty->write_fifo);
index c7054f5..a2bd75f 100644 (file)
@@ -9,7 +9,6 @@ obj-$(CONFIG_AUDIT)             += tty_audit.o
 obj-$(CONFIG_MAGIC_SYSRQ)      += sysrq.o
 obj-$(CONFIG_N_HDLC)           += n_hdlc.o
 obj-$(CONFIG_N_GSM)            += n_gsm.o
-obj-$(CONFIG_R3964)            += n_r3964.o
 
 obj-y                          += vt/
 obj-$(CONFIG_HVC_DRIVER)       += hvc/
index ca48ce5..5ec19c4 100644 (file)
@@ -148,7 +148,7 @@ static __inline__ void rtsdtr_ctrl(int bits)
  * ------------------------------------------------------------
  * rs_stop() and rs_start()
  *
- * This routines are called before setting or resetting tty->stopped.
+ * This routines are called before setting or resetting tty->flow.stopped.
  * They enable or disable transmitter interrupts, as necessary.
  * ------------------------------------------------------------
  */
@@ -309,7 +309,7 @@ static void transmit_chars(struct serial_state *info)
                return;
        }
        if (info->xmit.head == info->xmit.tail
-           || info->tport.tty->stopped
+           || info->tport.tty->flow.stopped
            || info->tport.tty->hw_stopped) {
                info->IER &= ~UART_IER_THRI;
                custom.intena = IF_TBE;
@@ -768,7 +768,7 @@ static void rs_flush_chars(struct tty_struct *tty)
        unsigned long flags;
 
        if (info->xmit.head == info->xmit.tail
-           || tty->stopped
+           || tty->flow.stopped
            || tty->hw_stopped
            || !info->xmit.buf)
                return;
@@ -812,7 +812,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
        local_irq_restore(flags);
 
        if (info->xmit.head != info->xmit.tail
-           && !tty->stopped
+           && !tty->flow.stopped
            && !tty->hw_stopped
            && !(info->IER & UART_IER_THRI)) {
                info->IER |= UART_IER_THRI;
@@ -827,14 +827,14 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
        return ret;
 }
 
-static int rs_write_room(struct tty_struct *tty)
+static unsigned int rs_write_room(struct tty_struct *tty)
 {
        struct serial_state *info = tty->driver_data;
 
        return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
 }
 
-static int rs_chars_in_buffer(struct tty_struct *tty)
+static unsigned int rs_chars_in_buffer(struct tty_struct *tty)
 {
        struct serial_state *info = tty->driver_data;
 
index 3c6dd06..445e5ff 100644 (file)
@@ -536,11 +536,11 @@ static void ehv_bc_tty_close(struct tty_struct *ttys, struct file *filp)
  * how much write room the driver can guarantee will be sent OR BUFFERED.  This
  * driver MUST honor the return value.
  */
-static int ehv_bc_tty_write_room(struct tty_struct *ttys)
+static unsigned int ehv_bc_tty_write_room(struct tty_struct *ttys)
 {
        struct ehv_bc_data *bc = ttys->driver_data;
        unsigned long flags;
-       int count;
+       unsigned int count;
 
        spin_lock_irqsave(&bc->lock, flags);
        count = CIRC_SPACE(bc->head, bc->tail, BUF_SIZE);
index cd23a4b..ccb683a 100644 (file)
@@ -193,12 +193,12 @@ static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf,
        return count;
 }
 
-static int goldfish_tty_write_room(struct tty_struct *tty)
+static unsigned int goldfish_tty_write_room(struct tty_struct *tty)
 {
        return 0x10000;
 }
 
-static int goldfish_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int goldfish_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct goldfish_tty *qtty = &goldfish_ttys[tty->index];
        void __iomem *base = qtty->base;
index cdcc64e..5bb8c4e 100644 (file)
@@ -292,7 +292,7 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
        if (vtermnos[index] != -1)
                return -1;
 
-       /* make sure no no tty has been registered in this index */
+       /* make sure no tty has been registered in this index */
        hp = hvc_get_by_index(index);
        if (hp) {
                tty_port_put(&hp->port);
@@ -586,7 +586,7 @@ static void hvc_set_winsz(struct work_struct *work)
  * how much write room the driver can guarantee will be sent OR BUFFERED.  This
  * driver MUST honor the return value.
  */
-static int hvc_write_room(struct tty_struct *tty)
+static unsigned int hvc_write_room(struct tty_struct *tty)
 {
        struct hvc_struct *hp = tty->driver_data;
 
@@ -596,7 +596,7 @@ static int hvc_write_room(struct tty_struct *tty)
        return hp->outbuf_size - hp->n_outbuf;
 }
 
-static int hvc_chars_in_buffer(struct tty_struct *tty)
+static unsigned int hvc_chars_in_buffer(struct tty_struct *tty)
 {
        struct hvc_struct *hp = tty->driver_data;
 
@@ -620,7 +620,7 @@ static u32 timeout = MIN_TIMEOUT;
 /*
  * Maximum number of bytes to get from the console driver if hvc_poll is
  * called from driver (and can't sleep). Any more than this and we break
- * and start polling with khvcd. This value was derived from from an OpenBMC
+ * and start polling with khvcd. This value was derived from an OpenBMC
  * console with the OPAL driver that results in about 0.25ms interrupts off
  * latency.
  */
index 2af1e57..3bd03ae 100644 (file)
@@ -438,8 +438,6 @@ static void hvc_iucv_sndbuf_work(struct work_struct *work)
        struct hvc_iucv_private *priv;
 
        priv = container_of(work, struct hvc_iucv_private, sndbuf_work.work);
-       if (!priv)
-               return;
 
        spin_lock_bh(&priv->lock);
        hvc_iucv_send(priv);
index 197988c..fe5e6b4 100644 (file)
@@ -1376,7 +1376,7 @@ static int hvcs_write(struct tty_struct *tty,
  * absolutely WILL BUFFER if we can't send it.  This driver MUST honor the
  * return value, hence the reason for hvcs_struct buffering.
  */
-static int hvcs_write_room(struct tty_struct *tty)
+static unsigned int hvcs_write_room(struct tty_struct *tty)
 {
        struct hvcs_struct *hvcsd = tty->driver_data;
 
@@ -1386,7 +1386,7 @@ static int hvcs_write_room(struct tty_struct *tty)
        return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
 }
 
-static int hvcs_chars_in_buffer(struct tty_struct *tty)
+static unsigned int hvcs_chars_in_buffer(struct tty_struct *tty)
 {
        struct hvcs_struct *hvcsd = tty->driver_data;
 
index e8c58f9..bfc1527 100644 (file)
@@ -890,14 +890,14 @@ out:
        spin_unlock_irqrestore(&hp->lock, flags);
 }
 
-static int hvsi_write_room(struct tty_struct *tty)
+static unsigned int hvsi_write_room(struct tty_struct *tty)
 {
        struct hvsi_struct *hp = tty->driver_data;
 
        return N_OUTBUF - hp->n_outbuf;
 }
 
-static int hvsi_chars_in_buffer(struct tty_struct *tty)
+static unsigned int hvsi_chars_in_buffer(struct tty_struct *tty)
 {
        struct hvsi_struct *hp = tty->driver_data;
 
@@ -929,7 +929,7 @@ static int hvsi_write(struct tty_struct *tty,
         * will see there is no room in outbuf and return.
         */
        while ((count > 0) && (hvsi_write_room(tty) > 0)) {
-               int chunksize = min(count, hvsi_write_room(tty));
+               int chunksize = min_t(int, count, hvsi_write_room(tty));
 
                BUG_ON(hp->n_outbuf < 0);
                memcpy(hp->outbuf + hp->n_outbuf, source, chunksize);
index 99bb2f1..e01ca68 100644 (file)
@@ -228,7 +228,7 @@ static int ipw_write(struct tty_struct *linux_tty,
        return count;
 }
 
-static int ipw_write_room(struct tty_struct *linux_tty)
+static unsigned int ipw_write_room(struct tty_struct *linux_tty)
 {
        struct ipw_tty *tty = linux_tty->driver_data;
        int room;
@@ -270,7 +270,7 @@ static int ipwireless_set_serial_info(struct tty_struct *linux_tty,
        return 0;       /* Keeps the PCMCIA scripts happy. */
 }
 
-static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
+static unsigned int ipw_chars_in_buffer(struct tty_struct *linux_tty)
 {
        struct ipw_tty *tty = linux_tty->driver_data;
 
index a8e19b4..3b5915b 100644 (file)
@@ -840,11 +840,11 @@ static int mips_ejtag_fdc_tty_write(struct tty_struct *tty,
        return total;
 }
 
-static int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty)
+static unsigned int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty)
 {
        struct mips_ejtag_fdc_tty_port *dport = tty->driver_data;
        struct mips_ejtag_fdc_tty *priv = dport->driver;
-       int room;
+       unsigned int room;
 
        /* Report the space in the xmit buffer */
        spin_lock(&dport->xmit_lock);
@@ -854,10 +854,10 @@ static int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty)
        return room;
 }
 
-static int mips_ejtag_fdc_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int mips_ejtag_fdc_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct mips_ejtag_fdc_tty_port *dport = tty->driver_data;
-       int chars;
+       unsigned int chars;
 
        /* Report the number of bytes in the xmit buffer */
        spin_lock(&dport->xmit_lock);
index 4d4f15b..64b1817 100644 (file)
@@ -188,9 +188,9 @@ module_param(ttymajor, int, 0);
 static int moxa_open(struct tty_struct *, struct file *);
 static void moxa_close(struct tty_struct *, struct file *);
 static int moxa_write(struct tty_struct *, const unsigned char *, int);
-static int moxa_write_room(struct tty_struct *);
+static unsigned int moxa_write_room(struct tty_struct *);
 static void moxa_flush_buffer(struct tty_struct *);
-static int moxa_chars_in_buffer(struct tty_struct *);
+static unsigned int moxa_chars_in_buffer(struct tty_struct *);
 static void moxa_set_termios(struct tty_struct *, struct ktermios *);
 static void moxa_stop(struct tty_struct *);
 static void moxa_start(struct tty_struct *);
@@ -216,9 +216,9 @@ static int MoxaPortLineStatus(struct moxa_port *);
 static void MoxaPortFlushData(struct moxa_port *, int);
 static int MoxaPortWriteData(struct tty_struct *, const unsigned char *, int);
 static int MoxaPortReadData(struct moxa_port *);
-static int MoxaPortTxQueue(struct moxa_port *);
+static unsigned int MoxaPortTxQueue(struct moxa_port *);
 static int MoxaPortRxQueue(struct moxa_port *);
-static int MoxaPortTxFree(struct moxa_port *);
+static unsigned int MoxaPortTxFree(struct moxa_port *);
 static void MoxaPortTxDisable(struct moxa_port *);
 static void MoxaPortTxEnable(struct moxa_port *);
 static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *);
@@ -1217,11 +1217,11 @@ static int moxa_write(struct tty_struct *tty,
        return len;
 }
 
-static int moxa_write_room(struct tty_struct *tty)
+static unsigned int moxa_write_room(struct tty_struct *tty)
 {
        struct moxa_port *ch;
 
-       if (tty->stopped)
+       if (tty->flow.stopped)
                return 0;
        ch = tty->driver_data;
        if (ch == NULL)
@@ -1239,10 +1239,10 @@ static void moxa_flush_buffer(struct tty_struct *tty)
        tty_wakeup(tty);
 }
 
-static int moxa_chars_in_buffer(struct tty_struct *tty)
+static unsigned int moxa_chars_in_buffer(struct tty_struct *tty)
 {
        struct moxa_port *ch = tty->driver_data;
-       int chars;
+       unsigned int chars;
 
        chars = MoxaPortTxQueue(ch);
        if (chars)
@@ -1374,7 +1374,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
                        clear_bit(EMPTYWAIT, &p->statusflags);
                        tty_wakeup(tty);
                }
-               if (test_bit(LOWWAIT, &p->statusflags) && !tty->stopped &&
+               if (test_bit(LOWWAIT, &p->statusflags) && !tty->flow.stopped &&
                                MoxaPortTxQueue(p) <= WAKEUP_CHARS) {
                        clear_bit(LOWWAIT, &p->statusflags);
                        tty_wakeup(tty);
@@ -1981,7 +1981,7 @@ static int MoxaPortReadData(struct moxa_port *port)
 }
 
 
-static int MoxaPortTxQueue(struct moxa_port *port)
+static unsigned int MoxaPortTxQueue(struct moxa_port *port)
 {
        void __iomem *ofsAddr = port->tableAddr;
        u16 rptr, wptr, mask;
@@ -1992,7 +1992,7 @@ static int MoxaPortTxQueue(struct moxa_port *port)
        return (wptr - rptr) & mask;
 }
 
-static int MoxaPortTxFree(struct moxa_port *port)
+static unsigned int MoxaPortTxFree(struct moxa_port *port)
 {
        void __iomem *ofsAddr = port->tableAddr;
        u16 rptr, wptr, mask;
index 16a852e..a74e614 100644 (file)
@@ -1118,7 +1118,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
                total += c;
        }
 
-       if (info->xmit_cnt && !tty->stopped) {
+       if (info->xmit_cnt && !tty->flow.stopped) {
                if (!tty->hw_stopped ||
                                (info->type == PORT_16550A) ||
                                (info->board->chip_flag)) {
@@ -1149,7 +1149,7 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
        info->xmit_head &= SERIAL_XMIT_SIZE - 1;
        info->xmit_cnt++;
        spin_unlock_irqrestore(&info->slock, flags);
-       if (!tty->stopped) {
+       if (!tty->flow.stopped) {
                if (!tty->hw_stopped ||
                                (info->type == PORT_16550A) ||
                                info->board->chip_flag) {
@@ -1169,7 +1169,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
        struct mxser_port *info = tty->driver_data;
        unsigned long flags;
 
-       if (info->xmit_cnt <= 0 || tty->stopped || !info->port.xmit_buf ||
+       if (info->xmit_cnt <= 0 || tty->flow.stopped || !info->port.xmit_buf ||
                        (tty->hw_stopped && info->type != PORT_16550A &&
                         !info->board->chip_flag))
                return;
@@ -1183,7 +1183,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
        spin_unlock_irqrestore(&info->slock, flags);
 }
 
-static int mxser_write_room(struct tty_struct *tty)
+static unsigned int mxser_write_room(struct tty_struct *tty)
 {
        struct mxser_port *info = tty->driver_data;
        int ret;
@@ -1192,7 +1192,7 @@ static int mxser_write_room(struct tty_struct *tty)
        return ret < 0 ? 0 : ret;
 }
 
-static int mxser_chars_in_buffer(struct tty_struct *tty)
+static unsigned int mxser_chars_in_buffer(struct tty_struct *tty)
 {
        struct mxser_port *info = tty->driver_data;
        return info->xmit_cnt;
@@ -1917,7 +1917,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
 /*
  * mxser_stop() and mxser_start()
  *
- * This routines are called before setting or resetting tty->stopped.
+ * This routines are called before setting or resetting tty->flow.stopped.
  * They enable or disable transmitter interrupts, as necessary.
  */
 static void mxser_stop(struct tty_struct *tty)
@@ -1963,7 +1963,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
 
        /* Handle sw stopped */
        if ((old_termios->c_iflag & IXON) && !I_IXON(tty)) {
-               tty->stopped = 0;
+               tty->flow.stopped = 0;
 
                if (info->board->chip_flag) {
                        spin_lock_irqsave(&info->slock, flags);
@@ -2175,7 +2175,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
        if (port->port.xmit_buf == NULL)
                return;
 
-       if (port->xmit_cnt <= 0 || tty->stopped ||
+       if (port->xmit_cnt <= 0 || tty->flow.stopped ||
                        (tty->hw_stopped &&
                        (port->type != PORT_16550A) &&
                        (!port->board->chip_flag))) {
index 5fea02c..e907b7a 100644 (file)
@@ -512,7 +512,7 @@ static void gsm_print_packet(const char *hdr, int addr, int cr,
  */
 
 /**
- *     gsm_stuff_packet        -       bytestuff a packet
+ *     gsm_stuff_frame -       bytestuff a packet
  *     @input: input buffer
  *     @output: output buffer
  *     @len: length of input
@@ -1594,7 +1594,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
 }
 
 /**
- *     gsm_dlci_control        -       data arrived on control channel
+ *     gsm_dlci_command        -       data arrived on control channel
  *     @dlci: channel
  *     @data: block of bytes received
  *     @len: length of received block
@@ -2424,7 +2424,7 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
 }
 
 static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                             char *fp, int count)
+                             const char *fp, int count)
 {
        struct gsm_mux *gsm = tty->disc_data;
        char flags = TTY_NORMAL;
@@ -2557,6 +2557,8 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
  *     @file: file object
  *     @buf: userspace buffer pointer
  *     @nr: size of I/O
+ *     @cookie: unused
+ *     @offset: unused
  *
  *     Perform reads for the line discipline. We are guaranteed that the
  *     line discipline will not be closed under us but we may get multiple
@@ -2857,6 +2859,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
 /* Line discipline for real tty */
 static struct tty_ldisc_ops tty_ldisc_packet = {
        .owner           = THIS_MODULE,
+       .num             = N_GSM0710,
        .name            = "n_gsm",
        .open            = gsmld_open,
        .close           = gsmld_close,
@@ -3055,7 +3058,7 @@ static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
        return sent;
 }
 
-static int gsmtty_write_room(struct tty_struct *tty)
+static unsigned int gsmtty_write_room(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
        if (dlci->state == DLCI_CLOSED)
@@ -3063,7 +3066,7 @@ static int gsmtty_write_room(struct tty_struct *tty)
        return TX_SIZE - kfifo_len(&dlci->fifo);
 }
 
-static int gsmtty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int gsmtty_chars_in_buffer(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
        if (dlci->state == DLCI_CLOSED)
@@ -3242,7 +3245,7 @@ static const struct tty_operations gsmtty_ops = {
 static int __init gsm_init(void)
 {
        /* Fill in our line protocol discipline, and register it */
-       int status = tty_register_ldisc(N_GSM0710, &tty_ldisc_packet);
+       int status = tty_register_ldisc(&tty_ldisc_packet);
        if (status != 0) {
                pr_err("n_gsm: can't register line discipline (err = %d)\n",
                                                                status);
@@ -3251,9 +3254,9 @@ static int __init gsm_init(void)
 
        gsm_tty_driver = alloc_tty_driver(256);
        if (!gsm_tty_driver) {
-               tty_unregister_ldisc(N_GSM0710);
                pr_err("gsm_init: tty allocation failed.\n");
-               return -EINVAL;
+               status = -ENOMEM;
+               goto err_unreg_ldisc;
        }
        gsm_tty_driver->driver_name     = "gsmtty";
        gsm_tty_driver->name            = "gsmtty";
@@ -3269,22 +3272,23 @@ static int __init gsm_init(void)
        tty_set_operations(gsm_tty_driver, &gsmtty_ops);
 
        if (tty_register_driver(gsm_tty_driver)) {
-               put_tty_driver(gsm_tty_driver);
-               tty_unregister_ldisc(N_GSM0710);
                pr_err("gsm_init: tty registration failed.\n");
-               return -EBUSY;
+               status = -EBUSY;
+               goto err_put_driver;
        }
        pr_debug("gsm_init: loaded as %d,%d.\n",
                        gsm_tty_driver->major, gsm_tty_driver->minor_start);
        return 0;
+err_put_driver:
+       put_tty_driver(gsm_tty_driver);
+err_unreg_ldisc:
+       tty_unregister_ldisc(&tty_ldisc_packet);
+       return status;
 }
 
 static void __exit gsm_exit(void)
 {
-       int status = tty_unregister_ldisc(N_GSM0710);
-       if (status != 0)
-               pr_err("n_gsm: can't unregister line discipline (err = %d)\n",
-                                                               status);
+       tty_unregister_ldisc(&tty_ldisc_packet);
        tty_unregister_driver(gsm_tty_driver);
        put_tty_driver(gsm_tty_driver);
 }
index b0f33e8..580a37b 100644 (file)
@@ -358,7 +358,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
  * interpreted as one HDLC frame.
  */
 static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
-                              char *flags, int count)
+                              const char *flags, int count)
 {
        register struct n_hdlc *n_hdlc = tty->disc_data;
        register struct n_hdlc_buf *buf;
@@ -411,8 +411,10 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
  * n_hdlc_tty_read - Called to retrieve one frame of data (if available)
  * @tty: pointer to tty instance data
  * @file: pointer to open file object
- * @buf: pointer to returned data buffer
+ * @kbuf: pointer to returned data buffer
  * @nr: size of returned data buffer
+ * @cookie: stored rbuf from previous run
+ * @offset: offset into the data buffer
  *
  * Returns the number of bytes returned or error code.
  */
@@ -788,6 +790,7 @@ static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *buf_list)
 
 static struct tty_ldisc_ops n_hdlc_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_HDLC,
        .name           = "hdlc",
        .open           = n_hdlc_tty_open,
        .close          = n_hdlc_tty_close,
@@ -807,7 +810,7 @@ static int __init n_hdlc_init(void)
        /* range check maxframe arg */
        maxframe = clamp(maxframe, 4096, MAX_HDLC_FRAME_SIZE);
 
-       status = tty_register_ldisc(N_HDLC, &n_hdlc_ldisc);
+       status = tty_register_ldisc(&n_hdlc_ldisc);
        if (!status)
                pr_info("N_HDLC line discipline registered with maxframe=%d\n",
                                maxframe);
@@ -821,14 +824,7 @@ static int __init n_hdlc_init(void)
 
 static void __exit n_hdlc_exit(void)
 {
-       /* Release tty registration of line discipline */
-       int status = tty_unregister_ldisc(N_HDLC);
-
-       if (status)
-               pr_err("N_HDLC: can't unregister line discipline (err = %d)\n",
-                               status);
-       else
-               pr_info("N_HDLC: line discipline unregistered\n");
+       tty_unregister_ldisc(&n_hdlc_ldisc);
 }
 
 module_init(n_hdlc_init);
index b8f67b5..f913b66 100644 (file)
@@ -33,13 +33,14 @@ static ssize_t n_null_write(struct tty_struct *tty, struct file *file,
 }
 
 static void n_null_receivebuf(struct tty_struct *tty,
-                                const unsigned char *cp, char *fp,
+                                const unsigned char *cp, const char *fp,
                                 int cnt)
 {
 }
 
 static struct tty_ldisc_ops null_ldisc = {
        .owner          =       THIS_MODULE,
+       .num            =       N_NULL,
        .name           =       "n_null",
        .open           =       n_null_open,
        .close          =       n_null_close,
@@ -50,13 +51,13 @@ static struct tty_ldisc_ops null_ldisc = {
 
 static int __init n_null_init(void)
 {
-       BUG_ON(tty_register_ldisc(N_NULL, &null_ldisc));
+       BUG_ON(tty_register_ldisc(&null_ldisc));
        return 0;
 }
 
 static void __exit n_null_exit(void)
 {
-       tty_unregister_ldisc(N_NULL);
+       tty_unregister_ldisc(&null_ldisc);
 }
 
 module_init(n_null_init);
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
deleted file mode 100644 (file)
index 2eb76ea..0000000
+++ /dev/null
@@ -1,1283 +0,0 @@
-// SPDX-License-Identifier: GPL-1.0+
-/* r3964 linediscipline for linux
- *
- * -----------------------------------------------------------
- * Copyright by 
- * Philips Automation Projects
- * Kassel (Germany)
- * -----------------------------------------------------------
- * Author:
- * L. Haag
- *
- * $Log: n_r3964.c,v $
- * Revision 1.10  2001/03/18 13:02:24  dwmw2
- * Fix timer usage, use spinlocks properly.
- *
- * Revision 1.9  2001/03/18 12:52:14  dwmw2
- * Merge changes in 2.4.2
- *
- * Revision 1.8  2000/03/23 14:14:54  dwmw2
- * Fix race in sleeping in r3964_read()
- *
- * Revision 1.7  1999/28/08 11:41:50  dwmw2
- * Port to 2.3 kernel
- *
- * Revision 1.6  1998/09/30 00:40:40  dwmw2
- * Fixed compilation on 2.0.x kernels
- * Updated to newly registered tty-ldisc number 9
- *
- * Revision 1.5  1998/09/04 21:57:36  dwmw2
- * Signal handling bug fixes, port to 2.1.x.
- *
- * Revision 1.4  1998/04/02 20:26:59  lhaag
- * select, blocking, ...
- *
- * Revision 1.3  1998/02/12 18:58:43  root
- * fixed some memory leaks
- * calculation of checksum characters
- *
- * Revision 1.2  1998/02/07 13:03:34  root
- * ioctl read_telegram
- *
- * Revision 1.1  1998/02/06 19:21:03  root
- * Initial revision
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/in.h>
-#include <linux/slab.h>
-#include <linux/tty.h>
-#include <linux/errno.h>
-#include <linux/string.h>      /* used in new tty drivers */
-#include <linux/signal.h>      /* used in new tty drivers */
-#include <linux/ioctl.h>
-#include <linux/n_r3964.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/uaccess.h>
-
-/*#define DEBUG_QUEUE*/
-
-/* Log successful handshake and protocol operations  */
-/*#define DEBUG_PROTO_S*/
-
-/* Log handshake and protocol errors: */
-/*#define DEBUG_PROTO_E*/
-
-/* Log Linediscipline operations (open, close, read, write...): */
-/*#define DEBUG_LDISC*/
-
-/* Log module and memory operations (init, cleanup; kmalloc, kfree): */
-/*#define DEBUG_MODUL*/
-
-/* Macro helpers for debug output: */
-#define TRACE(format, args...) printk("r3964: " format "\n" , ## args)
-
-#ifdef DEBUG_MODUL
-#define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_M(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_PROTO_S
-#define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_PS(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_PROTO_E
-#define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_PE(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_LDISC
-#define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_L(fmt, arg...) do {} while (0)
-#endif
-#ifdef DEBUG_QUEUE
-#define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args)
-#else
-#define TRACE_Q(fmt, arg...) do {} while (0)
-#endif
-static void add_tx_queue(struct r3964_info *, struct r3964_block_header *);
-static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code);
-static void put_char(struct r3964_info *pInfo, unsigned char ch);
-static void trigger_transmit(struct r3964_info *pInfo);
-static void retry_transmit(struct r3964_info *pInfo);
-static void transmit_block(struct r3964_info *pInfo);
-static void receive_char(struct r3964_info *pInfo, const unsigned char c);
-static void receive_error(struct r3964_info *pInfo, const char flag);
-static void on_timeout(struct timer_list *t);
-static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg);
-static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
-               unsigned char __user * buf);
-static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
-               int error_code, struct r3964_block_header *pBlock);
-static struct r3964_message *remove_msg(struct r3964_info *pInfo,
-               struct r3964_client_info *pClient);
-static void remove_client_block(struct r3964_info *pInfo,
-               struct r3964_client_info *pClient);
-
-static int r3964_open(struct tty_struct *tty);
-static void r3964_close(struct tty_struct *tty);
-static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
-               void *cookie, unsigned char *buf, size_t nr);
-static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
-               const unsigned char *buf, size_t nr);
-static int r3964_ioctl(struct tty_struct *tty, struct file *file,
-               unsigned int cmd, unsigned long arg);
-#ifdef CONFIG_COMPAT
-static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file,
-               unsigned int cmd, unsigned long arg);
-#endif
-static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
-static __poll_t r3964_poll(struct tty_struct *tty, struct file *file,
-               struct poll_table_struct *wait);
-static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-               char *fp, int count);
-
-static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
-       .owner = THIS_MODULE,
-       .name = "R3964",
-       .open = r3964_open,
-       .close = r3964_close,
-       .read = r3964_read,
-       .write = r3964_write,
-       .ioctl = r3964_ioctl,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl = r3964_compat_ioctl,
-#endif
-       .set_termios = r3964_set_termios,
-       .poll = r3964_poll,
-       .receive_buf = r3964_receive_buf,
-};
-
-static void dump_block(const unsigned char *block, unsigned int length)
-{
-       unsigned int i, j;
-       char linebuf[16 * 3 + 1];
-
-       for (i = 0; i < length; i += 16) {
-               for (j = 0; (j < 16) && (j + i < length); j++) {
-                       sprintf(linebuf + 3 * j, "%02x ", block[i + j]);
-               }
-               linebuf[3 * j] = '\0';
-               TRACE_PS("%s", linebuf);
-       }
-}
-
-/*************************************************************
- * Driver initialisation
- *************************************************************/
-
-/*************************************************************
- * Module support routines
- *************************************************************/
-
-static void __exit r3964_exit(void)
-{
-       int status;
-
-       TRACE_M("cleanup_module()");
-
-       status = tty_unregister_ldisc(N_R3964);
-
-       if (status != 0) {
-               printk(KERN_ERR "r3964: error unregistering linediscipline: "
-                               "%d\n", status);
-       } else {
-               TRACE_L("linediscipline successfully unregistered");
-       }
-}
-
-static int __init r3964_init(void)
-{
-       int status;
-
-       printk("r3964: Philips r3964 Driver $Revision: 1.10 $\n");
-
-       /*
-        * Register the tty line discipline
-        */
-
-       status = tty_register_ldisc(N_R3964, &tty_ldisc_N_R3964);
-       if (status == 0) {
-               TRACE_L("line discipline %d registered", N_R3964);
-               TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags,
-                       tty_ldisc_N_R3964.num);
-               TRACE_L("open=%p", tty_ldisc_N_R3964.open);
-               TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
-       } else {
-               printk(KERN_ERR "r3964: error registering line discipline: "
-                               "%d\n", status);
-       }
-       return status;
-}
-
-module_init(r3964_init);
-module_exit(r3964_exit);
-
-/*************************************************************
- * Protocol implementation routines
- *************************************************************/
-
-static void add_tx_queue(struct r3964_info *pInfo,
-                        struct r3964_block_header *pHeader)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       pHeader->next = NULL;
-
-       if (pInfo->tx_last == NULL) {
-               pInfo->tx_first = pInfo->tx_last = pHeader;
-       } else {
-               pInfo->tx_last->next = pHeader;
-               pInfo->tx_last = pHeader;
-       }
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       TRACE_Q("add_tx_queue %p, length %d, tx_first = %p",
-               pHeader, pHeader->length, pInfo->tx_first);
-}
-
-static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
-{
-       struct r3964_block_header *pHeader;
-       unsigned long flags;
-#ifdef DEBUG_QUEUE
-       struct r3964_block_header *pDump;
-#endif
-
-       pHeader = pInfo->tx_first;
-
-       if (pHeader == NULL)
-               return;
-
-#ifdef DEBUG_QUEUE
-       printk("r3964: remove_from_tx_queue: %p, length %u - ",
-               pHeader, pHeader->length);
-       for (pDump = pHeader; pDump; pDump = pDump->next)
-               printk("%p ", pDump);
-       printk("\n");
-#endif
-
-       if (pHeader->owner) {
-               if (error_code) {
-                       add_msg(pHeader->owner, R3964_MSG_ACK, 0,
-                               error_code, NULL);
-               } else {
-                       add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length,
-                               error_code, NULL);
-               }
-               wake_up_interruptible(&pInfo->tty->read_wait);
-       }
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       pInfo->tx_first = pHeader->next;
-       if (pInfo->tx_first == NULL) {
-               pInfo->tx_last = NULL;
-       }
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       kfree(pHeader);
-       TRACE_M("remove_from_tx_queue - kfree %p", pHeader);
-
-       TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
-               pInfo->tx_first, pInfo->tx_last);
-}
-
-static void add_rx_queue(struct r3964_info *pInfo,
-                        struct r3964_block_header *pHeader)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       pHeader->next = NULL;
-
-       if (pInfo->rx_last == NULL) {
-               pInfo->rx_first = pInfo->rx_last = pHeader;
-       } else {
-               pInfo->rx_last->next = pHeader;
-               pInfo->rx_last = pHeader;
-       }
-       pInfo->blocks_in_rx_queue++;
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
-               pHeader, pHeader->length,
-               pInfo->rx_first, pInfo->blocks_in_rx_queue);
-}
-
-static void remove_from_rx_queue(struct r3964_info *pInfo,
-                                struct r3964_block_header *pHeader)
-{
-       unsigned long flags;
-       struct r3964_block_header *pFind;
-
-       if (pHeader == NULL)
-               return;
-
-       TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
-               pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
-       TRACE_Q("remove_from_rx_queue: %p, length %u",
-               pHeader, pHeader->length);
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       if (pInfo->rx_first == pHeader) {
-               /* Remove the first block in the linked list: */
-               pInfo->rx_first = pHeader->next;
-
-               if (pInfo->rx_first == NULL) {
-                       pInfo->rx_last = NULL;
-               }
-               pInfo->blocks_in_rx_queue--;
-       } else {
-               /* Find block to remove: */
-               for (pFind = pInfo->rx_first; pFind; pFind = pFind->next) {
-                       if (pFind->next == pHeader) {
-                               /* Got it. */
-                               pFind->next = pHeader->next;
-                               pInfo->blocks_in_rx_queue--;
-                               if (pFind->next == NULL) {
-                                       /* Oh, removed the last one! */
-                                       pInfo->rx_last = pFind;
-                               }
-                               break;
-                       }
-               }
-       }
-
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       kfree(pHeader);
-       TRACE_M("remove_from_rx_queue - kfree %p", pHeader);
-
-       TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
-               pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
-}
-
-static void put_char(struct r3964_info *pInfo, unsigned char ch)
-{
-       struct tty_struct *tty = pInfo->tty;
-       /* FIXME: put_char should not be called from an IRQ */
-       tty_put_char(tty, ch);
-       pInfo->bcc ^= ch;
-}
-
-static void flush(struct r3964_info *pInfo)
-{
-       struct tty_struct *tty = pInfo->tty;
-
-       if (tty == NULL || tty->ops->flush_chars == NULL)
-               return;
-       tty->ops->flush_chars(tty);
-}
-
-static void trigger_transmit(struct r3964_info *pInfo)
-{
-       unsigned long flags;
-
-       spin_lock_irqsave(&pInfo->lock, flags);
-
-       if ((pInfo->state == R3964_IDLE) && (pInfo->tx_first != NULL)) {
-               pInfo->state = R3964_TX_REQUEST;
-               pInfo->nRetry = 0;
-               pInfo->flags &= ~R3964_ERROR;
-               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-
-               spin_unlock_irqrestore(&pInfo->lock, flags);
-
-               TRACE_PS("trigger_transmit - sent STX");
-
-               put_char(pInfo, STX);
-               flush(pInfo);
-
-               pInfo->bcc = 0;
-       } else {
-               spin_unlock_irqrestore(&pInfo->lock, flags);
-       }
-}
-
-static void retry_transmit(struct r3964_info *pInfo)
-{
-       if (pInfo->nRetry < R3964_MAX_RETRIES) {
-               TRACE_PE("transmission failed. Retry #%d", pInfo->nRetry);
-               pInfo->bcc = 0;
-               put_char(pInfo, STX);
-               flush(pInfo);
-               pInfo->state = R3964_TX_REQUEST;
-               pInfo->nRetry++;
-               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-       } else {
-               TRACE_PE("transmission failed after %d retries",
-                        R3964_MAX_RETRIES);
-
-               remove_from_tx_queue(pInfo, R3964_TX_FAIL);
-
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-
-               trigger_transmit(pInfo);
-       }
-}
-
-static void transmit_block(struct r3964_info *pInfo)
-{
-       struct tty_struct *tty = pInfo->tty;
-       struct r3964_block_header *pBlock = pInfo->tx_first;
-       int room = 0;
-
-       if (tty == NULL || pBlock == NULL) {
-               return;
-       }
-
-       room = tty_write_room(tty);
-
-       TRACE_PS("transmit_block %p, room %d, length %d",
-                pBlock, room, pBlock->length);
-
-       while (pInfo->tx_position < pBlock->length) {
-               if (room < 2)
-                       break;
-
-               if (pBlock->data[pInfo->tx_position] == DLE) {
-                       /* send additional DLE char: */
-                       put_char(pInfo, DLE);
-               }
-               put_char(pInfo, pBlock->data[pInfo->tx_position++]);
-
-               room--;
-       }
-
-       if ((pInfo->tx_position == pBlock->length) && (room >= 3)) {
-               put_char(pInfo, DLE);
-               put_char(pInfo, ETX);
-               if (pInfo->flags & R3964_BCC) {
-                       put_char(pInfo, pInfo->bcc);
-               }
-               pInfo->state = R3964_WAIT_FOR_TX_ACK;
-               mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
-       }
-       flush(pInfo);
-}
-
-static void on_receive_block(struct r3964_info *pInfo)
-{
-       unsigned int length;
-       struct r3964_client_info *pClient;
-       struct r3964_block_header *pBlock;
-
-       length = pInfo->rx_position;
-
-       /* compare byte checksum characters: */
-       if (pInfo->flags & R3964_BCC) {
-               if (pInfo->bcc != pInfo->last_rx) {
-                       TRACE_PE("checksum error - got %x but expected %x",
-                                pInfo->last_rx, pInfo->bcc);
-                       pInfo->flags |= R3964_CHECKSUM;
-               }
-       }
-
-       /* check for errors (parity, overrun,...): */
-       if (pInfo->flags & R3964_ERROR) {
-               TRACE_PE("on_receive_block - transmission failed error %x",
-                        pInfo->flags & R3964_ERROR);
-
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               if (pInfo->nRetry < R3964_MAX_RETRIES) {
-                       pInfo->state = R3964_WAIT_FOR_RX_REPEAT;
-                       pInfo->nRetry++;
-                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC);
-               } else {
-                       TRACE_PE("on_receive_block - failed after max retries");
-                       pInfo->state = R3964_IDLE;
-               }
-               return;
-       }
-
-       /* received block; submit DLE: */
-       put_char(pInfo, DLE);
-       flush(pInfo);
-       del_timer_sync(&pInfo->tmr);
-       TRACE_PS(" rx success: got %d chars", length);
-
-       /* prepare struct r3964_block_header: */
-       pBlock = kmalloc(length + sizeof(struct r3964_block_header),
-                       GFP_KERNEL);
-       TRACE_M("on_receive_block - kmalloc %p", pBlock);
-
-       if (pBlock == NULL)
-               return;
-
-       pBlock->length = length;
-       pBlock->data = ((unsigned char *)pBlock) +
-                       sizeof(struct r3964_block_header);
-       pBlock->locks = 0;
-       pBlock->next = NULL;
-       pBlock->owner = NULL;
-
-       memcpy(pBlock->data, pInfo->rx_buf, length);
-
-       /* queue block into rx_queue: */
-       add_rx_queue(pInfo, pBlock);
-
-       /* notify attached client processes: */
-       for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
-               if (pClient->sig_flags & R3964_SIG_DATA) {
-                       add_msg(pClient, R3964_MSG_DATA, length, R3964_OK,
-                               pBlock);
-               }
-       }
-       wake_up_interruptible(&pInfo->tty->read_wait);
-
-       pInfo->state = R3964_IDLE;
-
-       trigger_transmit(pInfo);
-}
-
-static void receive_char(struct r3964_info *pInfo, const unsigned char c)
-{
-       switch (pInfo->state) {
-       case R3964_TX_REQUEST:
-               if (c == DLE) {
-                       TRACE_PS("TX_REQUEST - got DLE");
-
-                       pInfo->state = R3964_TRANSMITTING;
-                       pInfo->tx_position = 0;
-
-                       transmit_block(pInfo);
-               } else if (c == STX) {
-                       if (pInfo->nRetry == 0) {
-                               TRACE_PE("TX_REQUEST - init conflict");
-                               if (pInfo->priority == R3964_SLAVE) {
-                                       goto start_receiving;
-                               }
-                       } else {
-                               TRACE_PE("TX_REQUEST - secondary init "
-                                       "conflict!? Switching to SLAVE mode "
-                                       "for next rx.");
-                               goto start_receiving;
-                       }
-               } else {
-                       TRACE_PE("TX_REQUEST - char != DLE: %x", c);
-                       retry_transmit(pInfo);
-               }
-               break;
-       case R3964_TRANSMITTING:
-               if (c == NAK) {
-                       TRACE_PE("TRANSMITTING - got NAK");
-                       retry_transmit(pInfo);
-               } else {
-                       TRACE_PE("TRANSMITTING - got invalid char");
-
-                       pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY;
-                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-               }
-               break;
-       case R3964_WAIT_FOR_TX_ACK:
-               if (c == DLE) {
-                       TRACE_PS("WAIT_FOR_TX_ACK - got DLE");
-                       remove_from_tx_queue(pInfo, R3964_OK);
-
-                       pInfo->state = R3964_IDLE;
-                       trigger_transmit(pInfo);
-               } else {
-                       retry_transmit(pInfo);
-               }
-               break;
-       case R3964_WAIT_FOR_RX_REPEAT:
-       case R3964_IDLE:
-               if (c == STX) {
-                       /* Prevent rx_queue from overflow: */
-                       if (pInfo->blocks_in_rx_queue >=
-                           R3964_MAX_BLOCKS_IN_RX_QUEUE) {
-                               TRACE_PE("IDLE - got STX but no space in "
-                                               "rx_queue!");
-                               pInfo->state = R3964_WAIT_FOR_RX_BUF;
-                               mod_timer(&pInfo->tmr,
-                                         jiffies + R3964_TO_NO_BUF);
-                               break;
-                       }
-start_receiving:
-                       /* Ok, start receiving: */
-                       TRACE_PS("IDLE - got STX");
-                       pInfo->rx_position = 0;
-                       pInfo->last_rx = 0;
-                       pInfo->flags &= ~R3964_ERROR;
-                       pInfo->state = R3964_RECEIVING;
-                       mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-                       pInfo->nRetry = 0;
-                       put_char(pInfo, DLE);
-                       flush(pInfo);
-                       pInfo->bcc = 0;
-               }
-               break;
-       case R3964_RECEIVING:
-               if (pInfo->rx_position < RX_BUF_SIZE) {
-                       pInfo->bcc ^= c;
-
-                       if (c == DLE) {
-                               if (pInfo->last_rx == DLE) {
-                                       pInfo->last_rx = 0;
-                                       goto char_to_buf;
-                               }
-                               pInfo->last_rx = DLE;
-                               break;
-                       } else if ((c == ETX) && (pInfo->last_rx == DLE)) {
-                               if (pInfo->flags & R3964_BCC) {
-                                       pInfo->state = R3964_WAIT_FOR_BCC;
-                                       mod_timer(&pInfo->tmr,
-                                                 jiffies + R3964_TO_ZVZ);
-                               } else {
-                                       on_receive_block(pInfo);
-                               }
-                       } else {
-                               pInfo->last_rx = c;
-char_to_buf:
-                               pInfo->rx_buf[pInfo->rx_position++] = c;
-                               mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
-                       }
-               }
-               /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */
-               break;
-       case R3964_WAIT_FOR_BCC:
-               pInfo->last_rx = c;
-               on_receive_block(pInfo);
-               break;
-       }
-}
-
-static void receive_error(struct r3964_info *pInfo, const char flag)
-{
-       switch (flag) {
-       case TTY_NORMAL:
-               break;
-       case TTY_BREAK:
-               TRACE_PE("received break");
-               pInfo->flags |= R3964_BREAK;
-               break;
-       case TTY_PARITY:
-               TRACE_PE("parity error");
-               pInfo->flags |= R3964_PARITY;
-               break;
-       case TTY_FRAME:
-               TRACE_PE("frame error");
-               pInfo->flags |= R3964_FRAME;
-               break;
-       case TTY_OVERRUN:
-               TRACE_PE("frame overrun");
-               pInfo->flags |= R3964_OVERRUN;
-               break;
-       default:
-               TRACE_PE("receive_error - unknown flag %d", flag);
-               pInfo->flags |= R3964_UNKNOWN;
-               break;
-       }
-}
-
-static void on_timeout(struct timer_list *t)
-{
-       struct r3964_info *pInfo = from_timer(pInfo, t, tmr);
-
-       switch (pInfo->state) {
-       case R3964_TX_REQUEST:
-               TRACE_PE("TX_REQUEST - timeout");
-               retry_transmit(pInfo);
-               break;
-       case R3964_WAIT_ZVZ_BEFORE_TX_RETRY:
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               retry_transmit(pInfo);
-               break;
-       case R3964_WAIT_FOR_TX_ACK:
-               TRACE_PE("WAIT_FOR_TX_ACK - timeout");
-               retry_transmit(pInfo);
-               break;
-       case R3964_WAIT_FOR_RX_BUF:
-               TRACE_PE("WAIT_FOR_RX_BUF - timeout");
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-               break;
-       case R3964_RECEIVING:
-               TRACE_PE("RECEIVING - timeout after %d chars",
-                        pInfo->rx_position);
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-               break;
-       case R3964_WAIT_FOR_RX_REPEAT:
-               TRACE_PE("WAIT_FOR_RX_REPEAT - timeout");
-               pInfo->state = R3964_IDLE;
-               break;
-       case R3964_WAIT_FOR_BCC:
-               TRACE_PE("WAIT_FOR_BCC - timeout");
-               put_char(pInfo, NAK);
-               flush(pInfo);
-               pInfo->state = R3964_IDLE;
-               break;
-       }
-}
-
-static struct r3964_client_info *findClient(struct r3964_info *pInfo,
-               struct pid *pid)
-{
-       struct r3964_client_info *pClient;
-
-       for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
-               if (pClient->pid == pid) {
-                       return pClient;
-               }
-       }
-       return NULL;
-}
-
-static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
-{
-       struct r3964_client_info *pClient;
-       struct r3964_client_info **ppClient;
-       struct r3964_message *pMsg;
-
-       if ((arg & R3964_SIG_ALL) == 0) {
-               /* Remove client from client list */
-               for (ppClient = &pInfo->firstClient; *ppClient;
-                    ppClient = &(*ppClient)->next) {
-                       pClient = *ppClient;
-
-                       if (pClient->pid == pid) {
-                               TRACE_PS("removing client %d from client list",
-                                        pid_nr(pid));
-                               *ppClient = pClient->next;
-                               while (pClient->msg_count) {
-                                       pMsg = remove_msg(pInfo, pClient);
-                                       if (pMsg) {
-                                               kfree(pMsg);
-                                               TRACE_M("enable_signals - msg "
-                                                       "kfree %p", pMsg);
-                                       }
-                               }
-                               put_pid(pClient->pid);
-                               kfree(pClient);
-                               TRACE_M("enable_signals - kfree %p", pClient);
-                               return 0;
-                       }
-               }
-               return -EINVAL;
-       } else {
-               pClient = findClient(pInfo, pid);
-               if (pClient) {
-                       /* update signal options */
-                       pClient->sig_flags = arg;
-               } else {
-                       /* add client to client list */
-                       pClient = kmalloc(sizeof(struct r3964_client_info),
-                                       GFP_KERNEL);
-                       TRACE_M("enable_signals - kmalloc %p", pClient);
-                       if (pClient == NULL)
-                               return -ENOMEM;
-
-                       TRACE_PS("add client %d to client list", pid_nr(pid));
-                       spin_lock_init(&pClient->lock);
-                       pClient->sig_flags = arg;
-                       pClient->pid = get_pid(pid);
-                       pClient->next = pInfo->firstClient;
-                       pClient->first_msg = NULL;
-                       pClient->last_msg = NULL;
-                       pClient->next_block_to_read = NULL;
-                       pClient->msg_count = 0;
-                       pInfo->firstClient = pClient;
-               }
-       }
-
-       return 0;
-}
-
-static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
-                        unsigned char __user * buf)
-{
-       struct r3964_client_info *pClient;
-       struct r3964_block_header *block;
-
-       if (!buf) {
-               return -EINVAL;
-       }
-
-       pClient = findClient(pInfo, pid);
-       if (pClient == NULL) {
-               return -EINVAL;
-       }
-
-       block = pClient->next_block_to_read;
-       if (!block) {
-               return 0;
-       } else {
-               if (copy_to_user(buf, block->data, block->length))
-                       return -EFAULT;
-
-               remove_client_block(pInfo, pClient);
-               return block->length;
-       }
-
-       return -EINVAL;
-}
-
-static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
-               int error_code, struct r3964_block_header *pBlock)
-{
-       struct r3964_message *pMsg;
-       unsigned long flags;
-
-       if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) {
-queue_the_message:
-
-               pMsg = kmalloc(sizeof(struct r3964_message),
-                               error_code ? GFP_ATOMIC : GFP_KERNEL);
-               TRACE_M("add_msg - kmalloc %p", pMsg);
-               if (pMsg == NULL) {
-                       return;
-               }
-
-               spin_lock_irqsave(&pClient->lock, flags);
-
-               pMsg->msg_id = msg_id;
-               pMsg->arg = arg;
-               pMsg->error_code = error_code;
-               pMsg->block = pBlock;
-               pMsg->next = NULL;
-
-               if (pClient->last_msg == NULL) {
-                       pClient->first_msg = pClient->last_msg = pMsg;
-               } else {
-                       pClient->last_msg->next = pMsg;
-                       pClient->last_msg = pMsg;
-               }
-
-               pClient->msg_count++;
-
-               if (pBlock != NULL) {
-                       pBlock->locks++;
-               }
-               spin_unlock_irqrestore(&pClient->lock, flags);
-       } else {
-               if ((pClient->last_msg->msg_id == R3964_MSG_ACK)
-                   && (pClient->last_msg->error_code == R3964_OVERFLOW)) {
-                       pClient->last_msg->arg++;
-                       TRACE_PE("add_msg - inc prev OVERFLOW-msg");
-               } else {
-                       msg_id = R3964_MSG_ACK;
-                       arg = 0;
-                       error_code = R3964_OVERFLOW;
-                       pBlock = NULL;
-                       TRACE_PE("add_msg - queue OVERFLOW-msg");
-                       goto queue_the_message;
-               }
-       }
-       /* Send SIGIO signal to client process: */
-       if (pClient->sig_flags & R3964_USE_SIGIO) {
-               kill_pid(pClient->pid, SIGIO, 1);
-       }
-}
-
-static struct r3964_message *remove_msg(struct r3964_info *pInfo,
-                                       struct r3964_client_info *pClient)
-{
-       struct r3964_message *pMsg = NULL;
-       unsigned long flags;
-
-       if (pClient->first_msg) {
-               spin_lock_irqsave(&pClient->lock, flags);
-
-               pMsg = pClient->first_msg;
-               pClient->first_msg = pMsg->next;
-               if (pClient->first_msg == NULL) {
-                       pClient->last_msg = NULL;
-               }
-
-               pClient->msg_count--;
-               if (pMsg->block) {
-                       remove_client_block(pInfo, pClient);
-                       pClient->next_block_to_read = pMsg->block;
-               }
-               spin_unlock_irqrestore(&pClient->lock, flags);
-       }
-       return pMsg;
-}
-
-static void remove_client_block(struct r3964_info *pInfo,
-                               struct r3964_client_info *pClient)
-{
-       struct r3964_block_header *block;
-
-       TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
-
-       block = pClient->next_block_to_read;
-       if (block) {
-               block->locks--;
-               if (block->locks == 0) {
-                       remove_from_rx_queue(pInfo, block);
-               }
-       }
-       pClient->next_block_to_read = NULL;
-}
-
-/*************************************************************
- * Line discipline routines
- *************************************************************/
-
-static int r3964_open(struct tty_struct *tty)
-{
-       struct r3964_info *pInfo;
-
-       TRACE_L("open");
-       TRACE_L("tty=%p, PID=%d, disc_data=%p",
-               tty, current->pid, tty->disc_data);
-
-       pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
-       TRACE_M("r3964_open - info kmalloc %p", pInfo);
-
-       if (!pInfo) {
-               printk(KERN_ERR "r3964: failed to alloc info structure\n");
-               return -ENOMEM;
-       }
-
-       pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
-       TRACE_M("r3964_open - rx_buf kmalloc %p", pInfo->rx_buf);
-
-       if (!pInfo->rx_buf) {
-               printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
-               kfree(pInfo);
-               TRACE_M("r3964_open - info kfree %p", pInfo);
-               return -ENOMEM;
-       }
-
-       pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
-       TRACE_M("r3964_open - tx_buf kmalloc %p", pInfo->tx_buf);
-
-       if (!pInfo->tx_buf) {
-               printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
-               kfree(pInfo->rx_buf);
-               TRACE_M("r3964_open - rx_buf kfree %p", pInfo->rx_buf);
-               kfree(pInfo);
-               TRACE_M("r3964_open - info kfree %p", pInfo);
-               return -ENOMEM;
-       }
-
-       spin_lock_init(&pInfo->lock);
-       mutex_init(&pInfo->read_lock);
-       pInfo->tty = tty;
-       pInfo->priority = R3964_MASTER;
-       pInfo->rx_first = pInfo->rx_last = NULL;
-       pInfo->tx_first = pInfo->tx_last = NULL;
-       pInfo->rx_position = 0;
-       pInfo->tx_position = 0;
-       pInfo->last_rx = 0;
-       pInfo->blocks_in_rx_queue = 0;
-       pInfo->firstClient = NULL;
-       pInfo->state = R3964_IDLE;
-       pInfo->flags = R3964_DEBUG;
-       pInfo->nRetry = 0;
-
-       tty->disc_data = pInfo;
-       tty->receive_room = 65536;
-
-       timer_setup(&pInfo->tmr, on_timeout, 0);
-
-       return 0;
-}
-
-static void r3964_close(struct tty_struct *tty)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_client_info *pClient, *pNext;
-       struct r3964_message *pMsg;
-       struct r3964_block_header *pHeader, *pNextHeader;
-       unsigned long flags;
-
-       TRACE_L("close");
-
-       /*
-        * Make sure that our task queue isn't activated.  If it
-        * is, take it out of the linked list.
-        */
-       del_timer_sync(&pInfo->tmr);
-
-       /* Remove client-structs and message queues: */
-       pClient = pInfo->firstClient;
-       while (pClient) {
-               pNext = pClient->next;
-               while (pClient->msg_count) {
-                       pMsg = remove_msg(pInfo, pClient);
-                       if (pMsg) {
-                               kfree(pMsg);
-                               TRACE_M("r3964_close - msg kfree %p", pMsg);
-                       }
-               }
-               put_pid(pClient->pid);
-               kfree(pClient);
-               TRACE_M("r3964_close - client kfree %p", pClient);
-               pClient = pNext;
-       }
-       /* Remove jobs from tx_queue: */
-       spin_lock_irqsave(&pInfo->lock, flags);
-       pHeader = pInfo->tx_first;
-       pInfo->tx_first = pInfo->tx_last = NULL;
-       spin_unlock_irqrestore(&pInfo->lock, flags);
-
-       while (pHeader) {
-               pNextHeader = pHeader->next;
-               kfree(pHeader);
-               pHeader = pNextHeader;
-       }
-
-       /* Free buffers: */
-       kfree(pInfo->rx_buf);
-       TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf);
-       kfree(pInfo->tx_buf);
-       TRACE_M("r3964_close - tx_buf kfree %p", pInfo->tx_buf);
-       kfree(pInfo);
-       TRACE_M("r3964_close - info kfree %p", pInfo);
-}
-
-static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
-                         unsigned char *kbuf, size_t nr,
-                         void **cookie, unsigned long offset)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_client_info *pClient;
-       struct r3964_message *pMsg;
-       struct r3964_client_message theMsg;
-       int ret;
-
-       TRACE_L("read()");
-
-       /*
-        *      Internal serialization of reads.
-        */
-       if (file->f_flags & O_NONBLOCK) {
-               if (!mutex_trylock(&pInfo->read_lock))
-                       return -EAGAIN;
-       } else {
-               if (mutex_lock_interruptible(&pInfo->read_lock))
-                       return -ERESTARTSYS;
-       }
-
-       pClient = findClient(pInfo, task_pid(current));
-       if (pClient) {
-               pMsg = remove_msg(pInfo, pClient);
-               if (pMsg == NULL) {
-                       /* no messages available. */
-                       if (tty_io_nonblock(tty, file)) {
-                               ret = -EAGAIN;
-                               goto unlock;
-                       }
-                       /* block until there is a message: */
-                       wait_event_interruptible(tty->read_wait,
-                                       (pMsg = remove_msg(pInfo, pClient)));
-               }
-
-               /* If we still haven't got a message, we must have been signalled */
-
-               if (!pMsg) {
-                       ret = -EINTR;
-                       goto unlock;
-               }
-
-               /* deliver msg to client process: */
-               theMsg.msg_id = pMsg->msg_id;
-               theMsg.arg = pMsg->arg;
-               theMsg.error_code = pMsg->error_code;
-               ret = sizeof(struct r3964_client_message);
-
-               kfree(pMsg);
-               TRACE_M("r3964_read - msg kfree %p", pMsg);
-
-               memcpy(kbuf, &theMsg, ret);
-
-               TRACE_PS("read - return %d", ret);
-               goto unlock;
-       }
-       ret = -EPERM;
-unlock:
-       mutex_unlock(&pInfo->read_lock);
-       return ret;
-}
-
-static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
-                          const unsigned char *data, size_t count)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_block_header *pHeader;
-       struct r3964_client_info *pClient;
-       unsigned char *new_data;
-
-       TRACE_L("write request, %d characters", count);
-/* 
- * Verify the pointers 
- */
-
-       if (!pInfo)
-               return -EIO;
-
-/*
- * Ensure that the caller does not wish to send too much.
- */
-       if (count > R3964_MTU) {
-               if (pInfo->flags & R3964_DEBUG) {
-                       TRACE_L(KERN_WARNING "r3964_write: truncating user "
-                               "packet from %u to mtu %d", count, R3964_MTU);
-               }
-               count = R3964_MTU;
-       }
-/*
- * Allocate a buffer for the data and copy it from the buffer with header prepended
- */
-       new_data = kmalloc(count + sizeof(struct r3964_block_header),
-                       GFP_KERNEL);
-       TRACE_M("r3964_write - kmalloc %p", new_data);
-       if (new_data == NULL) {
-               if (pInfo->flags & R3964_DEBUG) {
-                       printk(KERN_ERR "r3964_write: no memory\n");
-               }
-               return -ENOSPC;
-       }
-
-       pHeader = (struct r3964_block_header *)new_data;
-       pHeader->data = new_data + sizeof(struct r3964_block_header);
-       pHeader->length = count;
-       pHeader->locks = 0;
-       pHeader->owner = NULL;
-
-       pClient = findClient(pInfo, task_pid(current));
-       if (pClient) {
-               pHeader->owner = pClient;
-       }
-
-       memcpy(pHeader->data, data, count);     /* We already verified this */
-
-       if (pInfo->flags & R3964_DEBUG) {
-               dump_block(pHeader->data, count);
-       }
-
-/*
- * Add buffer to transmit-queue:
- */
-       add_tx_queue(pInfo, pHeader);
-       trigger_transmit(pInfo);
-
-       return 0;
-}
-
-static int r3964_ioctl(struct tty_struct *tty, struct file *file,
-               unsigned int cmd, unsigned long arg)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       if (pInfo == NULL)
-               return -EINVAL;
-       switch (cmd) {
-       case R3964_ENABLE_SIGNALS:
-               return enable_signals(pInfo, task_pid(current), arg);
-       case R3964_SETPRIORITY:
-               if (arg < R3964_MASTER || arg > R3964_SLAVE)
-                       return -EINVAL;
-               pInfo->priority = arg & 0xff;
-               return 0;
-       case R3964_USE_BCC:
-               if (arg)
-                       pInfo->flags |= R3964_BCC;
-               else
-                       pInfo->flags &= ~R3964_BCC;
-               return 0;
-       case R3964_READ_TELEGRAM:
-               return read_telegram(pInfo, task_pid(current),
-                               (unsigned char __user *)arg);
-       default:
-               return -ENOIOCTLCMD;
-       }
-}
-
-#ifdef CONFIG_COMPAT
-static int r3964_compat_ioctl(struct tty_struct *tty, struct file *file,
-               unsigned int cmd, unsigned long arg)
-{
-       switch (cmd) {
-       case R3964_ENABLE_SIGNALS:
-       case R3964_SETPRIORITY:
-       case R3964_USE_BCC:
-               return r3964_ioctl(tty, file, cmd, arg);
-       default:
-               return -ENOIOCTLCMD;
-       }
-}
-#endif
-
-static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
-{
-       TRACE_L("set_termios");
-}
-
-/* Called without the kernel lock held - fine */
-static __poll_t r3964_poll(struct tty_struct *tty, struct file *file,
-                       struct poll_table_struct *wait)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       struct r3964_client_info *pClient;
-       struct r3964_message *pMsg = NULL;
-       unsigned long flags;
-       __poll_t result = EPOLLOUT;
-
-       TRACE_L("POLL");
-
-       pClient = findClient(pInfo, task_pid(current));
-       if (pClient) {
-               poll_wait(file, &tty->read_wait, wait);
-               spin_lock_irqsave(&pInfo->lock, flags);
-               pMsg = pClient->first_msg;
-               spin_unlock_irqrestore(&pInfo->lock, flags);
-               if (pMsg)
-                       result |= EPOLLIN | EPOLLRDNORM;
-       } else {
-               result = -EINVAL;
-       }
-       return result;
-}
-
-static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                       char *fp, int count)
-{
-       struct r3964_info *pInfo = tty->disc_data;
-       const unsigned char *p;
-       char *f, flags = TTY_NORMAL;
-       int i;
-
-       for (i = count, p = cp, f = fp; i; i--, p++) {
-               if (f)
-                       flags = *f++;
-               if (flags == TTY_NORMAL) {
-                       receive_char(pInfo, *p);
-               } else {
-                       receive_error(pInfo, flags);
-               }
-
-       }
-}
-
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_LDISC(N_R3964);
index 9686c5d..0ec93f1 100644 (file)
@@ -342,10 +342,10 @@ static void n_tty_packet_mode_flush(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       if (tty->link->packet) {
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               tty->ctrl_status |= TIOCPKT_FLUSHREAD;
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       if (tty->link->ctrl.packet) {
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               tty->ctrl.pktstatus |= TIOCPKT_FLUSHREAD;
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                wake_up_interruptible(&tty->link->read_wait);
        }
 }
@@ -361,7 +361,7 @@ static void n_tty_packet_mode_flush(struct tty_struct *tty)
  *     Holds termios_rwsem to exclude producer/consumer while
  *     buffer indices are reset.
  *
- *     Locking: ctrl_lock, exclusive termios_rwsem
+ *     Locking: ctrl.lock, exclusive termios_rwsem
  */
 
 static void n_tty_flush_buffer(struct tty_struct *tty)
@@ -1103,7 +1103,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
  *     buffer is 'output'. The signal is processed first to alert any current
  *     readers or writers to discontinue and exit their i/o loops.
  *
- *     Locking: ctrl_lock
+ *     Locking: ctrl.lock
  */
 
 static void __isig(int sig, struct tty_struct *tty)
@@ -1245,7 +1245,6 @@ n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c)
                commit_echoes(tty);
        } else
                process_echoes(tty);
-       return;
 }
 
 /**
@@ -1260,12 +1259,8 @@ n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c)
  *     n_tty_receive_buf()/producer path:
  *             caller holds non-exclusive termios_rwsem
  *             publishes canon_head if canonical mode is active
- *
- *     Returns 1 if LNEXT was received, else returns 0
  */
-
-static int
-n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
+static void n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
 {
        struct n_tty_data *ldata = tty->disc_data;
 
@@ -1273,35 +1268,35 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
                if (c == START_CHAR(tty)) {
                        start_tty(tty);
                        process_echoes(tty);
-                       return 0;
+                       return;
                }
                if (c == STOP_CHAR(tty)) {
                        stop_tty(tty);
-                       return 0;
+                       return;
                }
        }
 
        if (L_ISIG(tty)) {
                if (c == INTR_CHAR(tty)) {
                        n_tty_receive_signal_char(tty, SIGINT, c);
-                       return 0;
+                       return;
                } else if (c == QUIT_CHAR(tty)) {
                        n_tty_receive_signal_char(tty, SIGQUIT, c);
-                       return 0;
+                       return;
                } else if (c == SUSP_CHAR(tty)) {
                        n_tty_receive_signal_char(tty, SIGTSTP, c);
-                       return 0;
+                       return;
                }
        }
 
-       if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) {
+       if (tty->flow.stopped && !tty->flow.tco_stopped && I_IXON(tty) && I_IXANY(tty)) {
                start_tty(tty);
                process_echoes(tty);
        }
 
        if (c == '\r') {
                if (I_IGNCR(tty))
-                       return 0;
+                       return;
                if (I_ICRNL(tty))
                        c = '\n';
        } else if (c == '\n' && I_INLCR(tty))
@@ -1312,7 +1307,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
                    (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) {
                        eraser(c, tty);
                        commit_echoes(tty);
-                       return 0;
+                       return;
                }
                if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) {
                        ldata->lnext = 1;
@@ -1324,7 +1319,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
                                        commit_echoes(tty);
                                }
                        }
-                       return 1;
+                       return;
                }
                if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) {
                        size_t tail = ldata->canon_head;
@@ -1337,7 +1332,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
                                tail++;
                        }
                        commit_echoes(tty);
-                       return 0;
+                       return;
                }
                if (c == '\n') {
                        if (L_ECHO(tty) || L_ECHONL(tty)) {
@@ -1375,7 +1370,7 @@ handle_newline:
                        smp_store_release(&ldata->canon_head, ldata->read_head);
                        kill_fasync(&tty->fasync, SIGIO, POLL_IN);
                        wake_up_interruptible_poll(&tty->read_wait, EPOLLIN);
-                       return 0;
+                       return;
                }
        }
 
@@ -1397,15 +1392,13 @@ handle_newline:
                put_tty_queue(c, ldata);
 
        put_tty_queue(c, ldata);
-       return 0;
 }
 
-static inline void
-n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c)
+static void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
 {
        struct n_tty_data *ldata = tty->disc_data;
 
-       if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) {
+       if (tty->flow.stopped && !tty->flow.tco_stopped && I_IXON(tty) && I_IXANY(tty)) {
                start_tty(tty);
                process_echoes(tty);
        }
@@ -1423,31 +1416,6 @@ n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c)
        put_tty_queue(c, ldata);
 }
 
-static void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
-{
-       n_tty_receive_char_inline(tty, c);
-}
-
-static inline void
-n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c)
-{
-       struct n_tty_data *ldata = tty->disc_data;
-
-       if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) {
-               start_tty(tty);
-               process_echoes(tty);
-       }
-       if (L_ECHO(tty)) {
-               finish_erasing(ldata);
-               /* Record the column of first canon char. */
-               if (ldata->canon_head == ldata->read_head)
-                       echo_set_canon_col(ldata);
-               echo_char(c, tty);
-               commit_echoes(tty);
-       }
-       put_tty_queue(c, ldata);
-}
-
 static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c)
 {
        if (I_ISTRIP(tty))
@@ -1459,7 +1427,7 @@ static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c)
                if (c == STOP_CHAR(tty))
                        stop_tty(tty);
                else if (c == START_CHAR(tty) ||
-                        (tty->stopped && !tty->flow_stopped && I_IXANY(tty) &&
+                        (tty->flow.stopped && !tty->flow.tco_stopped && I_IXANY(tty) &&
                          c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) &&
                          c != SUSP_CHAR(tty))) {
                        start_tty(tty);
@@ -1506,7 +1474,7 @@ n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag)
 
 static void
 n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp,
-                          char *fp, int count)
+                          const char *fp, int count)
 {
        struct n_tty_data *ldata = tty->disc_data;
        size_t n, head;
@@ -1526,7 +1494,7 @@ n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp,
 
 static void
 n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp,
-                     char *fp, int count)
+                     const char *fp, int count)
 {
        struct n_tty_data *ldata = tty->disc_data;
        char flag = TTY_NORMAL;
@@ -1543,7 +1511,7 @@ n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp,
 
 static void
 n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp,
-                         char *fp, int count)
+                         const char *fp, int count)
 {
        char flag = TTY_NORMAL;
 
@@ -1555,68 +1523,46 @@ n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp,
        }
 }
 
-static void
-n_tty_receive_buf_standard(struct tty_struct *tty, const unsigned char *cp,
-                         char *fp, int count)
+static void n_tty_receive_buf_standard(struct tty_struct *tty,
+               const unsigned char *cp, const char *fp, int count)
 {
        struct n_tty_data *ldata = tty->disc_data;
        char flag = TTY_NORMAL;
 
        while (count--) {
+               unsigned char c = *cp++;
+
                if (fp)
                        flag = *fp++;
-               if (likely(flag == TTY_NORMAL)) {
-                       unsigned char c = *cp++;
-
-                       if (I_ISTRIP(tty))
-                               c &= 0x7f;
-                       if (I_IUCLC(tty) && L_IEXTEN(tty))
-                               c = tolower(c);
-                       if (L_EXTPROC(tty)) {
-                               put_tty_queue(c, ldata);
-                               continue;
-                       }
-                       if (!test_bit(c, ldata->char_map))
-                               n_tty_receive_char_inline(tty, c);
-                       else if (n_tty_receive_char_special(tty, c) && count) {
-                               if (fp)
-                                       flag = *fp++;
-                               n_tty_receive_char_lnext(tty, *cp++, flag);
-                               count--;
-                       }
-               } else
-                       n_tty_receive_char_flagged(tty, *cp++, flag);
-       }
-}
 
-static void
-n_tty_receive_buf_fast(struct tty_struct *tty, const unsigned char *cp,
-                      char *fp, int count)
-{
-       struct n_tty_data *ldata = tty->disc_data;
-       char flag = TTY_NORMAL;
+               if (ldata->lnext) {
+                       n_tty_receive_char_lnext(tty, c, flag);
+                       continue;
+               }
 
-       while (count--) {
-               if (fp)
-                       flag = *fp++;
-               if (likely(flag == TTY_NORMAL)) {
-                       unsigned char c = *cp++;
-
-                       if (!test_bit(c, ldata->char_map))
-                               n_tty_receive_char_fast(tty, c);
-                       else if (n_tty_receive_char_special(tty, c) && count) {
-                               if (fp)
-                                       flag = *fp++;
-                               n_tty_receive_char_lnext(tty, *cp++, flag);
-                               count--;
-                       }
-               } else
-                       n_tty_receive_char_flagged(tty, *cp++, flag);
+               if (unlikely(flag != TTY_NORMAL)) {
+                       n_tty_receive_char_flagged(tty, c, flag);
+                       continue;
+               }
+
+               if (I_ISTRIP(tty))
+                       c &= 0x7f;
+               if (I_IUCLC(tty) && L_IEXTEN(tty))
+                       c = tolower(c);
+               if (L_EXTPROC(tty)) {
+                       put_tty_queue(c, ldata);
+                       continue;
+               }
+
+               if (test_bit(c, ldata->char_map))
+                       n_tty_receive_char_special(tty, c);
+               else
+                       n_tty_receive_char(tty, c);
        }
 }
 
 static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                         char *fp, int count)
+                         const char *fp, int count)
 {
        struct n_tty_data *ldata = tty->disc_data;
        bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty));
@@ -1628,19 +1574,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
        else if (tty->closing && !L_EXTPROC(tty))
                n_tty_receive_buf_closing(tty, cp, fp, count);
        else {
-               if (ldata->lnext) {
-                       char flag = TTY_NORMAL;
-
-                       if (fp)
-                               flag = *fp++;
-                       n_tty_receive_char_lnext(tty, *cp++, flag);
-                       count--;
-               }
-
-               if (!preops && !I_PARMRK(tty))
-                       n_tty_receive_buf_fast(tty, cp, fp, count);
-               else
-                       n_tty_receive_buf_standard(tty, cp, fp, count);
+               n_tty_receive_buf_standard(tty, cp, fp, count);
 
                flush_echoes(tty);
                if (tty->ops->flush_chars)
@@ -1695,7 +1629,7 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
  */
 static int
 n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
-                        char *fp, int count, int flow)
+                        const char *fp, int count, int flow)
 {
        struct n_tty_data *ldata = tty->disc_data;
        int room, n, rcvd = 0, overflow;
@@ -1764,13 +1698,13 @@ n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
 }
 
 static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
-                             char *fp, int count)
+                             const char *fp, int count)
 {
        n_tty_receive_buf_common(tty, cp, fp, count, 0);
 }
 
 static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
-                             char *fp, int count)
+                             const char *fp, int count)
 {
        return n_tty_receive_buf_common(tty, cp, fp, count, 1);
 }
@@ -1863,7 +1797,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
         * Fix tty hang when I_IXON(tty) is cleared, but the tty
         * been stopped by STOP_CHAR(tty) before it.
         */
-       if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) {
+       if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow.tco_stopped) {
                start_tty(tty);
                process_echoes(tty);
        }
@@ -2091,7 +2025,7 @@ static bool canon_copy_from_read_buf(struct tty_struct *tty,
  *
  *     Locking: redirected write test is safe
  *              current->signal->tty check is safe
- *              ctrl_lock to safely reference tty->pgrp
+ *              ctrl.lock to safely reference tty->ctrl.pgrp
  */
 
 static int job_control(struct tty_struct *tty, struct file *file)
@@ -2138,7 +2072,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
        int minimum, time;
        ssize_t retval = 0;
        long timeout;
-       int packet;
+       bool packet;
        size_t tail;
 
        /*
@@ -2194,20 +2128,20 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
                }
        }
 
-       packet = tty->packet;
+       packet = tty->ctrl.packet;
        tail = ldata->read_tail;
 
        add_wait_queue(&tty->read_wait, &wait);
        while (nr) {
                /* First test for status change. */
-               if (packet && tty->link->ctrl_status) {
+               if (packet && tty->link->ctrl.pktstatus) {
                        unsigned char cs;
                        if (kb != kbuf)
                                break;
-                       spin_lock_irq(&tty->link->ctrl_lock);
-                       cs = tty->link->ctrl_status;
-                       tty->link->ctrl_status = 0;
-                       spin_unlock_irq(&tty->link->ctrl_lock);
+                       spin_lock_irq(&tty->link->ctrl.lock);
+                       cs = tty->link->ctrl.pktstatus;
+                       tty->link->ctrl.pktstatus = 0;
+                       spin_unlock_irq(&tty->link->ctrl.lock);
                        *kb++ = cs;
                        nr--;
                        break;
@@ -2434,7 +2368,7 @@ static __poll_t n_tty_poll(struct tty_struct *tty, struct file *file,
                if (input_available_p(tty, 1))
                        mask |= EPOLLIN | EPOLLRDNORM;
        }
-       if (tty->packet && tty->link->ctrl_status)
+       if (tty->ctrl.packet && tty->link->ctrl.pktstatus)
                mask |= EPOLLPRI | EPOLLIN | EPOLLRDNORM;
        if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
                mask |= EPOLLHUP;
@@ -2490,6 +2424,7 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file,
 
 static struct tty_ldisc_ops n_tty_ops = {
        .owner           = THIS_MODULE,
+       .num             = N_TTY,
        .name            = "n_tty",
        .open            = n_tty_open,
        .close           = n_tty_close,
@@ -2515,11 +2450,11 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
 {
        *ops = n_tty_ops;
        ops->owner = NULL;
-       ops->refcount = ops->flags = 0;
+       ops->flags = 0;
 }
 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
 
 void __init n_tty_init(void)
 {
-       tty_register_ldisc(N_TTY, &n_tty_ops);
+       tty_register_ldisc(&n_tty_ops);
 }
index 9a2d78a..0c80f25 100644 (file)
@@ -1378,7 +1378,7 @@ static int nozomi_card_init(struct pci_dev *pdev,
                        NOZOMI_NAME, dc);
        if (unlikely(ret)) {
                dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
-               goto err_free_kfifo;
+               goto err_free_all_kfifo;
        }
 
        DBG1("base_addr: %p", dc->base_addr);
@@ -1416,12 +1416,15 @@ static int nozomi_card_init(struct pci_dev *pdev,
        return 0;
 
 err_free_tty:
-       for (i = 0; i < MAX_PORT; ++i) {
+       for (i--; i >= 0; i--) {
                tty_unregister_device(ntty_driver, dc->index_start + i);
                tty_port_destroy(&dc->port[i].port);
        }
+       free_irq(pdev->irq, dc);
+err_free_all_kfifo:
+       i = MAX_PORT;
 err_free_kfifo:
-       for (i = 0; i < MAX_PORT; i++)
+       for (i--; i >= PORT_MDM; i--)
                kfifo_free(&dc->port[i].fifo_ul);
 err_free_sbuf:
        kfree(dc->send_buf);
@@ -1636,10 +1639,10 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
  * If the port is unplugged report lots of room and let the bits
  * dribble away so we don't block anything.
  */
-static int ntty_write_room(struct tty_struct *tty)
+static unsigned int ntty_write_room(struct tty_struct *tty)
 {
        struct port *port = tty->driver_data;
-       int room = 4096;
+       unsigned int room = 4096;
        const struct nozomi *dc = get_dc_by_tty(tty);
 
        if (dc)
@@ -1776,20 +1779,15 @@ static void ntty_throttle(struct tty_struct *tty)
 }
 
 /* Returns number of chars in buffer, called by tty layer */
-static s32 ntty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int ntty_chars_in_buffer(struct tty_struct *tty)
 {
        struct port *port = tty->driver_data;
        struct nozomi *dc = get_dc_by_tty(tty);
-       s32 rval = 0;
 
-       if (unlikely(!dc || !port)) {
-               goto exit_in_buffer;
-       }
-
-       rval = kfifo_len(&port->fifo_ul);
+       if (unlikely(!dc || !port))
+               return 0;
 
-exit_in_buffer:
-       return rval;
+       return kfifo_len(&port->fifo_ul);
 }
 
 static const struct tty_port_operations noz_tty_port_ops = {
index 9b5d4ae..74bfabe 100644 (file)
@@ -57,9 +57,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        set_bit(TTY_IO_ERROR, &tty->flags);
        wake_up_interruptible(&tty->read_wait);
        wake_up_interruptible(&tty->write_wait);
-       spin_lock_irq(&tty->ctrl_lock);
-       tty->packet = 0;
-       spin_unlock_irq(&tty->ctrl_lock);
+       spin_lock_irq(&tty->ctrl.lock);
+       tty->ctrl.packet = false;
+       spin_unlock_irq(&tty->ctrl.lock);
        /* Review - krefs on tty_link ?? */
        if (!tty->link)
                return;
@@ -113,7 +113,7 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
        struct tty_struct *to = tty->link;
        unsigned long flags;
 
-       if (tty->stopped)
+       if (tty->flow.stopped)
                return 0;
 
        if (c > 0) {
@@ -136,26 +136,13 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
  *     the other device.
  */
 
-static int pty_write_room(struct tty_struct *tty)
+static unsigned int pty_write_room(struct tty_struct *tty)
 {
-       if (tty->stopped)
+       if (tty->flow.stopped)
                return 0;
        return tty_buffer_space_avail(tty->link->port);
 }
 
-/**
- *     pty_chars_in_buffer     -       characters currently in our tx queue
- *     @tty: our tty
- *
- *     Report how much we have in the transmit queue. As everything is
- *     instantly at the other end this is easy to implement.
- */
-
-static int pty_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0;
-}
-
 /* Set the lock flag on a pty */
 static int pty_set_lock(struct tty_struct *tty, int __user *arg)
 {
@@ -185,16 +172,16 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
        if (get_user(pktmode, arg))
                return -EFAULT;
 
-       spin_lock_irq(&tty->ctrl_lock);
+       spin_lock_irq(&tty->ctrl.lock);
        if (pktmode) {
-               if (!tty->packet) {
-                       tty->link->ctrl_status = 0;
+               if (!tty->ctrl.packet) {
+                       tty->link->ctrl.pktstatus = 0;
                        smp_mb();
-                       tty->packet = 1;
+                       tty->ctrl.packet = true;
                }
        } else
-               tty->packet = 0;
-       spin_unlock_irq(&tty->ctrl_lock);
+               tty->ctrl.packet = false;
+       spin_unlock_irq(&tty->ctrl.lock);
 
        return 0;
 }
@@ -202,7 +189,7 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
 /* Get the packet mode of a pty */
 static int pty_get_pktmode(struct tty_struct *tty, int __user *arg)
 {
-       int pktmode = tty->packet;
+       int pktmode = tty->ctrl.packet;
 
        return put_user(pktmode, arg);
 }
@@ -232,11 +219,11 @@ static void pty_flush_buffer(struct tty_struct *tty)
                return;
 
        tty_buffer_flush(to, NULL);
-       if (to->packet) {
-               spin_lock_irq(&tty->ctrl_lock);
-               tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
+       if (to->ctrl.packet) {
+               spin_lock_irq(&tty->ctrl.lock);
+               tty->ctrl.pktstatus |= TIOCPKT_FLUSHWRITE;
                wake_up_interruptible(&to->read_wait);
-               spin_unlock_irq(&tty->ctrl_lock);
+               spin_unlock_irq(&tty->ctrl.lock);
        }
 }
 
@@ -266,7 +253,7 @@ static void pty_set_termios(struct tty_struct *tty,
                                        struct ktermios *old_termios)
 {
        /* See if packet mode change of state. */
-       if (tty->link && tty->link->packet) {
+       if (tty->link && tty->link->ctrl.packet) {
                int extproc = (old_termios->c_lflag & EXTPROC) | L_EXTPROC(tty);
                int old_flow = ((old_termios->c_iflag & IXON) &&
                                (old_termios->c_cc[VSTOP] == '\023') &&
@@ -275,17 +262,17 @@ static void pty_set_termios(struct tty_struct *tty,
                                STOP_CHAR(tty) == '\023' &&
                                START_CHAR(tty) == '\021');
                if ((old_flow != new_flow) || extproc) {
-                       spin_lock_irq(&tty->ctrl_lock);
+                       spin_lock_irq(&tty->ctrl.lock);
                        if (old_flow != new_flow) {
-                               tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
+                               tty->ctrl.pktstatus &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
                                if (new_flow)
-                                       tty->ctrl_status |= TIOCPKT_DOSTOP;
+                                       tty->ctrl.pktstatus |= TIOCPKT_DOSTOP;
                                else
-                                       tty->ctrl_status |= TIOCPKT_NOSTOP;
+                                       tty->ctrl.pktstatus |= TIOCPKT_NOSTOP;
                        }
                        if (extproc)
-                               tty->ctrl_status |= TIOCPKT_IOCTL;
-                       spin_unlock_irq(&tty->ctrl_lock);
+                               tty->ctrl.pktstatus |= TIOCPKT_IOCTL;
+                       spin_unlock_irq(&tty->ctrl.lock);
                        wake_up_interruptible(&tty->link->read_wait);
                }
        }
@@ -295,7 +282,7 @@ static void pty_set_termios(struct tty_struct *tty,
 }
 
 /**
- *     pty_do_resize           -       resize event
+ *     pty_resize              -       resize event
  *     @tty: tty being resized
  *     @ws: window size being set.
  *
@@ -346,11 +333,11 @@ static void pty_start(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       if (tty->link && tty->link->packet) {
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               tty->ctrl_status &= ~TIOCPKT_STOP;
-               tty->ctrl_status |= TIOCPKT_START;
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       if (tty->link && tty->link->ctrl.packet) {
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               tty->ctrl.pktstatus &= ~TIOCPKT_STOP;
+               tty->ctrl.pktstatus |= TIOCPKT_START;
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN);
        }
 }
@@ -359,11 +346,11 @@ static void pty_stop(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       if (tty->link && tty->link->packet) {
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               tty->ctrl_status &= ~TIOCPKT_START;
-               tty->ctrl_status |= TIOCPKT_STOP;
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       if (tty->link && tty->link->ctrl.packet) {
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               tty->ctrl.pktstatus &= ~TIOCPKT_START;
+               tty->ctrl.pktstatus |= TIOCPKT_STOP;
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                wake_up_interruptible_poll(&tty->link->read_wait, EPOLLIN);
        }
 }
@@ -525,7 +512,6 @@ static const struct tty_operations master_pty_ops_bsd = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .ioctl = pty_bsd_ioctl,
        .compat_ioctl = pty_bsd_compat_ioctl,
@@ -541,7 +527,6 @@ static const struct tty_operations slave_pty_ops_bsd = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .set_termios = pty_set_termios,
        .cleanup = pty_cleanup,
@@ -626,7 +611,7 @@ static struct cdev ptmx_cdev;
  */
 int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
 {
-       int fd = -1;
+       int fd;
        struct file *filp;
        int retval = -EINVAL;
        struct path path;
@@ -776,7 +761,6 @@ static const struct tty_operations ptm_unix98_ops = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .ioctl = pty_unix98_ioctl,
        .compat_ioctl = pty_unix98_compat_ioctl,
@@ -794,7 +778,6 @@ static const struct tty_operations pty_unix98_ops = {
        .write = pty_write,
        .write_room = pty_write_room,
        .flush_buffer = pty_flush_buffer,
-       .chars_in_buffer = pty_chars_in_buffer,
        .unthrottle = pty_unthrottle,
        .set_termios = pty_set_termios,
        .start = pty_start,
index aead0c0..9cdfcfe 100644 (file)
@@ -798,7 +798,7 @@ void serdev_controller_remove(struct serdev_controller *ctrl)
 EXPORT_SYMBOL_GPL(serdev_controller_remove);
 
 /**
- * serdev_driver_register() - Register client driver with serdev core
+ * __serdev_device_driver_register() - Register client driver with serdev core
  * @sdrv:      client driver to be associated with client-device.
  * @owner:     client driver owner to set.
  *
index d035d08..4caab87 100644 (file)
@@ -34,7 +34,6 @@
 
 struct aspeed_vuart {
        struct device           *dev;
-       void __iomem            *regs;
        struct clk              *clk;
        int                     line;
        struct timer_list       unthrottle_timer;
@@ -64,14 +63,24 @@ static const int unthrottle_timeout = HZ/10;
  * different system (though most of them use 3f8/4).
  */
 
+static inline u8 aspeed_vuart_readb(struct aspeed_vuart *vuart, u8 reg)
+{
+       return readb(vuart->port->port.membase + reg);
+}
+
+static inline void aspeed_vuart_writeb(struct aspeed_vuart *vuart, u8 val, u8 reg)
+{
+       writeb(val, vuart->port->port.membase + reg);
+}
+
 static ssize_t lpc_address_show(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
        struct aspeed_vuart *vuart = dev_get_drvdata(dev);
        u16 addr;
 
-       addr = (readb(vuart->regs + ASPEED_VUART_ADDRH) << 8) |
-               (readb(vuart->regs + ASPEED_VUART_ADDRL));
+       addr = (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRH) << 8) |
+               (aspeed_vuart_readb(vuart, ASPEED_VUART_ADDRL));
 
        return snprintf(buf, PAGE_SIZE - 1, "0x%x\n", addr);
 }
@@ -81,8 +90,8 @@ static int aspeed_vuart_set_lpc_address(struct aspeed_vuart *vuart, u32 addr)
        if (addr > U16_MAX)
                return -EINVAL;
 
-       writeb(addr >> 8, vuart->regs + ASPEED_VUART_ADDRH);
-       writeb(addr >> 0, vuart->regs + ASPEED_VUART_ADDRL);
+       aspeed_vuart_writeb(vuart, addr >> 8, ASPEED_VUART_ADDRH);
+       aspeed_vuart_writeb(vuart, addr >> 0, ASPEED_VUART_ADDRL);
 
        return 0;
 }
@@ -111,7 +120,7 @@ static ssize_t sirq_show(struct device *dev,
        struct aspeed_vuart *vuart = dev_get_drvdata(dev);
        u8 reg;
 
-       reg = readb(vuart->regs + ASPEED_VUART_GCRB);
+       reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRB);
        reg &= ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
        reg >>= ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT;
 
@@ -128,10 +137,10 @@ static int aspeed_vuart_set_sirq(struct aspeed_vuart *vuart, u32 sirq)
        sirq <<= ASPEED_VUART_GCRB_HOST_SIRQ_SHIFT;
        sirq &= ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
 
-       reg = readb(vuart->regs + ASPEED_VUART_GCRB);
+       reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRB);
        reg &= ~ASPEED_VUART_GCRB_HOST_SIRQ_MASK;
        reg |= sirq;
-       writeb(reg, vuart->regs + ASPEED_VUART_GCRB);
+       aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRB);
 
        return 0;
 }
@@ -159,7 +168,7 @@ static ssize_t sirq_polarity_show(struct device *dev,
        struct aspeed_vuart *vuart = dev_get_drvdata(dev);
        u8 reg;
 
-       reg = readb(vuart->regs + ASPEED_VUART_GCRA);
+       reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA);
        reg &= ASPEED_VUART_GCRA_HOST_SIRQ_POLARITY;
 
        return snprintf(buf, PAGE_SIZE - 1, "%u\n", reg ? 1 : 0);
@@ -168,14 +177,14 @@ static ssize_t sirq_polarity_show(struct device *dev,
 static void aspeed_vuart_set_sirq_polarity(struct aspeed_vuart *vuart,
                                           bool polarity)
 {
-       u8 reg = readb(vuart->regs + ASPEED_VUART_GCRA);
+       u8 reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA);
 
        if (polarity)
                reg |= ASPEED_VUART_GCRA_HOST_SIRQ_POLARITY;
        else
                reg &= ~ASPEED_VUART_GCRA_HOST_SIRQ_POLARITY;
 
-       writeb(reg, vuart->regs + ASPEED_VUART_GCRA);
+       aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRA);
 }
 
 static ssize_t sirq_polarity_store(struct device *dev,
@@ -210,14 +219,14 @@ static const struct attribute_group aspeed_vuart_attr_group = {
 
 static void aspeed_vuart_set_enabled(struct aspeed_vuart *vuart, bool enabled)
 {
-       u8 reg = readb(vuart->regs + ASPEED_VUART_GCRA);
+       u8 reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA);
 
        if (enabled)
                reg |= ASPEED_VUART_GCRA_VUART_EN;
        else
                reg &= ~ASPEED_VUART_GCRA_VUART_EN;
 
-       writeb(reg, vuart->regs + ASPEED_VUART_GCRA);
+       aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRA);
 }
 
 static void aspeed_vuart_set_host_tx_discard(struct aspeed_vuart *vuart,
@@ -225,7 +234,7 @@ static void aspeed_vuart_set_host_tx_discard(struct aspeed_vuart *vuart,
 {
        u8 reg;
 
-       reg = readb(vuart->regs + ASPEED_VUART_GCRA);
+       reg = aspeed_vuart_readb(vuart, ASPEED_VUART_GCRA);
 
        /* If the DISABLE_HOST_TX_DISCARD bit is set, discard is disabled */
        if (!discard)
@@ -233,7 +242,7 @@ static void aspeed_vuart_set_host_tx_discard(struct aspeed_vuart *vuart,
        else
                reg &= ~ASPEED_VUART_GCRA_DISABLE_HOST_TX_DISCARD;
 
-       writeb(reg, vuart->regs + ASPEED_VUART_GCRA);
+       aspeed_vuart_writeb(vuart, reg, ASPEED_VUART_GCRA);
 }
 
 static int aspeed_vuart_startup(struct uart_port *uart_port)
@@ -320,7 +329,7 @@ static int aspeed_vuart_handle_irq(struct uart_port *port)
 {
        struct uart_8250_port *up = up_to_u8250p(port);
        unsigned int iir, lsr;
-       int space, count;
+       unsigned int space, count;
 
        iir = serial_port_in(port, UART_IIR);
 
@@ -339,14 +348,12 @@ static int aspeed_vuart_handle_irq(struct uart_port *port)
                        struct aspeed_vuart *vuart = port->private_data;
                        __aspeed_vuart_set_throttle(up, true);
 
-                       if (!timer_pending(&vuart->unthrottle_timer)) {
-                               vuart->port = up;
+                       if (!timer_pending(&vuart->unthrottle_timer))
                                mod_timer(&vuart->unthrottle_timer,
                                          jiffies + unthrottle_timeout);
-                       }
 
                } else {
-                       count = min(space, 256);
+                       count = min(space, 256U);
 
                        do {
                                serial8250_read_char(up, lsr);
@@ -421,13 +428,9 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
        timer_setup(&vuart->unthrottle_timer, aspeed_vuart_unthrottle_exp, 0);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       vuart->regs = devm_ioremap_resource(&pdev->dev, res);
-       if (IS_ERR(vuart->regs))
-               return PTR_ERR(vuart->regs);
 
        memset(&port, 0, sizeof(port));
        port.port.private_data = vuart;
-       port.port.membase = vuart->regs;
        port.port.mapbase = res->start;
        port.port.mapsize = resource_size(res);
        port.port.startup = aspeed_vuart_startup;
@@ -485,7 +488,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
        port.port.iotype = UPIO_MEM;
        port.port.type = PORT_16550A;
        port.port.uartclk = clk;
-       port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF
+       port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
                | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST;
 
        if (of_property_read_bool(np, "no-loopback-test"))
@@ -502,6 +505,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
                goto err_clk_disable;
 
        vuart->line = rc;
+       vuart->port = serial8250_get_port(vuart->line);
 
        rc = of_parse_phandle_with_fixed_args(
                np, "aspeed,sirq-polarity-sense", 2, 0,
index cae61d1..1ce193d 100644 (file)
@@ -172,7 +172,6 @@ static void serial_do_unlink(struct irq_info *i, struct uart_8250_port *up)
 static int serial_link_irq_chain(struct uart_8250_port *up)
 {
        struct hlist_head *h;
-       struct hlist_node *n;
        struct irq_info *i;
        int ret;
 
@@ -180,13 +179,11 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 
        h = &irq_lists[up->port.irq % NR_IRQ_HASH];
 
-       hlist_for_each(n, h) {
-               i = hlist_entry(n, struct irq_info, node);
+       hlist_for_each_entry(i, h, node)
                if (i->irq == up->port.irq)
                        break;
-       }
 
-       if (n == NULL) {
+       if (i == NULL) {
                i = kzalloc(sizeof(struct irq_info), GFP_KERNEL);
                if (i == NULL) {
                        mutex_unlock(&hash_mutex);
@@ -220,25 +217,18 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 
 static void serial_unlink_irq_chain(struct uart_8250_port *up)
 {
-       /*
-        * yes, some broken gcc emit "warning: 'i' may be used uninitialized"
-        * but no, we are not going to take a patch that assigns NULL below.
-        */
        struct irq_info *i;
-       struct hlist_node *n;
        struct hlist_head *h;
 
        mutex_lock(&hash_mutex);
 
        h = &irq_lists[up->port.irq % NR_IRQ_HASH];
 
-       hlist_for_each(n, h) {
-               i = hlist_entry(n, struct irq_info, node);
+       hlist_for_each_entry(i, h, node)
                if (i->irq == up->port.irq)
                        break;
-       }
 
-       BUG_ON(n == NULL);
+       BUG_ON(i == NULL);
        BUG_ON(i->head == NULL);
 
        if (list_empty(i->head))
@@ -331,9 +321,9 @@ static int univ8250_setup_irq(struct uart_8250_port *up)
         * hardware interrupt, we use a timer-based system.  The original
         * driver used to do this with IRQ0.
         */
-       if (!port->irq) {
+       if (!port->irq)
                mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
-       else
+       else
                retval = serial_link_irq_chain(up);
 
        return retval;
@@ -762,6 +752,7 @@ void serial8250_suspend_port(int line)
        if (!console_suspend_enabled && uart_console(port) &&
            port->type != PORT_8250) {
                unsigned char canary = 0xa5;
+
                serial_out(up, UART_SCR, canary);
                if (serial_in(up, UART_SCR) == canary)
                        up->canary = canary;
@@ -915,7 +906,7 @@ static struct platform_device *serial8250_isa_devs;
  */
 static DEFINE_MUTEX(serial_mutex);
 
-static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port)
+static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_port *port)
 {
        int i;
 
@@ -980,7 +971,7 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)
  *
  *     On success the port is ready to use and the line number is returned.
  */
-int serial8250_register_8250_port(struct uart_8250_port *up)
+int serial8250_register_8250_port(const struct uart_8250_port *up)
 {
        struct uart_8250_port *uart;
        int ret = -ENOSPC;
index 0b077b4..bce2872 100644 (file)
@@ -192,6 +192,10 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
        u32 tx_threshold;
        int ret;
 
+       if (IS_ENABLED(CONFIG_SERIAL_8250_BCM7271) &&
+           of_device_is_compatible(ofdev->dev.of_node, "brcm,bcm7271-uart"))
+               return -ENODEV;
+
        port_type = (unsigned long)of_device_get_match_data(&ofdev->dev);
        if (port_type == PORT_UNKNOWN)
                return -EINVAL;
index 8ac11ea..c06631c 100644 (file)
@@ -813,7 +813,7 @@ static void __dma_rx_do_complete(struct uart_8250_port *p)
                               poll_count--)
                                cpu_relax();
 
-                       if (!poll_count)
+                       if (poll_count == -1)
                                dev_err(p->port.dev, "teardown incomplete\n");
                }
        }
index 63ea9c4..3708114 100644 (file)
@@ -306,6 +306,7 @@ static int serial_resume(struct pcmcia_device *link)
 static int serial_probe(struct pcmcia_device *link)
 {
        struct serial_info *info;
+       int ret;
 
        dev_dbg(&link->dev, "serial_attach()\n");
 
@@ -320,7 +321,15 @@ static int serial_probe(struct pcmcia_device *link)
        if (do_sound)
                link->config_flags |= CONF_ENABLE_SPKR;
 
-       return serial_config(link);
+       ret = serial_config(link);
+       if (ret)
+               goto free_info;
+
+       return 0;
+
+free_info:
+       kfree(info);
+       return ret;
 }
 
 static void serial_detach(struct pcmcia_device *link)
index 682f917..24282ad 100644 (file)
@@ -1553,6 +1553,7 @@ config SERIAL_LITEUART_CONSOLE
        bool "LiteUART serial port console support"
        depends on SERIAL_LITEUART=y
        select SERIAL_CORE_CONSOLE
+       select SERIAL_EARLYCON
        help
          Say 'Y' or 'M' here if you wish to use the FPGA-based LiteUART serial
          controller from LiteX SoC builder as the system console
index 78682c1..e14f337 100644 (file)
@@ -1062,7 +1062,7 @@ static void pl011_dma_rx_poll(struct timer_list *t)
        struct tty_port *port = &uap->port.state->port;
        struct pl011_dmarx_data *dmarx = &uap->dmarx;
        struct dma_chan *rxchan = uap->dmarx.chan;
-       unsigned long flags = 0;
+       unsigned long flags;
        unsigned int dmataken = 0;
        unsigned int size = 0;
        struct pl011_sgbuf *sgbuf;
index 1a9444b..596217d 100644 (file)
@@ -149,7 +149,7 @@ static unsigned int arc_serial_tx_empty(struct uart_port *port)
 /*
  * Driver internal routine, used by both tty(serial core) as well as tx-isr
  *  -Called under spinlock in either cases
- *  -also tty->stopped has already been checked
+ *  -also tty->flow.stopped has already been checked
  *     = by uart_start( ) before calling us
  *     = tx_ist checks that too before calling
  */
index 058886d..249ea35 100644 (file)
@@ -30,9 +30,9 @@
 #include <linux/irq.h>
 #include <linux/suspend.h>
 #include <linux/mm.h>
+#include <linux/io.h>
 
 #include <asm/div64.h>
-#include <asm/io.h>
 #include <asm/ioctls.h>
 
 #define PDC_BUFFER_SIZE                512
index 4552742..e9edabc 100644 (file)
@@ -47,8 +47,8 @@
 #include <linux/tty_flip.h>
 
 #include <linux/atomic.h>
+#include <linux/io.h>
 #include <asm/bootinfo.h>
-#include <asm/io.h>
 
 #include <asm/dec/interrupts.h>
 #include <asm/dec/kn01.h>
@@ -115,7 +115,7 @@ static void dz_out(struct dz_port *dport, unsigned offset, u16 value)
  * rs_stop () and rs_start ()
  *
  * These routines are called before setting or resetting
- * tty->stopped. They enable or disable transmitter interrupts,
+ * tty->flow.stopped. They enable or disable transmitter interrupts,
  * as necessary.
  * ------------------------------------------------------------
  */
index 7940350..508128d 100644 (file)
@@ -824,21 +824,18 @@ static unsigned int lpuart32_tx_empty(struct uart_port *port)
 
 static void lpuart_txint(struct lpuart_port *sport)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&sport->port.lock, flags);
+       spin_lock(&sport->port.lock);
        lpuart_transmit_buffer(sport);
-       spin_unlock_irqrestore(&sport->port.lock, flags);
+       spin_unlock(&sport->port.lock);
 }
 
 static void lpuart_rxint(struct lpuart_port *sport)
 {
        unsigned int flg, ignored = 0, overrun = 0;
        struct tty_port *port = &sport->port.state->port;
-       unsigned long flags;
        unsigned char rx, sr;
 
-       spin_lock_irqsave(&sport->port.lock, flags);
+       spin_lock(&sport->port.lock);
 
        while (!(readb(sport->port.membase + UARTSFIFO) & UARTSFIFO_RXEMPT)) {
                flg = TTY_NORMAL;
@@ -850,7 +847,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
                sr = readb(sport->port.membase + UARTSR1);
                rx = readb(sport->port.membase + UARTDR);
 
-               if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
+               if (uart_prepare_sysrq_char(&sport->port, rx))
                        continue;
 
                if (sr & (UARTSR1_PE | UARTSR1_OR | UARTSR1_FE)) {
@@ -896,28 +893,26 @@ out:
                writeb(UARTSFIFO_RXOF, sport->port.membase + UARTSFIFO);
        }
 
-       spin_unlock_irqrestore(&sport->port.lock, flags);
+       uart_unlock_and_check_sysrq(&sport->port);
 
        tty_flip_buffer_push(port);
 }
 
 static void lpuart32_txint(struct lpuart_port *sport)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&sport->port.lock, flags);
+       spin_lock(&sport->port.lock);
        lpuart32_transmit_buffer(sport);
-       spin_unlock_irqrestore(&sport->port.lock, flags);
+       spin_unlock(&sport->port.lock);
 }
 
 static void lpuart32_rxint(struct lpuart_port *sport)
 {
        unsigned int flg, ignored = 0;
        struct tty_port *port = &sport->port.state->port;
-       unsigned long flags;
        unsigned long rx, sr;
+       bool is_break;
 
-       spin_lock_irqsave(&sport->port.lock, flags);
+       spin_lock(&sport->port.lock);
 
        while (!(lpuart32_read(&sport->port, UARTFIFO) & UARTFIFO_RXEMPT)) {
                flg = TTY_NORMAL;
@@ -928,16 +923,29 @@ static void lpuart32_rxint(struct lpuart_port *sport)
                 */
                sr = lpuart32_read(&sport->port, UARTSTAT);
                rx = lpuart32_read(&sport->port, UARTDATA);
-               rx &= 0x3ff;
+               rx &= UARTDATA_MASK;
+
+               /*
+                * The LPUART can't distinguish between a break and a framing error,
+                * thus we assume it is a break if the received data is zero.
+                */
+               is_break = (sr & UARTSTAT_FE) && !rx;
 
-               if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
+               if (is_break && uart_handle_break(&sport->port))
+                       continue;
+
+               if (uart_prepare_sysrq_char(&sport->port, rx))
                        continue;
 
                if (sr & (UARTSTAT_PE | UARTSTAT_OR | UARTSTAT_FE)) {
-                       if (sr & UARTSTAT_PE)
-                               sport->port.icount.parity++;
-                       else if (sr & UARTSTAT_FE)
+                       if (sr & UARTSTAT_PE) {
+                               if (is_break)
+                                       sport->port.icount.brk++;
+                               else
+                                       sport->port.icount.parity++;
+                       } else if (sr & UARTSTAT_FE) {
                                sport->port.icount.frame++;
+                       }
 
                        if (sr & UARTSTAT_OR)
                                sport->port.icount.overrun++;
@@ -950,22 +958,24 @@ static void lpuart32_rxint(struct lpuart_port *sport)
 
                        sr &= sport->port.read_status_mask;
 
-                       if (sr & UARTSTAT_PE)
-                               flg = TTY_PARITY;
-                       else if (sr & UARTSTAT_FE)
+                       if (sr & UARTSTAT_PE) {
+                               if (is_break)
+                                       flg = TTY_BREAK;
+                               else
+                                       flg = TTY_PARITY;
+                       } else if (sr & UARTSTAT_FE) {
                                flg = TTY_FRAME;
+                       }
 
                        if (sr & UARTSTAT_OR)
                                flg = TTY_OVERRUN;
-
-                       sport->port.sysrq = 0;
                }
 
                tty_insert_flip_char(port, rx, flg);
        }
 
 out:
-       spin_unlock_irqrestore(&sport->port.lock, flags);
+       uart_unlock_and_check_sysrq(&sport->port);
 
        tty_flip_buffer_push(port);
 }
@@ -1393,58 +1403,54 @@ static int lpuart32_config_rs485(struct uart_port *port,
 
 static unsigned int lpuart_get_mctrl(struct uart_port *port)
 {
-       unsigned int temp = 0;
-       unsigned char reg;
-
-       reg = readb(port->membase + UARTMODEM);
-       if (reg & UARTMODEM_TXCTSE)
-               temp |= TIOCM_CTS;
+       unsigned int mctrl = 0;
+       u8 reg;
 
-       if (reg & UARTMODEM_RXRTSE)
-               temp |= TIOCM_RTS;
+       reg = readb(port->membase + UARTCR1);
+       if (reg & UARTCR1_LOOPS)
+               mctrl |= TIOCM_LOOP;
 
-       return temp;
+       return mctrl;
 }
 
 static unsigned int lpuart32_get_mctrl(struct uart_port *port)
 {
-       unsigned int temp = 0;
-       unsigned long reg;
-
-       reg = lpuart32_read(port, UARTMODIR);
-       if (reg & UARTMODIR_TXCTSE)
-               temp |= TIOCM_CTS;
+       unsigned int mctrl = 0;
+       u32 reg;
 
-       if (reg & UARTMODIR_RXRTSE)
-               temp |= TIOCM_RTS;
+       reg = lpuart32_read(port, UARTCTRL);
+       if (reg & UARTCTRL_LOOPS)
+               mctrl |= TIOCM_LOOP;
 
-       return temp;
+       return mctrl;
 }
 
 static void lpuart_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
-       unsigned char temp;
-       struct lpuart_port *sport = container_of(port,
-                               struct lpuart_port, port);
+       u8 reg;
 
-       /* Make sure RXRTSE bit is not set when RS485 is enabled */
-       if (!(sport->port.rs485.flags & SER_RS485_ENABLED)) {
-               temp = readb(sport->port.membase + UARTMODEM) &
-                       ~(UARTMODEM_RXRTSE | UARTMODEM_TXCTSE);
+       reg = readb(port->membase + UARTCR1);
 
-               if (mctrl & TIOCM_RTS)
-                       temp |= UARTMODEM_RXRTSE;
+       /* for internal loopback we need LOOPS=1 and RSRC=0 */
+       reg &= ~(UARTCR1_LOOPS | UARTCR1_RSRC);
+       if (mctrl & TIOCM_LOOP)
+               reg |= UARTCR1_LOOPS;
 
-               if (mctrl & TIOCM_CTS)
-                       temp |= UARTMODEM_TXCTSE;
-
-               writeb(temp, port->membase + UARTMODEM);
-       }
+       writeb(reg, port->membase + UARTCR1);
 }
 
 static void lpuart32_set_mctrl(struct uart_port *port, unsigned int mctrl)
 {
+       u32 reg;
+
+       reg = lpuart32_read(port, UARTCTRL);
 
+       /* for internal loopback we need LOOPS=1 and RSRC=0 */
+       reg &= ~(UARTCTRL_LOOPS | UARTCTRL_RSRC);
+       if (mctrl & TIOCM_LOOP)
+               reg |= UARTCTRL_LOOPS;
+
+       lpuart32_write(port, reg, UARTCTRL);
 }
 
 static void lpuart_break_ctl(struct uart_port *port, int break_state)
@@ -1581,6 +1587,9 @@ static void lpuart_tx_dma_startup(struct lpuart_port *sport)
        u32 uartbaud;
        int ret;
 
+       if (uart_console(&sport->port))
+               goto err;
+
        if (!sport->dma_tx_chan)
                goto err;
 
@@ -1610,6 +1619,9 @@ static void lpuart_rx_dma_startup(struct lpuart_port *sport)
        int ret;
        unsigned char cr3;
 
+       if (uart_console(&sport->port))
+               goto err;
+
        if (!sport->dma_rx_chan)
                goto err;
 
@@ -1625,7 +1637,7 @@ static void lpuart_rx_dma_startup(struct lpuart_port *sport)
        sport->lpuart_dma_rx_use = true;
        rx_dma_timer_init(sport);
 
-       if (sport->port.has_sysrq) {
+       if (sport->port.has_sysrq && !lpuart_is_32(sport)) {
                cr3 = readb(sport->port.membase + UARTCR3);
                cr3 |= UARTCR3_FEIE;
                writeb(cr3, sport->port.membase + UARTCR3);
@@ -2278,7 +2290,7 @@ lpuart_console_write(struct console *co, const char *s, unsigned int count)
        unsigned long flags;
        int locked = 1;
 
-       if (sport->port.sysrq || oops_in_progress)
+       if (oops_in_progress)
                locked = spin_trylock_irqsave(&sport->port.lock, flags);
        else
                spin_lock_irqsave(&sport->port.lock, flags);
@@ -2308,7 +2320,7 @@ lpuart32_console_write(struct console *co, const char *s, unsigned int count)
        unsigned long flags;
        int locked = 1;
 
-       if (sport->port.sysrq || oops_in_progress)
+       if (oops_in_progress)
                locked = spin_trylock_irqsave(&sport->port.lock, flags);
        else
                spin_lock_irqsave(&sport->port.lock, flags);
@@ -2414,6 +2426,9 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud,
 
        bd = lpuart32_read(&sport->port, UARTBAUD);
        bd &= UARTBAUD_SBR_MASK;
+       if (!bd)
+               return;
+
        sbr = bd;
        uartclk = lpuart_get_baud_clk_rate(sport);
        /*
index 9e9abfc..03a2fe9 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/firmware.h>
 #include <linux/bitops.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 #include <linux/uaccess.h>
 
index 7d5a8df..4b83860 100644 (file)
@@ -1975,8 +1975,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
 {
        struct imx_port *sport = imx_uart_ports[co->index];
        struct imx_port_ucrs old_ucr;
+       unsigned long flags;
        unsigned int ucr1;
-       unsigned long flags = 0;
        int locked = 1;
 
        if (sport->port.sysrq)
index 86fff69..f4dc5fe 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/spinlock.h>
 #include <linux/init.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/sgialib.h>
 #include <asm/sgi/ioc.h>
index db059b6..3e7c6ee 100644 (file)
@@ -115,7 +115,7 @@ static void kgdb_tty_recv(int ch)
 static int kgdb_nmi_poll_one_knock(void)
 {
        static int n;
-       int c = -1;
+       int c;
        const char *magic = kgdb_nmi_magic;
        size_t m = strlen(magic);
        bool printch = false;
@@ -298,7 +298,7 @@ static void kgdb_nmi_tty_hangup(struct tty_struct *tty)
        tty_port_hangup(&priv->port);
 }
 
-static int kgdb_nmi_tty_write_room(struct tty_struct *tty)
+static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty)
 {
        /* Actually, we can handle any amount as we use polled writes. */
        return 2048;
index 0b06770..dbc0559 100644 (file)
@@ -370,6 +370,27 @@ static int __init liteuart_console_init(void)
        return 0;
 }
 console_initcall(liteuart_console_init);
+
+static void early_liteuart_write(struct console *console, const char *s,
+                                   unsigned int count)
+{
+       struct earlycon_device *device = console->data;
+       struct uart_port *port = &device->port;
+
+       uart_console_write(port, s, count, liteuart_putchar);
+}
+
+static int __init early_liteuart_setup(struct earlycon_device *device,
+                                      const char *options)
+{
+       if (!device->port.membase)
+               return -ENODEV;
+
+       device->con->write = early_liteuart_write;
+       return 0;
+}
+
+OF_EARLYCON_DECLARE(liteuart, "litex,liteuart", early_liteuart_setup);
 #endif /* CONFIG_SERIAL_LITEUART_CONSOLE */
 
 static int __init liteuart_init(void)
index 3cbc757..0c1e4df 100644 (file)
@@ -552,7 +552,7 @@ static int max310x_update_best_err(unsigned long f, long *besterr)
        return 1;
 }
 
-static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
+static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
                               unsigned long freq, bool xtal)
 {
        unsigned int div, clksrc, pllcfg = 0;
@@ -618,7 +618,7 @@ static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
                }
        }
 
-       return (int)bestfreq;
+       return bestfreq;
 }
 
 static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len)
@@ -1253,9 +1253,10 @@ static int max310x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
 static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype,
                         struct regmap *regmap, int irq)
 {
-       int i, ret, fmin, fmax, freq, uartclk;
+       int i, ret, fmin, fmax, freq;
        struct max310x_port *s;
-       bool xtal = false;
+       u32 uartclk = 0;
+       bool xtal;
 
        if (IS_ERR(regmap))
                return PTR_ERR(regmap);
@@ -1267,24 +1268,20 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
                return -ENOMEM;
        }
 
+       /* Always ask for fixed clock rate from a property. */
+       device_property_read_u32(dev, "clock-frequency", &uartclk);
+
        s->clk = devm_clk_get_optional(dev, "osc");
        if (IS_ERR(s->clk))
                return PTR_ERR(s->clk);
        if (s->clk) {
-               fmin = 500000;
-               fmax = 35000000;
+               xtal = false;
        } else {
                s->clk = devm_clk_get_optional(dev, "xtal");
                if (IS_ERR(s->clk))
                        return PTR_ERR(s->clk);
-               if (s->clk) {
-                       fmin = 1000000;
-                       fmax = 4000000;
-                       xtal = true;
-               } else {
-                       dev_err(dev, "Cannot get clock\n");
-                       return -EINVAL;
-               }
+
+               xtal = true;
        }
 
        ret = clk_prepare_enable(s->clk);
@@ -1292,6 +1289,21 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
                return ret;
 
        freq = clk_get_rate(s->clk);
+       if (freq == 0)
+               freq = uartclk;
+       if (freq == 0) {
+               dev_err(dev, "Cannot get clock rate\n");
+               return -EINVAL;
+       }
+
+       if (xtal) {
+               fmin = 1000000;
+               fmax = 4000000;
+       } else {
+               fmin = 500000;
+               fmax = 35000000;
+       }
+
        /* Check frequency limits */
        if (freq < fmin || freq > fmax) {
                ret = -ERANGE;
index 529cd02..efee393 100644 (file)
@@ -715,13 +715,15 @@ static int meson_uart_probe(struct platform_device *pdev)
 {
        struct resource *res_mem, *res_irq;
        struct uart_port *port;
+       u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */
        int ret = 0;
-       int id = -1;
 
        if (pdev->dev.of_node)
                pdev->id = of_alias_get_id(pdev->dev.of_node, "serial");
 
        if (pdev->id < 0) {
+               int id;
+
                for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) {
                        if (!meson_ports[id]) {
                                pdev->id = id;
@@ -741,6 +743,8 @@ static int meson_uart_probe(struct platform_device *pdev)
        if (!res_irq)
                return -ENODEV;
 
+       of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize);
+
        if (meson_ports[pdev->id]) {
                dev_err(&pdev->dev, "port %d already allocated\n", pdev->id);
                return -EBUSY;
@@ -770,7 +774,7 @@ static int meson_uart_probe(struct platform_device *pdev)
        port->type = PORT_MESON;
        port->x_char = 0;
        port->ops = &meson_uart_ops;
-       port->fifosize = 64;
+       port->fifosize = fifosize;
 
        meson_ports[pdev->id] = port;
        platform_set_drvdata(pdev, port);
index 47ab280..be640d9 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/console.h>
 #include <linux/delay.h> /* for udelay */
 #include <linux/device.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/parisc-device.h>
 
index 84e8158..9e81b09 100644 (file)
@@ -626,7 +626,7 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)
 static unsigned int serial_omap_tx_empty(struct uart_port *port)
 {
        struct uart_omap_port *up = to_uart_omap_port(port);
-       unsigned long flags = 0;
+       unsigned long flags;
        unsigned int ret = 0;
 
        pm_runtime_get_sync(up->dev);
@@ -704,7 +704,7 @@ static void serial_omap_set_mctrl(struct uart_port *port, unsigned int mctrl)
 static void serial_omap_break_ctl(struct uart_port *port, int break_state)
 {
        struct uart_omap_port *up = to_uart_omap_port(port);
-       unsigned long flags = 0;
+       unsigned long flags;
 
        dev_dbg(up->port.dev, "serial_omap_break_ctl+%d\n", up->port.line);
        pm_runtime_get_sync(up->dev);
@@ -722,7 +722,7 @@ static void serial_omap_break_ctl(struct uart_port *port, int break_state)
 static int serial_omap_startup(struct uart_port *port)
 {
        struct uart_omap_port *up = to_uart_omap_port(port);
-       unsigned long flags = 0;
+       unsigned long flags;
        int retval;
 
        /*
@@ -797,7 +797,7 @@ static int serial_omap_startup(struct uart_port *port)
 static void serial_omap_shutdown(struct uart_port *port)
 {
        struct uart_omap_port *up = to_uart_omap_port(port);
-       unsigned long flags = 0;
+       unsigned long flags;
 
        dev_dbg(up->port.dev, "serial_omap_shutdown+%d\n", up->port.line);
 
@@ -845,7 +845,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
 {
        struct uart_omap_port *up = to_uart_omap_port(port);
        unsigned char cval = 0;
-       unsigned long flags = 0;
+       unsigned long flags;
        unsigned int baud, quot;
 
        switch (termios->c_cflag & CSIZE) {
index d6aef8a..12ce150 100644 (file)
@@ -47,7 +47,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <asm/sections.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 
 #ifdef CONFIG_PPC_PMAC
index 23d729e..463f84a 100644 (file)
@@ -1338,7 +1338,7 @@ static const struct uart_ops qcom_geni_uart_pops = {
 static int qcom_geni_serial_probe(struct platform_device *pdev)
 {
        int ret = 0;
-       int line = -1;
+       int line;
        struct qcom_geni_serial_port *port;
        struct uart_port *uport;
        struct resource *res;
index d9e4b67..9fbc611 100644 (file)
@@ -2220,8 +2220,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
                        default:
                                dev_warn(&pdev->dev, "unsupported reg-io-width (%d)\n",
                                                prop);
-                               ret = -EINVAL;
-                               break;
+                               return -EINVAL;
                        }
                }
        }
index 22c7bc9..738df6d 100644 (file)
@@ -34,7 +34,7 @@
 #include <linux/types.h>
 
 #include <linux/refcount.h>
-#include <asm/io.h>
+#include <linux/io.h>
 
 #include <asm/sibyte/sb1250.h>
 #include <asm/sibyte/sb1250_uart.h>
index 9adb836..acbb615 100644 (file)
@@ -1208,8 +1208,16 @@ static int sc16is7xx_probe(struct device *dev,
        /* Always ask for fixed clock rate from a property. */
        device_property_read_u32(dev, "clock-frequency", &uartclk);
 
-       s->clk = devm_clk_get(dev, NULL);
-       if (IS_ERR(s->clk)) {
+       s->clk = devm_clk_get_optional(dev, NULL);
+       if (IS_ERR(s->clk))
+               return PTR_ERR(s->clk);
+
+       ret = clk_prepare_enable(s->clk);
+       if (ret)
+               return ret;
+
+       freq = clk_get_rate(s->clk);
+       if (freq == 0) {
                if (uartclk)
                        freq = uartclk;
                if (pfreq)
@@ -1217,13 +1225,7 @@ static int sc16is7xx_probe(struct device *dev,
                if (freq)
                        dev_dbg(dev, "Clock frequency: %luHz\n", freq);
                else
-                       return PTR_ERR(s->clk);
-       } else {
-               ret = clk_prepare_enable(s->clk);
-               if (ret)
-                       return ret;
-
-               freq = clk_get_rate(s->clk);
+                       return -EINVAL;
        }
 
        s->regmap = regmap;
@@ -1358,8 +1360,7 @@ out_thread:
        kthread_stop(s->kworker_task);
 
 out_clk:
-       if (!IS_ERR(s->clk))
-               clk_disable_unprepare(s->clk);
+       clk_disable_unprepare(s->clk);
 
        return ret;
 }
@@ -1383,8 +1384,7 @@ static int sc16is7xx_remove(struct device *dev)
        kthread_flush_worker(&s->kworker);
        kthread_stop(s->kworker_task);
 
-       if (!IS_ERR(s->clk))
-               clk_disable_unprepare(s->clk);
+       clk_disable_unprepare(s->clk);
 
        return 0;
 }
index 18ff85a..642e24d 100644 (file)
@@ -184,8 +184,8 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
                int init_hw)
 {
        struct uart_port *uport = uart_port_check(state);
+       unsigned long flags;
        unsigned long page;
-       unsigned long flags = 0;
        int retval = 0;
 
        if (uport->type == PORT_UNKNOWN)
@@ -275,7 +275,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 {
        struct uart_port *uport = uart_port_check(state);
        struct tty_port *port = &state->port;
-       unsigned long flags = 0;
+       unsigned long flags;
        char *xmit_buf = NULL;
 
        /*
@@ -616,12 +616,12 @@ static int uart_write(struct tty_struct *tty,
        return ret;
 }
 
-static int uart_write_room(struct tty_struct *tty)
+static unsigned int uart_write_room(struct tty_struct *tty)
 {
        struct uart_state *state = tty->driver_data;
        struct uart_port *port;
        unsigned long flags;
-       int ret;
+       unsigned int ret;
 
        port = uart_port_lock(state, flags);
        ret = uart_circ_chars_free(&state->xmit);
@@ -629,12 +629,12 @@ static int uart_write_room(struct tty_struct *tty)
        return ret;
 }
 
-static int uart_chars_in_buffer(struct tty_struct *tty)
+static unsigned int uart_chars_in_buffer(struct tty_struct *tty)
 {
        struct uart_state *state = tty->driver_data;
        struct uart_port *port;
        unsigned long flags;
-       int ret;
+       unsigned int ret;
 
        port = uart_port_lock(state, flags);
        ret = uart_circ_chars_pending(&state->xmit);
@@ -3029,26 +3029,28 @@ out:
 /*
  *     Are the two ports equivalent?
  */
-int uart_match_port(struct uart_port *port1, struct uart_port *port2)
+bool uart_match_port(const struct uart_port *port1,
+               const struct uart_port *port2)
 {
        if (port1->iotype != port2->iotype)
-               return 0;
+               return false;
 
        switch (port1->iotype) {
        case UPIO_PORT:
-               return (port1->iobase == port2->iobase);
+               return port1->iobase == port2->iobase;
        case UPIO_HUB6:
-               return (port1->iobase == port2->iobase) &&
-                      (port1->hub6   == port2->hub6);
+               return port1->iobase == port2->iobase &&
+                      port1->hub6   == port2->hub6;
        case UPIO_MEM:
        case UPIO_MEM16:
        case UPIO_MEM32:
        case UPIO_MEM32BE:
        case UPIO_AU:
        case UPIO_TSI:
-               return (port1->mapbase == port2->mapbase);
+               return port1->mapbase == port2->mapbase;
        }
-       return 0;
+
+       return false;
 }
 EXPORT_SYMBOL(uart_match_port);
 
index 0a7e5b7..aaca4fe 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 
 static char *serial_version = "1.11";
 static char *serial_name = "TX39/49 Serial driver";
index e704851..87e480c 100644 (file)
@@ -65,7 +65,7 @@ static struct uart_driver asc_uart_driver;
 /* ASC_RXBUF */
 #define ASC_RXBUF_PE                   0x100
 #define ASC_RXBUF_FE                   0x200
-/**
+/*
  * Some of status comes from higher bits of the character and some come from
  * the status register. Combining both of them in to single status using dummy
  * bits.
@@ -478,7 +478,7 @@ static void asc_pm(struct uart_port *port, unsigned int state,
                unsigned int oldstate)
 {
        struct asc_port *ascport = to_asc_port(port);
-       unsigned long flags = 0;
+       unsigned long flags;
        u32 ctl;
 
        switch (state) {
index c2ae7b3..bf188bd 100644 (file)
@@ -980,7 +980,7 @@ static void stm32_usart_pm(struct uart_port *port, unsigned int state,
                        struct stm32_port, port);
        const struct stm32_usart_offsets *ofs = &stm32port->info->ofs;
        const struct stm32_usart_config *cfg = &stm32port->info->cfg;
-       unsigned long flags = 0;
+       unsigned long flags;
 
        switch (state) {
        case UART_PM_STATE_ON:
index bab551f..92e5726 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/init.h>
 #include <linux/of_device.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
 #include <asm/setup.h>
index 12c2468..425a016 100644 (file)
@@ -39,7 +39,7 @@
 #include <linux/delay.h>
 #include <linux/of_device.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
 #include <asm/setup.h>
index 001e19d..1a54e3e 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/init.h>
 #include <linux/of_device.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
 #include <asm/setup.h>
index eeb4b65..647198b 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <asm/vr41xx/siu.h>
 #include <asm/vr41xx/vr41xx.h>
 
index 67a2db6..bafdf75 100644 (file)
@@ -484,7 +484,7 @@ static unsigned int cdns_uart_set_baud_rate(struct uart_port *port,
 
 #ifdef CONFIG_COMMON_CLK
 /**
- * cdns_uart_clk_notitifer_cb - Clock notifier callback
+ * cdns_uart_clk_notifier_cb - Clock notifier callback
  * @nb:                Notifier block
  * @event:     Notify event
  * @data:      Notifier data
@@ -497,8 +497,8 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,
        struct uart_port *port;
        int locked = 0;
        struct clk_notifier_data *ndata = data;
-       unsigned long flags = 0;
        struct cdns_uart *cdns_uart = to_cdns_uart(nb);
+       unsigned long flags;
 
        port = cdns_uart->port;
        if (port->suspended)
@@ -1210,7 +1210,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
                                unsigned int count)
 {
        struct uart_port *port = console_port;
-       unsigned long flags = 0;
+       unsigned long flags;
        unsigned int imr, ctrl;
        int locked = 1;
 
@@ -1308,7 +1308,7 @@ static int cdns_uart_suspend(struct device *device)
        may_wake = device_may_wakeup(device);
 
        if (console_suspend_enabled && uart_console(port) && may_wake) {
-               unsigned long flags = 0;
+               unsigned long flags;
 
                spin_lock_irqsave(&port->lock, flags);
                /* Empty the receive FIFO 1st before making changes */
@@ -1339,7 +1339,7 @@ static int cdns_uart_resume(struct device *device)
 {
        struct uart_port *port = dev_get_drvdata(device);
        struct cdns_uart *cdns_uart = port->private_data;
-       unsigned long flags = 0;
+       unsigned long flags;
        u32 ctrl_reg;
        int may_wake;
 
index 5523cf7..cf87dc6 100644 (file)
@@ -768,7 +768,7 @@ static int write(struct tty_struct *tty,
        if (!info->tx_buf || (count > info->max_frame_size))
                return -EIO;
 
-       if (!count || tty->stopped || tty->hw_stopped)
+       if (!count || tty->flow.stopped || tty->hw_stopped)
                return 0;
 
        spin_lock_irqsave(&info->lock, flags);
@@ -868,15 +868,15 @@ exit:
        DBGINFO(("%s wait_until_sent exit\n", info->device_name));
 }
 
-static int write_room(struct tty_struct *tty)
+static unsigned int write_room(struct tty_struct *tty)
 {
        struct slgt_info *info = tty->driver_data;
-       int ret;
+       unsigned int ret;
 
        if (sanity_check(info, tty->name, "write_room"))
                return 0;
        ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE;
-       DBGINFO(("%s write_room=%d\n", info->device_name, ret));
+       DBGINFO(("%s write_room=%u\n", info->device_name, ret));
        return ret;
 }
 
@@ -889,7 +889,7 @@ static void flush_chars(struct tty_struct *tty)
                return;
        DBGINFO(("%s flush_chars entry tx_count=%d\n", info->device_name, info->tx_count));
 
-       if (info->tx_count <= 0 || tty->stopped ||
+       if (info->tx_count <= 0 || tty->flow.stopped ||
            tty->hw_stopped || !info->tx_buf)
                return;
 
@@ -1254,14 +1254,14 @@ static int synclink_gt_proc_show(struct seq_file *m, void *v)
 /*
  * return count of bytes in transmit buffer
  */
-static int chars_in_buffer(struct tty_struct *tty)
+static unsigned int chars_in_buffer(struct tty_struct *tty)
 {
        struct slgt_info *info = tty->driver_data;
-       int count;
+       unsigned int count;
        if (sanity_check(info, tty->name, "chars_in_buffer"))
                return 0;
        count = tbuf_bytes(info);
-       DBGINFO(("%s chars_in_buffer()=%d\n", info->device_name, count));
+       DBGINFO(("%s chars_in_buffer()=%u\n", info->device_name, count));
        return count;
 }
 
@@ -2241,7 +2241,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
                else
 #endif
                {
-                       if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) {
+                       if (info->port.tty && (info->port.tty->flow.stopped || info->port.tty->hw_stopped)) {
                                tx_stop(info);
                                return;
                        }
index 48b5de6..426b125 100644 (file)
@@ -147,7 +147,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
        int iclose = ibaud/50, oclose = obaud/50;
        int ibinput = 0;
 
-       if (obaud == 0)                 /* CD dropped             */
+       if (obaud == 0)                 /* CD dropped */
                ibaud = 0;              /* Clear ibaud to be sure */
 
        termios->c_ispeed = ibaud;
@@ -159,8 +159,9 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 #endif
 #ifdef BOTHER
        /* If the user asked for a precise weird speed give a precise weird
-          answer. If they asked for a Bfoo speed they may have problems
-          digesting non-exact replies so fuzz a bit */
+        * answer. If they asked for a Bfoo speed they may have problems
+        * digesting non-exact replies so fuzz a bit.
+        */
 
        if ((termios->c_cflag & CBAUD) == BOTHER) {
                oclose = 0;
@@ -191,7 +192,8 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
                if (ibaud - iclose <= baud_table[i] &&
                    ibaud + iclose >= baud_table[i]) {
                        /* For the case input == output don't set IBAUD bits
-                          if the user didn't do so */
+                        * if the user didn't do so.
+                        */
                        if (ofound == i && !ibinput)
                                ifound  = i;
 #ifdef IBSHIFT
@@ -211,7 +213,8 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
        if (ofound == -1)
                termios->c_cflag |= BOTHER;
        /* Set exact input bits only if the input and output differ or the
-          user already did */
+        * user already did.
+        */
        if (ifound == -1 && (ibaud != obaud || ibinput))
                termios->c_cflag |= (BOTHER << IBSHIFT);
 #else
index 9733469..635d0af 100644 (file)
@@ -32,8 +32,8 @@
  * We default to dicing tty buffer allocations to this many characters
  * in order to avoid multiple page allocations. We know the size of
  * tty_buffer itself but it must also be taken into account that the
- * the buffer is 256 byte aligned. See tty_buffer_find for the allocation
- * logic this must match
+ * buffer is 256 byte aligned. See tty_buffer_find for the allocation
+ * logic this must match.
  */
 
 #define TTY_BUFFER_PAGE        (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
@@ -88,9 +88,10 @@ EXPORT_SYMBOL_GPL(tty_buffer_unlock_exclusive);
  *     pre-allocate if memory guarantee is required).
  */
 
-int tty_buffer_space_avail(struct tty_port *port)
+unsigned int tty_buffer_space_avail(struct tty_port *port)
 {
        int space = port->buf.mem_limit - atomic_read(&port->buf.mem_used);
+
        return max(space, 0);
 }
 EXPORT_SYMBOL_GPL(tty_buffer_space_avail);
@@ -169,7 +170,8 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size)
        }
 
        /* Should possibly check if this fails for the largest buffer we
-          have queued and recycle that ? */
+        * have queued and recycle that ?
+        */
        if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit)
                return NULL;
        p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC);
@@ -242,7 +244,7 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld)
 }
 
 /**
- *     tty_buffer_request_room         -       grow tty buffer if needed
+ *     __tty_buffer_request_room               -       grow tty buffer if needed
  *     @port: tty port
  *     @size: size desired
  *     @flags: buffer flags if new buffer allocated (default = 0)
@@ -312,11 +314,13 @@ int tty_insert_flip_string_fixed_flag(struct tty_port *port,
                const unsigned char *chars, char flag, size_t size)
 {
        int copied = 0;
+
        do {
                int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
                int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0;
                int space = __tty_buffer_request_room(port, goal, flags);
                struct tty_buffer *tb = port->buf.tail;
+
                if (unlikely(space == 0))
                        break;
                memcpy(char_buf_ptr(tb, tb->used), chars, space);
@@ -326,7 +330,8 @@ int tty_insert_flip_string_fixed_flag(struct tty_port *port,
                copied += space;
                chars += space;
                /* There is a small chance that we need to split the data over
-                  several buffers. If this is the case we must loop */
+                * several buffers. If this is the case we must loop.
+                */
        } while (unlikely(size > copied));
        return copied;
 }
@@ -348,10 +353,12 @@ int tty_insert_flip_string_flags(struct tty_port *port,
                const unsigned char *chars, const char *flags, size_t size)
 {
        int copied = 0;
+
        do {
                int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
                int space = tty_buffer_request_room(port, goal);
                struct tty_buffer *tb = port->buf.tail;
+
                if (unlikely(space == 0))
                        break;
                memcpy(char_buf_ptr(tb, tb->used), chars, space);
@@ -361,7 +368,8 @@ int tty_insert_flip_string_flags(struct tty_port *port,
                chars += space;
                flags += space;
                /* There is a small chance that we need to split the data over
-                  several buffers. If this is the case we must loop */
+                * several buffers. If this is the case we must loop.
+                */
        } while (unlikely(size > copied));
        return copied;
 }
@@ -431,8 +439,10 @@ int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars,
                size_t size)
 {
        int space = __tty_buffer_request_room(port, size, TTYB_NORMAL);
+
        if (likely(space)) {
                struct tty_buffer *tb = port->buf.tail;
+
                *chars = char_buf_ptr(tb, tb->used);
                if (~tb->flags & TTYB_NORMAL)
                        memset(flag_buf_ptr(tb, tb->used), TTY_NORMAL, space);
@@ -455,7 +465,7 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string);
  *     Returns the number of bytes processed
  */
 int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p,
-                         char *f, int count)
+                         const char *f, int count)
 {
        if (ld->ops->receive_buf2)
                count = ld->ops->receive_buf2(ld->tty, p, f, count);
@@ -472,7 +482,7 @@ static int
 receive_buf(struct tty_port *port, struct tty_buffer *head, int count)
 {
        unsigned char *p = char_buf_ptr(head, head->read);
-       char          *f = NULL;
+       const char *f = NULL;
        int n;
 
        if (~head->flags & TTYB_NORMAL)
index 5b5e996..26debec 100644 (file)
@@ -33,7 +33,7 @@
  *     -- Nick Holloway <alfie@dcs.warwick.ac.uk>, 27th May 1993.
  *
  * Rewrote canonical mode and added more termios flags.
- *     -- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94
+ *     -- julian@uhunix.uhcc.hawaii.edu (J. Cowley), 13Jan94
  *
  * Reorganized FASYNC support so mouse code can share it.
  *     -- ctm@ardi.com, 9Sep95
@@ -131,12 +131,12 @@ struct ktermios tty_std_termios = {       /* for the benefit of tty drivers  */
        .c_ospeed = 38400,
        /* .c_line = N_TTY, */
 };
-
 EXPORT_SYMBOL(tty_std_termios);
 
 /* This list gets poked at by procfs and various bits of boot up code. This
-   could do with some rationalisation such as pulling the tty proc function
-   into this file */
+ * could do with some rationalisation such as pulling the tty proc function
+ * into this file.
+ */
 
 LIST_HEAD(tty_drivers);                        /* linked list of tty drivers */
 
@@ -248,7 +248,6 @@ const char *tty_name(const struct tty_struct *tty)
                return "NULL tty";
        return tty->name;
 }
-
 EXPORT_SYMBOL(tty_name);
 
 const char *tty_driver_name(const struct tty_struct *tty)
@@ -320,6 +319,7 @@ static struct tty_driver *get_tty_driver(dev_t device, int *index)
 
        list_for_each_entry(p, &tty_drivers, tty_drivers) {
                dev_t base = MKDEV(p->major, p->minor_start);
+
                if (device < base || device >= base + p->num)
                        continue;
                *index = device - base;
@@ -537,7 +537,6 @@ void tty_wakeup(struct tty_struct *tty)
        }
        wake_up_interruptible_poll(&tty->write_wait, EPOLLOUT);
 }
-
 EXPORT_SYMBOL_GPL(tty_wakeup);
 
 /**
@@ -613,8 +612,9 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
        set_bit(TTY_HUPPING, &tty->flags);
 
        /* inuse_filps is protected by the single tty lock,
-          this really needs to change if we want to flush the
-          workqueue with the lock held */
+        * this really needs to change if we want to flush the
+        * workqueue with the lock held.
+        */
        check_tty_count(tty, "tty_hangup");
 
        spin_lock(&tty->files_lock);
@@ -638,15 +638,15 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
 
        tty_ldisc_hangup(tty, cons_filp != NULL);
 
-       spin_lock_irq(&tty->ctrl_lock);
+       spin_lock_irq(&tty->ctrl.lock);
        clear_bit(TTY_THROTTLED, &tty->flags);
        clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-       put_pid(tty->session);
-       put_pid(tty->pgrp);
-       tty->session = NULL;
-       tty->pgrp = NULL;
-       tty->ctrl_status = 0;
-       spin_unlock_irq(&tty->ctrl_lock);
+       put_pid(tty->ctrl.session);
+       put_pid(tty->ctrl.pgrp);
+       tty->ctrl.session = NULL;
+       tty->ctrl.pgrp = NULL;
+       tty->ctrl.pktstatus = 0;
+       spin_unlock_irq(&tty->ctrl.lock);
 
        /*
         * If one of the devices matches a console pointer, we
@@ -694,7 +694,6 @@ void tty_hangup(struct tty_struct *tty)
        tty_debug_hangup(tty, "hangup\n");
        schedule_work(&tty->hangup_work);
 }
-
 EXPORT_SYMBOL(tty_hangup);
 
 /**
@@ -711,7 +710,6 @@ void tty_vhangup(struct tty_struct *tty)
        tty_debug_hangup(tty, "vhangup\n");
        __tty_hangup(tty, 0);
 }
-
 EXPORT_SYMBOL(tty_vhangup);
 
 
@@ -761,9 +759,17 @@ int tty_hung_up_p(struct file *filp)
 {
        return (filp && filp->f_op == &hung_up_tty_fops);
 }
-
 EXPORT_SYMBOL(tty_hung_up_p);
 
+void __stop_tty(struct tty_struct *tty)
+{
+       if (tty->flow.stopped)
+               return;
+       tty->flow.stopped = true;
+       if (tty->ops->stop)
+               tty->ops->stop(tty);
+}
+
 /**
  *     stop_tty        -       propagate flow control
  *     @tty: tty to stop
@@ -778,28 +784,28 @@ EXPORT_SYMBOL(tty_hung_up_p);
  *     but not always.
  *
  *     Locking:
- *             flow_lock
+ *             flow.lock
  */
-
-void __stop_tty(struct tty_struct *tty)
-{
-       if (tty->stopped)
-               return;
-       tty->stopped = 1;
-       if (tty->ops->stop)
-               tty->ops->stop(tty);
-}
-
 void stop_tty(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&tty->flow_lock, flags);
+       spin_lock_irqsave(&tty->flow.lock, flags);
        __stop_tty(tty);
-       spin_unlock_irqrestore(&tty->flow_lock, flags);
+       spin_unlock_irqrestore(&tty->flow.lock, flags);
 }
 EXPORT_SYMBOL(stop_tty);
 
+void __start_tty(struct tty_struct *tty)
+{
+       if (!tty->flow.stopped || tty->flow.tco_stopped)
+               return;
+       tty->flow.stopped = false;
+       if (tty->ops->start)
+               tty->ops->start(tty);
+       tty_wakeup(tty);
+}
+
 /**
  *     start_tty       -       propagate flow control
  *     @tty: tty to start
@@ -809,26 +815,15 @@ EXPORT_SYMBOL(stop_tty);
  *     start method is invoked and the line discipline woken.
  *
  *     Locking:
- *             flow_lock
+ *             flow.lock
  */
-
-void __start_tty(struct tty_struct *tty)
-{
-       if (!tty->stopped || tty->flow_stopped)
-               return;
-       tty->stopped = 0;
-       if (tty->ops->start)
-               tty->ops->start(tty);
-       tty_wakeup(tty);
-}
-
 void start_tty(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&tty->flow_lock, flags);
+       spin_lock_irqsave(&tty->flow.lock, flags);
        __start_tty(tty);
-       spin_unlock_irqrestore(&tty->flow_lock, flags);
+       spin_unlock_irqrestore(&tty->flow.lock, flags);
 }
 EXPORT_SYMBOL(start_tty);
 
@@ -914,10 +909,8 @@ static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty,
 
 /**
  *     tty_read        -       read method for tty device files
- *     @file: pointer to tty file
- *     @buf: user buffer
- *     @count: size of user buffer
- *     @ppos: unused
+ *     @iocb: kernel I/O control block
+ *     @to: destination for the data read
  *
  *     Perform the read system call function on this terminal device. Checks
  *     for hung up devices before calling the line discipline method.
@@ -941,7 +934,8 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to)
                return -EIO;
 
        /* We want to wait for the line discipline to sort out in this
-          situation */
+        * situation.
+        */
        ld = tty_ldisc_ref_wait(tty);
        if (!ld)
                return hung_up_tty_read(iocb, to);
@@ -1033,6 +1027,7 @@ static inline ssize_t do_tty_write(
        /* Do the write .. */
        for (;;) {
                size_t size = count;
+
                if (size > chunk)
                        size = chunk;
 
@@ -1091,36 +1086,18 @@ void tty_write_message(struct tty_struct *tty, char *msg)
                tty_unlock(tty);
                tty_write_unlock(tty);
        }
-       return;
 }
 
-
-/**
- *     tty_write               -       write method for tty device file
- *     @file: tty file pointer
- *     @buf: user data to write
- *     @count: bytes to write
- *     @ppos: unused
- *
- *     Write data to a tty device via the line discipline.
- *
- *     Locking:
- *             Locks the line discipline as required
- *             Writes to the tty driver are serialized by the atomic_write_lock
- *     and are then processed in chunks to the device. The line discipline
- *     write method will not be invoked in parallel for each device.
- */
-
 static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_iter *from)
 {
        struct tty_struct *tty = file_tty(file);
-       struct tty_ldisc *ld;
+       struct tty_ldisc *ld;
        ssize_t ret;
 
        if (tty_paranoia_check(tty, file_inode(file), "tty_write"))
                return -EIO;
        if (!tty || !tty->ops->write || tty_io_error(tty))
-                       return -EIO;
+               return -EIO;
        /* Short term debug to catch buggy drivers */
        if (tty->ops->write_room == NULL)
                tty_err(tty, "missing write_room method\n");
@@ -1135,6 +1112,20 @@ static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_
        return ret;
 }
 
+/**
+ *     tty_write               -       write method for tty device file
+ *     @iocb: kernel I/O control block
+ *     @from: iov_iter with data to write
+ *
+ *     Write data to a tty device via the line discipline.
+ *
+ *     Locking:
+ *             Locks the line discipline as required
+ *             Writes to the tty driver are serialized by the atomic_write_lock
+ *             and are then processed in chunks to the device. The line
+ *             discipline write method will not be invoked in parallel for
+ *             each device.
+ */
 static ssize_t tty_write(struct kiocb *iocb, struct iov_iter *from)
 {
        return file_tty_write(iocb->ki_filp, iocb, from);
@@ -1150,11 +1141,12 @@ ssize_t redirected_tty_write(struct kiocb *iocb, struct iov_iter *iter)
        spin_unlock(&redirect_lock);
 
        /*
-        * We know the redirected tty is just another tty, we can can
+        * We know the redirected tty is just another tty, we can
         * call file_tty_write() directly with that file pointer.
         */
        if (p) {
                ssize_t res;
+
                res = file_tty_write(p, iocb, iter);
                fput(p);
                return res;
@@ -1172,7 +1164,7 @@ ssize_t redirected_tty_write(struct kiocb *iocb, struct iov_iter *iter)
 
 int tty_send_xchar(struct tty_struct *tty, char ch)
 {
-       int     was_stopped = tty->stopped;
+       bool was_stopped = tty->flow.stopped;
 
        if (tty->ops->send_xchar) {
                down_read(&tty->termios_rwsem);
@@ -1559,8 +1551,8 @@ static void release_one_tty(struct work_struct *work)
        list_del_init(&tty->tty_files);
        spin_unlock(&tty->files_lock);
 
-       put_pid(tty->pgrp);
-       put_pid(tty->session);
+       put_pid(tty->ctrl.pgrp);
+       put_pid(tty->ctrl.session);
        free_tty_struct(tty);
 }
 
@@ -1569,7 +1561,8 @@ static void queue_release_one_tty(struct kref *kref)
        struct tty_struct *tty = container_of(kref, struct tty_struct, kref);
 
        /* The hangup queue is now free so we can reuse it rather than
-          waste a chunk of memory for each port */
+        *  waste a chunk of memory for each port.
+        */
        INIT_WORK(&tty->hangup_work, release_one_tty);
        schedule_work(&tty->hangup_work);
 }
@@ -1861,9 +1854,9 @@ int tty_release(struct inode *inode, struct file *filp)
         */
        if (!tty->count) {
                read_lock(&tasklist_lock);
-               session_clear_tty(tty->session);
+               session_clear_tty(tty->ctrl.session);
                if (o_tty)
-                       session_clear_tty(o_tty->session);
+                       session_clear_tty(o_tty->ctrl.session);
                read_unlock(&tasklist_lock);
        }
 
@@ -1874,7 +1867,8 @@ int tty_release(struct inode *inode, struct file *filp)
        tty_unlock(tty);
 
        /* At this point, the tty->count == 0 should ensure a dead tty
-          cannot be re-opened by a racing opener */
+        * cannot be re-opened by a racing opener.
+        */
 
        if (!final)
                return 0;
@@ -1928,8 +1922,8 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)
  *     @index: index for the device in the @return driver
  *     @return: driver for this inode (with increased refcount)
  *
- *     If @return is not erroneous, the caller is responsible to decrement the
- *     refcount by tty_driver_kref_put.
+ *     If @return is not erroneous, the caller is responsible to decrement the
+ *     refcount by tty_driver_kref_put.
  *
  *     Locking: tty_mutex protects get_tty_driver
  */
@@ -1942,6 +1936,7 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,
 #ifdef CONFIG_VT
        case MKDEV(TTY_MAJOR, 0): {
                extern struct tty_driver *console_driver;
+
                driver = tty_driver_kref_get(console_driver);
                *index = fg_console;
                break;
@@ -1949,6 +1944,7 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,
 #endif
        case MKDEV(TTYAUX_MAJOR, 1): {
                struct tty_driver *console_driver = console_device(index);
+
                if (console_driver) {
                        driver = tty_driver_kref_get(console_driver);
                        if (driver && filp) {
@@ -2250,16 +2246,16 @@ static int __tty_fasync(int fd, struct file *filp, int on)
                enum pid_type type;
                struct pid *pid;
 
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               if (tty->pgrp) {
-                       pid = tty->pgrp;
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               if (tty->ctrl.pgrp) {
+                       pid = tty->ctrl.pgrp;
                        type = PIDTYPE_PGID;
                } else {
                        pid = task_pid(current);
                        type = PIDTYPE_TGID;
                }
                get_pid(pid);
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                __f_setown(filp, pid, type, 0);
                put_pid(pid);
                retval = 0;
@@ -2336,7 +2332,7 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg)
        err = copy_to_user(arg, &tty->winsize, sizeof(*arg));
        mutex_unlock(&tty->winsize_mutex);
 
-       return err ? -EFAULT: 0;
+       return err ? -EFAULT : 0;
 }
 
 /**
@@ -2381,13 +2377,14 @@ EXPORT_SYMBOL(tty_do_resize);
  *
  *     Locking:
  *             Driver dependent. The default do_resize method takes the
- *     tty termios mutex and ctrl_lock. The console takes its own lock
+ *     tty termios mutex and ctrl.lock. The console takes its own lock
  *     then calls into the default method.
  */
 
 static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg)
 {
        struct winsize tmp_ws;
+
        if (copy_from_user(&tmp_ws, arg, sizeof(*arg)))
                return -EFAULT;
 
@@ -2412,6 +2409,7 @@ static int tioccons(struct file *file)
                return -EPERM;
        if (file->f_op->write_iter == redirected_tty_write) {
                struct file *f;
+
                spin_lock(&redirect_lock);
                f = redirect;
                redirect = NULL;
@@ -2734,6 +2732,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case TIOCGEXCL:
        {
                int excl = test_bit(TTY_EXCLUSIVE, &tty->flags);
+
                return put_user(excl, (int __user *)p);
        }
        case TIOCGETD:
@@ -2748,6 +2747,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case TIOCGDEV:
        {
                unsigned int ret = new_encode_dev(tty_devnum(real_tty));
+
                return put_user(ret, (unsigned int __user *)p);
        }
        /*
@@ -3006,7 +3006,7 @@ static int this_tty(const void *t, struct file *file, unsigned fd)
                return 0;
        return file_tty(file) != t ? 0 : fd + 1;
 }
-       
+
 /*
  * This implements the "Secure Attention Key" ---  the idea is to
  * prevent trojan horses by killing all processes associated with this
@@ -3039,9 +3039,9 @@ void __do_SAK(struct tty_struct *tty)
        if (!tty)
                return;
 
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
-       session = get_pid(tty->session);
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       spin_lock_irqsave(&tty->ctrl.lock, flags);
+       session = get_pid(tty->ctrl.session);
+       spin_unlock_irqrestore(&tty->ctrl.lock, flags);
 
        tty_ldisc_flush(tty);
 
@@ -3096,13 +3096,13 @@ void do_SAK(struct tty_struct *tty)
                return;
        schedule_work(&tty->SAK_work);
 }
-
 EXPORT_SYMBOL(do_SAK);
 
 /* Must put_device() after it's unused! */
 static struct device *tty_get_device(struct tty_struct *tty)
 {
        dev_t devt = tty_devnum(tty);
+
        return class_find_device_by_devt(tty_class, devt);
 }
 
@@ -3129,8 +3129,8 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
                kfree(tty);
                return NULL;
        }
-       tty->session = NULL;
-       tty->pgrp = NULL;
+       tty->ctrl.session = NULL;
+       tty->ctrl.pgrp = NULL;
        mutex_init(&tty->legacy_mutex);
        mutex_init(&tty->throttle_mutex);
        init_rwsem(&tty->termios_rwsem);
@@ -3140,8 +3140,8 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
        init_waitqueue_head(&tty->read_wait);
        INIT_WORK(&tty->hangup_work, do_tty_hangup);
        mutex_init(&tty->atomic_write_lock);
-       spin_lock_init(&tty->ctrl_lock);
-       spin_lock_init(&tty->flow_lock);
+       spin_lock_init(&tty->ctrl.lock);
+       spin_lock_init(&tty->flow.lock);
        spin_lock_init(&tty->files_lock);
        INIT_LIST_HEAD(&tty->tty_files);
        INIT_WORK(&tty->SAK_work, do_SAK_work);
@@ -3317,11 +3317,11 @@ err_put:
 EXPORT_SYMBOL_GPL(tty_register_device_attr);
 
 /**
- *     tty_unregister_device - unregister a tty device
- *     @driver: the tty driver that describes the tty device
- *     @index: the index in the tty driver for this tty device
+ *     tty_unregister_device - unregister a tty device
+ *     @driver: the tty driver that describes the tty device
+ *     @index: the index in the tty driver for this tty device
  *
- *     If a tty device is registered with a call to tty_register_device() then
+ *     If a tty device is registered with a call to tty_register_device() then
  *     this function must be called when the tty device is gone.
  *
  *     Locking: ??
index 41f7449..75885d5 100644 (file)
@@ -54,7 +54,7 @@
  *     to be no queue on the device.
  */
 
-int tty_chars_in_buffer(struct tty_struct *tty)
+unsigned int tty_chars_in_buffer(struct tty_struct *tty)
 {
        if (tty->ops->chars_in_buffer)
                return tty->ops->chars_in_buffer(tty);
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(tty_chars_in_buffer);
  *     returned and data may be lost as there will be no flow control.
  */
  
-int tty_write_room(struct tty_struct *tty)
+unsigned int tty_write_room(struct tty_struct *tty)
 {
        if (tty->ops->write_room)
                return tty->ops->write_room(tty);
@@ -96,28 +96,6 @@ void tty_driver_flush_buffer(struct tty_struct *tty)
 }
 EXPORT_SYMBOL(tty_driver_flush_buffer);
 
-/**
- *     tty_throttle            -       flow control
- *     @tty: terminal
- *
- *     Indicate that a tty should stop transmitting data down the stack.
- *     Takes the termios rwsem to protect against parallel throttle/unthrottle
- *     and also to ensure the driver can consistently reference its own
- *     termios data at this point when implementing software flow control.
- */
-
-void tty_throttle(struct tty_struct *tty)
-{
-       down_write(&tty->termios_rwsem);
-       /* check TTY_THROTTLED first so it indicates our state */
-       if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) &&
-           tty->ops->throttle)
-               tty->ops->throttle(tty);
-       tty->flow_change = 0;
-       up_write(&tty->termios_rwsem);
-}
-EXPORT_SYMBOL(tty_throttle);
-
 /**
  *     tty_unthrottle          -       flow control
  *     @tty: terminal
@@ -146,10 +124,11 @@ EXPORT_SYMBOL(tty_unthrottle);
  *     tty_throttle_safe       -       flow control
  *     @tty: terminal
  *
- *     Similar to tty_throttle() but will only attempt throttle
- *     if tty->flow_change is TTY_THROTTLE_SAFE. Prevents an accidental
- *     throttle due to race conditions when throttling is conditional
- *     on factors evaluated prior to throttling.
+ *     Indicate that a tty should stop transmitting data down the stack.
+ *     tty_throttle_safe will only attempt throttle if tty->flow_change is
+ *     TTY_THROTTLE_SAFE. Prevents an accidental throttle due to race
+ *     conditions when throttling is conditional on factors evaluated prior to
+ *     throttling.
  *
  *     Returns 0 if tty is throttled (or was already throttled)
  */
@@ -846,20 +825,20 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
                        return retval;
                switch (arg) {
                case TCOOFF:
-                       spin_lock_irq(&tty->flow_lock);
-                       if (!tty->flow_stopped) {
-                               tty->flow_stopped = 1;
+                       spin_lock_irq(&tty->flow.lock);
+                       if (!tty->flow.tco_stopped) {
+                               tty->flow.tco_stopped = true;
                                __stop_tty(tty);
                        }
-                       spin_unlock_irq(&tty->flow_lock);
+                       spin_unlock_irq(&tty->flow.lock);
                        break;
                case TCOON:
-                       spin_lock_irq(&tty->flow_lock);
-                       if (tty->flow_stopped) {
-                               tty->flow_stopped = 0;
+                       spin_lock_irq(&tty->flow.lock);
+                       if (tty->flow.tco_stopped) {
+                               tty->flow.tco_stopped = false;
                                __start_tty(tty);
                        }
-                       spin_unlock_irq(&tty->flow_lock);
+                       spin_unlock_irq(&tty->flow.lock);
                        break;
                case TCIOFF:
                        if (STOP_CHAR(tty) != __DISABLED_CHAR)
index 7813dc9..80b86a7 100644 (file)
@@ -20,7 +20,7 @@ static int is_ignored(int sig)
 }
 
 /**
- *     tty_check_change        -       check for POSIX terminal changes
+ *     __tty_check_change      -       check for POSIX terminal changes
  *     @tty: tty to check
  *     @sig: signal to send
  *
@@ -28,7 +28,7 @@ static int is_ignored(int sig)
  *     not in the foreground, send a SIGTTOU.  If the signal is blocked or
  *     ignored, go ahead and perform the operation.  (POSIX 7.2)
  *
- *     Locking: ctrl_lock
+ *     Locking: ctrl.lock
  */
 int __tty_check_change(struct tty_struct *tty, int sig)
 {
@@ -42,9 +42,9 @@ int __tty_check_change(struct tty_struct *tty, int sig)
        rcu_read_lock();
        pgrp = task_pgrp(current);
 
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
-       tty_pgrp = tty->pgrp;
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       spin_lock_irqsave(&tty->ctrl.lock, flags);
+       tty_pgrp = tty->ctrl.pgrp;
+       spin_unlock_irqrestore(&tty->ctrl.lock, flags);
 
        if (tty_pgrp && pgrp != tty_pgrp) {
                if (is_ignored(sig)) {
@@ -85,7 +85,7 @@ void proc_clear_tty(struct task_struct *p)
 }
 
 /**
- * proc_set_tty -  set the controlling terminal
+ * __proc_set_tty -  set the controlling terminal
  *     @tty: tty structure
  *
  * Only callable by the session leader and only if it does not already have
@@ -99,16 +99,16 @@ static void __proc_set_tty(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
+       spin_lock_irqsave(&tty->ctrl.lock, flags);
        /*
         * The session and fg pgrp references will be non-NULL if
         * tiocsctty() is stealing the controlling tty
         */
-       put_pid(tty->session);
-       put_pid(tty->pgrp);
-       tty->pgrp = get_pid(task_pgrp(current));
-       tty->session = get_pid(task_session(current));
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       put_pid(tty->ctrl.session);
+       put_pid(tty->ctrl.pgrp);
+       tty->ctrl.pgrp = get_pid(task_pgrp(current));
+       tty->ctrl.session = get_pid(task_session(current));
+       spin_unlock_irqrestore(&tty->ctrl.lock, flags);
        if (current->signal->tty) {
                tty_debug(tty, "current tty %s not NULL!!\n",
                          current->signal->tty->name);
@@ -135,7 +135,7 @@ void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty)
        spin_lock_irq(&current->sighand->siglock);
        if (current->signal->leader &&
            !current->signal->tty &&
-           tty->session == NULL) {
+           tty->ctrl.session == NULL) {
                /*
                 * Don't let a process that only has write access to the tty
                 * obtain the privileges associated with having a tty as
@@ -200,8 +200,8 @@ int tty_signal_session_leader(struct tty_struct *tty, int exit_session)
        struct pid *tty_pgrp = NULL;
 
        read_lock(&tasklist_lock);
-       if (tty->session) {
-               do_each_pid_task(tty->session, PIDTYPE_SID, p) {
+       if (tty->ctrl.session) {
+               do_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p) {
                        spin_lock_irq(&p->sighand->siglock);
                        if (p->signal->tty == tty) {
                                p->signal->tty = NULL;
@@ -218,13 +218,14 @@ int tty_signal_session_leader(struct tty_struct *tty, int exit_session)
                        __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p);
                        __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
                        put_pid(p->signal->tty_old_pgrp);  /* A noop */
-                       spin_lock(&tty->ctrl_lock);
-                       tty_pgrp = get_pid(tty->pgrp);
-                       if (tty->pgrp)
-                               p->signal->tty_old_pgrp = get_pid(tty->pgrp);
-                       spin_unlock(&tty->ctrl_lock);
+                       spin_lock(&tty->ctrl.lock);
+                       tty_pgrp = get_pid(tty->ctrl.pgrp);
+                       if (tty->ctrl.pgrp)
+                               p->signal->tty_old_pgrp =
+                                       get_pid(tty->ctrl.pgrp);
+                       spin_unlock(&tty->ctrl.lock);
                        spin_unlock_irq(&p->sighand->siglock);
-               } while_each_pid_task(tty->session, PIDTYPE_SID, p);
+               } while_each_pid_task(tty->ctrl.session, PIDTYPE_SID, p);
        }
        read_unlock(&tasklist_lock);
 
@@ -309,12 +310,12 @@ void disassociate_ctty(int on_exit)
                unsigned long flags;
 
                tty_lock(tty);
-               spin_lock_irqsave(&tty->ctrl_lock, flags);
-               put_pid(tty->session);
-               put_pid(tty->pgrp);
-               tty->session = NULL;
-               tty->pgrp = NULL;
-               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+               spin_lock_irqsave(&tty->ctrl.lock, flags);
+               put_pid(tty->ctrl.session);
+               put_pid(tty->ctrl.pgrp);
+               tty->ctrl.session = NULL;
+               tty->ctrl.pgrp = NULL;
+               spin_unlock_irqrestore(&tty->ctrl.lock, flags);
                tty_unlock(tty);
                tty_kref_put(tty);
        }
@@ -363,7 +364,8 @@ static int tiocsctty(struct tty_struct *tty, struct file *file, int arg)
        tty_lock(tty);
        read_lock(&tasklist_lock);
 
-       if (current->signal->leader && (task_session(current) == tty->session))
+       if (current->signal->leader &&
+                       task_session(current) == tty->ctrl.session)
                goto unlock;
 
        /*
@@ -375,7 +377,7 @@ static int tiocsctty(struct tty_struct *tty, struct file *file, int arg)
                goto unlock;
        }
 
-       if (tty->session) {
+       if (tty->ctrl.session) {
                /*
                 * This tty is already the controlling
                 * tty for another session group!
@@ -384,7 +386,7 @@ static int tiocsctty(struct tty_struct *tty, struct file *file, int arg)
                        /*
                         * Steal it away
                         */
-                       session_clear_tty(tty->session);
+                       session_clear_tty(tty->ctrl.session);
                } else {
                        ret = -EPERM;
                        goto unlock;
@@ -416,9 +418,9 @@ struct pid *tty_get_pgrp(struct tty_struct *tty)
        unsigned long flags;
        struct pid *pgrp;
 
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
-       pgrp = get_pid(tty->pgrp);
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       spin_lock_irqsave(&tty->ctrl.lock, flags);
+       pgrp = get_pid(tty->ctrl.pgrp);
+       spin_unlock_irqrestore(&tty->ctrl.lock, flags);
 
        return pgrp;
 }
@@ -499,10 +501,10 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
        if (pgrp_nr < 0)
                return -EINVAL;
 
-       spin_lock_irq(&real_tty->ctrl_lock);
+       spin_lock_irq(&real_tty->ctrl.lock);
        if (!current->signal->tty ||
            (current->signal->tty != real_tty) ||
-           (real_tty->session != task_session(current))) {
+           (real_tty->ctrl.session != task_session(current))) {
                retval = -ENOTTY;
                goto out_unlock_ctrl;
        }
@@ -515,12 +517,12 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
        if (session_of_pgrp(pgrp) != task_session(current))
                goto out_unlock;
        retval = 0;
-       put_pid(real_tty->pgrp);
-       real_tty->pgrp = get_pid(pgrp);
+       put_pid(real_tty->ctrl.pgrp);
+       real_tty->ctrl.pgrp = get_pid(pgrp);
 out_unlock:
        rcu_read_unlock();
 out_unlock_ctrl:
-       spin_unlock_irq(&real_tty->ctrl_lock);
+       spin_unlock_irq(&real_tty->ctrl.lock);
        return retval;
 }
 
@@ -545,16 +547,16 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _
        if (tty == real_tty && current->signal->tty != real_tty)
                return -ENOTTY;
 
-       spin_lock_irqsave(&real_tty->ctrl_lock, flags);
-       if (!real_tty->session)
+       spin_lock_irqsave(&real_tty->ctrl.lock, flags);
+       if (!real_tty->ctrl.session)
                goto err;
-       sid = pid_vnr(real_tty->session);
-       spin_unlock_irqrestore(&real_tty->ctrl_lock, flags);
+       sid = pid_vnr(real_tty->ctrl.session);
+       spin_unlock_irqrestore(&real_tty->ctrl.lock, flags);
 
        return put_user(sid, p);
 
 err:
-       spin_unlock_irqrestore(&real_tty->ctrl_lock, flags);
+       spin_unlock_irqrestore(&real_tty->ctrl.lock, flags);
        return -ENOTTY;
 }
 
index 03f4141..8edd73a 100644 (file)
@@ -59,18 +59,16 @@ static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
  *             takes tty_ldiscs_lock to guard against ldisc races
  */
 
-int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
+int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc)
 {
        unsigned long flags;
        int ret = 0;
 
-       if (disc < N_TTY || disc >= NR_LDISCS)
+       if (new_ldisc->num < N_TTY || new_ldisc->num >= NR_LDISCS)
                return -EINVAL;
 
        raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
-       tty_ldiscs[disc] = new_ldisc;
-       new_ldisc->num = disc;
-       new_ldisc->refcount = 0;
+       tty_ldiscs[new_ldisc->num] = new_ldisc;
        raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
 
        return ret;
@@ -88,22 +86,13 @@ EXPORT_SYMBOL(tty_register_ldisc);
  *             takes tty_ldiscs_lock to guard against ldisc races
  */
 
-int tty_unregister_ldisc(int disc)
+void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc)
 {
        unsigned long flags;
-       int ret = 0;
-
-       if (disc < N_TTY || disc >= NR_LDISCS)
-               return -EINVAL;
 
        raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
-       if (tty_ldiscs[disc]->refcount)
-               ret = -EBUSY;
-       else
-               tty_ldiscs[disc] = NULL;
+       tty_ldiscs[ldisc->num] = NULL;
        raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
-
-       return ret;
 }
 EXPORT_SYMBOL(tty_unregister_ldisc);
 
@@ -117,10 +106,8 @@ static struct tty_ldisc_ops *get_ldops(int disc)
        ldops = tty_ldiscs[disc];
        if (ldops) {
                ret = ERR_PTR(-EAGAIN);
-               if (try_module_get(ldops->owner)) {
-                       ldops->refcount++;
+               if (try_module_get(ldops->owner))
                        ret = ldops;
-               }
        }
        raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
        return ret;
@@ -131,7 +118,6 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
        unsigned long flags;
 
        raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
-       ldops->refcount--;
        module_put(ldops->owner);
        raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
 }
index 303c198..2f1061a 100644 (file)
@@ -468,7 +468,8 @@ int tty_port_block_til_ready(struct tty_port *port,
        DEFINE_WAIT(wait);
 
        /* if non-blocking mode is set we can pass directly to open unless
-          the port has just hung up or is in another error state */
+        * the port has just hung up or is in another error state.
+        */
        if (tty_io_error(tty)) {
                tty_port_set_active(port, 1);
                return 0;
@@ -485,8 +486,9 @@ int tty_port_block_til_ready(struct tty_port *port,
                do_clocal = 1;
 
        /* Block waiting until we can proceed. We may need to wait for the
-          carrier, but we must also wait for any close that is in progress
-          before the next open may complete */
+        * carrier, but we must also wait for any close that is in progress
+        * before the next open may complete.
+        */
 
        retval = 0;
 
@@ -503,7 +505,8 @@ int tty_port_block_til_ready(struct tty_port *port,
 
                prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE);
                /* Check for a hangup or uninitialised port.
-                                                       Return accordingly */
+                * Return accordingly.
+                */
                if (tty_hung_up_p(filp) || !tty_port_initialized(port)) {
                        if (port->flags & ASYNC_HUP_NOTIFY)
                                retval = -EAGAIN;
@@ -530,7 +533,8 @@ int tty_port_block_til_ready(struct tty_port *port,
        finish_wait(&port->open_wait, &wait);
 
        /* Update counts. A parallel hangup will have set count to zero and
-          we must not mess that up further */
+        * we must not mess that up further.
+        */
        spin_lock_irqsave(&port->lock, flags);
        if (!tty_hung_up_p(filp))
                port->count++;
@@ -587,7 +591,7 @@ int tty_port_close_start(struct tty_port *port,
 
        if (tty_port_initialized(port)) {
                /* Don't block on a stalled port, just pull the chain */
-               if (tty->flow_stopped)
+               if (tty->flow.tco_stopped)
                        tty_driver_flush_buffer(tty);
                if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
                        tty_wait_until_sent(tty, port->closing_wait);
@@ -688,6 +692,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
                clear_bit(TTY_IO_ERROR, &tty->flags);
                if (port->ops->activate) {
                        int retval = port->ops->activate(port, tty);
+
                        if (retval) {
                                mutex_unlock(&port->mutex);
                                return retval;
@@ -698,5 +703,4 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
        mutex_unlock(&port->mutex);
        return tty_port_block_til_ready(port, tty, filp);
 }
-
 EXPORT_SYMBOL(tty_port_open);
index 17f05b7..af3311a 100644 (file)
@@ -35,7 +35,7 @@ static int ttynull_write(struct tty_struct *tty, const unsigned char *buf,
        return count;
 }
 
-static int ttynull_write_room(struct tty_struct *tty)
+static unsigned int ttynull_write_room(struct tty_struct *tty)
 {
        return 65536;
 }
index 0a3a71e..e883b8f 100644 (file)
@@ -870,10 +870,10 @@ static int vcc_write(struct tty_struct *tty, const unsigned char *buf,
        return total_sent ? total_sent : rv;
 }
 
-static int vcc_write_room(struct tty_struct *tty)
+static unsigned int vcc_write_room(struct tty_struct *tty)
 {
        struct vcc_port *port;
-       u64 num;
+       unsigned int num;
 
        port = vcc_get_ne(tty->index);
        if (unlikely(!port)) {
@@ -888,10 +888,10 @@ static int vcc_write_room(struct tty_struct *tty)
        return num;
 }
 
-static int vcc_chars_in_buffer(struct tty_struct *tty)
+static unsigned int vcc_chars_in_buffer(struct tty_struct *tty)
 {
        struct vcc_port *port;
-       u64 num;
+       unsigned int num;
 
        port = vcc_get_ne(tty->index);
        if (unlikely(!port)) {
index 5d23097..4b0d690 100644 (file)
@@ -515,7 +515,7 @@ static void fn_hold(struct vc_data *vc)
         * these routines are also activated by ^S/^Q.
         * (And SCROLLOCK can also be set by the ioctl KDSKBLED.)
         */
-       if (tty->stopped)
+       if (tty->flow.stopped)
                start_tty(tty);
        else
                stop_tty(tty);
index f245a5a..f7755e7 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/sched/signal.h>
 
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
-#define isspace(c)     ((c) == ' ')
+#define is_space_on_vt(c)      ((c) == ' ')
 
 /* FIXME: all this needs locking */
 static struct vc_selection {
@@ -109,7 +109,7 @@ static inline int inword(const u32 c)
 }
 
 /**
- *     set loadlut             -       load the LUT table
+ *     sel_loadlut()           -       load the LUT table
  *     @p: user table
  *
  *     Load the LUT table from user space. The caller must hold the console
@@ -209,7 +209,7 @@ static int vc_selection_store_chars(struct vc_data *vc, bool unicode)
                        bp += store_utf8(c, bp);
                else
                        *bp++ = c;
-               if (!isspace(c))
+               if (!is_space_on_vt(c))
                        obp = bp;
                if (!((i + 2) % vc->vc_size_row)) {
                        /* strip trailing blanks from line and add newline,
@@ -238,9 +238,9 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
                new_sel_end = pe;
                break;
        case TIOCL_SELWORD:     /* word-by-word selection */
-               spc = isspace(sel_pos(ps, unicode));
+               spc = is_space_on_vt(sel_pos(ps, unicode));
                for (new_sel_start = ps; ; ps -= 2) {
-                       if ((spc && !isspace(sel_pos(ps, unicode))) ||
+                       if ((spc && !is_space_on_vt(sel_pos(ps, unicode))) ||
                            (!spc && !inword(sel_pos(ps, unicode))))
                                break;
                        new_sel_start = ps;
@@ -248,9 +248,9 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
                                break;
                }
 
-               spc = isspace(sel_pos(pe, unicode));
+               spc = is_space_on_vt(sel_pos(pe, unicode));
                for (new_sel_end = pe; ; pe += 2) {
-                       if ((spc && !isspace(sel_pos(pe, unicode))) ||
+                       if ((spc && !is_space_on_vt(sel_pos(pe, unicode))) ||
                            (!spc && !inword(sel_pos(pe, unicode))))
                                break;
                        new_sel_end = pe;
@@ -276,12 +276,12 @@ static int vc_do_selection(struct vc_data *vc, unsigned short mode, int ps,
        /* select to end of line if on trailing space */
        if (new_sel_end > new_sel_start &&
                !atedge(new_sel_end, vc->vc_size_row) &&
-               isspace(sel_pos(new_sel_end, unicode))) {
+               is_space_on_vt(sel_pos(new_sel_end, unicode))) {
                for (pe = new_sel_end + 2; ; pe += 2)
-                       if (!isspace(sel_pos(pe, unicode)) ||
+                       if (!is_space_on_vt(sel_pos(pe, unicode)) ||
                            atedge(pe, vc->vc_size_row))
                                break;
-               if (isspace(sel_pos(pe, unicode)))
+               if (is_space_on_vt(sel_pos(pe, unicode)))
                        new_sel_end = pe;
        }
        if (vc_sel.start == -1) /* no current selection */
index fa1548d..ef981d3 100644 (file)
@@ -1189,7 +1189,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
  *     information and perform any necessary signal handling.
  *
  *     Caller must hold the console semaphore. Takes the termios rwsem and
- *     ctrl_lock of the tty IFF a tty is passed.
+ *     ctrl.lock of the tty IFF a tty is passed.
  */
 
 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
@@ -1355,7 +1355,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows)
  *     the actual work.
  *
  *     Takes the console sem and the called methods then take the tty
- *     termios_rwsem and the tty ctrl_lock in that order.
+ *     termios_rwsem and the tty ctrl.lock in that order.
  */
 static int vt_resize(struct tty_struct *tty, struct winsize *ws)
 {
@@ -2888,7 +2888,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
 
        param.vc = vc;
 
-       while (!tty->stopped && count) {
+       while (!tty->flow.stopped && count) {
                int orig = *buf;
                buf++;
                n++;
@@ -3260,23 +3260,16 @@ static int con_write(struct tty_struct *tty, const unsigned char *buf, int count
 
 static int con_put_char(struct tty_struct *tty, unsigned char ch)
 {
-       if (in_interrupt())
-               return 0;       /* n_r3964 calls put_char() from interrupt context */
        return do_con_write(tty, &ch, 1);
 }
 
-static int con_write_room(struct tty_struct *tty)
+static unsigned int con_write_room(struct tty_struct *tty)
 {
-       if (tty->stopped)
+       if (tty->flow.stopped)
                return 0;
        return 32768;           /* No limit, really; we're not buffering */
 }
 
-static int con_chars_in_buffer(struct tty_struct *tty)
-{
-       return 0;               /* we're not buffering */
-}
-
 /*
  * con_throttle and con_unthrottle are only used for
  * paste_selection(), which has to stuff in a large number of
@@ -3523,7 +3516,6 @@ static const struct tty_operations con_ops = {
        .write_room = con_write_room,
        .put_char = con_put_char,
        .flush_chars = con_flush_chars,
-       .chars_in_buffer = con_chars_in_buffer,
        .ioctl = vt_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl = vt_compat_ioctl,
index ca7a611..81199ef 100644 (file)
@@ -838,7 +838,7 @@ static int acm_tty_write(struct tty_struct *tty,
        return count;
 }
 
-static int acm_tty_write_room(struct tty_struct *tty)
+static unsigned int acm_tty_write_room(struct tty_struct *tty)
 {
        struct acm *acm = tty->driver_data;
        /*
@@ -848,7 +848,7 @@ static int acm_tty_write_room(struct tty_struct *tty)
        return acm_wb_is_avail(acm) ? acm->writesize : 0;
 }
 
-static int acm_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int acm_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct acm *acm = tty->driver_data;
        /*
index 1e59204..bffef8e 100644 (file)
@@ -774,34 +774,34 @@ static void gs_flush_chars(struct tty_struct *tty)
        spin_unlock_irqrestore(&port->port_lock, flags);
 }
 
-static int gs_write_room(struct tty_struct *tty)
+static unsigned int gs_write_room(struct tty_struct *tty)
 {
        struct gs_port  *port = tty->driver_data;
        unsigned long   flags;
-       int             room = 0;
+       unsigned int room = 0;
 
        spin_lock_irqsave(&port->port_lock, flags);
        if (port->port_usb)
                room = kfifo_avail(&port->port_write_buf);
        spin_unlock_irqrestore(&port->port_lock, flags);
 
-       pr_vdebug("gs_write_room: (%d,%p) room=%d\n",
+       pr_vdebug("gs_write_room: (%d,%p) room=%u\n",
                port->port_num, tty, room);
 
        return room;
 }
 
-static int gs_chars_in_buffer(struct tty_struct *tty)
+static unsigned int gs_chars_in_buffer(struct tty_struct *tty)
 {
        struct gs_port  *port = tty->driver_data;
        unsigned long   flags;
-       int             chars = 0;
+       unsigned int    chars;
 
        spin_lock_irqsave(&port->port_lock, flags);
        chars = kfifo_len(&port->port_write_buf);
        spin_unlock_irqrestore(&port->port_lock, flags);
 
-       pr_vdebug("gs_chars_in_buffer: (%d,%p) chars=%d\n",
+       pr_vdebug("gs_chars_in_buffer: (%d,%p) chars=%u\n",
                port->port_num, tty, chars);
 
        return chars;
index ae4e4ab..bef1045 100644 (file)
@@ -240,11 +240,11 @@ static void dbc_tty_flush_chars(struct tty_struct *tty)
        spin_unlock_irqrestore(&port->port_lock, flags);
 }
 
-static int dbc_tty_write_room(struct tty_struct *tty)
+static unsigned int dbc_tty_write_room(struct tty_struct *tty)
 {
        struct dbc_port         *port = tty->driver_data;
        unsigned long           flags;
-       int                     room = 0;
+       unsigned int            room;
 
        spin_lock_irqsave(&port->port_lock, flags);
        room = kfifo_avail(&port->write_fifo);
@@ -253,11 +253,11 @@ static int dbc_tty_write_room(struct tty_struct *tty)
        return room;
 }
 
-static int dbc_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int dbc_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct dbc_port         *port = tty->driver_data;
        unsigned long           flags;
-       int                     chars = 0;
+       unsigned int            chars;
 
        spin_lock_irqsave(&port->port_lock, flags);
        chars = kfifo_len(&port->write_fifo);
index 98b33b1..eeb441c 100644 (file)
@@ -376,7 +376,7 @@ exit:
        return retval;
 }
 
-static int serial_write_room(struct tty_struct *tty)
+static unsigned int serial_write_room(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
 
@@ -385,7 +385,7 @@ static int serial_write_room(struct tty_struct *tty)
        return port->serial->type->write_room(tty);
 }
 
-static int serial_chars_in_buffer(struct tty_struct *tty)
+static unsigned int serial_chars_in_buffer(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
diff --git a/include/linux/n_r3964.h b/include/linux/n_r3964.h
deleted file mode 100644 (file)
index 90a803a..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/* r3964 linediscipline for linux
- *
- * -----------------------------------------------------------
- * Copyright by
- * Philips Automation Projects
- * Kassel (Germany)
- * -----------------------------------------------------------
- * This software may be used and distributed according to the terms of
- * the GNU General Public License, incorporated herein by reference.
- *
- * Author:
- * L. Haag
- *
- * $Log: r3964.h,v $
- * Revision 1.4  2005/12/21 19:54:24  Kurt Huwig <kurt huwig de>
- * Fixed HZ usage on 2.6 kernels
- * Removed unnecessary include
- *
- * Revision 1.3  2001/03/18 13:02:24  dwmw2
- * Fix timer usage, use spinlocks properly.
- *
- * Revision 1.2  2001/03/18 12:53:15  dwmw2
- * Merge changes in 2.4.2
- *
- * Revision 1.1.1.1  1998/10/13 16:43:14  dwmw2
- * This'll screw the version control
- *
- * Revision 1.6  1998/09/30 00:40:38  dwmw2
- * Updated to use kernel's N_R3964 if available
- *
- * Revision 1.4  1998/04/02 20:29:44  lhaag
- * select, blocking, ...
- *
- * Revision 1.3  1998/02/12 18:58:43  root
- * fixed some memory leaks
- * calculation of checksum characters
- *
- * Revision 1.2  1998/02/07 13:03:17  root
- * ioctl read_telegram
- *
- * Revision 1.1  1998/02/06 19:19:43  root
- * Initial revision
- *
- *
- */
-#ifndef __LINUX_N_R3964_H__
-#define __LINUX_N_R3964_H__
-
-
-#include <linux/param.h>
-#include <uapi/linux/n_r3964.h>
-
-/*
- * Common ascii handshake characters:
- */
-
-#define STX 0x02
-#define ETX 0x03
-#define DLE 0x10
-#define NAK 0x15
-
-/*
- * Timeouts (from milliseconds to jiffies)
- */
-
-#define R3964_TO_QVZ ((550)*HZ/1000)
-#define R3964_TO_ZVZ ((220)*HZ/1000)
-#define R3964_TO_NO_BUF ((400)*HZ/1000)
-#define R3964_NO_TX_ROOM ((100)*HZ/1000)
-#define R3964_TO_RX_PANIC ((4000)*HZ/1000)
-#define R3964_MAX_RETRIES 5
-
-
-enum { R3964_IDLE, 
-          R3964_TX_REQUEST, R3964_TRANSMITTING, 
-          R3964_WAIT_ZVZ_BEFORE_TX_RETRY, R3964_WAIT_FOR_TX_ACK,
-          R3964_WAIT_FOR_RX_BUF,
-          R3964_RECEIVING, R3964_WAIT_FOR_BCC, R3964_WAIT_FOR_RX_REPEAT
-          };
-
-/*
- * All open file-handles are 'clients' and are stored in a linked list:
- */
-
-struct r3964_message;
-
-struct r3964_client_info {
-       spinlock_t     lock;
-       struct pid    *pid;
-       unsigned int   sig_flags;
-
-       struct r3964_client_info *next;
-
-       struct r3964_message *first_msg;
-       struct r3964_message *last_msg;
-       struct r3964_block_header *next_block_to_read;
-       int            msg_count;
-};
-
-
-
-struct r3964_block_header;
-
-/* internal version of client_message: */
-struct r3964_message {
-         int     msg_id;
-         int     arg;
-         int     error_code;
-         struct r3964_block_header *block;
-         struct r3964_message *next;
-};
-
-/*
- * Header of received block in rx_buf/tx_buf:
- */
-
-struct r3964_block_header 
-{
-       unsigned int length;             /* length in chars without header */
-       unsigned char *data;             /* usually data is located 
-                                        immediately behind this struct */
-       unsigned int locks;              /* only used in rx_buffer */
-         
-    struct r3964_block_header *next;
-       struct r3964_client_info *owner;  /* =NULL in rx_buffer */
-};
-
-/*
- * If rx_buf hasn't enough space to store R3964_MTU chars,
- * we will reject all incoming STX-requests by sending NAK.
- */
-
-#define RX_BUF_SIZE    4000
-#define TX_BUF_SIZE    4000
-#define R3964_MAX_BLOCKS_IN_RX_QUEUE 100
-
-#define R3964_PARITY 0x0001
-#define R3964_FRAME  0x0002
-#define R3964_OVERRUN 0x0004
-#define R3964_UNKNOWN 0x0008
-#define R3964_BREAK   0x0010
-#define R3964_CHECKSUM 0x0020
-#define R3964_ERROR  0x003f
-#define R3964_BCC   0x4000
-#define R3964_DEBUG 0x8000
-
-
-struct r3964_info {
-       spinlock_t     lock;
-       struct tty_struct *tty;
-       unsigned char priority;
-       unsigned char *rx_buf;            /* ring buffer */
-       unsigned char *tx_buf;
-
-       struct r3964_block_header *rx_first;
-       struct r3964_block_header *rx_last;
-       struct r3964_block_header *tx_first;
-       struct r3964_block_header *tx_last;
-       unsigned int tx_position;
-        unsigned int rx_position;
-       unsigned char last_rx;
-       unsigned char bcc;
-        unsigned int  blocks_in_rx_queue;
-
-       struct mutex read_lock;         /* serialize r3964_read */
-
-       struct r3964_client_info *firstClient;
-       unsigned int state;
-       unsigned int flags;
-
-       struct timer_list tmr;
-       int nRetry;
-};
-
-#endif
index 9e65505..5db211f 100644 (file)
@@ -146,7 +146,7 @@ static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
        return container_of(up, struct uart_8250_port, port);
 }
 
-int serial8250_register_8250_port(struct uart_8250_port *);
+int serial8250_register_8250_port(const struct uart_8250_port *);
 void serial8250_unregister_port(int line);
 void serial8250_suspend_port(int line);
 void serial8250_resume_port(int line);
index d7ed00f..52d7fb9 100644 (file)
@@ -408,7 +408,8 @@ int uart_register_driver(struct uart_driver *uart);
 void uart_unregister_driver(struct uart_driver *uart);
 int uart_add_one_port(struct uart_driver *reg, struct uart_port *port);
 int uart_remove_one_port(struct uart_driver *reg, struct uart_port *port);
-int uart_match_port(struct uart_port *port1, struct uart_port *port2);
+bool uart_match_port(const struct uart_port *port1,
+               const struct uart_port *port2);
 
 /*
  * Power Management
@@ -428,7 +429,7 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
 static inline int uart_tx_stopped(struct uart_port *port)
 {
        struct tty_struct *tty = port->state->port.tty;
-       if ((tty && tty->stopped) || port->hw_stopped)
+       if ((tty && tty->flow.stopped) || port->hw_stopped)
                return 1;
        return 0;
 }
index e5d6b1f..4c0c7ca 100644 (file)
@@ -243,20 +243,29 @@ struct tty_port {
 #define TTY_PORT_KOPENED       5       /* device exclusively opened by
                                           kernel */
 
-/*
- * Where all of the state associated with a tty is kept while the tty
- * is open.  Since the termios state should be kept even if the tty
- * has been closed --- for things like the baud rate, etc --- it is
- * not stored here, but rather a pointer to the real state is stored
- * here.  Possible the winsize structure should have the same
- * treatment, but (1) the default 80x24 is usually right and (2) it's
- * most often used by a windowing system, which will set the correct
- * size each time the window is created or resized anyway.
- *                                             - TYT, 9/14/92
- */
-
 struct tty_operations;
 
+/**
+ * struct tty_struct - state associated with a tty while open
+ *
+ * @flow.lock: lock for flow members
+ * @flow.stopped: tty stopped/started by tty_stop/tty_start
+ * @flow.tco_stopped: tty stopped/started by TCOOFF/TCOON ioctls (it has
+ *                   precedense over @flow.stopped)
+ * @flow.unused: alignment for Alpha, so that no members other than @flow.* are
+ *              modified by the same 64b word store. The @flow's __aligned is
+ *              there for the very same reason.
+ * @ctrl.lock: lock for ctrl members
+ * @ctrl.pgrp: process group of this tty (setpgrp(2))
+ * @ctrl.session: session of this tty (setsid(2)). Writes are protected by both
+ *               @ctrl.lock and legacy mutex, readers must use at least one of
+ *               them.
+ * @ctrl.pktstatus: packet mode status (bitwise OR of TIOCPKT_* constants)
+ * @ctrl.packet: packet mode enabled
+ *
+ * All of the state associated with a tty while the tty is open. Persistent
+ * storage for tty devices is referenced here as @port in struct tty_port.
+ */
 struct tty_struct {
        int     magic;
        struct kref kref;
@@ -274,27 +283,30 @@ struct tty_struct {
        struct mutex throttle_mutex;
        struct rw_semaphore termios_rwsem;
        struct mutex winsize_mutex;
-       spinlock_t ctrl_lock;
-       spinlock_t flow_lock;
        /* Termios values are protected by the termios rwsem */
        struct ktermios termios, termios_locked;
        char name[64];
-       struct pid *pgrp;               /* Protected by ctrl lock */
-       /*
-        * Writes protected by both ctrl lock and legacy mutex, readers must use
-        * at least one of them.
-        */
-       struct pid *session;
        unsigned long flags;
        int count;
        struct winsize winsize;         /* winsize_mutex */
-       unsigned long stopped:1,        /* flow_lock */
-                     flow_stopped:1,
-                     unused:BITS_PER_LONG - 2;
+
+       struct {
+               spinlock_t lock;
+               bool stopped;
+               bool tco_stopped;
+               unsigned long unused[0];
+       } __aligned(sizeof(unsigned long)) flow;
+
+       struct {
+               spinlock_t lock;
+               struct pid *pgrp;
+               struct pid *session;
+               unsigned char pktstatus;
+               bool packet;
+               unsigned long unused[0];
+       } __aligned(sizeof(unsigned long)) ctrl;
+
        int hw_stopped;
-       unsigned long ctrl_status:8,    /* ctrl_lock */
-                     packet:1,
-                     unused_ctrl:BITS_PER_LONG - 9;
        unsigned int receive_room;      /* Bytes free for queue */
        int flow_change;
 
@@ -446,10 +458,9 @@ extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
 extern void tty_write_message(struct tty_struct *tty, char *msg);
 extern int tty_send_xchar(struct tty_struct *tty, char ch);
 extern int tty_put_char(struct tty_struct *tty, unsigned char c);
-extern int tty_chars_in_buffer(struct tty_struct *tty);
-extern int tty_write_room(struct tty_struct *tty);
+extern unsigned int tty_chars_in_buffer(struct tty_struct *tty);
+extern unsigned int tty_write_room(struct tty_struct *tty);
 extern void tty_driver_flush_buffer(struct tty_struct *tty);
-extern void tty_throttle(struct tty_struct *tty);
 extern void tty_unthrottle(struct tty_struct *tty);
 extern int tty_throttle_safe(struct tty_struct *tty);
 extern int tty_unthrottle_safe(struct tty_struct *tty);
@@ -624,11 +635,11 @@ static inline int tty_port_users(struct tty_port *port)
        return port->count + port->blocked_open;
 }
 
-extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
-extern int tty_unregister_ldisc(int disc);
+extern int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc);
+extern void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc);
 extern int tty_set_ldisc(struct tty_struct *tty, int disc);
 extern int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p,
-                                char *f, int count);
+                                const char *f, int count);
 
 /* n_tty.c */
 extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops);
index 2f719b4..448f8ee 100644 (file)
@@ -89,7 +89,7 @@
  *
  *     Note: Do not call this function directly, call tty_driver_flush_chars
  * 
- * int  (*write_room)(struct tty_struct *tty);
+ * unsigned int  (*write_room)(struct tty_struct *tty);
  *
  *     This routine returns the numbers of characters the tty driver
  *     will accept for queuing to be written.  This number is subject
  *     the line discipline are close to full, and it should somehow
  *     signal that no more characters should be sent to the tty.
  *
- *     Optional: Always invoke via tty_throttle(), called under the
+ *     Optional: Always invoke via tty_throttle_safe(), called under the
  *     termios lock.
  * 
  * void (*unthrottle)(struct tty_struct * tty);
  *     This routine notifies the tty driver that it should stop
  *     outputting characters to the tty device.  
  *
- *     Called with ->flow_lock held. Serialized with start() method.
+ *     Called with ->flow.lock held. Serialized with start() method.
  *
  *     Optional:
  *
  *     This routine notifies the tty driver that it resume sending
  *     characters to the tty device.
  *
- *     Called with ->flow_lock held. Serialized with stop() method.
+ *     Called with ->flow.lock held. Serialized with stop() method.
  *
  *     Optional:
  *
@@ -256,8 +256,8 @@ struct tty_operations {
                      const unsigned char *buf, int count);
        int  (*put_char)(struct tty_struct *tty, unsigned char ch);
        void (*flush_chars)(struct tty_struct *tty);
-       int  (*write_room)(struct tty_struct *tty);
-       int  (*chars_in_buffer)(struct tty_struct *tty);
+       unsigned int (*write_room)(struct tty_struct *tty);
+       unsigned int (*chars_in_buffer)(struct tty_struct *tty);
        int  (*ioctl)(struct tty_struct *tty,
                    unsigned int cmd, unsigned long arg);
        long (*compat_ioctl)(struct tty_struct *tty,
index 767f620..d672928 100644 (file)
@@ -3,7 +3,7 @@
 #define _LINUX_TTY_FLIP_H
 
 extern int tty_buffer_set_limit(struct tty_port *port, int limit);
-extern int tty_buffer_space_avail(struct tty_port *port);
+extern unsigned int tty_buffer_space_avail(struct tty_port *port);
 extern int tty_buffer_request_room(struct tty_port *port, size_t size);
 extern int tty_insert_flip_string_flags(struct tty_port *port,
                const unsigned char *chars, const char *flags, size_t size);
index 31284b5..fbe9de2 100644 (file)
@@ -201,15 +201,13 @@ struct tty_ldisc_ops {
         * The following routines are called from below.
         */
        void    (*receive_buf)(struct tty_struct *, const unsigned char *cp,
-                              char *fp, int count);
+                              const char *fp, int count);
        void    (*write_wakeup)(struct tty_struct *);
        void    (*dcd_change)(struct tty_struct *, unsigned int);
        int     (*receive_buf2)(struct tty_struct *, const unsigned char *cp,
-                               char *fp, int count);
+                               const char *fp, int count);
 
        struct  module *owner;
-
-       int refcount;
 };
 
 struct tty_ldisc {
diff --git a/include/uapi/linux/n_r3964.h b/include/uapi/linux/n_r3964.h
deleted file mode 100644 (file)
index 6bbd185..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
-/* r3964 linediscipline for linux
- *
- * -----------------------------------------------------------
- * Copyright by
- * Philips Automation Projects
- * Kassel (Germany)
- * -----------------------------------------------------------
- * This software may be used and distributed according to the terms of
- * the GNU General Public License, incorporated herein by reference.
- *
- * Author:
- * L. Haag
- *
- * $Log: r3964.h,v $
- * Revision 1.4  2005/12/21 19:54:24  Kurt Huwig <kurt huwig de>
- * Fixed HZ usage on 2.6 kernels
- * Removed unnecessary include
- *
- * Revision 1.3  2001/03/18 13:02:24  dwmw2
- * Fix timer usage, use spinlocks properly.
- *
- * Revision 1.2  2001/03/18 12:53:15  dwmw2
- * Merge changes in 2.4.2
- *
- * Revision 1.1.1.1  1998/10/13 16:43:14  dwmw2
- * This'll screw the version control
- *
- * Revision 1.6  1998/09/30 00:40:38  dwmw2
- * Updated to use kernel's N_R3964 if available
- *
- * Revision 1.4  1998/04/02 20:29:44  lhaag
- * select, blocking, ...
- *
- * Revision 1.3  1998/02/12 18:58:43  root
- * fixed some memory leaks
- * calculation of checksum characters
- *
- * Revision 1.2  1998/02/07 13:03:17  root
- * ioctl read_telegram
- *
- * Revision 1.1  1998/02/06 19:19:43  root
- * Initial revision
- *
- *
- */
-
-#ifndef _UAPI__LINUX_N_R3964_H__
-#define _UAPI__LINUX_N_R3964_H__
-
-/* line disciplines for r3964 protocol */
-
-
-/*
- * Ioctl-commands
- */
-
-#define R3964_ENABLE_SIGNALS      0x5301
-#define R3964_SETPRIORITY         0x5302
-#define R3964_USE_BCC             0x5303
-#define R3964_READ_TELEGRAM       0x5304
-
-/* Options for R3964_SETPRIORITY */
-#define R3964_MASTER   0
-#define R3964_SLAVE    1
-
-/* Options for R3964_ENABLE_SIGNALS */
-#define R3964_SIG_ACK   0x0001
-#define R3964_SIG_DATA  0x0002
-#define R3964_SIG_ALL   0x000f
-#define R3964_SIG_NONE  0x0000
-#define R3964_USE_SIGIO 0x1000
-
-/*
- * r3964 operation states:
- */
-
-/* types for msg_id: */
-enum {R3964_MSG_ACK=1, R3964_MSG_DATA };
-
-#define R3964_MAX_MSG_COUNT 32
-
-/* error codes for client messages */
-#define R3964_OK 0        /* no error. */
-#define R3964_TX_FAIL -1  /* transmission error, block NOT sent */
-#define R3964_OVERFLOW -2 /* msg queue overflow */
-
-/* the client gets this struct when calling read(fd,...): */
-struct r3964_client_message {
-         int     msg_id;
-         int     arg;
-         int     error_code;
-};
-
-#define R3964_MTU      256
-
-
-
-#endif /* _UAPI__LINUX_N_R3964_H__ */
index a585849..c76dcc0 100644 (file)
@@ -807,7 +807,7 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in
        return sent;
 }
 
-static int rfcomm_tty_write_room(struct tty_struct *tty)
+static unsigned int rfcomm_tty_write_room(struct tty_struct *tty)
 {
        struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
        int room = 0;
@@ -1010,7 +1010,7 @@ static void rfcomm_tty_unthrottle(struct tty_struct *tty)
        rfcomm_dlc_unthrottle(dev->dlc);
 }
 
-static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty)
+static unsigned int rfcomm_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
index 1248faf..502e7a3 100644 (file)
@@ -308,7 +308,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data,
  * Return Value:    None
  */
 static void nci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
-                                char *flags, int count)
+                                const char *flags, int count)
 {
        struct nci_uart *nu = (void *)tty->disc_data;
 
@@ -442,6 +442,7 @@ EXPORT_SYMBOL_GPL(nci_uart_set_config);
 
 static struct tty_ldisc_ops nci_uart_ldisc = {
        .owner          = THIS_MODULE,
+       .num            = N_NCI,
        .name           = "n_nci",
        .open           = nci_uart_tty_open,
        .close          = nci_uart_tty_close,
@@ -456,12 +457,12 @@ static struct tty_ldisc_ops nci_uart_ldisc = {
 
 static int __init nci_uart_init(void)
 {
-       return tty_register_ldisc(N_NCI, &nci_uart_ldisc);
+       return tty_register_ldisc(&nci_uart_ldisc);
 }
 
 static void __exit nci_uart_exit(void)
 {
-       tty_unregister_ldisc(N_NCI);
+       tty_unregister_ldisc(&nci_uart_ldisc);
 }
 
 module_init(nci_uart_init);
index 61dfa86..ec8d6e7 100644 (file)
@@ -259,8 +259,8 @@ static int v253_hangup(struct tty_struct *tty)
 }
 
 /* Line discipline .receive_buf() */
-static void v253_receive(struct tty_struct *tty,
-                               const unsigned char *cp, char *fp, int count)
+static void v253_receive(struct tty_struct *tty, const unsigned char *cp,
+               const char *fp, int count)
 {
        struct snd_soc_component *component = tty->disc_data;
        struct cx20442_priv *cx20442;
index aba0017..ecd24d4 100644 (file)
@@ -337,8 +337,8 @@ static int cx81801_hangup(struct tty_struct *tty)
 }
 
 /* Line discipline .receive_buf() */
-static void cx81801_receive(struct tty_struct *tty,
-                               const unsigned char *cp, char *fp, int count)
+static void cx81801_receive(struct tty_struct *tty, const unsigned char *cp,
+               const char *fp, int count)
 {
        struct snd_soc_component *component = tty->disc_data;
        const unsigned char *c;
@@ -396,6 +396,7 @@ static void cx81801_wakeup(struct tty_struct *tty)
 
 static struct tty_ldisc_ops cx81801_ops = {
        .name = "cx81801",
+       .num = N_V253,
        .owner = THIS_MODULE,
        .open = cx81801_open,
        .close = cx81801_close,
@@ -503,7 +504,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
        }
 
        /* Register optional line discipline for over the modem control */
-       ret = tty_register_ldisc(N_V253, &cx81801_ops);
+       ret = tty_register_ldisc(&cx81801_ops);
        if (ret) {
                dev_warn(card->dev,
                                "Failed to register line discipline, "
@@ -582,9 +583,7 @@ static int ams_delta_remove(struct platform_device *pdev)
 {
        struct snd_soc_card *card = platform_get_drvdata(pdev);
 
-       if (tty_unregister_ldisc(N_V253) != 0)
-               dev_warn(&pdev->dev,
-                       "failed to unregister V253 line discipline\n");
+       tty_unregister_ldisc(&cx81801_ops);
 
        snd_soc_unregister_card(card);
        card->dev = NULL;