[PATCH 2/3] serial: sprd: add console_initcall in sprd's uart driver

From: Chunyan Zhang
Date: Mon Aug 26 2019 - 03:29:59 EST


From: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>

Use console_initcall to save the console index we selected on the
command line to sprd_console before probe finished. Thus we can
make different processes to the uart devices during initialization
according to whether it is used for console.

Signed-off-by: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>
Signed-off-by: Chunyan Zhang <zhang.lyra@xxxxxxxxx>
---
drivers/tty/serial/sprd_serial.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index a3be4e2dd019..aead823c650b 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -1008,6 +1008,13 @@ static struct console sprd_console = {
.data = &sprd_uart_driver,
};

+static int __init sprd_serial_console_init(void)
+{
+ register_console(&sprd_console);
+ return 0;
+}
+console_initcall(sprd_serial_console_init);
+
#define SPRD_CONSOLE (&sprd_console)

/* Support for earlycon */
--
2.20.1