diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-08-28 11:08:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-28 19:00:42 -0400 |
commit | 124155351331a53feb00d10874f0c620405fd385 (patch) | |
tree | d07b24b0a57e132893704faa806c9472112d2822 | |
parent | 0710e5626f524a26fe5992adb91a6289b2139928 (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.c | 25 |
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 | ||
53 | static inline bool ar933x_uart_console_enabled(void) | ||
54 | { | ||
55 | return config_enabled(CONFIG_SERIAL_AR933X_CONSOLE); | ||
56 | } | ||
57 | |||
53 | static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, | 58 | static 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 | |||
505 | static struct ar933x_uart_port * | 508 | static struct ar933x_uart_port * |
506 | ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; | 509 | ar933x_console_ports[CONFIG_SERIAL_AR933X_NR_UARTS]; |
507 | 510 | ||
@@ -600,25 +603,18 @@ static struct console ar933x_uart_console = { | |||
600 | 603 | ||
601 | static void ar933x_uart_add_console_port(struct ar933x_uart_port *up) | 604 | static 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 | |||
610 | static 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 | |||
616 | static struct uart_driver ar933x_uart_driver = { | 612 | static 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 | ||
624 | static int ar933x_uart_probe(struct platform_device *pdev) | 620 | static 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; |