Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: ar933x_uart: Fix build failure with disabled console

Andrey has reported on OpenWrt's bug tracking system[1], that he
currently can't use ar93xx_uart as pure serial UART without console
(CONFIG_SERIAL_8250_CONSOLE and CONFIG_SERIAL_AR933X_CONSOLE undefined),
because compilation ends with following error:

ar933x_uart.c: In function 'ar933x_uart_console_write':
ar933x_uart.c:550:14: error: 'struct uart_port' has no
member named 'sysrq'

So this patch moves all the code related to console handling behind
series of CONFIG_SERIAL_AR933X_CONSOLE ifdefs.

1. https://bugs.openwrt.org/index.php?do=details&task_id=2152

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andrey Batyiev <batyiev@gmail.com>
Reported-by: Andrey Batyiev <batyiev@gmail.com>
Tested-by: Andrey Batyiev <batyiev@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Petr Štetiar and committed by
Greg Kroah-Hartman
72ff51d8 c5cbc78a

+8 -16
+8 -16
drivers/tty/serial/ar933x_uart.c
··· 49 49 struct clk *clk; 50 50 }; 51 51 52 - static inline bool ar933x_uart_console_enabled(void) 53 - { 54 - return IS_ENABLED(CONFIG_SERIAL_AR933X_CONSOLE); 55 - } 56 - 57 52 static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, 58 53 int offset) 59 54 { ··· 503 508 .verify_port = ar933x_uart_verify_port, 504 509 }; 505 510 511 + #ifdef CONFIG_SERIAL_AR933X_CONSOLE 506 512 static struct ar933x_uart_port * 507 513 ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; 508 514 ··· 600 604 .index = -1, 601 605 .data = &ar933x_uart_driver, 602 606 }; 603 - 604 - static void ar933x_uart_add_console_port(struct ar933x_uart_port *up) 605 - { 606 - if (!ar933x_uart_console_enabled()) 607 - return; 608 - 609 - ar933x_console_ports[up->port.line] = up; 610 - } 607 + #endif /* CONFIG_SERIAL_AR933X_CONSOLE */ 611 608 612 609 static struct uart_driver ar933x_uart_driver = { 613 610 .owner = THIS_MODULE, ··· 689 700 baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP); 690 701 up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD); 691 702 692 - ar933x_uart_add_console_port(up); 703 + #ifdef CONFIG_SERIAL_AR933X_CONSOLE 704 + ar933x_console_ports[up->port.line] = up; 705 + #endif 693 706 694 707 ret = uart_add_one_port(&ar933x_uart_driver, &up->port); 695 708 if (ret) ··· 740 749 { 741 750 int ret; 742 751 743 - if (ar933x_uart_console_enabled()) 744 - ar933x_uart_driver.cons = &ar933x_uart_console; 752 + #ifdef CONFIG_SERIAL_AR933X_CONSOLE 753 + ar933x_uart_driver.cons = &ar933x_uart_console; 754 + #endif 745 755 746 756 ret = uart_register_driver(&ar933x_uart_driver); 747 757 if (ret)