aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-08-28 11:08:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-28 19:00:42 -0400
commit124155351331a53feb00d10874f0c620405fd385 (patch)
treed07b24b0a57e132893704faa806c9472112d2822
parent0710e5626f524a26fe5992adb91a6289b2139928 (diff)
tty: ar933x_uart: use config_enabled() macro to clean up ifdefs
Add a new ar933x_uart_console_enabled() helper function which uses the config_enable(CONFIG_SERIAL_AR933X_CONSOLE) macro to decide if the console support is enabled or not. Remove the 'ifdef CONFIG_SERIAL_AR933X_CONSOLE' statements and use the new helper function to conditionally enable console support instead. If CONFIG_SERIAL_AR933X_CONSOLE is not enabled, the new helper function will become a null stub which allows the compiler to optimize out the unused console specific functions/variables. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/ar933x_uart.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 2d83a45dcc8d..0437a9e08d58 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -50,6 +50,11 @@ struct ar933x_uart_port {
50 struct clk *clk; 50 struct clk *clk;
51}; 51};
52 52
53static inline bool ar933x_uart_console_enabled(void)
54{
55 return config_enabled(CONFIG_SERIAL_AR933X_CONSOLE);
56}
57
53static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, 58static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
54 int offset) 59 int offset)
55{ 60{
@@ -500,8 +505,6 @@ static struct uart_ops ar933x_uart_ops = {
500 .verify_port = ar933x_uart_verify_port, 505 .verify_port = ar933x_uart_verify_port,
501}; 506};
502 507
503#ifdef CONFIG_SERIAL_AR933X_CONSOLE
504
505static struct ar933x_uart_port * 508static struct ar933x_uart_port *
506ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; 509ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS];
507 510
@@ -600,25 +603,18 @@ static struct console ar933x_uart_console = {
600 603
601static void ar933x_uart_add_console_port(struct ar933x_uart_port *up) 604static void ar933x_uart_add_console_port(struct ar933x_uart_port *up)
602{ 605{
606 if (!ar933x_uart_console_enabled())
607 return;
608
603 ar933x_console_ports[up->port.line] = up; 609 ar933x_console_ports[up->port.line] = up;
604} 610}
605 611
606#define AR933X_SERIAL_CONSOLE (&ar933x_uart_console)
607
608#else
609
610static inline void ar933x_uart_add_console_port(struct ar933x_uart_port *up) {}
611
612#define AR933X_SERIAL_CONSOLE NULL
613
614#endif /* CONFIG_SERIAL_AR933X_CONSOLE */
615
616static struct uart_driver ar933x_uart_driver = { 612static struct uart_driver ar933x_uart_driver = {
617 .owner = THIS_MODULE, 613 .owner = THIS_MODULE,
618 .driver_name = DRIVER_NAME, 614 .driver_name = DRIVER_NAME,
619 .dev_name = "ttyATH", 615 .dev_name = "ttyATH",
620 .nr = CONFIG_SERIAL_AR933X_NR_UARTS, 616 .nr = CONFIG_SERIAL_AR933X_NR_UARTS,
621 .cons = AR933X_SERIAL_CONSOLE, 617 .cons = NULL, /* filled in runtime */
622}; 618};
623 619
624static int ar933x_uart_probe(struct platform_device *pdev) 620static int ar933x_uart_probe(struct platform_device *pdev)
@@ -730,6 +726,9 @@ static int __init ar933x_uart_init(void)
730{ 726{
731 int ret; 727 int ret;
732 728
729 if (ar933x_uart_console_enabled())
730 ar933x_uart_driver.cons = &ar933x_uart_console;
731
733 ret = uart_register_driver(&ar933x_uart_driver); 732 ret = uart_register_driver(&ar933x_uart_driver);
734 if (ret) 733 if (ret)
735 goto err_out; 734 goto err_out;