struct uart_port has no member named 'sysrq' (was: linux-next: parisc build failure)

From: Helge Deller
Date: Tue Nov 18 2008 - 14:25:34 EST


On Sunday 16 November 2008, Stephen Rothwell wrote:
> Hi Kyle,
>
> Today's linux-next build (parisc allmodconfig) failed like this:
>
> In file included from drivers/serial/mux.c:38:
> include/linux/serial_core.h: In function 'uart_handle_sysrq_char':
> include/linux/serial_core.h:450: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:451: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:451: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:453: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:456: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:473: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:474: error: 'struct uart_port' has no member named 'sysrq'
> include/linux/serial_core.h:477: error: 'struct uart_port' has no member named 'sysrq'
>
> This is happening in mainline as well. In fact, this has been happening
> back as far as I have results (Aug 27). The sysrq element of struct
> uart_port is dependent on CONFIG_SERIAL_CORE_CONSOLE while the references
> failing above are dependent on SUPPORT_SYSRQ which is defined if
> CONFIG_MAGIC_SYSRQ is defined in mux.c.

I assume you don't have CONFIG_SERIAL_CORE_CONSOLE set in your config, which is probably why this build failure shows up.
Looking at other serial drivers, which all seem to have similiar coding like mux.c, I'm wondering that it only shows up on parisc.

Anyway, since I assume we can't make the sysrq element of struct uart_port depended on SUPPORT_SYSRQ (since it depends on each serial driver if it wants to support the sysrq feature and we need to keep the size of struct uart_port constant), I think we need to add an additional check for CONFIG_SERIAL_CORE_CONSOLE to where we already check for SUPPORT_SYSRQ.
Proposed patch and RFC below.

-------

[RFC] [PATCH] check for SUPPORT_SYSRQ and CONFIG_SERIAL_CORE_CONSOLE before accessing the "sysrq" member of struct uart_port.

Serial drivers (like mux.c) can #define SUPPORT_SYSRQ to tell the core serial functions that they want to have SYSRQ-support built-in.
If SUPPORT_SYSRQ is defined, the functions uart_handle_sysrq_char() and uart_handle_break() in include/linux/serial_core.h unconditionally access the "sysrq" member of struct uart_port.
Since the "sysrq" member of struct uart_port is only compiled into the kernel if CONFIG_SERIAL_CORE_CONSOLE is defined, builds will break if
SUPPORT_SYSRQ is defined and CONFIG_SERIAL_CORE_CONSOLE is not defined.

This patch works around the problem by checking for SUPPORT_SYSRQ _and_ CONFIG_SERIAL_CORE_CONSOLE before accessing the "sysrq" member of struct uart_port.

Signed-off-by: Helge Deller <deller@xxxxxx>


diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 4e4f127..b9d79f1 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -446,7 +446,7 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
static inline int
uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
{
-#ifdef SUPPORT_SYSRQ
+#if defined(SUPPORT_SYSRQ) && defined(CONFIG_SERIAL_CORE_CONSOLE)
if (port->sysrq) {
if (ch && time_before(jiffies, port->sysrq)) {
handle_sysrq(ch, port->info ? port->info->port.tty : NULL);
@@ -458,9 +458,6 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
#endif
return 0;
}
-#ifndef SUPPORT_SYSRQ
-#define uart_handle_sysrq_char(port,ch) uart_handle_sysrq_char(port, 0)
-#endif

/*
* We do the SysRQ and SAK checking like this...
@@ -468,7 +465,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
static inline int uart_handle_break(struct uart_port *port)
{
struct uart_info *info = port->info;
-#ifdef SUPPORT_SYSRQ
+#if defined(SUPPORT_SYSRQ) && defined(CONFIG_SERIAL_CORE_CONSOLE)
if (port->cons && port->cons->index == port->line) {
if (!port->sysrq) {
port->sysrq = jiffies + HZ*5;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/