Linux-Serial Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 01/58] sysrq: Remove sysrq_handler_registered
       [not found] <20191213000657.931618-1-dima@arista.com>
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 02/58] serial: Move sysrq members above Dmitry Safonov
                   ` (56 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

sysrq_toggle_support() can be called in parallel, in return calling
input_(un)register_handler(), which fortunately is safe to call
in parallel and regardless of registered/unregistered status of
sysrq_handler.
Remove sysrq_handler_registered as it doesn't have any function there
and may confuse reader about possible race.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/sysrq.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 573b2055173c..1d4f317a0e42 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -967,8 +967,6 @@ static struct input_handler sysrq_handler = {
 	.id_table	= sysrq_ids,
 };
 
-static bool sysrq_handler_registered;
-
 static inline void sysrq_register_handler(void)
 {
 	int error;
@@ -978,16 +976,11 @@ static inline void sysrq_register_handler(void)
 	error = input_register_handler(&sysrq_handler);
 	if (error)
 		pr_err("Failed to register input handler, error %d", error);
-	else
-		sysrq_handler_registered = true;
 }
 
 static inline void sysrq_unregister_handler(void)
 {
-	if (sysrq_handler_registered) {
-		input_unregister_handler(&sysrq_handler);
-		sysrq_handler_registered = false;
-	}
+	input_unregister_handler(&sysrq_handler);
 }
 
 static int sysrq_reset_seq_param_set(const char *buffer,
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 02/58] serial: Move sysrq members above
       [not found] <20191213000657.931618-1-dima@arista.com>
  2019-12-13  0:06 ` [PATCH 01/58] sysrq: Remove sysrq_handler_registered Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  7:17   ` Greg Kroah-Hartman
  2019-12-13  0:06 ` [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ Dmitry Safonov
                   ` (55 subsequent siblings)
  57 siblings, 1 reply; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

At the current place members those follow are:
:	upf_t			flags;
:	upstat_t		status;
:	int			hw_stopped;
:	unsigned int		mctrl;
:	unsigned int		timeout;
:	unsigned int		type;
:	const struct uart_ops	*ops;

Together, they give (*ops) 8-byte align on 64-bit platforms.
And `sysrq_ch` introduces 4-byte padding.

On the other side, above:
:	struct device		*dev;
:	unsigned char		hub6;
:	unsigned char		suspended;
:	unsigned char		unused[2];
:	const char		*name;

Adds another 4-byte padding.

Moving sysrq members just before `hub6` allows to save 8 bytes
per-uart_port on 64-bit platforms:
On my gcc, x86_64 sizeof(struct uart_port) goes from 528 to 520.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 include/linux/serial_core.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 2b78cc734719..bbbe57bf5163 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -161,11 +161,6 @@ struct uart_port {
 	struct uart_icount	icount;			/* statistics */
 
 	struct console		*cons;			/* struct console, if any */
-#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
-	unsigned long		sysrq;			/* sysrq timeout */
-	unsigned int		sysrq_ch;		/* char for sysrq */
-#endif
-
 	/* flags must be updated while holding port mutex */
 	upf_t			flags;
 
@@ -244,6 +239,12 @@ struct uart_port {
 	resource_size_t		mapbase;		/* for ioremap */
 	resource_size_t		mapsize;
 	struct device		*dev;			/* parent device */
+
+#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
+	unsigned long		sysrq;			/* sysrq timeout */
+	unsigned int		sysrq_ch;		/* char for sysrq */
+#endif
+
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
 	unsigned char		unused[2];
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ
       [not found] <20191213000657.931618-1-dima@arista.com>
  2019-12-13  0:06 ` [PATCH 01/58] sysrq: Remove sysrq_handler_registered Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 02/58] serial: Move sysrq members above Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  7:18   ` Greg Kroah-Hartman
                     ` (2 more replies)
  2019-12-13  0:06 ` [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq Dmitry Safonov
                   ` (54 subsequent siblings)
  57 siblings, 3 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

The SUPPORT_SYSRQ is messy: every .c source should define it before
including "serial_core.h" if sysrq is supported or struct uart_port will
differ in sizes. Also this prevents moving to serial_core.c functions:
uart_handle_sysrq_char(), uart_prepare_sysrq_char(),
uart_unlock_and_check_sysrq().

It doesn't save many bytes in the structure, and a better way to reduce
it's size would be making rs485 and iso7816 pointers.

Introduce `has_sysrq` member to be used by serial line drivers further.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 include/linux/serial_core.h | 77 +++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 34 deletions(-)

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index bbbe57bf5163..5f761c399282 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -240,14 +240,13 @@ struct uart_port {
 	resource_size_t		mapsize;
 	struct device		*dev;			/* parent device */
 
-#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
 	unsigned long		sysrq;			/* sysrq timeout */
 	unsigned int		sysrq_ch;		/* char for sysrq */
-#endif
+	unsigned char		has_sysrq;
 
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
-	unsigned char		unused[2];
+	unsigned char		unused;
 	const char		*name;			/* port name */
 	struct attribute_group	*attr_group;		/* port specific attributes */
 	const struct attribute_group **tty_groups;	/* all attributes (serial core use only) */
@@ -461,31 +460,46 @@ extern void uart_handle_cts_change(struct uart_port *uport,
 extern void uart_insert_char(struct uart_port *port, unsigned int status,
 		 unsigned int overrun, unsigned int ch, unsigned int flag);
 
-#if defined(SUPPORT_SYSRQ) && defined(CONFIG_MAGIC_SYSRQ_SERIAL)
 static inline int
 uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 {
-	if (port->sysrq) {
-		if (ch && time_before(jiffies, port->sysrq)) {
-			handle_sysrq(ch);
-			port->sysrq = 0;
-			return 1;
-		}
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
+		return 0;
+
+	if (!port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		handle_sysrq(ch);
 		port->sysrq = 0;
+		return 1;
 	}
+	port->sysrq = 0;
+
 	return 0;
 }
 static inline int
 uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
 {
-	if (port->sysrq) {
-		if (ch && time_before(jiffies, port->sysrq)) {
-			port->sysrq_ch = ch;
-			port->sysrq = 0;
-			return 1;
-		}
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
+		return 0;
+
+	if (!port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		port->sysrq_ch = ch;
 		port->sysrq = 0;
+		return 1;
 	}
+	port->sysrq = 0;
+
 	return 0;
 }
 static inline void
@@ -493,6 +507,11 @@ uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
 {
 	int sysrq_ch;
 
+	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ)) {
+		spin_unlock_irqrestore(&port->lock, irqflags);
+		return;
+	}
+
 	sysrq_ch = port->sysrq_ch;
 	port->sysrq_ch = 0;
 
@@ -501,17 +520,6 @@ uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
 	if (sysrq_ch)
 		handle_sysrq(sysrq_ch);
 }
-#else
-static inline int
-uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) { return 0; }
-static inline int
-uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) { return 0; }
-static inline void
-uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
-{
-	spin_unlock_irqrestore(&port->lock, irqflags);
-}
-#endif
 
 /*
  * We do the SysRQ and SAK checking like this...
@@ -523,15 +531,16 @@ static inline int uart_handle_break(struct uart_port *port)
 	if (port->handle_break)
 		port->handle_break(port);
 
-#ifdef SUPPORT_SYSRQ
-	if (port->cons && port->cons->index == port->line) {
-		if (!port->sysrq) {
-			port->sysrq = jiffies + HZ*5;
-			return 1;
+	if (port->has_sysrq || IS_ENABLED(SUPPORT_SYSRQ)) {
+		if (port->cons && port->cons->index == port->line) {
+			if (!port->sysrq) {
+				port->sysrq = jiffies + HZ*5;
+				return 1;
+			}
+			port->sysrq = 0;
 		}
-		port->sysrq = 0;
 	}
-#endif
+
 	if (port->flags & UPF_SAK)
 		do_SAK(state->port.tty);
 	return 0;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (2 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  1:32   ` Andrew Jeffery
  2019-12-13  0:06 ` [PATCH 05/58] tty/serial: Migrate 8250_fsl " Dmitry Safonov
                   ` (53 subsequent siblings)
  57 siblings, 1 reply; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Andrew Jeffery, Joel Stanley,
	linux-arm-kernel, linux-aspeed

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.

Cc: Andrew Jeffery <andrew@aj.id.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-aspeed@lists.ozlabs.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/8250/8250_aspeed_vuart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c
index 6e67fd89445a..d657aa14c3e4 100644
--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -5,10 +5,6 @@
  *    Copyright (C) 2016 Jeremy Kerr <jk@ozlabs.org>, IBM Corp.
  *    Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp.
  */
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
@@ -406,6 +402,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
 	port.port.unthrottle = aspeed_vuart_unthrottle;
 	port.port.status = UPSTAT_SYNC_FIFO;
 	port.port.dev = &pdev->dev;
