diff options
Diffstat (limited to 'include/linux/serial_core.h')
-rw-r--r-- | include/linux/serial_core.h | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 2b78cc734719..9cf1682dc580 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,9 +239,14 @@ struct uart_port { resource_size_t mapbase; /* for ioremap */ resource_size_t mapsize; struct device *dev; /* parent device */ + + unsigned long sysrq; /* sysrq timeout */ + unsigned int sysrq_ch; /* char for sysrq */ + 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) */ @@ -460,31 +460,40 @@ 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 || !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 || !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 @@ -492,6 +501,11 @@ 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; @@ -500,17 +514,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... @@ -522,15 +525,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) { + 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; |