tty/serial: Migrate 8250_fsl to use has_sysrq
authorDmitry Safonov <dima@arista.com>
Fri, 13 Dec 2019 00:06:04 +0000 (00:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Dec 2019 14:04:42 +0000 (15:04 +0100)
The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between
  different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added.
Initialise it in driver's probe and remove ifdeffery.

In contrast to 8250/8250_of, legacy_serial on powerpc does fill
(struct plat_serial8250_port). The reason is likely that it's done on
device_initcall(), not on probe. So, 8250_core is not yet probed.

Propagate value from platform_device on 8250 probe - in case powepc
legacy driver it's initialized on initcall, in case 8250_of it will be
initialized later on of_platform_serial_setup().

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
Link: https://lore.kernel.org/r/20191213000657.931618-6-dima@arista.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kernel/legacy_serial.c
drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/8250/8250_fsl.c
drivers/tty/serial/8250/8250_of.c
include/linux/serial_8250.h

index 7cea597..f061e06 100644 (file)
@@ -479,8 +479,10 @@ static void __init fixup_port_irq(int index,
        port->irq = virq;
 
 #ifdef CONFIG_SERIAL_8250_FSL
-       if (of_device_is_compatible(np, "fsl,ns16550"))
+       if (of_device_is_compatible(np, "fsl,ns16550")) {
                port->handle_irq = fsl8250_handle_irq;
+               port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
+       }
 #endif
 }
 
index e682390..0894a22 100644 (file)
@@ -816,6 +816,7 @@ static int serial8250_probe(struct platform_device *dev)
                uart.port.flags         = p->flags;
                uart.port.mapbase       = p->mapbase;
                uart.port.hub6          = p->hub6;
+               uart.port.has_sysrq     = p->has_sysrq;
                uart.port.private_data  = p->private_data;
                uart.port.type          = p->type;
                uart.port.serial_in     = p->serial_in;
index aa0e216..0d0c809 100644 (file)
@@ -1,8 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_reg.h>
 #include <linux/serial_8250.h>
 
index 92fbf46..531ad67 100644 (file)
@@ -222,8 +222,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 
        if (IS_ENABLED(CONFIG_SERIAL_8250_FSL) &&
            (of_device_is_compatible(np, "fsl,ns16550") ||
-            of_device_is_compatible(np, "fsl,16550-FIFO64")))
+            of_device_is_compatible(np, "fsl,16550-FIFO64"))) {
                port->handle_irq = fsl8250_handle_irq;
+               port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
+       }
 
        return 0;
 err_unprepare:
index bb2bc99..6a8e8c4 100644 (file)
@@ -25,6 +25,7 @@ struct plat_serial8250_port {
        unsigned char   regshift;       /* register shift */
        unsigned char   iotype;         /* UPIO_* */
        unsigned char   hub6;
+       unsigned char   has_sysrq;      /* supports magic SysRq */
        upf_t           flags;          /* UPF_* flags */
        unsigned int    type;           /* If UPF_FIXED_TYPE */
        unsigned int    (*serial_in)(struct uart_port *, int);