+	port.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
 	rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
 	if (rc < 0)
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 05/58] tty/serial: Migrate 8250_fsl to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (3 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 06/58] tty/serial: Migrate bcm63xx_uart " Dmitry Safonov
                   ` (52 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, linuxppc-dev

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.

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>
---
 arch/powerpc/kernel/legacy_serial.c | 4 +++-
 drivers/tty/serial/8250/8250_fsl.c  | 4 ----
 drivers/tty/serial/8250/8250_of.c   | 4 +++-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 7cea5978f21f..f061e06e9f51 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -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
 }
 
diff --git a/drivers/tty/serial/8250/8250_fsl.c b/drivers/tty/serial/8250/8250_fsl.c
index aa0e216d5ead..0d0c80905c58 100644
--- a/drivers/tty/serial/8250/8250_fsl.c
+++ b/drivers/tty/serial/8250/8250_fsl.c
@@ -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>
 
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 92fbf46ce3bd..531ad67395e0 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -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:
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 06/58] tty/serial: Migrate bcm63xx_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (4 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 05/58] tty/serial: Migrate 8250_fsl " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 07/58] tty/serial: Migrate 8250_omap " Dmitry Safonov
                   ` (51 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Florian Fainelli,
	bcm-kernel-feedback-list, linux-arm-kernel

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.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/bcm63xx_uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index b7adc6127b3d..5674da2b76f0 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -10,10 +10,6 @@
  * my board.
  */
 
-#if defined(CONFIG_SERIAL_BCM63XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/init.h>
@@ -858,6 +854,7 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	port->fifosize = 16;
 	port->uartclk = clk_get_rate(clk) / 2;
 	port->line = pdev->id;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_BCM63XX_CONSOLE);
 	clk_put(clk);
 
 	ret = uart_add_one_port(&bcm_uart_driver, port);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 07/58] tty/serial: Migrate 8250_omap to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (5 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 06/58] tty/serial: Migrate bcm63xx_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 08/58] tty/serial: Migrate 8250_port " Dmitry Safonov
                   ` (50 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/8250/8250_omap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 836e736ae188..1ee7b89817dd 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -8,10 +8,6 @@
  *
  */
 
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/io.h>
@@ -1192,6 +1188,7 @@ static int omap8250_probe(struct platform_device *pdev)
 	up.port.throttle = omap_8250_throttle;
 	up.port.unthrottle = omap_8250_unthrottle;
 	up.port.rs485_config = omap_8250_rs485_config;
+	up.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
 	ret = of_alias_get_id(np, "serial");
 	if (ret < 0) {
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 08/58] tty/serial: Migrate 8250_port to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (6 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 07/58] tty/serial: Migrate 8250_omap " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 09/58] tty/serial: Migrate amba-pl01* " Dmitry Safonov
                   ` (49 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/8250/8250_port.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 90655910b0c7..8243f280a2ec 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -11,10 +11,6 @@
  *  membase is an 'ioremapped' cookie.
  */
 
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ioport.h>
@@ -3055,6 +3051,7 @@ void serial8250_init_port(struct uart_8250_port *up)
 
 	spin_lock_init(&port->lock);
 	port->ops = &serial8250_pops;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
 	up->cur_iotype = 0xFF;
 }
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 09/58] tty/serial: Migrate amba-pl01* to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (7 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 08/58] tty/serial: Migrate 8250_port " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 10/58] tty/serial: Migrate apbuart " Dmitry Safonov
                   ` (48 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Russell King

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.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/amba-pl010.c | 5 +----
 drivers/tty/serial/amba-pl011.c | 6 +-----
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 2c37d11726ab..3284f34e9dfe 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -15,10 +15,6 @@
  * and hooked into this driver.
  */
 
-#if defined(CONFIG_SERIAL_AMBA_PL010_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -728,6 +724,7 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
 	uap->port.iotype = UPIO_MEM;
 	uap->port.irq = dev->irq[0];
 	uap->port.fifosize = 16;
+	uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_AMBA_PL010_CONSOLE);
 	uap->port.ops = &amba_pl010_pops;
 	uap->port.flags = UPF_BOOT_AUTOCONF;
 	uap->port.line = i;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 4b28134d596a..952483ec8ea1 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -16,11 +16,6 @@
  * and hooked into this driver.
  */
 
-
-#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -2579,6 +2574,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
 	uap->port.mapbase = mmiobase->start;
 	uap->port.membase = base;
 	uap->port.fifosize = uap->fifosize;
+	uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_AMBA_PL011_CONSOLE);
 	uap->port.flags = UPF_BOOT_AUTOCONF;
 	uap->port.line = index;
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 10/58] tty/serial: Migrate apbuart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (8 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 09/58] tty/serial: Migrate amba-pl01* " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 11/58] tty/serial: Migrate arc_uart " Dmitry Safonov
                   ` (47 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/apbuart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 60cd133ffbbc..e8d56e899ec7 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -11,10 +11,6 @@
  *  Copyright (C) 2009 Kristoffer Glembo <kristoffer@gaisler.com>, Aeroflex Gaisler AB
  */
 
-#if defined(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
@@ -626,6 +622,7 @@ static int __init grlib_apbuart_configure(void)
 		port->irq = 0;
 		port->iotype = UPIO_MEM;
 		port->ops = &grlib_apbuart_ops;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE);
 		port->flags = UPF_BOOT_AUTOCONF;
 		port->line = line;
 		port->uartclk = *freq_hz;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 11/58] tty/serial: Migrate arc_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (9 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 10/58] tty/serial: Migrate apbuart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 12/58] tty/serial: Migrate atmel_serial " Dmitry Safonov
                   ` (46 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Vineet Gupta

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.

Cc: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/arc_uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index d904a3a345e7..17c3fc398fc6 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -21,10 +21,6 @@
  *  -check if sysreq works
  */
 
-#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -625,6 +621,7 @@ static int arc_serial_probe(struct platform_device *pdev)
 	port->flags = UPF_BOOT_AUTOCONF;
 	port->line = dev_id;
 	port->ops = &arc_serial_pops;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ARC_CONSOLE);
 
 	port->fifosize = ARC_UART_TX_FIFO_SIZE;
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 12/58] tty/serial: Migrate atmel_serial to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (10 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 11/58] tty/serial: Migrate arc_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 13/58] tty/serial: Migrate clps711x " Dmitry Safonov
                   ` (45 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Alexandre Belloni,
	Ludovic Desroches, Richard Genoud, linux-arm-kernel

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.

While at it, remove forward-declaration of atmel_console - it wasn't
needed even at the moment the driver was first time introduced:
commit 1e6c9c2878c9 ("[ARM] 3242/2: AT91RM9200 support for 2.6 (Serial)")

Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Richard Genoud <richard.genoud@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/atmel_serial.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index a8dc8af83f39..4020fc8ceb49 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -51,10 +51,6 @@
 #define ATMEL_RTS_HIGH_OFFSET	16
 #define ATMEL_RTS_LOW_OFFSET	20
 
-#if defined(CONFIG_SERIAL_ATMEL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 #include "serial_mctrl_gpio.h"
@@ -196,10 +192,6 @@ struct atmel_uart_port {
 static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
 static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART);
 
-#ifdef SUPPORT_SYSRQ
-static struct console atmel_console;
-#endif
-
 #if defined(CONFIG_OF)
 static const struct of_device_id atmel_serial_dt_ids[] = {
 	{ .compatible = "atmel,at91rm9200-usart-serial" },
@@ -2877,6 +2869,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
 	atmel_port = &atmel_ports[ret];
 	atmel_port->backup_imr = 0;
 	atmel_port->uart.line = ret;
+	atmel_port->uart.has_sysrq = IS_ENABLED(CONFIG_SERIAL_ATMEL_CONSOLE);
 	atmel_serial_probe_fifos(atmel_port, pdev);
 
 	atomic_set(&atmel_port->tasklet_shutdown, 0);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 13/58] tty/serial: Migrate clps711x to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (11 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 12/58] tty/serial: Migrate atmel_serial " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 14/58] tty/serial: Migrate cpm_uart " Dmitry Safonov
                   ` (44 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Alexander Shiyan,
	linux-arm-kernel

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.

Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/clps711x.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index 061590795680..95abc6faa3d5 100644
--- a/drivers/tty/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
@@ -8,10 +8,6 @@
  *  Copyright (C) 2000 Deep Blue Solutions Ltd.
  */
 
-#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/console.h>
@@ -479,6 +475,7 @@ static int uart_clps711x_probe(struct platform_device *pdev)
 	s->port.mapbase		= res->start;
 	s->port.type		= PORT_CLPS711X;
 	s->port.fifosize	= 16;
+	s->port.has_sysrq	= IS_ENABLED(CONFIG_SERIAL_CLPS711X_CONSOLE);
 	s->port.flags		= UPF_SKIP_TEST | UPF_FIXED_TYPE;
 	s->port.uartclk		= clk_get_rate(uart_clk);
 	s->port.ops		= &uart_clps711x_ops;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 14/58] tty/serial: Migrate cpm_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (12 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 13/58] tty/serial: Migrate clps711x " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 15/58] tty/serial: Migrate dz " Dmitry Safonov
                   ` (43 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index de6d02f7abe2..19d5a4cf29a6 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -40,10 +40,6 @@
 #include <asm/fs_pd.h>
 #include <asm/udbg.h>
 
-#if defined(CONFIG_SERIAL_CPM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/kernel.h>
 
@@ -347,9 +343,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
 		/* ASSUMPTION: it contains nothing valid */
 		i = 0;
 	}
-#ifdef SUPPORT_SYSRQ
 	port->sysrq = 0;
-#endif
 	goto error_return;
 }
 
