Skip to contentSkip to conversation

serial: samsung: Remove redundant console initcalls

PATCH New Thomas Abraham 1 participant 3 messages May 19, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover serial: samsung: Remove redundant console initcalls

The explicit console_initcall in Samsung's serial drivers leads to calls to clk_get before the platform_device is registered. This is problematic when adding support for clkdev and device tree. So the explicit calls to console_initcall can be removed and let the driver's probe function handle the console registration.

Thomas Abraham (2):
serial: samsung: Fix unintended usage of uart port 0 as console
serial: Remove redundant console_initcall from s3c and s5p console
drivers

 drivers/tty/serial/s3c2400.c |    2 --
 drivers/tty/serial/s3c2410.c |    2 --
 drivers/tty/serial/s3c2412.c |    2 --
 drivers/tty/serial/s3c2440.c |    2 --
 drivers/tty/serial/s3c24a0.c |    2 --
 drivers/tty/serial/s3c6400.c |    2 --
 drivers/tty/serial/s5pv210.c |    7 -------
 drivers/tty/serial/samsung.c |    9 ++++-----
 drivers/tty/serial/samsung.h |   19 -------------------
 9 files changed, 4 insertions(+), 43 deletions(-)
#1 lore raw

PATCH 1/2 serial: samsung: Fix unintended usage of uart port 0 as console

In s3c24xx_serial_console_setup function, if the uart port that is being setup as a console has not been initialized, an error can be returned instead of using uart port 0 as the default console port. The uart port that was intended to be used as a console could be initialized at a later point during boot and then registered as a console. This will avoid using uart port 0 as a unintended console port.

---
 drivers/tty/serial/samsung.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/samsung.c +2 -4
index 9e2fa8d..08e72a2 100644
@@ -1417,10 +1417,8 @@ s3c24xx_serial_console_setup(struct console *co, char *options)
 
 	/* is the port configured? */
 
-	if (port->mapbase == 0x0) {
-		co->index = 0;
-		port = &s3c24xx_serial_ports[co->index].port;
-	}
+	if (port->mapbase == 0x0)
+		return -ENODEV;
 
 	cons_uart = port;
 
Signature · 1 line
1.6.6.rc2
#2 lore raw

PATCH 2/2 serial: Remove redundant console_initcall from s3c and s5p console drivers

In reply to Thomas Abraham

Uart port is registered as a console during the driver's probe. So explict registration of console with console_initcall is removed.

---
 drivers/tty/serial/s3c2400.c |    2 --
 drivers/tty/serial/s3c2410.c |    2 --
 drivers/tty/serial/s3c2412.c |    2 --
 drivers/tty/serial/s3c2440.c |    2 --
 drivers/tty/serial/s3c24a0.c |    2 --
 drivers/tty/serial/s3c6400.c |    2 --
 drivers/tty/serial/s5pv210.c |    7 -------
 drivers/tty/serial/samsung.c |    3 ++-
 drivers/tty/serial/samsung.h |   19 -------------------
 9 files changed, 2 insertions(+), 39 deletions(-)
drivers/tty/serial/s3c2400.c +0 -2
index fed1a9a..48f1611 100644
@@ -85,8 +85,6 @@ static struct platform_driver s3c2400_serial_driver = {
 	},
 };
 
-s3c24xx_console_init(&s3c2400_serial_driver, &s3c2400_uart_inf);
-
 static inline int s3c2400_serial_init(void)
 {
 	return s3c24xx_serial_init(&s3c2400_serial_driver, &s3c2400_uart_inf);
drivers/tty/serial/s3c2410.c +0 -2
index 73f089d..f042c35 100644
@@ -97,8 +97,6 @@ static struct platform_driver s3c2410_serial_driver = {
 	},
 };
 
-s3c24xx_console_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
-
 static int __init s3c2410_serial_init(void)
 {
 	return s3c24xx_serial_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
drivers/tty/serial/s3c2412.c +0 -2
index 1700b1a..6ecfff3 100644
@@ -131,8 +131,6 @@ static struct platform_driver s3c2412_serial_driver = {
 	},
 };
 
