Skip to contentSkip to conversation

serial: make serial_uart_config non-global

PATCH In review Paul Gortmaker 2 participants 5 messages Aug 20, 2012 – Aug 21, 2012

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

cover serial: make serial_uart_config non-global

I happened to notice that serial_uart_config was largely a relic of the past and only used by two drivers (one of which was just a trivial use case) so it seemed to make sense to reduce its scope by removing the trivial use case and giving exclusive ownership of the struct to the one real remaining user (sparc's sunsu.c).

Build tested on sparc64 defconfig and m32r defconfig.

Paul.
---

Cc Hirokazu Takata <[email protected]>
Cc "David S. Miller" <[email protected]>

Paul Gortmaker (3):
m32r_sio: remove dependency on struct serial_uart_config
serial: sunsu.c - don't explicitly tie array size to dynamic entity
serial: diminish usage of struct serial_uart_config

 drivers/staging/speakup/serialio.h |  3 +--
 drivers/tty/serial/8250/8250.h     |  3 ---
 drivers/tty/serial/m32r_sio.c      | 36 ++----------------------------------
 drivers/tty/serial/sunsu.c         |  8 +++++++-
 include/linux/serial.h             |  6 ------
 5 files changed, 10 insertions(+), 46 deletions(-)
Signature · 1 line
1.7.11.1
#1 lore raw

PATCH 1/3 m32r_sio: remove dependency on struct serial_uart_config

The struct serial_uart_config is hardly used at all, and the use case like this one are somewhat needless. Remove the trivial usage so that we can remove serial_uart_config.

Since the type field isn't really used at all, we also delete the initialization and references of it here as well.

---
 drivers/tty/serial/m32r_sio.c | 36 ++----------------------------------
 1 file changed, 2 insertions(+), 34 deletions(-)
drivers/tty/serial/m32r_sio.c +2 -34
index a070362..b13949a 100644
@@ -44,8 +44,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#define PORT_M32R_BASE	PORT_M32R_SIO
-#define PORT_INDEX(x)	(x - PORT_M32R_BASE + 1)
 #define BAUD_RATE	115200
 
 #include <linux/serial_core.h>
@@ -132,22 +130,6 @@ struct irq_info {
 
 static struct irq_info irq_lists[NR_IRQS];
 
-/*
- * Here we define the default xmit fifo size used for each type of UART.
- */
-static const struct serial_uart_config uart_config[] = {
-	[PORT_UNKNOWN] = {
-		.name			= "unknown",
-		.dfl_xmit_fifo_size	= 1,
-		.flags			= 0,
-	},
-	[PORT_INDEX(PORT_M32R_SIO)] = {
-		.name			= "M32RSIO",
-		.dfl_xmit_fifo_size	= 1,
-		.flags			= 0,
-	},
-};
-
 #ifdef CONFIG_SERIAL_M32R_PLDSIO
 
 #define __sio_in(x) inw((unsigned long)(x))
@@ -907,8 +889,7 @@ static void m32r_sio_config_port(struct uart_port *port, int unused)
 
 	spin_lock_irqsave(&up->port.lock, flags);
 
-	up->port.type = (PORT_M32R_SIO - PORT_M32R_BASE + 1);
-	up->port.fifosize = uart_config[up->port.type].dfl_xmit_fifo_size;
+	up->port.fifosize = 1;
 
 	spin_unlock_irqrestore(&up->port.lock, flags);
 }
@@ -916,23 +897,11 @@ static void m32r_sio_config_port(struct uart_port *port, int unused)
 static int
 m32r_sio_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
-	if (ser->irq >= nr_irqs || ser->irq < 0 ||
-	    ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
-	    ser->type >= ARRAY_SIZE(uart_config))
+	if (ser->irq >= nr_irqs || ser->irq < 0 || ser->baud_base < 9600)
 		return -EINVAL;
 	return 0;
 }
 