@@ -1204,7 +1198,8 @@ static int cpm_uart_init_port(struct device_node *np,
 	pinfo->port.uartclk = ppc_proc_freq;
 	pinfo->port.mapbase = (unsigned long)mem;
 	pinfo->port.type = PORT_CPM;
-	pinfo->port.ops = &cpm_uart_pops,
+	pinfo->port.ops = &cpm_uart_pops;
+	pinfo->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_CPM_CONSOLE);
 	pinfo->port.iotype = UPIO_MEM;
 	pinfo->port.fifosize = pinfo->tx_nrfifos * pinfo->tx_fifosize;
 	spin_lock_init(&pinfo->port.lock);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 15/58] tty/serial: Migrate dz to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (13 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 14/58] tty/serial: Migrate cpm_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 16/58] tty/serial: Migrate efm32-uart " Dmitry Safonov
                   ` (42 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Maciej W. Rozycki

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.

Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/dz.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 7b57e840e255..6192ed011bc3 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -29,10 +29,6 @@
 
 #undef DEBUG_DZ
 
-#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <linux/console.h>
@@ -787,6 +783,7 @@ static void __init dz_init_ports(void)
 		uport->ops	= &dz_ops;
 		uport->line	= line;
 		uport->mapbase	= base;
+		uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_DZ_CONSOLE);
 	}
 }
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 16/58] tty/serial: Migrate efm32-uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (14 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 15/58] tty/serial: Migrate dz " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 17/58] tty/serial: Migrate fsl_linflexuart " Dmitry Safonov
                   ` (41 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Uwe Kleine-König,
	Pengutronix Kernel Team, linux-arm-kernel

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.

Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/efm32-uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index d6b5e5463746..2ac87128d7fd 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -1,8 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#if defined(CONFIG_SERIAL_EFM32_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/io.h>
@@ -748,6 +744,7 @@ static int efm32_uart_probe(struct platform_device *pdev)
 	efm_port->port.type = PORT_EFMUART;
 	efm_port->port.iotype = UPIO_MEM32;
 	efm_port->port.fifosize = 2;
+	efm_port->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_EFM32_UART_CONSOLE);
 	efm_port->port.ops = &efm32_uart_pops;
 	efm_port->port.flags = UPF_BOOT_AUTOCONF;
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 17/58] tty/serial: Migrate fsl_linflexuart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (15 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 16/58] tty/serial: Migrate efm32-uart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 18/58] tty/serial: Migrate fsl_lpuart " Dmitry Safonov
                   ` (40 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/fsl_linflexuart.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c
index 205c31a61684..3e28be402aef 100644
--- a/drivers/tty/serial/fsl_linflexuart.c
+++ b/drivers/tty/serial/fsl_linflexuart.c
@@ -6,11 +6,6 @@
  * Copyright 2017-2019 NXP
  */
 
-#if defined(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE) && \
-	defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/console.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -279,10 +274,8 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
 		if (brk) {
 			uart_handle_break(sport);
 		} else {
-#ifdef SUPPORT_SYSRQ
 			if (uart_handle_sysrq_char(sport, (unsigned char)rx))
 				continue;
-#endif
 			tty_insert_flip_char(port, rx, flg);
 		}
 	}
@@ -863,6 +856,7 @@ static int linflex_probe(struct platform_device *pdev)
 	sport->irq = platform_get_irq(pdev, 0);
 	sport->ops = &linflex_pops;
 	sport->flags = UPF_BOOT_AUTOCONF;
+	sport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE);
 
 	linflex_ports[sport->line] = sport;
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 18/58] tty/serial: Migrate fsl_lpuart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (16 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 17/58] tty/serial: Migrate fsl_linflexuart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 19/58] tty/serial: Migrate imx " Dmitry Safonov
                   ` (39 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/fsl_lpuart.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 4e128d19e0ad..76c69d255d92 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -5,10 +5,6 @@
  *  Copyright 2012-2014 Freescale Semiconductor, Inc.
  */
 
-#if defined(CONFIG_SERIAL_FSL_LPUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/dma-mapping.h>
@@ -864,9 +860,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
 			if (sr & UARTSR1_OR)
 				flg = TTY_OVERRUN;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		tty_insert_flip_char(port, rx, flg);
@@ -946,9 +940,7 @@ static void lpuart32_rxint(struct lpuart_port *sport)
 			if (sr & UARTSTAT_OR)
 				flg = TTY_OVERRUN;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		tty_insert_flip_char(port, rx, flg);
@@ -2461,6 +2453,7 @@ static int lpuart_probe(struct platform_device *pdev)
 		sport->port.ops = &lpuart32_pops;
 	else
 		sport->port.ops = &lpuart_pops;
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_FSL_LPUART_CONSOLE);
 	sport->port.flags = UPF_BOOT_AUTOCONF;
 
 	if (lpuart_is_32(sport))
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 19/58] tty/serial: Migrate imx to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (17 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 18/58] tty/serial: Migrate fsl_lpuart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 20/58] tty/serial: Migrate ip22zilog " Dmitry Safonov
                   ` (38 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Fabio Estevam, NXP Linux Team,
	Pengutronix Kernel Team, Sascha Hauer, Shawn Guo,
	linux-arm-kernel

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.

Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/imx.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index a9e20e6c63ad..83c6e2ac0e8d 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -8,10 +8,6 @@
  * Copyright (C) 2004 Pengutronix
  */
 
-#if defined(CONFIG_SERIAL_IMX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -779,9 +775,7 @@ static irqreturn_t imx_uart_rxint(int irq, void *dev_id)
 			if (rx & URXD_OVRRUN)
 				flg = TTY_OVERRUN;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		if (sport->port.ignore_status_mask & URXD_DUMMY_READ)
@@ -2231,6 +2225,7 @@ static int imx_uart_probe(struct platform_device *pdev)
 	sport->port.iotype = UPIO_MEM;
 	sport->port.irq = rxirq;
 	sport->port.fifosize = 32;
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE);
 	sport->port.ops = &imx_uart_pops;
 	sport->port.rs485_config = imx_uart_rs485_config;
 	sport->port.flags = UPF_BOOT_AUTOCONF;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 20/58] tty/serial: Migrate ip22zilog to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (18 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 19/58] tty/serial: Migrate imx " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 21/58] tty/serial: Migrate meson_uart " Dmitry Safonov
                   ` (37 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/ip22zilog.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 8c810733df3d..86fff69d7e7c 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -38,10 +38,6 @@
 #include <asm/sgi/hpc3.h>
 #include <asm/sgi/ip22.h>
 
-#if defined(CONFIG_SERIAL_IP22_ZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 #include "ip22zilog.h"
@@ -1080,6 +1076,7 @@ static struct uart_driver ip22zilog_reg = {
 
 static void __init ip22zilog_prepare(void)
 {
+	unsigned char sysrq_on = IS_ENABLED(CONFIG_SERIAL_IP22_ZILOG_CONSOLE);
 	struct uart_ip22zilog_port *up;
 	struct zilog_layout *rp;
 	int channel, chip;
@@ -1115,6 +1112,7 @@ static void __init ip22zilog_prepare(void)
 		up[(chip * 2) + 0].port.irq = zilog_irq;
 		up[(chip * 2) + 0].port.uartclk = ZS_CLOCK;
 		up[(chip * 2) + 0].port.fifosize = 1;
+		up[(chip * 2) + 0].port.has_sysrq = sysrq_on;
 		up[(chip * 2) + 0].port.ops = &ip22zilog_pops;
 		up[(chip * 2) + 0].port.type = PORT_IP22ZILOG;
 		up[(chip * 2) + 0].port.flags = 0;
@@ -1126,6 +1124,7 @@ static void __init ip22zilog_prepare(void)
 		up[(chip * 2) + 1].port.irq = zilog_irq;
 		up[(chip * 2) + 1].port.uartclk = ZS_CLOCK;
 		up[(chip * 2) + 1].port.fifosize = 1;
+		up[(chip * 2) + 1].port.has_sysrq = sysrq_on;
 		up[(chip * 2) + 1].port.ops = &ip22zilog_pops;
 		up[(chip * 2) + 1].port.type = PORT_IP22ZILOG;
 		up[(chip * 2) + 1].port.line = (chip * 2) + 1;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 21/58] tty/serial: Migrate meson_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (19 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 20/58] tty/serial: Migrate ip22zilog " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 22/58] tty/serial: Migrate milbeaut_usio " Dmitry Safonov
                   ` (36 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Kevin Hilman, linux-arm-kernel,
	linux-amlogic

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.

Cc: Kevin Hilman <khilman@baylibre.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-amlogic@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/meson_uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index fbc5bc022a39..12e15358554c 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -5,10 +5,6 @@
  * Copyright (C) 2014 Carlo Caione <carlo@caione.org>
  */
 
-#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -703,6 +699,7 @@ static int meson_uart_probe(struct platform_device *pdev)
 	port->mapsize = resource_size(res_mem);
 	port->irq = res_irq->start;
 	port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE);
 	port->dev = &pdev->dev;
 	port->line = pdev->id;
 	port->type = PORT_MESON;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 22/58] tty/serial: Migrate milbeaut_usio to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (20 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 21/58] tty/serial: Migrate meson_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 23/58] tty/serial: Migrate mpc52xx_uart " Dmitry Safonov
                   ` (35 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/milbeaut_usio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/milbeaut_usio.c b/drivers/tty/serial/milbeaut_usio.c
index 949ab7efc4fc..8f2cab7f66ad 100644
--- a/drivers/tty/serial/milbeaut_usio.c
+++ b/drivers/tty/serial/milbeaut_usio.c
@@ -3,10 +3,6 @@
  * Copyright (C) 2018 Socionext Inc.
  */
 
-#if defined(CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/module.h>
@@ -537,6 +533,7 @@ static int mlb_usio_probe(struct platform_device *pdev)
 	port->irq = mlb_usio_irq[index][RX];
 	port->uartclk = clk_get_rate(clk);
 	port->fifosize = 128;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE);
 	port->iotype = UPIO_MEM32;
 	port->flags = UPF_BOOT_AUTOCONF | UPF_SPD_VHI;
 	port->line = index;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 23/58] tty/serial: Migrate mpc52xx_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (21 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 22/58] tty/serial: Migrate milbeaut_usio " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 24/58] tty/serial: Don't zero port->sysrq Dmitry Safonov
                   ` (34 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/mpc52xx_uart.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 3a75ee08d619..ba1fddb6801c 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -44,10 +44,6 @@
 #include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
 
-#if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 
@@ -1382,12 +1378,10 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
 		ch = psc_ops->read_char(port);
 
 		/* Handle sysreq char */
-#ifdef SUPPORT_SYSRQ
 		if (uart_handle_sysrq_char(port, ch)) {
 			port->sysrq = 0;
 			continue;
 		}
-#endif
 
 		/* Store it */
 
@@ -1770,6 +1764,7 @@ static int mpc52xx_uart_of_probe(struct platform_device *op)
 	spin_lock_init(&port->lock);
 	port->uartclk = uartclk;
 	port->fifosize	= 512;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MPC52xx_CONSOLE);
 	port->iotype	= UPIO_MEM;
 	port->flags	= UPF_BOOT_AUTOCONF |
 			  (uart_console(port) ? 0 : UPF_IOREMAP);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 24/58] tty/serial: Don't zero port->sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (22 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 23/58] tty/serial: Migrate mpc52xx_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 25/58] tty/serial: Migrate msm_serial to use has_sysrq Dmitry Safonov
                   ` (33 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

uart_handle_sysrq_char() already does it.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/mpc52xx_uart.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index ba1fddb6801c..af1700445251 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -1378,10 +1378,8 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
 		ch = psc_ops->read_char(port);
 
 		/* Handle sysreq char */
-		if (uart_handle_sysrq_char(port, ch)) {
-			port->sysrq = 0;
+		if (uart_handle_sysrq_char(port, ch))
 			continue;
-		}
 
 		/* Store it */
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 25/58] tty/serial: Migrate msm_serial to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (23 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 24/58] tty/serial: Don't zero port->sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 26/58] tty/serial: Migrate mux " Dmitry Safonov
                   ` (32 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Andy Gross, Bjorn Andersson,
	linux-arm-msm

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.

Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-arm-msm@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/msm_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 1cbae0768b1f..375d6d3f17b2 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -7,10 +7,6 @@
  * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
  */
 
-#if defined(CONFIG_SERIAL_MSM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-# define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/atomic.h>
 #include <linux/dma-mapping.h>
@@ -1801,6 +1797,7 @@ static int msm_serial_probe(struct platform_device *pdev)
 	if (unlikely(irq < 0))
 		return -ENXIO;
 	port->irq = irq;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MSM_CONSOLE);
 
 	platform_set_drvdata(pdev, port);
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 26/58] tty/serial: Migrate mux to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (24 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 25/58] tty/serial: Migrate msm_serial to use has_sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 27/58] tty/serial: Migrate mxs-auart " Dmitry Safonov
                   ` (31 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/mux.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c
index 00ce31e8d19a..2a9953211a2a 100644
--- a/drivers/tty/serial/mux.c
+++ b/drivers/tty/serial/mux.c
@@ -25,11 +25,7 @@
 #include <asm/irq.h>
 #include <asm/parisc-device.h>
 
-#if defined(CONFIG_SERIAL_MUX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #include <linux/sysrq.h>
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 #define MUX_OFFSET 0x800
@@ -483,6 +479,7 @@ static int __init mux_probe(struct parisc_device *dev)
 		port->ops	= &mux_pops;
 		port->flags	= UPF_BOOT_AUTOCONF;
 		port->line	= port_cnt;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MUX_CONSOLE);
 
 		/* The port->timeout needs to match what is present in
 		 * uart_wait_until_sent in serial_core.c.  Otherwise
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 27/58] tty/serial: Migrate mxs-auart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (25 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 26/58] tty/serial: Migrate mux " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 28/58] tty/serial: Migrate omap-serial " Dmitry Safonov
                   ` (30 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Fabio Estevam, NXP Linux Team,
	Pengutronix Kernel Team, Shawn Guo, Sascha Hauer,
	linux-arm-kernel

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.

Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/mxs-auart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index e34525970682..b4f835e7de23 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -12,10 +12,6 @@
  * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
  */
 
-#if defined(CONFIG_SERIAL_MXS_AUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -1693,6 +1689,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
 	s->port.fifosize = MXS_AUART_FIFO_SIZE;
 	s->port.uartclk = clk_get_rate(s->clk);
 	s->port.type = PORT_IMX;
+	s->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_MXS_AUART_CONSOLE);
 
 	mxs_init_regs(s);
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 28/58] tty/serial: Migrate omap-serial to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (26 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 27/58] tty/serial: Migrate mxs-auart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 29/58] tty/serial: Migrate pch_uart " Dmitry Safonov
                   ` (29 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/omap-serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6420ae581a80..53b38a226f26 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -16,10 +16,6 @@
  * this driver as required for the omap-platform.
  */
 
-#if defined(CONFIG_SERIAL_OMAP_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -1680,6 +1676,7 @@ static int serial_omap_probe(struct platform_device *pdev)
 	up->port.regshift = 2;
 	up->port.fifosize = 64;
 	up->port.ops = &serial_omap_pops;
+	up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_OMAP_CONSOLE);
 
 	if (pdev->dev.of_node)
 		ret = of_alias_get_id(pdev->dev.of_node, "serial");
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 29/58] tty/serial: Migrate pch_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (27 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 28/58] tty/serial: Migrate omap-serial " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 30/58] tty/serial: Don't check port->sysrq Dmitry Safonov
                   ` (28 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/pch_uart.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index c16234bca78f..c625bf7b8a92 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -2,9 +2,6 @@
 /*
  *Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
  */
-#if defined(CONFIG_SERIAL_PCH_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
 #include <linux/kernel.h>
 #include <linux/serial_reg.h>
 #include <linux/slab.h>
@@ -587,12 +584,10 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf,
 			if (uart_handle_break(port))
 				continue;
 		}
-#ifdef SUPPORT_SYSRQ
 		if (port->sysrq) {
 			if (uart_handle_sysrq_char(port, rbr))
 				continue;
 		}
-#endif
 
 		buf[i++] = rbr;
 	}
