Skip to contentSkip to conversation

tty: serial: samsung: Clean-up selection of number of available UARTs

PATCH New Abhilash Kesavan 4 participants 8 messages Sep 30, 2014

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

PATCH 1/2 tty: serial: samsung: Clean-up selection of number of available UARTs

Remove symbols SERIAL_SAMSUNG_UARTS_4 and SERIAL_SAMSUNG_UARTS which select the number of UART ports available on the SoC. Use the maximum number of UART ports possible across the serial driver in place of SERIAL_SAMSUNG_UARTS. Removal of these symbols also helps in Exynos7 serial enablement.

Cc Greg Kroah-Hartman <[email protected]>

---
Build tested using s3c2410_defconfig, s3c6400_defconfig, exynos_defconfig and arm64's defconfig with and without the serial driver enabled. Boot tested on Exynos5420 and Exynos7.

 drivers/tty/serial/Kconfig   |   16 ----------------
 drivers/tty/serial/samsung.c |   11 +++--------
 drivers/tty/serial/samsung.h |    5 ++++-
 3 files changed, 7 insertions(+), 25 deletions(-)
drivers/tty/serial/Kconfig +0 -16
index 81f6ee7..9fc9092 100644
@@ -247,22 +247,6 @@ config SERIAL_SAMSUNG
 	  provide all of these ports, depending on how the serial port
 	  pins are configured.
 
-config SERIAL_SAMSUNG_UARTS_4
-	bool
-	depends on PLAT_SAMSUNG
-	default y if !(CPU_S3C2410 || CPU_S3C2412 || CPU_S3C2440 || CPU_S3C2442)
-	help
-	  Internal node for the common case of 4 Samsung compatible UARTs
-
-config SERIAL_SAMSUNG_UARTS
-	int
-	depends on PLAT_SAMSUNG
-	default 4 if SERIAL_SAMSUNG_UARTS_4 || CPU_S3C2416
-	default 3
-	help
-	  Select the number of available UART ports for the Samsung S3C
-	  serial driver
-	
 config SERIAL_SAMSUNG_DEBUG
 	bool "Samsung SoC serial debug"
 	depends on SERIAL_SAMSUNG && DEBUG_LL
drivers/tty/serial/samsung.c +3 -8
index c78f43a..ba04c6d 100644
@@ -962,14 +962,14 @@ static struct uart_ops s3c24xx_serial_ops = {
 static struct uart_driver s3c24xx_uart_drv = {
 	.owner		= THIS_MODULE,
 	.driver_name	= "s3c2410_serial",
-	.nr		= CONFIG_SERIAL_SAMSUNG_UARTS,
+	.nr		= MAX_SAMSUNG_UARTS,
 	.cons		= S3C24XX_SERIAL_CONSOLE,
 	.dev_name	= S3C24XX_SERIAL_NAME,
 	.major		= S3C24XX_SERIAL_MAJOR,
 	.minor		= S3C24XX_SERIAL_MINOR,
 };
 
-static struct s3c24xx_uart_port s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS] = {
+static struct s3c24xx_uart_port s3c24xx_serial_ports[MAX_SAMSUNG_UARTS] = {
 	[0] = {
 		.port = {
 			.lock		= __SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[0].port.lock),
@@ -992,8 +992,6 @@ static struct s3c24xx_uart_port s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS
 			.line		= 1,
 		}
 	},
-#if CONFIG_SERIAL_SAMSUNG_UARTS > 2
-
 	[2] = {
 		.port = {
 			.lock		= __SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[2].port.lock),
@@ -1005,8 +1003,6 @@ static struct s3c24xx_uart_port s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS
 			.line		= 2,
 		}
 	},
-#endif
-#if CONFIG_SERIAL_SAMSUNG_UARTS > 3
 	[3] = {
 		.port = {
 			.lock		= __SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[3].port.lock),
@@ -1018,7 +1014,6 @@ static struct s3c24xx_uart_port s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS
 			.line		= 3,
 		}
 	}
-#endif
 };
 
 /* s3c24xx_serial_resetport
@@ -1590,7 +1585,7 @@ s3c24xx_serial_console_setup(struct console *co, char *options)
 
 	/* is this a valid port */
 
-	if (co->index == -1 || co->index >= CONFIG_SERIAL_SAMSUNG_UARTS)
+	if (co->index == -1 || co->index >= MAX_SAMSUNG_UARTS)
 		co->index = 0;
 
 	port = &s3c24xx_serial_ports[co->index].port;
drivers/tty/serial/samsung.h +4 -1
index eb071dd..484b49e 100644
@@ -1,6 +1,9 @@
 #ifndef __SAMSUNG_H
 #define __SAMSUNG_H
 