-s3c24xx_console_init(&s3c2412_serial_driver, &s3c2412_uart_inf);
-
 static inline int s3c2412_serial_init(void)
 {
 	return s3c24xx_serial_init(&s3c2412_serial_driver, &s3c2412_uart_inf);
drivers/tty/serial/s3c2440.c +0 -2
index 094cc39..389b6b3 100644
@@ -160,8 +160,6 @@ static struct platform_driver s3c2440_serial_driver = {
 	},
 };
 
-s3c24xx_console_init(&s3c2440_serial_driver, &s3c2440_uart_inf);
-
 static int __init s3c2440_serial_init(void)
 {
 	return s3c24xx_serial_init(&s3c2440_serial_driver, &s3c2440_uart_inf);
drivers/tty/serial/s3c24a0.c +0 -2
index fad6083..45e119d 100644
@@ -101,8 +101,6 @@ static struct platform_driver s3c24a0_serial_driver = {
 	},
 };
 
-s3c24xx_console_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
-
 static int __init s3c24a0_serial_init(void)
 {
 	return s3c24xx_serial_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
drivers/tty/serial/s3c6400.c +0 -2
index 4be92ab..1d8abe4 100644
@@ -131,8 +131,6 @@ static struct platform_driver s3c6400_serial_driver = {
 	},
 };
 
-s3c24xx_console_init(&s3c6400_serial_driver, &s3c6400_uart_inf);
-
 static int __init s3c6400_serial_init(void)
 {
 	return s3c24xx_serial_init(&s3c6400_serial_driver, &s3c6400_uart_inf);
drivers/tty/serial/s5pv210.c +0 -7
index 6ebccd7..cdee626 100644
@@ -136,13 +136,6 @@ static struct platform_driver s5p_serial_driver = {
 	},
 };
 
-static int __init s5pv210_serial_console_init(void)
-{
-	return s3c24xx_serial_initconsole(&s5p_serial_driver, s5p_uart_inf);
-}
-
-console_initcall(s5pv210_serial_console_init);
-
 static int __init s5p_serial_init(void)
 {
 	return s3c24xx_serial_init(&s5p_serial_driver, *s5p_uart_inf);
drivers/tty/serial/samsung.c +2 -1
index 08e72a2..14a2e41 100644
@@ -1450,7 +1450,8 @@ static struct console s3c24xx_serial_console = {
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
 	.write		= s3c24xx_serial_console_write,
-	.setup		= s3c24xx_serial_console_setup
+	.setup		= s3c24xx_serial_console_setup,
+	.data		= &s3c24xx_uart_drv,
 };
 
 int s3c24xx_serial_initconsole(struct platform_driver *drv,
drivers/tty/serial/samsung.h +0 -19
index 0ac06a0..5832660 100644
@@ -80,25 +80,6 @@ extern int s3c24xx_serial_initconsole(struct platform_driver *drv,
 extern int s3c24xx_serial_init(struct platform_driver *drv,
 			       struct s3c24xx_uart_info *info);
 
-#ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE
-
-#define s3c24xx_console_init(__drv, __inf)				\
-static int __init s3c_serial_console_init(void)				\
-{									\
-	struct s3c24xx_uart_info *uinfo[CONFIG_SERIAL_SAMSUNG_UARTS];	\
-	int i;								\
-									\
-	for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++)		\
-		uinfo[i] = __inf;					\
-	return s3c24xx_serial_initconsole(__drv, uinfo);		\
-}									\
-									\
-console_initcall(s3c_serial_console_init)
-
-#else
-#define s3c24xx_console_init(drv, inf) extern void no_console(void)
-#endif
-
 #ifdef CONFIG_SERIAL_SAMSUNG_DEBUG
 
 extern void printascii(const char *);
Signature · 1 line
1.6.6.rc2