@@ -1796,6 +1791,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	priv->port.flags = UPF_BOOT_AUTOCONF;
 	priv->port.fifosize = fifosize;
 	priv->port.line = board->line_no;
+	priv->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PCH_UART_CONSOLE);
 	priv->trigger = PCH_UART_HAL_TRIGGER_M;
 
 	snprintf(priv->irq_name, IRQ_NAME_SIZE,
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 30/58] tty/serial: Don't check port->sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (28 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 29/58] tty/serial: Migrate pch_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 31/58] tty/serial: Migrate pmac_zilog to use has_sysrq Dmitry Safonov
                   ` (27 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

uart_handle_sysrq_char() already handles it.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/pch_uart.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index c625bf7b8a92..0a96217dba67 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -584,10 +584,8 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf,
 			if (uart_handle_break(port))
 				continue;
 		}
-		if (port->sysrq) {
-			if (uart_handle_sysrq_char(port, rbr))
-				continue;
-		}
+		if (uart_handle_sysrq_char(port, rbr))
+			continue;
 
 		buf[i++] = rbr;
 	}
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 31/58] tty/serial: Migrate pmac_zilog to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (29 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 30/58] tty/serial: Don't check port->sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 32/58] tty/serial: Migrate pnx8xxx_uart " Dmitry Safonov
                   ` (26 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Benjamin Herrenschmidt,
	Michael Ellerman, Paul Mackerras, linuxppc-dev

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.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/pmac_zilog.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index bcb5bf70534e..ba65a3bbd72a 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -61,10 +61,6 @@
 #define of_machine_is_compatible(x) (0)
 #endif
 
-#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 
@@ -1721,6 +1717,7 @@ static int __init pmz_init_port(struct uart_pmac_port *uap)
 	uap->control_reg   = uap->port.membase;
 	uap->data_reg      = uap->control_reg + 4;
 	uap->port_type     = 0;
+	uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PMACZILOG_CONSOLE);
 
 	pmz_convert_to_zs(uap, CS8, 0, 9600);
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 32/58] tty/serial: Migrate pnx8xxx_uart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (30 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 31/58] tty/serial: Migrate pmac_zilog to use has_sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 33/58] serial/f81534: Don't check port->sysrq Dmitry Safonov
                   ` (25 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/pnx8xxx_uart.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c
index 223a9499104e..972d94e8d32b 100644
--- a/drivers/tty/serial/pnx8xxx_uart.c
+++ b/drivers/tty/serial/pnx8xxx_uart.c
@@ -10,10 +10,6 @@
  * Copyright (C) 2000 Deep Blue Solutions Ltd.
  */
 
-#if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -220,9 +216,7 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
 			else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE))
 				flg = TTY_FRAME;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		if (uart_handle_sysrq_char(&sport->port, ch))
@@ -800,6 +794,7 @@ static int pnx8xxx_serial_probe(struct platform_device *pdev)
 			if (pnx8xxx_ports[i].port.mapbase != res->start)
 				continue;
 
+			pnx8xxx_ports[i].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PNX8XXX_CONSOLE);
 			pnx8xxx_ports[i].port.dev = &pdev->dev;
 			uart_add_one_port(&pnx8xxx_reg, &pnx8xxx_ports[i].port);
 			platform_set_drvdata(pdev, &pnx8xxx_ports[i]);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 33/58] serial/f81534: Don't check port->sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (31 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 32/58] tty/serial: Migrate pnx8xxx_uart " Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-16 12:10   ` Johan Hovold
  2019-12-13  0:06 ` [PATCH 34/58] tty/serial: Migrate pxa to use has_sysrq Dmitry Safonov
                   ` (24 subsequent siblings)
  57 siblings, 1 reply; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

usb_serial_handle_sysrq_char() already checks it.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/usb/serial/f81534.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
index 2b39bda035c7..67a8e343eba1 100644
--- a/drivers/usb/serial/f81534.c
+++ b/drivers/usb/serial/f81534.c
@@ -1238,10 +1238,8 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
 			schedule_work(&port_priv->lsr_work);
 		}
 
-		if (port->port.console && port->sysrq) {
-			if (usb_serial_handle_sysrq_char(port, data[i]))
-				continue;
-		}
+		if (usb_serial_handle_sysrq_char(port, data[i]))
+			continue;
 
 		tty_insert_flip_char(&port->port, data[i], tty_flag);
 	}
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 34/58] tty/serial: Migrate pxa to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (32 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 33/58] serial/f81534: Don't check port->sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 35/58] tty/serial: Migrate qcom_geni_serial " Dmitry Safonov
                   ` (23 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/pxa.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 4932b674f7ef..41319ef96fa6 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -19,10 +19,6 @@
  */
 
 
-#if defined(CONFIG_SERIAL_PXA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -879,6 +875,7 @@ static int serial_pxa_probe(struct platform_device *dev)
 	sport->port.dev = &dev->dev;
 	sport->port.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
 	sport->port.uartclk = clk_get_rate(sport->clk);
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PXA_CONSOLE);
 
 	ret = serial_pxa_probe_dt(dev, sport);
 	if (ret > 0)
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 35/58] tty/serial: Migrate qcom_geni_serial to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (33 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 34/58] tty/serial: Migrate pxa to use has_sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 36/58] tty/serial: Migrate sa1100 " Dmitry Safonov
                   ` (22 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Andy Gross, Bjorn Andersson,
	linux-arm-msm

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.

Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-arm-msm@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/qcom_geni_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index ff63728a95f4..c41c766d6c7c 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1,10 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (c) 2017-2018, The Linux foundation. All rights reserved.
 
-#if defined(CONFIG_SERIAL_QCOM_GENI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-# define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/io.h>
@@ -1308,6 +1304,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 	uport->irq = irq;
+	uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE);
 
 	irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
 	ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 36/58] tty/serial: Migrate sa1100 to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (34 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 35/58] tty/serial: Migrate qcom_geni_serial " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 37/58] tty/serial: Migrate samsung_tty " Dmitry Safonov
                   ` (21 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sa1100.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index 8e618129e65c..75c2a22895f9 100644
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -7,10 +7,6 @@
  *  Copyright (C) 2000 Deep Blue Solutions Ltd.
  */
 
-#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -214,9 +210,7 @@ sa1100_rx_chars(struct sa1100_port *sport)
 			else if (status & UTSR1_TO_SM(UTSR1_FRE))
 				flg = TTY_FRAME;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		if (uart_handle_sysrq_char(&sport->port, ch))
@@ -860,6 +854,7 @@ static int sa1100_serial_resume(struct platform_device *dev)
 static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev)
 {
 	sport->port.dev = &dev->dev;
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SA1100_CONSOLE);
 
 	// mctrl_gpio_init() requires that the GPIO driver supports interrupts,
 	// but we need to support GPIO drivers for hardware that has no such
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 37/58] tty/serial: Migrate samsung_tty to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (35 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 36/58] tty/serial: Migrate sa1100 " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 38/58] tty/serial: Migrate sb1250-duart " Dmitry Safonov
                   ` (20 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/samsung_tty.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 83fd51607741..9770fe29ae86 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -21,10 +21,6 @@
  * BJD, 04-Nov-2004
 */
 
-#if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
@@ -1909,6 +1905,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 		ourport->port.fifosize = ourport->drv_data->fifosize[index];
 	else if (ourport->info->fifosize)
 		ourport->port.fifosize = ourport->info->fifosize;
+	ourport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SAMSUNG_CONSOLE);
 
 	/*
 	 * DMA transfers must be aligned at least to cache line size,
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 38/58] tty/serial: Migrate sb1250-duart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (36 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 37/58] tty/serial: Migrate samsung_tty " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 39/58] tty/serial: Migrate sccnxp " Dmitry Safonov
                   ` (19 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sb1250-duart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
index 329aced26bd8..cb8185bffe42 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -15,10 +15,6 @@
  *	"BCM1250/BCM1125/BCM1125H User Manual", Broadcom Corporation
  */
 
-#if defined(CONFIG_SERIAL_SB1250_DUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/compiler.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -813,6 +809,7 @@ static void __init sbd_probe_duarts(void)
 			uport->ops	= &sbd_ops;
 			uport->line	= line;
 			uport->mapbase	= SBD_CHANREGS(line);
