657a869493b454a21ad19d941ebd440f5ad60715
[oweals/openwrt.git] /
1 From 72ff51d8dd262d1fef25baedc2ac35116435be47 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz@true.cz>
3 Date: Wed, 6 Mar 2019 17:54:03 +0100
4 Subject: [PATCH] serial: ar933x_uart: Fix build failure with disabled console
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Andrey has reported on OpenWrt's bug tracking system[1], that he
10 currently can't use ar93xx_uart as pure serial UART without console
11 (CONFIG_SERIAL_8250_CONSOLE and CONFIG_SERIAL_AR933X_CONSOLE undefined),
12 because compilation ends with following error:
13
14  ar933x_uart.c: In function 'ar933x_uart_console_write':
15  ar933x_uart.c:550:14: error: 'struct uart_port' has no
16                                member named 'sysrq'
17
18 So this patch moves all the code related to console handling behind
19 series of CONFIG_SERIAL_AR933X_CONSOLE ifdefs.
20
21 1. https://bugs.openwrt.org/index.php?do=details&task_id=2152
22
23 Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 Cc: Jiri Slaby <jslaby@suse.com>
25 Cc: Andrey Batyiev <batyiev@gmail.com>
26 Reported-by: Andrey Batyiev <batyiev@gmail.com>
27 Tested-by: Andrey Batyiev <batyiev@gmail.com>
28 Signed-off-by: Petr Štetiar <ynezz@true.cz>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 ---
31  drivers/tty/serial/ar933x_uart.c | 24 ++++++++----------------
32  1 file changed, 8 insertions(+), 16 deletions(-)
33
34 --- a/drivers/tty/serial/ar933x_uart.c
35 +++ b/drivers/tty/serial/ar933x_uart.c
36 @@ -52,11 +52,6 @@ struct ar933x_uart_port {
37         struct clk              *clk;
38  };
39  
40 -static inline bool ar933x_uart_console_enabled(void)
41 -{
42 -       return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE);
43 -}
44 -
45  static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
46                                             int offset)
47  {
48 @@ -511,6 +506,7 @@ static const struct uart_ops ar933x_uart
49         .verify_port    = ar933x_uart_verify_port,
50  };
51  
52 +#ifdef CONFIG_SERIAL_AR933X_CONSOLE
53  static struct ar933x_uart_port *
54  ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
55  
56 @@ -607,14 +603,7 @@ static struct console ar933x_uart_consol
57         .index          = -1,
58         .data           = &ar933x_uart_driver,
59  };
60 -
61 -static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
62 -{
63 -       if (!ar933x_uart_console_enabled())
64 -               return;
65 -
66 -       ar933x_console_ports[up->port.line] = up;
67 -}
68 +#endif /* CONFIG_SERIAL_AR933X_CONSOLE */
69  
70  static struct uart_driver ar933x_uart_driver = {
71         .owner          = THIS_MODULE,
72 @@ -703,7 +692,9 @@ static int ar933x_uart_probe(struct plat
73         baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP);
74         up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD);
75  
76 -       ar933x_uart_add_console_port(up);
77 +#ifdef CONFIG_SERIAL_AR933X_CONSOLE
78 +       ar933x_console_ports[up->port.line] = up;
79 +#endif
80  
81         ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
82         if (ret)
83 @@ -752,8 +743,9 @@ static int __init ar933x_uart_init(void)
84  {
85         int ret;
86  
87 -       if (ar933x_uart_console_enabled())
88 -               ar933x_uart_driver.cons = &ar933x_uart_console;
89 +#ifdef CONFIG_SERIAL_AR933X_CONSOLE
90 +       ar933x_uart_driver.cons = &ar933x_uart_console;
91 +#endif
92  
93         ret = uart_register_driver(&ar933x_uart_driver);
94         if (ret)