-static const char *
-m32r_sio_type(struct uart_port *port)
-{
-	int type = port->type;
-
-	if (type >= ARRAY_SIZE(uart_config))
-		type = 0;
-	return uart_config[type].name;
-}
-
 static struct uart_ops m32r_sio_pops = {
 	.tx_empty	= m32r_sio_tx_empty,
 	.set_mctrl	= m32r_sio_set_mctrl,
@@ -946,7 +915,6 @@ static struct uart_ops m32r_sio_pops = {
 	.shutdown	= m32r_sio_shutdown,
 	.set_termios	= m32r_sio_set_termios,
 	.pm		= m32r_sio_pm,
-	.type		= m32r_sio_type,
 	.release_port	= m32r_sio_release_port,
 	.request_port	= m32r_sio_request_port,
 	.config_port	= m32r_sio_config_port,
Signature · 1 line
1.7.11.1
#2 lore raw

PATCH 2/3 serial: sunsu.c - don't explicitly tie array size to dynamic entity

In reply to Paul Gortmaker

The addition of 8250-like entities continues to grow, while this driver has a snapshot of a select few common 8250 UARTs. So it has no need to grow with the new additions, since it calls out its own (largely historic) static list which does not grow.

Cc "David S. Miller" <[email protected]>
---
 drivers/tty/serial/sunsu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sunsu.c +1 -1
index 675303b..d919095 100644
@@ -61,7 +61,7 @@ static char *su_typev[] = { "su(???)", "su(mouse)", "su(kbd)", "su(serial)" };
 /*
  * Here we define the default xmit fifo size used for each type of UART.
  */
-static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = {
+static const struct serial_uart_config uart_config[] = {
 	{ "unknown",	1,	0 },
 	{ "8250",	1,	0 },
 	{ "16450",	1,	0 },
Signature · 1 line
1.7.11.1
#3 lore raw

PATCH 3/3 serial: diminish usage of struct serial_uart_config

In reply to Paul Gortmaker

This structure might have made sense many years ago, but at this point it is only used in one specific driver, and referenced in stale comments elsewhere. Rather than change the sunsu.c driver, simply move the struct to be within the exclusive domain of that driver, so it won't get inadvertently picked up and used by other serial drivers going forward. The comments referencing the now driver specific struct are updated accordingly.

Note that 8250.c has a struct that is similar in usage, with the name serial8250_config; but is 100% independent and untouched here.

Cc "David S. Miller" <[email protected]>
---
 drivers/staging/speakup/serialio.h | 3 +--
 drivers/tty/serial/8250/8250.h     | 3 ---
 drivers/tty/serial/sunsu.c         | 6 ++++++
 include/linux/serial.h             | 6 ------
 4 files changed, 7 insertions(+), 11 deletions(-)
drivers/staging/speakup/serialio.h +1 -2
index 614271f..55d68b5 100644
@@ -1,8 +1,7 @@
 #ifndef _SPEAKUP_SERIAL_H
 #define _SPEAKUP_SERIAL_H
 
-#include <linux/serial.h>	/* for rs_table, serial constants &
-				   serial_uart_config */
+#include <linux/serial.h>	/* for rs_table, serial constants */
 #include <linux/serial_reg.h>	/* for more serial constants */
 #ifndef __sparc__
 #include <asm/serial.h>
drivers/tty/serial/8250/8250.h +0 -3
index 972b521..0c5e908 100644
@@ -26,9 +26,6 @@ struct old_serial_port {
 	unsigned long irqflags;
 };
 
-/*
- * This replaces serial_uart_config in include/linux/serial.h
- */
 struct serial8250_config {
 	const char	*name;
 	unsigned short	fifo_size;
drivers/tty/serial/sunsu.c +6 -0
index d919095..b97913d 100644
@@ -58,6 +58,12 @@
 enum su_type { SU_PORT_NONE, SU_PORT_MS, SU_PORT_KBD, SU_PORT_PORT };
 static char *su_typev[] = { "su(???)", "su(mouse)", "su(kbd)", "su(serial)" };
 
+struct serial_uart_config {
+	char	*name;
+	int	dfl_xmit_fifo_size;
+	int	flags;
+};
+
 /*
  * Here we define the default xmit fifo size used for each type of UART.
  */
include/linux/serial.h +0 -6
index 90e9f98..11f365c 100644
@@ -83,12 +83,6 @@ struct serial_struct {
 #define SERIAL_IO_HUB6	1
 #define SERIAL_IO_MEM	2
 
-struct serial_uart_config {
-	char	*name;
-	int	dfl_xmit_fifo_size;
-	int	flags;
-};
-
 #define UART_CLEAR_FIFO		0x01
 #define UART_USE_FIFO		0x02
 #define UART_STARTECH		0x04
Signature · 1 line
1.7.11.1
#4 lore raw
In reply to Paul Gortmaker
Quoted 7 lines · On Mon, 20 Aug 2012 19:56:25 -0400 Paul Gortmaker…

I happened to notice that serial_uart_config was largely a relic of the past and only used by two drivers (one of which was just a trivial use case) so it seemed to make sense to reduce its scope by removing the trivial use case and giving exclusive ownership of the struct to the one real remaining user (sparc's sunsu.c).

Build tested on sparc64 defconfig and m32r defconfig.

Looks good to me from the tty side.