+			uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SB1250_DUART_CONSOLE);
 		}
 	}
 }
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 39/58] tty/serial: Migrate sccnxp to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (37 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 38/58] tty/serial: Migrate sb1250-duart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 40/58] tty/serial: Migrate serial_txx9 " Dmitry Safonov
                   ` (18 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sccnxp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index d2b77aae42ae..10cc16a71f26 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -7,10 +7,6 @@
  *  Based on sc26xx.c, by Thomas Bogendörfer (tsbogend@alpha.franken.de)
  */
 
-#if defined(CONFIG_SERIAL_SCCNXP_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
@@ -1000,6 +996,7 @@ static int sccnxp_probe(struct platform_device *pdev)
 		s->port[i].regshift	= s->pdata.reg_shift;
 		s->port[i].uartclk	= uartclk;
 		s->port[i].ops		= &sccnxp_ops;
+		s->port[i].has_sysrq = IS_ENABLED(CONFIG_SERIAL_SCCNXP_CONSOLE);
 		uart_add_one_port(&s->uart, &s->port[i]);
 		/* Set direction to input */
 		if (s->chip->flags & SCCNXP_HAVE_IO)
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 40/58] tty/serial: Migrate serial_txx9 to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (38 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 39/58] tty/serial: Migrate sccnxp " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 41/58] tty/serial: Migrate sh-sci " Dmitry Safonov
                   ` (17 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/serial_txx9.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index d22ccb32aa9b..b4d89e31730e 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -12,10 +12,6 @@
  *  Serial driver for TX3927/TX4927/TX4925/TX4938 internal SIO controller
  */
 
-#if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -1095,6 +1091,7 @@ static int serial_txx9_probe(struct platform_device *dev)
 		port.flags	= p->flags;
 		port.mapbase	= p->mapbase;
 		port.dev	= &dev->dev;
+		port.has_sysrq	= IS_ENABLED(CONFIG_SERIAL_TXX9_CONSOLE);
 		ret = serial_txx9_register_port(&port);
 		if (ret < 0) {
 			dev_err(&dev->dev, "unable to register port at index %d "
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 41/58] tty/serial: Migrate sh-sci to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (39 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 40/58] tty/serial: Migrate serial_txx9 " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 42/58] tty/serial: Migrate sprd_serial " Dmitry Safonov
                   ` (16 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sh-sci.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 58bf9d496ba5..9b4ff872e297 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -15,10 +15,6 @@
  *   Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003).
  *   Removed SH7300 support (Jul 2007).
  */
-#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #undef DEBUG
 
 #include <linux/clk.h>
@@ -2887,6 +2883,7 @@ static int sci_init_single(struct platform_device *dev,
 	port->ops	= &sci_uart_ops;
 	port->iotype	= UPIO_MEM;
 	port->line	= index;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SH_SCI_CONSOLE);
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (res == NULL)
@@ -3015,12 +3012,9 @@ static void serial_console_write(struct console *co, const char *s,
 	unsigned long flags;
 	int locked = 1;
 
-#if defined(SUPPORT_SYSRQ)
 	if (port->sysrq)
 		locked = 0;
-	else
-#endif
-	if (oops_in_progress)
+	else if (oops_in_progress)
 		locked = spin_trylock_irqsave(&port->lock, flags);
 	else
 		spin_lock_irqsave(&port->lock, flags);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 42/58] tty/serial: Migrate sprd_serial to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (40 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 41/58] tty/serial: Migrate sh-sci " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-16  2:30   ` Chunyan Zhang
  2019-12-13  0:06 ` [PATCH 43/58] tty/serial: Migrate st-asc " Dmitry Safonov
                   ` (15 subsequent siblings)
  57 siblings, 1 reply; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Baolin Wang, Chunyan Zhang,
	Orson Zhai

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.

Cc: Baolin Wang <baolin.wang7@gmail.com>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Orson Zhai <orsonzhai@gmail.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sprd_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 31df23502562..0c3b7420b01e 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -3,10 +3,6 @@
  * Copyright (C) 2012-2015 Spreadtrum Communications Inc.
  */
 
-#if defined(CONFIG_SERIAL_SPRD_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -1227,6 +1223,7 @@ static int sprd_probe(struct platform_device *pdev)
 	up->fifosize = SPRD_FIFO_SIZE;
 	up->ops = &serial_sprd_ops;
 	up->flags = UPF_BOOT_AUTOCONF;
+	up->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SPRD_CONSOLE);
 
 	ret = sprd_clk_init(up);
 	if (ret)
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 43/58] tty/serial: Migrate st-asc to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (41 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 42/58] tty/serial: Migrate sprd_serial " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 44/58] tty/serial: Migrate stm32-usart " Dmitry Safonov
                   ` (14 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Patrice Chotard,
	linux-arm-kernel

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.

Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/st-asc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index 7971997cdead..fb6bbb5e2234 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -5,10 +5,6 @@
  * Copyright (C) 2003-2013 STMicroelectronics (R&D) Limited
  */
 
-#if defined(CONFIG_SERIAL_ST_ASC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -730,6 +726,7 @@ static int asc_init_port(struct asc_port *ascport,
 	port->fifosize	= ASC_FIFO_SIZE;
 	port->dev	= &pdev->dev;
 	port->irq	= platform_get_irq(pdev, 0);
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	port->membase = devm_ioremap_resource(&pdev->dev, res);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 44/58] tty/serial: Migrate stm32-usart to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (42 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 43/58] tty/serial: Migrate st-asc " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 45/58] tty/serial: Migrate sunhv " Dmitry Safonov
                   ` (13 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Alexandre Torgue,
	Maxime Coquelin, linux-arm-kernel, linux-stm32

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.

Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/stm32-usart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 2f72514d63ed..5e93e8d40f59 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -8,10 +8,6 @@
  * Inspired by st-asc.c from STMicroelectronics (c)
  */
 
-#if defined(CONFIG_SERIAL_STM32_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -926,6 +922,7 @@ static int stm32_init_port(struct stm32_port *stm32port,
 	port->ops	= &stm32_uart_ops;
 	port->dev	= &pdev->dev;
 	port->fifosize	= stm32port->info->cfg.fifosize;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_STM32_CONSOLE);
 
 	ret = platform_get_irq(pdev, 0);
 	if (ret <= 0)
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 45/58] tty/serial: Migrate sunhv to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (43 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 44/58] tty/serial: Migrate stm32-usart " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 46/58] tty/serial: Migrate sunsab " Dmitry Safonov
                   ` (12 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, David S. Miller, sparclinux

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.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sunhv.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index f8503f8fc44e..eafada8fb6fa 100644
--- a/drivers/tty/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
@@ -25,10 +25,6 @@
 #include <asm/irq.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -552,6 +548,7 @@ static int hv_probe(struct platform_device *op)
 
 	sunhv_port = port;
 
+	port->has_sysrq = 1;
 	port->line = 0;
 	port->ops = &sunhv_pops;
 	port->type = PORT_SUNHV;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 46/58] tty/serial: Migrate sunsab to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (44 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 45/58] tty/serial: Migrate sunhv " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 47/58] tty/serial: Migrate sunsu " Dmitry Safonov
                   ` (11 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, David S. Miller, sparclinux

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.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sunsab.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 72131b5e132e..1eb703c980e0 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -40,10 +40,6 @@
 #include <asm/prom.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_SERIAL_SUNSAB_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -985,6 +981,7 @@ static int sunsab_init_one(struct uart_sunsab_port *up,
 
 	up->port.fifosize = SAB82532_XMIT_FIFO_SIZE;
 	up->port.iotype = UPIO_MEM;
+	up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNSAB_CONSOLE);
 
 	writeb(SAB82532_IPC_IC_ACT_LOW, &up->regs->w.ipc);
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 47/58] tty/serial: Migrate sunsu to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (45 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 46/58] tty/serial: Migrate sunsab " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 48/58] tty/serial: Migrate sunzilog " Dmitry Safonov
                   ` (10 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, David S. Miller, sparclinux

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.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sunsu.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 4db6aaa330b2..8ce9a7a256e5 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -44,10 +44,6 @@
 #include <asm/prom.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_SERIAL_SUNSU_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -1475,6 +1471,7 @@ static int su_probe(struct platform_device *op)
 
 	up->port.type = PORT_UNKNOWN;
 	up->port.uartclk = (SU_BASE_BAUD * 16);
+	up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNSU_CONSOLE);
 
 	err = 0;
 	if (up->su_type == SU_PORT_KBD || up->su_type == SU_PORT_MS) {
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 48/58] tty/serial: Migrate sunzilog to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (46 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 47/58] tty/serial: Migrate sunsu " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 49/58] serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ Dmitry Safonov
                   ` (9 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, David S. Miller, sparclinux

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.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/sunzilog.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index bc7af8b08a72..103ab8c556e7 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -40,10 +40,6 @@
 #include <asm/prom.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_SERIAL_SUNZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -1444,6 +1440,7 @@ static int zs_probe(struct platform_device *op)
 	up[0].port.line = (inst * 2) + 0;
 	up[0].port.dev = &op->dev;
 	up[0].flags |= SUNZILOG_FLAG_IS_CHANNEL_A;
+	up[0].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNZILOG_CONSOLE);
 	if (keyboard_mouse)
 		up[0].flags |= SUNZILOG_FLAG_CONS_KEYB;
 	sunzilog_init_hw(&up[0]);
@@ -1461,6 +1458,7 @@ static int zs_probe(struct platform_device *op)
 	up[1].port.line = (inst * 2) + 1;
 	up[1].port.dev = &op->dev;
 	up[1].flags |= 0;
+	up[1].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNZILOG_CONSOLE);
 	if (keyboard_mouse)
 		up[1].flags |= SUNZILOG_FLAG_CONS_MOUSE;
 	sunzilog_init_hw(&up[1]);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 49/58] serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (47 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 48/58] tty/serial: Migrate sunzilog " Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 50/58] tty/serial: Migrate vr41xx_siu to use has_sysrq Dmitry Safonov
                   ` (8 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Timur Tabi, linuxppc-dev

ucc_uart doesn't seem to support console over itself, so maybe it can
be deleted with uart_handle_sysrq_char() from the file.

Cc: Timur Tabi <timur@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/ucc_uart.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index a0555ae2b1ef..ff7784047156 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -551,9 +551,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)
 	/* Overrun does not affect the current character ! */
 	if (status & BD_SC_OV)
 		tty_insert_flip_char(tport, 0, TTY_OVERRUN);
-#ifdef SUPPORT_SYSRQ
 	port->sysrq = 0;
-#endif
 	goto error_return;
 }
 
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 50/58] tty/serial: Migrate vr41xx_siu to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (48 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 49/58] serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 51/58] tty/serial: Migrate vt8500_serial " Dmitry Safonov
                   ` (7 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

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.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/vr41xx_siu.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c
index 6d106e33f842..eeb4b6568776 100644
--- a/drivers/tty/serial/vr41xx_siu.c
+++ b/drivers/tty/serial/vr41xx_siu.c
@@ -7,10 +7,6 @@
  *  Based on drivers/serial/8250.c, by Russell King.
  */
 
-#if defined(CONFIG_SERIAL_VR41XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/console.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -869,6 +865,7 @@ static int siu_probe(struct platform_device *dev)
 		port = &siu_uart_ports[i];
 		port->ops = &siu_uart_ops;
 		port->dev = &dev->dev;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_VR41XX_CONSOLE);
 
 		retval = uart_add_one_port(&siu_uart_driver, port);
 		if (retval < 0) {
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 51/58] tty/serial: Migrate vt8500_serial to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (49 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 50/58] tty/serial: Migrate vr41xx_siu to use has_sysrq Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 52/58] tty/serial: Migrate xilinx_uartps " Dmitry Safonov
                   ` (6 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Tony Prisk, linux-arm-kernel

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.

Cc: Tony Prisk <linux@prisktech.co.nz>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/vt8500_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 3d58e9b34553..764e992438b2 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -7,10 +7,6 @@
  * Author: Robert Love <rlove@google.com>
  */
 
-#if defined(CONFIG_SERIAL_VT8500_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-# define SUPPORT_SYSRQ
-#endif
-
 #include <linux/hrtimer.h>
 #include <linux/delay.h>
 #include <linux/io.h>
@@ -703,6 +699,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
 	vt8500_port->uart.line = port;
 	vt8500_port->uart.dev = &pdev->dev;
 	vt8500_port->uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
+	vt8500_port->uart.has_sysrq = IS_ENABLED(CONFIG_SERIAL_VT8500_CONSOLE);
 
 	/* Serial core uses the magic "16" everywhere - adjust for it */
 	vt8500_port->uart.uartclk = 16 * clk_get_rate(vt8500_port->clk) /
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 52/58] tty/serial: Migrate xilinx_uartps to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (50 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 51/58] tty/serial: Migrate vt8500_serial " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 53/58] tty/serial: Migrate zs " Dmitry Safonov
                   ` (5 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Michal Simek, linux-arm-kernel

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.

Cc: Michal Simek <michal.simek@xilinx.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/xilinx_uartps.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 4e55bc327a54..2b5606469bed 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -9,10 +9,6 @@
  * in the code.
  */
 
-#if defined(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/platform_device.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -1634,6 +1630,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
 	port->flags	= UPF_BOOT_AUTOCONF;
 	port->ops	= &cdns_uart_ops;
 	port->fifosize	= CDNS_UART_FIFO_SIZE;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE);
 
 	/*
 	 * Register the port.
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 53/58] tty/serial: Migrate zs to use has_sysrq
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (51 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 52/58] tty/serial: Migrate xilinx_uartps " Dmitry Safonov
@ 2019-12-13  0:06 ` " Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery Dmitry Safonov
                   ` (4 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Maciej W. Rozycki

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.

Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/zs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c
index b03d3e458ea2..1467952da3f6 100644
--- a/drivers/tty/serial/zs.c
+++ b/drivers/tty/serial/zs.c
@@ -44,10 +44,6 @@
  * complicated and prevents the use of some automatic modes of operation.
  */
 
-#if defined(CONFIG_SERIAL_ZS_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/bug.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -1106,6 +1102,7 @@ static int __init zs_probe_sccs(void)
 			zport->scc	= &zs_sccs[chip];
 			zport->clk_mode	= 16;
 
+			uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ZS_CONSOLE);
 			uport->irq	= zs_parms.irq[chip];
 			uport->uartclk	= ZS_CLOCK;
 			uport->fifosize	= 1;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (52 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 53/58] tty/serial: Migrate zs " Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-17 14:27   ` Greg Kroah-Hartman
  2019-12-13  0:06 ` [PATCH 55/58] usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled Dmitry Safonov
                   ` (3 subsequent siblings)
  57 siblings, 1 reply; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

No one defines it anymore.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 include/linux/serial_core.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 5f761c399282..9cf1682dc580 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -466,10 +466,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
 		return 0;
 