+/* Maximum UART ports available */
+#define MAX_SAMSUNG_UARTS       4
+
 /*
  * Driver for Samsung SoC onboard UARTs.
  *
@@ -38,7 +41,7 @@ struct s3c24xx_uart_info {
 struct s3c24xx_serial_drv_data {
 	struct s3c24xx_uart_info	*info;
 	struct s3c2410_uartcfg		*def_cfg;
-	unsigned int			fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
+	unsigned int			fifosize[MAX_SAMSUNG_UARTS];
 };
 
 struct s3c24xx_uart_port {
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 arch: arm: samsung: Clean-up usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol

Remove usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol from platform specific code.

---
 arch/arm/mach-s3c64xx/irq-pm.c |    6 +++---
 arch/arm/plat-samsung/init.c   |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/mach-s3c64xx/irq-pm.c +3 -3
index ae4ea76..b20024e 100644
@@ -55,10 +55,10 @@ static struct irq_grp_save {
 	u32	mask;
 } eint_grp_save[5];
 
-#ifndef CONFIG_SERIAL_SAMSUNG_UARTS
-#define SERIAL_SAMSUNG_UARTS 0
+#ifndef CONFIG_SERIAL_SAMSUNG
+#define SERIAL_SAMSUNG_UARTS	0
 #else
-#define	SERIAL_SAMSUNG_UARTS CONFIG_SERIAL_SAMSUNG_UARTS
+#define SERIAL_SAMSUNG_UARTS	4
 #endif
 
 static u32 irq_uart_mask[SERIAL_SAMSUNG_UARTS];
arch/arm/plat-samsung/init.c +3 -3
index 11fbbc2..03cafe9 100644
@@ -93,8 +93,8 @@ void __init s3c24xx_init_clocks(int xtal)
 #if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
 static int nr_uarts __initdata = 0;
 
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
-static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
+#ifdef CONFIG_SERIAL_SAMSUNG
+static struct s3c2410_uartcfg uart_cfgs[4];
 #endif
 
 /* s3c24xx_init_uartdevs
@@ -110,7 +110,7 @@ void __init s3c24xx_init_uartdevs(char *name,
 				  struct s3c24xx_uart_resources *res,
 				  struct s3c2410_uartcfg *cfg, int no)
 {
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
+#ifdef CONFIG_SERIAL_SAMSUNG
 	struct platform_device *platdev;
 	struct s3c2410_uartcfg *cfgptr = uart_cfgs;
 	struct s3c24xx_uart_resources *resp;
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 arch: arm: samsung: Clean-up usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol

Quoted 6 lines · On Tuesday 30 September 2014 20:04:55 Abhilash Kesavan wrote:
arch/arm/mach-s3c64xx/irq-pm.c +0 -0
@@ -55,10 +55,10 @@ static struct irq_grp_save {
        u32     mask;
 } eint_grp_save[5];
 

arch/arm/mach-s3c64xx/irq-pm.c static struct irq_grp_save { · line 64

Quoted 10 lines
arch/arm/mach-s3c64xx/irq-pm.c +3 -3
-#ifndef CONFIG_SERIAL_SAMSUNG_UARTS
-#define SERIAL_SAMSUNG_UARTS 0
+#ifndef CONFIG_SERIAL_SAMSUNG
+#define SERIAL_SAMSUNG_UARTS   0
 #else
-#define        SERIAL_SAMSUNG_UARTS CONFIG_SERIAL_SAMSUNG_UARTS
+#define SERIAL_SAMSUNG_UARTS   4
 #endif
 
 static u32 irq_uart_mask[SERIAL_SAMSUNG_UARTS];

I think this won't work because now you access invalid registers on machines that have only three uarts.

Quoted 16 lines
arch/arm/plat-samsung/init.c +2 -2
index 11fbbc2..03cafe9 100644
@@ -93,8 +93,8 @@ void __init s3c24xx_init_clocks(int xtal)
 #if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
 static int nr_uarts __initdata = 0;
 
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
-static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
+#ifdef CONFIG_SERIAL_SAMSUNG
+static struct s3c2410_uartcfg uart_cfgs[4];
 #endif
 
 /* s3c24xx_init_uartdevs

arch/arm/plat-samsung/init.c void __init s3c24xx_init_uartdevs(char *name, · line 116

Quoted 8 lines
arch/arm/plat-samsung/init.c +1 -1
@@ -110,7 +110,7 @@ void __init s3c24xx_init_uartdevs(char *name,
                                  struct s3c24xx_uart_resources *res,
                                  struct s3c2410_uartcfg *cfg, int no)
 {
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
+#ifdef CONFIG_SERIAL_SAMSUNG
        struct platform_device *platdev;
        struct s3c2410_uartcfg *cfgptr = uart_cfgs;
        struct s3c24xx_uart_resources *resp;

Since you hardcode the number here now, you can actually drop this #ifdef.

Arnd

#3 lore raw

PATCH 2/2 arch: arm: samsung: Clean-up usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol

Quoted 16 lines · Arnd Bergmann
Quoted 15 lines · On Tuesday 30 September 2014 20:04:55 Abhilash Kesavan wrote:
arch/arm/mach-s3c64xx/irq-pm.c +3 -3
@@ -55,10 +55,10 @@ static struct irq_grp_save {
        u32     mask;
 } eint_grp_save[5];
 
-#ifndef CONFIG_SERIAL_SAMSUNG_UARTS
-#define SERIAL_SAMSUNG_UARTS 0
+#ifndef CONFIG_SERIAL_SAMSUNG
+#define SERIAL_SAMSUNG_UARTS   0
 #else
-#define        SERIAL_SAMSUNG_UARTS CONFIG_SERIAL_SAMSUNG_UARTS
+#define SERIAL_SAMSUNG_UARTS   4
 #endif
 
Quoted 4 lines

arch/arm/mach-s3c64xx/irq-pm.c static struct irq_grp_save { · line 64

Quoted 1 line
arch/arm/mach-s3c64xx/irq-pm.c +0 -0
 static u32 irq_uart_mask[SERIAL_SAMSUNG_UARTS];

I think this won't work because now you access invalid registers on machines that have only three uarts.

Both S3C6400 and S3C6410 SoCs have 4 UART blocks. AFAICT CONFIG_SERIAL_SAMSUNG_UARTS was always set to 4 on ARCH_S3C64XX.

Quoted 9 lines
Quoted 9 lines
arch/arm/plat-samsung/init.c +0 -0
index 11fbbc2..03cafe9 100644
@@ -93,8 +93,8 @@ void __init s3c24xx_init_clocks(int xtal)
 #if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
 static int nr_uarts __initdata = 0;
 
Quoted 4 lines

arch/arm/plat-samsung/init.c void __init s3c24xx_init_clocks(int xtal) · line 97

Quoted 4 lines
arch/arm/plat-samsung/init.c +2 -2
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
-static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
+#ifdef CONFIG_SERIAL_SAMSUNG
+static struct s3c2410_uartcfg uart_cfgs[4];

Abhilash: Instead of using 4 directly, you could define a constant for it.

Quoted 14 lines

arch/arm/plat-samsung/init.c void __init s3c24xx_init_uartdevs(char *name, · line 116

Quoted 12 lines
arch/arm/plat-samsung/init.c +1 -1
 #endif
 
 /* s3c24xx_init_uartdevs
@@ -110,7 +110,7 @@ void __init s3c24xx_init_uartdevs(char *name,
                                  struct s3c24xx_uart_resources *res,
                                  struct s3c2410_uartcfg *cfg, int no)
 {
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
+#ifdef CONFIG_SERIAL_SAMSUNG
        struct platform_device *platdev;
        struct s3c2410_uartcfg *cfgptr = uart_cfgs;
        struct s3c24xx_uart_resources *resp;

Since you hardcode the number here now, you can actually drop this #ifdef.

I believe what Abhilash did is correct, because this code is not needed when there is no serial support enabled.

Best regards,
Tomasz

#4 lore raw

PATCH 2/2 arch: arm: samsung: Clean-up usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol

Quoted 12 lines · On Tuesday 30 September 2014 18:10:14 Tomasz Figa wrote:
Quoted 11 lines

arch/arm/plat-samsung/init.c void __init s3c24xx_init_uartdevs(char *name, · line 116

Quoted 9 lines
arch/arm/plat-samsung/init.c +1 -1
@@ -110,7 +110,7 @@ void __init s3c24xx_init_uartdevs(char *name,
                                  struct s3c24xx_uart_resources *res,
                                  struct s3c2410_uartcfg *cfg, int no)
 {
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
+#ifdef CONFIG_SERIAL_SAMSUNG
        struct platform_device *platdev;
        struct s3c2410_uartcfg *cfgptr = uart_cfgs;
        struct s3c24xx_uart_resources *resp;

Since you hardcode the number here now, you can actually drop this #ifdef.

Quoted 3 lines

I believe what Abhilash did is correct, because this code is not needed when there is no serial support enabled.

I only added the #ifdef here because it was broken when CONFIG_SERIAL_SAMSUNG_UARTS was undefined.

Arnd

#5 lore raw

PATCH 2/2 arch: arm: samsung: Clean-up usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol

Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · On Tuesday 30 September 2014 18:10:14 Tomasz Figa wrote:
Quoted 11 lines

arch/arm/plat-samsung/init.c void __init s3c24xx_init_uartdevs(char *name, · line 116

Quoted 9 lines
arch/arm/plat-samsung/init.c +1 -1
@@ -110,7 +110,7 @@ void __init s3c24xx_init_uartdevs(char *name,
                                  struct s3c24xx_uart_resources *res,
                                  struct s3c2410_uartcfg *cfg, int no)
 {
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
+#ifdef CONFIG_SERIAL_SAMSUNG
        struct platform_device *platdev;
        struct s3c2410_uartcfg *cfgptr = uart_cfgs;
        struct s3c24xx_uart_resources *resp;

Since you hardcode the number here now, you can actually drop this #ifdef.

Quoted 6 lines
Quoted 3 lines

I believe what Abhilash did is correct, because this code is not needed when there is no serial support enabled.

I only added the #ifdef here because it was broken when CONFIG_SERIAL_SAMSUNG_UARTS was undefined.

Fair enough. This isn't really that much code to really care and most (if not all) use cases have UART enabled anyway.

Best regards,
Tomasz

#6 lore raw

PATCH 2/2 arch: arm: samsung: Clean-up usage of CONFIG_SERIAL_SAMSUNG_UARTS symbol

In reply to Arnd Bergmann

Hi Arnd,

Quoted 16 lines · Arnd Bergmann
Quoted 15 lines · On Tuesday 30 September 2014 20:04:55 Abhilash Kesavan wrote:
arch/arm/mach-s3c64xx/irq-pm.c +3 -3
@@ -55,10 +55,10 @@ static struct irq_grp_save {
        u32     mask;
 } eint_grp_save[5];
 
-#ifndef CONFIG_SERIAL_SAMSUNG_UARTS
-#define SERIAL_SAMSUNG_UARTS 0
+#ifndef CONFIG_SERIAL_SAMSUNG
+#define SERIAL_SAMSUNG_UARTS   0
 #else
-#define        SERIAL_SAMSUNG_UARTS CONFIG_SERIAL_SAMSUNG_UARTS
+#define SERIAL_SAMSUNG_UARTS   4
 #endif
 
Quoted 4 lines

arch/arm/mach-s3c64xx/irq-pm.c static struct irq_grp_save { · line 64

Quoted 1 line
arch/arm/mach-s3c64xx/irq-pm.c +0 -0
 static u32 irq_uart_mask[SERIAL_SAMSUNG_UARTS];

I think this won't work because now you access invalid registers on machines that have only three uarts.

The 6400 and 6410 SoCs both have 4 uarts. Prior to this patch CONFIG_SERIAL_SAMSUNG_UARTS would have been 4 for 64xx.

Quoted 15 lines
Quoted 15 lines
arch/arm/plat-samsung/init.c +2 -2
index 11fbbc2..03cafe9 100644
@@ -93,8 +93,8 @@ void __init s3c24xx_init_clocks(int xtal)
 #if IS_ENABLED(CONFIG_SAMSUNG_ATAGS)
 static int nr_uarts __initdata = 0;
 
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
-static struct s3c2410_uartcfg uart_cfgs[CONFIG_SERIAL_SAMSUNG_UARTS];
+#ifdef CONFIG_SERIAL_SAMSUNG
+static struct s3c2410_uartcfg uart_cfgs[4];
 #endif
 
Quoted 12 lines

arch/arm/plat-samsung/init.c void __init s3c24xx_init_uartdevs(char *name, · line 116

Quoted 10 lines
arch/arm/plat-samsung/init.c +1 -1
 /* s3c24xx_init_uartdevs
@@ -110,7 +110,7 @@ void __init s3c24xx_init_uartdevs(char *name,
                                  struct s3c24xx_uart_resources *res,
                                  struct s3c2410_uartcfg *cfg, int no)
 {
-#ifdef CONFIG_SERIAL_SAMSUNG_UARTS
+#ifdef CONFIG_SERIAL_SAMSUNG
        struct platform_device *platdev;
        struct s3c2410_uartcfg *cfgptr = uart_cfgs;
        struct s3c24xx_uart_resources *resp;

Since you hardcode the number here now, you can actually drop this #ifdef.

Will remove it.

Regards,
Abhilash

Quoted 7 lines

Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw

PATCH 1/2 tty: serial: samsung: Clean-up selection of number of available UARTs

In reply to Abhilash Kesavan

Abhilash,

Quoted 6 lines · Abhilash Kesavan

Remove symbols SERIAL_SAMSUNG_UARTS_4 and SERIAL_SAMSUNG_UARTS which select the number of UART ports available on the SoC. Use the maximum number of UART ports possible across the serial driver in place of SERIAL_SAMSUNG_UARTS. Removal of these symbols also helps in Exynos7 serial enablement.

AFAICT this patch should be second in the series, because it removes symbols which are used by code that is yet to be updated in current patch 2.

Otherwise:

Best regards,
Tomasz