-	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
-		return 0;
-
-	if (!port->sysrq)
+	if (!port->has_sysrq || !port->sysrq)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
@@ -487,10 +484,7 @@ uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
 	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
 		return 0;
 
-	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
-		return 0;
-
-	if (!port->sysrq)
+	if (!port->has_sysrq || !port->sysrq)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
@@ -507,7 +501,7 @@ uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
 {
 	int sysrq_ch;
 
-	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ)) {
+	if (!port->has_sysrq) {
 		spin_unlock_irqrestore(&port->lock, irqflags);
 		return;
 	}
@@ -531,7 +525,7 @@ static inline int uart_handle_break(struct uart_port *port)
 	if (port->handle_break)
 		port->handle_break(port);
 
-	if (port->has_sysrq || IS_ENABLED(SUPPORT_SYSRQ)) {
+	if (port->has_sysrq) {
 		if (port->cons && port->cons->index == port->line) {
 			if (!port->sysrq) {
 				port->sysrq = jiffies + HZ*5;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 55/58] usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (53 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 56/58] serial_core: Move sysrq functions from header file Dmitry Safonov
                   ` (2 subsequent siblings)
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Johan Hovold

While at it, remove ifdeffery around usb_serial_handle_sysrq_char() as
it doesn't save much from .text anyway.

Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/usb/serial/generic.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 1be8bea372a2..37361031402e 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -571,7 +571,6 @@ int usb_serial_generic_get_icount(struct tty_struct *tty,
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
 
-#ifdef CONFIG_MAGIC_SYSRQ
 int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
 {
 	if (port->sysrq && port->port.console) {
@@ -584,16 +583,13 @@ int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
 	}
 	return 0;
 }
-#else
-int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
-{
-	return 0;
-}
-#endif
 EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
 
 int usb_serial_handle_break(struct usb_serial_port *port)
 {
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ))
+		return 0;
+
 	if (!port->sysrq) {
 		port->sysrq = jiffies + HZ*5;
 		return 1;
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 56/58] serial_core: Move sysrq functions from header file
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (54 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 55/58] usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 57/58] sysctl/sysrq: Remove __sysrq_enabled copy Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 58/58] serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE Dmitry Safonov
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

It's not worth to have them in every serial driver and I'm about to add
another one.

Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/serial_core.c | 83 +++++++++++++++++++++++++++++++
 include/linux/serial_core.h      | 84 ++------------------------------
 2 files changed, 88 insertions(+), 79 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b0a6eb106edb..ef43c168e848 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3080,6 +3080,89 @@ void uart_insert_char(struct uart_port *port, unsigned int status,
 }
 EXPORT_SYMBOL_GPL(uart_insert_char);
 
+int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
+{
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq || !port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		handle_sysrq(ch);
+		port->sysrq = 0;
+		return 1;
+	}
+	port->sysrq = 0;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(uart_handle_sysrq_char);
+
+int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
+{
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq || !port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		port->sysrq_ch = ch;
+		port->sysrq = 0;
+		return 1;
+	}
+	port->sysrq = 0;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(uart_prepare_sysrq_char);
+
+void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
+{
+	int sysrq_ch;
+
+	if (!port->has_sysrq) {
+		spin_unlock_irqrestore(&port->lock, irqflags);
+		return;
+	}
+
+	sysrq_ch = port->sysrq_ch;
+	port->sysrq_ch = 0;
+
+	spin_unlock_irqrestore(&port->lock, irqflags);
+
+	if (sysrq_ch)
+		handle_sysrq(sysrq_ch);
+}
+EXPORT_SYMBOL_GPL(uart_unlock_and_check_sysrq);
+
+/*
+ * We do the SysRQ and SAK checking like this...
+ */
+int uart_handle_break(struct uart_port *port)
+{
+	struct uart_state *state = port->state;
+
+	if (port->handle_break)
+		port->handle_break(port);
+
+	if (port->has_sysrq) {
+		if (port->cons && port->cons->index == port->line) {
+			if (!port->sysrq) {
+				port->sysrq = jiffies + HZ*5;
+				return 1;
+			}
+			port->sysrq = 0;
+		}
+	}
+
+	if (port->flags & UPF_SAK)
+		do_SAK(state->port.tty);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(uart_handle_break);
+
 EXPORT_SYMBOL(uart_write_wakeup);
 EXPORT_SYMBOL(uart_register_driver);
 EXPORT_SYMBOL(uart_unregister_driver);
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 9cf1682dc580..255e86a474e9 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -460,85 +460,11 @@ extern void uart_handle_cts_change(struct uart_port *uport,
 extern void uart_insert_char(struct uart_port *port, unsigned int status,
 		 unsigned int overrun, unsigned int ch, unsigned int flag);
 
-static inline int
-uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
-{
-	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
-		return 0;
-
-	if (!port->has_sysrq || !port->sysrq)
-		return 0;
-
-	if (ch && time_before(jiffies, port->sysrq)) {
-		handle_sysrq(ch);
-		port->sysrq = 0;
-		return 1;
-	}
-	port->sysrq = 0;
-
-	return 0;
-}
-static inline int
-uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
-{
-	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
-		return 0;
-
-	if (!port->has_sysrq || !port->sysrq)
-		return 0;
-
-	if (ch && time_before(jiffies, port->sysrq)) {
-		port->sysrq_ch = ch;
-		port->sysrq = 0;
-		return 1;
-	}
-	port->sysrq = 0;
-
-	return 0;
-}
-static inline void
-uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
-{
-	int sysrq_ch;
-
-	if (!port->has_sysrq) {
-		spin_unlock_irqrestore(&port->lock, irqflags);
-		return;
-	}
-
-	sysrq_ch = port->sysrq_ch;
-	port->sysrq_ch = 0;
-
-	spin_unlock_irqrestore(&port->lock, irqflags);
-
-	if (sysrq_ch)
-		handle_sysrq(sysrq_ch);
-}
-
-/*
- * We do the SysRQ and SAK checking like this...
- */
-static inline int uart_handle_break(struct uart_port *port)
-{
-	struct uart_state *state = port->state;
-
-	if (port->handle_break)
-		port->handle_break(port);
-
-	if (port->has_sysrq) {
-		if (port->cons && port->cons->index == port->line) {
-			if (!port->sysrq) {
-				port->sysrq = jiffies + HZ*5;
-				return 1;
-			}
-			port->sysrq = 0;
-		}
-	}
-
-	if (port->flags & UPF_SAK)
-		do_SAK(state->port.tty);
-	return 0;
-}
+extern int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch);
+extern int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch);
+extern void uart_unlock_and_check_sysrq(struct uart_port *port,
+					unsigned long irqflags);
+extern int uart_handle_break(struct uart_port *port);
 
 /*
  *	UART_ENABLE_MS - determine if port should enable modem status irqs
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 57/58] sysctl/sysrq: Remove __sysrq_enabled copy
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (55 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 56/58] serial_core: Move sysrq functions from header file Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  2019-12-13  0:06 ` [PATCH 58/58] serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE Dmitry Safonov
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Iurii Zaikin, Luis Chamberlain,
	Kees Cook, linux-fsdevel

Many embedded boards have a disconnected TTL level serial which can
generate some garbage that can lead to spurious false sysrq detects.

Currently, sysrq can be either completely disabled for serial console
or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since
commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port")

At Arista, we have such boards that can generate BREAK and random
garbage. While disabling sysrq for serial console would solve
the problem with spurious false sysrq triggers, it's also desirable
to have a way to enable sysrq back.

Having the way to enable sysrq was beneficial to debug lockups with
a manual investigation in field and on the other side preventing false
sysrq detections.

As a preparation to add sysrq_toggle_support() call into uart,
remove a private copy of sysrq_enabled from sysctl - it should reflect
the actual status of sysrq.

Furthermore, the private copy isn't correct already in case
sysrq_always_enabled is true. So, remove __sysrq_enabled and use a
getter-helper for sysrq enabled status.

Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/sysrq.c   |  7 +++++++
 include/linux/sysrq.h |  1 +
 kernel/sysctl.c       | 41 ++++++++++++++++++++++-------------------
 3 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 1d4f317a0e42..c21067765091 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -73,6 +73,13 @@ static bool sysrq_on_mask(int mask)
 	       (sysrq_enabled & mask);
 }
 
+int sysrq_get_mask(void)
+{
+	if (sysrq_always_enabled)
+		return 1;
+	return sysrq_enabled;
+}
+
 static int __init sysrq_always_enabled_setup(char *str)
 {
 	sysrq_always_enabled = true;
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
index 8c71874e8485..4a0b351fa2d3 100644
--- a/include/linux/sysrq.h
+++ b/include/linux/sysrq.h
@@ -50,6 +50,7 @@ int unregister_sysrq_key(int key, struct sysrq_key_op *op);
 struct sysrq_key_op *__sysrq_get_key_op(int key);
 
 int sysrq_toggle_support(int enable_mask);
+int sysrq_get_mask(void);
 
 #else
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 70665934d53e..66cebf6041b4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -229,25 +229,8 @@ static int proc_dopipe_max_size(struct ctl_table *table, int write,
 		void __user *buffer, size_t *lenp, loff_t *ppos);
 
 #ifdef CONFIG_MAGIC_SYSRQ
-/* Note: sysrq code uses its own private copy */
-static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
-
 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
-				void __user *buffer, size_t *lenp,
-				loff_t *ppos)
-{
-	int error;
-
-	error = proc_dointvec(table, write, buffer, lenp, ppos);
-	if (error)
-		return error;
-
-	if (write)
-		sysrq_toggle_support(__sysrq_enabled);
-
-	return 0;
-}
-
+			void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
 static struct ctl_table kern_table[];
@@ -747,7 +730,7 @@ static struct ctl_table kern_table[] = {
 #ifdef CONFIG_MAGIC_SYSRQ
 	{
 		.procname	= "sysrq",
-		.data		= &__sysrq_enabled,
+		.data		= NULL,
 		.maxlen		= sizeof (int),
 		.mode		= 0644,
 		.proc_handler	= sysrq_sysctl_handler,
@@ -2844,6 +2827,26 @@ static int proc_dostring_coredump(struct ctl_table *table, int write,
 }
 #endif
 
+#ifdef CONFIG_MAGIC_SYSRQ
+static int sysrq_sysctl_handler(struct ctl_table *table, int write,
+				void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+	int tmp, ret;
+
+	tmp = sysrq_get_mask();
+
+	ret = __do_proc_dointvec(&tmp, table, write, buffer,
+			       lenp, ppos, NULL, NULL);
+	if (ret || !write)
+		return ret;
+
+	if (write)
+		sysrq_toggle_support(tmp);
+
+	return 0;
+}
+#endif
+
 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
 				     void __user *buffer,
 				     size_t *lenp, loff_t *ppos,
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* [PATCH 58/58] serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE
       [not found] <20191213000657.931618-1-dima@arista.com>
                   ` (56 preceding siblings ...)
  2019-12-13  0:06 ` [PATCH 57/58] sysctl/sysrq: Remove __sysrq_enabled copy Dmitry Safonov
@ 2019-12-13  0:06 ` Dmitry Safonov
  57 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-13  0:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

Many embedded boards have a disconnected TTL level serial which can
generate some garbage that can lead to spurious false sysrq detects.

Currently, sysrq can be either completely disabled for serial console
or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since
commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port")

At Arista, we have such boards that can generate BREAK and random
garbage. While disabling sysrq for serial console would solve
the problem with spurious false sysrq triggers, it's also desirable
to have a way to enable sysrq back.

As a measure of balance between on and off options, add
MAGIC_SYSRQ_SERIAL_SEQUENCE which is a string sequence that can enable
sysrq if it follows BREAK on a serial line. The longer the string - the
less likely it may be in the garbage.

Having the way to enable sysrq was beneficial to debug lockups with
a manual investigation in field and on the other side preventing false
sysrq detections.

Based-on-patch-by: Vasiliy Khoruzhick <vasilykh@arista.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 drivers/tty/serial/serial_core.c | 52 ++++++++++++++++++++++++++++----
 include/linux/serial_core.h      |  2 +-
 lib/Kconfig.debug                |  8 +++++
 3 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index ef43c168e848..4570c99a137a 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3080,6 +3080,38 @@ void uart_insert_char(struct uart_port *port, unsigned int status,
 }
 EXPORT_SYMBOL_GPL(uart_insert_char);
 
+const char sysrq_toggle_seq[] = CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE;
+
+static void uart_sysrq_on(struct work_struct *w)
+{
+	sysrq_toggle_support(1);
+	pr_info("SysRq is enabled by magic sequience on serial\n");
+}
+static DECLARE_WORK(sysrq_enable_work, uart_sysrq_on);
+
+static int uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
+{
+	if (sysrq_toggle_seq[0] == '\0')
+		return 0;
+
+	BUILD_BUG_ON(ARRAY_SIZE(sysrq_toggle_seq) >= sizeof(port->sysrq_seq)*U8_MAX);
+	if (sysrq_toggle_seq[port->sysrq_seq] != ch) {
+		port->sysrq_seq = 0;
+		return 0;
+	}
+
+	/* Without the last \0 */
+	if (++port->sysrq_seq < (ARRAY_SIZE(sysrq_toggle_seq) - 1)) {
+		port->sysrq = jiffies + HZ*5;
+		return 1;
+	}
+
+	schedule_work(&sysrq_enable_work);
+
+	port->sysrq = 0;
+	return 1;
+}
+
 int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 {
 	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
@@ -3089,9 +3121,13 @@ int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
-		handle_sysrq(ch);
-		port->sysrq = 0;
-		return 1;
+		if (sysrq_get_mask()) {
+			handle_sysrq(ch);
+			port->sysrq = 0;
+			return 1;
+		}
+		if (uart_try_toggle_sysrq(port, ch))
+			return 1;
 	}
 	port->sysrq = 0;
 
@@ -3108,9 +3144,13 @@ int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
-		port->sysrq_ch = ch;
-		port->sysrq = 0;
-		return 1;
+		if (sysrq_get_mask()) {
+			port->sysrq_ch = ch;
+			port->sysrq = 0;
+			return 1;
+		}
+		if (uart_try_toggle_sysrq(port, ch))
+			return 1;
 	}
 	port->sysrq = 0;
 
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 255e86a474e9..1f4443db5474 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -243,10 +243,10 @@ struct uart_port {
 	unsigned long		sysrq;			/* sysrq timeout */
 	unsigned int		sysrq_ch;		/* char for sysrq */
 	unsigned char		has_sysrq;
+	unsigned char		sysrq_seq;		/* index in sysrq_toggle_seq */
 
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
-	unsigned char		unused;
 	const char		*name;			/* port name */
 	struct attribute_group	*attr_group;		/* port specific attributes */
 	const struct attribute_group **tty_groups;	/* all attributes (serial core use only) */
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d1842fe756d5..babc464ce14a 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -431,6 +431,14 @@ config MAGIC_SYSRQ_SERIAL
 	  This option allows you to decide whether you want to enable the
 	  magic SysRq key.
 
+config MAGIC_SYSRQ_SERIAL_SEQUENCE
+	string "Char sequence that enables magic SysRq over serial"
+	depends on MAGIC_SYSRQ_SERIAL
+	default ""
+	help
+	  Specifies a sequence of characters that can follow BREAK to enable
+	  SysRq on a serial console.
+
 config DEBUG_FS
 	bool "Debug Filesystem"
 	help
-- 
2.24.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq
  2019-12-13  0:06 ` [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq Dmitry Safonov
@ 2019-12-13  1:32   ` Andrew Jeffery
  0 siblings, 0 replies; 68+ messages in thread
From: Andrew Jeffery @ 2019-12-13  1:32 UTC (permalink / raw)
  To: Dmitry Safonov, linux-kernel
  Cc: Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial, Joel Stanley, linux-arm-kernel,
	linux-aspeed



On Fri, 13 Dec 2019, at 10:36, Dmitry Safonov wrote:
> 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.
> 
> Cc: Andrew Jeffery <andrew@aj.id.au>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-aspeed@lists.ozlabs.org
> Signed-off-by: Dmitry Safonov <dima@arista.com>

Acked-by: Andrew Jeffery <andrew@aj.id.au>

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 02/58] serial: Move sysrq members above
  2019-12-13  0:06 ` [PATCH 02/58] serial: Move sysrq members above Dmitry Safonov
@ 2019-12-13  7:17   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 68+ messages in thread
From: Greg Kroah-Hartman @ 2019-12-13  7:17 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Jiri Slaby, Vasiliy Khoruzhick,
	linux-serial

On Fri, Dec 13, 2019 at 12:06:01AM +0000, Dmitry Safonov wrote:
> At the current place members those follow are:
> :	upf_t			flags;
> :	upstat_t		status;
> :	int			hw_stopped;
> :	unsigned int		mctrl;
> :	unsigned int		timeout;
> :	unsigned int		type;
> :	const struct uart_ops	*ops;
> 
> Together, they give (*ops) 8-byte align on 64-bit platforms.
> And `sysrq_ch` introduces 4-byte padding.
> 
> On the other side, above:
> :	struct device		*dev;
> :	unsigned char		hub6;
> :	unsigned char		suspended;
> :	unsigned char		unused[2];
> :	const char		*name;
> 
> Adds another 4-byte padding.
> 
> Moving sysrq members just before `hub6` allows to save 8 bytes
> per-uart_port on 64-bit platforms:
> On my gcc, x86_64 sizeof(struct uart_port) goes from 528 to 520.
> 
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>  include/linux/serial_core.h | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index 2b78cc734719..bbbe57bf5163 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -161,11 +161,6 @@ struct uart_port {
>  	struct uart_icount	icount;			/* statistics */
>  
>  	struct console		*cons;			/* struct console, if any */
> -#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
> -	unsigned long		sysrq;			/* sysrq timeout */
> -	unsigned int		sysrq_ch;		/* char for sysrq */
> -#endif
> -
>  	/* flags must be updated while holding port mutex */
>  	upf_t			flags;
>  
> @@ -244,6 +239,12 @@ struct uart_port {
>  	resource_size_t		mapbase;		/* for ioremap */
>  	resource_size_t		mapsize;
>  	struct device		*dev;			/* parent device */
> +
> +#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
> +	unsigned long		sysrq;			/* sysrq timeout */
> +	unsigned int		sysrq_ch;		/* char for sysrq */
> +#endif

Let's just always have these 2 fields in the structure, no need for a
#ifdef at all, right?  There is no real "savings" from removing them (8
bytes for a structure that is maybe created 2-4 times per machine?)

That way it would keep any of this mess of if the SUPPORT_SYSRQ is
enabled or not to keep everything in sync.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ
  2019-12-13  0:06 ` [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ Dmitry Safonov
@ 2019-12-13  7:18   ` Greg Kroah-Hartman
  2019-12-17 13:48   ` Greg Kroah-Hartman
  2019-12-17 13:51   ` Greg Kroah-Hartman
  2 siblings, 0 replies; 68+ messages in thread
From: Greg Kroah-Hartman @ 2019-12-13  7:18 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Jiri Slaby, Vasiliy Khoruzhick,
	linux-serial

On Fri, Dec 13, 2019 at 12:06:02AM +0000, Dmitry Safonov wrote:
> The SUPPORT_SYSRQ is messy: every .c source should define it before
> including "serial_core.h" if sysrq is supported or struct uart_port will
> differ in sizes. Also this prevents moving to serial_core.c functions:
> uart_handle_sysrq_char(), uart_prepare_sysrq_char(),
> uart_unlock_and_check_sysrq().
> 
> It doesn't save many bytes in the structure, and a better way to reduce
> it's size would be making rs485 and iso7816 pointers.
> 
> Introduce `has_sysrq` member to be used by serial line drivers further.
> 
> Signed-off-by: Dmitry Safonov <dima@arista.com>

Ah, you did what I asked here in patch 3.  Nevermind on my comments on
patch 2 :)

looks good, thanks!

greg k-h

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 42/58] tty/serial: Migrate sprd_serial to use has_sysrq
  2019-12-13  0:06 ` [PATCH 42/58] tty/serial: Migrate sprd_serial " Dmitry Safonov
@ 2019-12-16  2:30   ` Chunyan Zhang
  0 siblings, 0 replies; 68+ messages in thread
From: Chunyan Zhang @ 2019-12-16  2:30 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: Linux Kernel Mailing List, Dmitry Safonov, Greg Kroah-Hartman,
	Jiri Slaby, Vasiliy Khoruzhick, linux-serial, Baolin Wang,
	Orson Zhai

On Fri, 13 Dec 2019 at 08:09, Dmitry Safonov <dima@arista.com> wrote:
>
> 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.
>
> Cc: Baolin Wang <baolin.wang7@gmail.com>
> Cc: Chunyan Zhang <zhang.lyra@gmail.com>
> Cc: Orson Zhai <orsonzhai@gmail.com>
> Signed-off-by: Dmitry Safonov <dima@arista.com>

Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>

> ---
>  drivers/tty/serial/sprd_serial.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
> index 31df23502562..0c3b7420b01e 100644
> --- a/drivers/tty/serial/sprd_serial.c
> +++ b/drivers/tty/serial/sprd_serial.c
> @@ -3,10 +3,6 @@
>   * Copyright (C) 2012-2015 Spreadtrum Communications Inc.
>   */
>
> -#if defined(CONFIG_SERIAL_SPRD_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
> -#define SUPPORT_SYSRQ
> -#endif
> -
>  #include <linux/clk.h>
>  #include <linux/console.h>
>  #include <linux/delay.h>
> @@ -1227,6 +1223,7 @@ static int sprd_probe(struct platform_device *pdev)
>         up->fifosize = SPRD_FIFO_SIZE;
>         up->ops = &serial_sprd_ops;
>         up->flags = UPF_BOOT_AUTOCONF;
> +       up->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SPRD_CONSOLE);
>
>         ret = sprd_clk_init(up);
>         if (ret)
> --
> 2.24.0
>

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 33/58] serial/f81534: Don't check port->sysrq
  2019-12-13  0:06 ` [PATCH 33/58] serial/f81534: Don't check port->sysrq Dmitry Safonov
@ 2019-12-16 12:10   ` Johan Hovold
  2019-12-16 16:36     ` Dmitry Safonov
  0 siblings, 1 reply; 68+ messages in thread
From: Johan Hovold @ 2019-12-16 12:10 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

On Fri, Dec 13, 2019 at 12:06:32AM +0000, Dmitry Safonov wrote:
> usb_serial_handle_sysrq_char() already checks it.
> 
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>  drivers/usb/serial/f81534.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c
> index 2b39bda035c7..67a8e343eba1 100644
> --- a/drivers/usb/serial/f81534.c
> +++ b/drivers/usb/serial/f81534.c
> @@ -1238,10 +1238,8 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
>  			schedule_work(&port_priv->lsr_work);
>  		}
>  
> -		if (port->port.console && port->sysrq) {
> -			if (usb_serial_handle_sysrq_char(port, data[i]))
> -				continue;
> -		}
> +		if (usb_serial_handle_sysrq_char(port, data[i]))
> +			continue;

This is unrelated to the rest of the series.

Please break all usb-serial patches out of this series and submit them
to me and the usb list for review.

Johan

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 33/58] serial/f81534: Don't check port->sysrq
  2019-12-16 12:10   ` Johan Hovold
@ 2019-12-16 16:36     ` Dmitry Safonov
  0 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-16 16:36 UTC (permalink / raw)
  To: Johan Hovold
  Cc: linux-kernel, Dmitry Safonov, Greg Kroah-Hartman, Jiri Slaby,
	Vasiliy Khoruzhick, linux-serial

Hi Johan,

On 12/16/19 12:10 PM, Johan Hovold wrote:
> On Fri, Dec 13, 2019 at 12:06:32AM +0000, Dmitry Safonov wrote:
>> -		if (port->port.console && port->sysrq) {
>> -			if (usb_serial_handle_sysrq_char(port, data[i]))
>> -				continue;
>> -		}
>> +		if (usb_serial_handle_sysrq_char(port, data[i]))
>> +			continue;
> 
> This is unrelated to the rest of the series.

Right, will drop it from v2.

> 
> Please break all usb-serial patches out of this series and submit them
> to me and the usb list for review.
Thanks,
          Dmitry

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ
  2019-12-13  0:06 ` [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ Dmitry Safonov
  2019-12-13  7:18   ` Greg Kroah-Hartman
@ 2019-12-17 13:48   ` Greg Kroah-Hartman
  2019-12-17 13:51   ` Greg Kroah-Hartman
  2 siblings, 0 replies; 68+ messages in thread
From: Greg Kroah-Hartman @ 2019-12-17 13:48 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Jiri Slaby, Vasiliy Khoruzhick,
	linux-serial

On Fri, Dec 13, 2019 at 12:06:02AM +0000, Dmitry Safonov wrote:
> The SUPPORT_SYSRQ is messy: every .c source should define it before
> including "serial_core.h" if sysrq is supported or struct uart_port will
> differ in sizes. Also this prevents moving to serial_core.c functions:
> uart_handle_sysrq_char(), uart_prepare_sysrq_char(),
> uart_unlock_and_check_sysrq().
> 
> It doesn't save many bytes in the structure, and a better way to reduce
> it's size would be making rs485 and iso7816 pointers.

Yes, the whole thing needs some work with the tool 'pahole' to fix it
up.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ
  2019-12-13  0:06 ` [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ Dmitry Safonov
  2019-12-13  7:18   ` Greg Kroah-Hartman
  2019-12-17 13:48   ` Greg Kroah-Hartman
@ 2019-12-17 13:51   ` Greg Kroah-Hartman
  2 siblings, 0 replies; 68+ messages in thread
From: Greg Kroah-Hartman @ 2019-12-17 13:51 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Jiri Slaby, Vasiliy Khoruzhick,
	linux-serial

On Fri, Dec 13, 2019 at 12:06:02AM +0000, Dmitry Safonov wrote:
> The SUPPORT_SYSRQ is messy: every .c source should define it before
> including "serial_core.h" if sysrq is supported or struct uart_port will
> differ in sizes. Also this prevents moving to serial_core.c functions:
> uart_handle_sysrq_char(), uart_prepare_sysrq_char(),
> uart_unlock_and_check_sysrq().
> 
> It doesn't save many bytes in the structure, and a better way to reduce
> it's size would be making rs485 and iso7816 pointers.
> 
> Introduce `has_sysrq` member to be used by serial line drivers further.
> 
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>  include/linux/serial_core.h | 77 +++++++++++++++++++++----------------
>  1 file changed, 43 insertions(+), 34 deletions(-)
> 
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index bbbe57bf5163..5f761c399282 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -240,14 +240,13 @@ struct uart_port {
>  	resource_size_t		mapsize;
>  	struct device		*dev;			/* parent device */
>  
> -#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
>  	unsigned long		sysrq;			/* sysrq timeout */
>  	unsigned int		sysrq_ch;		/* char for sysrq */
> -#endif
> +	unsigned char		has_sysrq;
>  
>  	unsigned char		hub6;			/* this should be in the 8250 driver */
>  	unsigned char		suspended;
> -	unsigned char		unused[2];

Ugh, the samsung driver was using both of these fields to overload
things for it's own use :(

It's not your fault, I'll go fix up that driver first before applying
this one.

bah, what a horrid hack they did...

greg k-h

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery
  2019-12-13  0:06 ` [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery Dmitry Safonov
@ 2019-12-17 14:27   ` Greg Kroah-Hartman
  2019-12-17 15:50     ` Dmitry Safonov
  0 siblings, 1 reply; 68+ messages in thread
From: Greg Kroah-Hartman @ 2019-12-17 14:27 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Dmitry Safonov, Jiri Slaby, Vasiliy Khoruzhick,
	linux-serial

On Fri, Dec 13, 2019 at 12:06:53AM +0000, Dmitry Safonov wrote:
> No one defines it anymore.
> 
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>  include/linux/serial_core.h | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)

I've applied this series up to here, skipping the usb-serial driver
patch that Johan called out.

Can you rebase your series and resend the remaining based on my tty-next
tree, after these patches move there (give them 24 hours to get through
0-day testing.)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 68+ messages in thread

* Re: [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery
  2019-12-17 14:27   ` Greg Kroah-Hartman
@ 2019-12-17 15:50     ` Dmitry Safonov
  0 siblings, 0 replies; 68+ messages in thread
From: Dmitry Safonov @ 2019-12-17 15:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Dmitry Safonov, Jiri Slaby, Vasiliy Khoruzhick,
	linux-serial

On 12/17/19 2:27 PM, Greg Kroah-Hartman wrote:
> On Fri, Dec 13, 2019 at 12:06:53AM +0000, Dmitry Safonov wrote:
>> No one defines it anymore.
>>
>> Signed-off-by: Dmitry Safonov <dima@arista.com>
>> ---
>>  include/linux/serial_core.h | 14 ++++----------
>>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> I've applied this series up to here, skipping the usb-serial driver
> patch that Johan called out.
> 
> Can you rebase your series and resend the remaining based on my tty-next
> tree, after these patches move there (give them 24 hours to get through
> 0-day testing.)

Thanks much, Greg, will do!

Thanks,
          Dmitry

^ permalink raw reply	[flat|nested] 68+ messages in thread

end of thread, back to index

Thread overview: 68+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20191213000657.931618-1-dima@arista.com>
2019-12-13  0:06 ` [PATCH 01/58] sysrq: Remove sysrq_handler_registered Dmitry Safonov
2019-12-13  0:06 ` [PATCH 02/58] serial: Move sysrq members above Dmitry Safonov
2019-12-13  7:17   ` Greg Kroah-Hartman
2019-12-13  0:06 ` [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ Dmitry Safonov
2019-12-13  7:18   ` Greg Kroah-Hartman
2019-12-17 13:48   ` Greg Kroah-Hartman
2019-12-17 13:51   ` Greg Kroah-Hartman
2019-12-13  0:06 ` [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq Dmitry Safonov
2019-12-13  1:32   ` Andrew Jeffery
2019-12-13  0:06 ` [PATCH 05/58] tty/serial: Migrate 8250_fsl " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 06/58] tty/serial: Migrate bcm63xx_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 07/58] tty/serial: Migrate 8250_omap " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 08/58] tty/serial: Migrate 8250_port " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 09/58] tty/serial: Migrate amba-pl01* " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 10/58] tty/serial: Migrate apbuart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 11/58] tty/serial: Migrate arc_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 12/58] tty/serial: Migrate atmel_serial " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 13/58] tty/serial: Migrate clps711x " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 14/58] tty/serial: Migrate cpm_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 15/58] tty/serial: Migrate dz " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 16/58] tty/serial: Migrate efm32-uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 17/58] tty/serial: Migrate fsl_linflexuart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 18/58] tty/serial: Migrate fsl_lpuart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 19/58] tty/serial: Migrate imx " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 20/58] tty/serial: Migrate ip22zilog " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 21/58] tty/serial: Migrate meson_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 22/58] tty/serial: Migrate milbeaut_usio " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 23/58] tty/serial: Migrate mpc52xx_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 24/58] tty/serial: Don't zero port->sysrq Dmitry Safonov
2019-12-13  0:06 ` [PATCH 25/58] tty/serial: Migrate msm_serial to use has_sysrq Dmitry Safonov
2019-12-13  0:06 ` [PATCH 26/58] tty/serial: Migrate mux " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 27/58] tty/serial: Migrate mxs-auart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 28/58] tty/serial: Migrate omap-serial " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 29/58] tty/serial: Migrate pch_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 30/58] tty/serial: Don't check port->sysrq Dmitry Safonov
2019-12-13  0:06 ` [PATCH 31/58] tty/serial: Migrate pmac_zilog to use has_sysrq Dmitry Safonov
2019-12-13  0:06 ` [PATCH 32/58] tty/serial: Migrate pnx8xxx_uart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 33/58] serial/f81534: Don't check port->sysrq Dmitry Safonov
2019-12-16 12:10   ` Johan Hovold
2019-12-16 16:36     ` Dmitry Safonov
2019-12-13  0:06 ` [PATCH 34/58] tty/serial: Migrate pxa to use has_sysrq Dmitry Safonov
2019-12-13  0:06 ` [PATCH 35/58] tty/serial: Migrate qcom_geni_serial " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 36/58] tty/serial: Migrate sa1100 " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 37/58] tty/serial: Migrate samsung_tty " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 38/58] tty/serial: Migrate sb1250-duart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 39/58] tty/serial: Migrate sccnxp " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 40/58] tty/serial: Migrate serial_txx9 " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 41/58] tty/serial: Migrate sh-sci " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 42/58] tty/serial: Migrate sprd_serial " Dmitry Safonov
2019-12-16  2:30   ` Chunyan Zhang
2019-12-13  0:06 ` [PATCH 43/58] tty/serial: Migrate st-asc " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 44/58] tty/serial: Migrate stm32-usart " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 45/58] tty/serial: Migrate sunhv " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 46/58] tty/serial: Migrate sunsab " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 47/58] tty/serial: Migrate sunsu " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 48/58] tty/serial: Migrate sunzilog " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 49/58] serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ Dmitry Safonov
2019-12-13  0:06 ` [PATCH 50/58] tty/serial: Migrate vr41xx_siu to use has_sysrq Dmitry Safonov
2019-12-13  0:06 ` [PATCH 51/58] tty/serial: Migrate vt8500_serial " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 52/58] tty/serial: Migrate xilinx_uartps " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 53/58] tty/serial: Migrate zs " Dmitry Safonov
2019-12-13  0:06 ` [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery Dmitry Safonov
2019-12-17 14:27   ` Greg Kroah-Hartman
2019-12-17 15:50     ` Dmitry Safonov
2019-12-13  0:06 ` [PATCH 55/58] usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled Dmitry Safonov
2019-12-13  0:06 ` [PATCH 56/58] serial_core: Move sysrq functions from header file Dmitry Safonov
2019-12-13  0:06 ` [PATCH 57/58] sysctl/sysrq: Remove __sysrq_enabled copy Dmitry Safonov
2019-12-13  0:06 ` [PATCH 58/58] serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE Dmitry Safonov

Linux-Serial Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-serial/0 linux-serial/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-serial linux-serial/ https://lore.kernel.org/linux-serial \
		linux-serial@vger.kernel.org
	public-inbox-index linux-serial

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-serial


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git