Subject: Re: [patch] Incorrect mapping of serial ports to lines

From: "Maciej W. Rozycki" <[email-masked]>
Date: Fri, 2 Jul 2004 17:09:28 +0200 (CEST)

On Tue, 29 Jun 2004, Ralf Baechle wrote:

> How about you leave CONFIG_HAVE_STD_PC_SERIAL_PORT disabled for Malta then
> and supply your own MALTA_SERIAL_PORT_DEFNS instead then?  That would
> require some small changes to no longer nest the CONFIG_SERIAL_MANY_PORTS
> ifdef inside CONFIG_HAVE_STD_PC_SERIAL_PORT - about as below.

 I couldn't care less about CONFIG_SERIAL_MANY_PORTS for Malta -- the
ports it adds are AFAIK all ISA boards.  While in theory one can have a
PCI-ISA bridge and a bus extender on an option card (such devices exist,
I'm told), I don't think it's possible to use one with Malta as it already
includes a PCI-ISA bridge onboard.  If there's a need for such stuff in
the future, it can be added then.  After a brief look at the sources I
think the option itself might actually depend on CONFIG_ISA.

 So I propose the following simpler patch instead.  I'd like to have the
comment included so that no one tries to "fix" the order in the future
without a careful consideration.  It works for me.

 OK to apply?

  Maciej

patch-mips-2.4.26-20040531-mips-serial-2
diff -up --recursive --new-file linux-mips-2.4.26-20040531.macro/include/asm-mips/serial.h linux-mips-2.4.26-20040531/include/asm-mips/serial.h
--- linux-mips-2.4.26-20040531.macro/include/asm-mips/serial.h	2004-06-13 23:16:56.000000000 +0000
+++ linux-mips-2.4.26-20040531/include/asm-mips/serial.h	2004-07-02 00:40:52.000000000 +0000
@@ -410,14 +410,23 @@
 #define DDB5477_SERIAL_PORT_DEFNS
 #endif
 
+/*
+ * The order matters here and should be as follows:
+ *
+ * 1. board-specific ports (please keep sorted)
+ * 2. STD_SERIAL_PORT_DEFNS
+ * 3. EXTRA_SERIAL_PORT_DEFNS
+ * 4. HUB6_SERIAL_PORT_DFNS
+ *
+ * otherwise serial line numbers may change across
+ * kernel builds if configuration changes. --macro
+ */
 #define SERIAL_PORT_DFNS			\
 	ATLAS_SERIAL_PORT_DEFNS			\
 	AU1000_SERIAL_PORT_DEFNS		\
 	COBALT_SERIAL_PORT_DEFNS		\
 	DDB5477_SERIAL_PORT_DEFNS		\
 	EV96100_SERIAL_PORT_DEFNS		\
-	EXTRA_SERIAL_PORT_DEFNS			\
-	HUB6_SERIAL_PORT_DFNS			\
 	ITE_SERIAL_PORT_DEFNS           	\
 	IVR_SERIAL_PORT_DEFNS           	\
 	JAZZ_SERIAL_PORT_DEFNS			\
@@ -426,8 +435,11 @@
 	MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS	\
 	MOMENCO_JAGUAR_ATX_SERIAL_PORT_DEFNS	\
 	SEAD_SERIAL_PORT_DEFNS			\
-	STD_SERIAL_PORT_DEFNS			\
 	TITAN_SERIAL_PORT_DEFNS			\
-	TXX927_SERIAL_PORT_DEFNS
+	TXX927_SERIAL_PORT_DEFNS		\
+						\
+	STD_SERIAL_PORT_DEFNS			\
+	EXTRA_SERIAL_PORT_DEFNS			\
+	HUB6_SERIAL_PORT_DFNS
 
 #endif /* _ASM_SERIAL_H */
diff -up --recursive --new-file linux-mips-2.4.26-20040531.macro/include/asm-mips64/serial.h linux-mips-2.4.26-20040531/include/asm-mips64/serial.h
--- linux-mips-2.4.26-20040531.macro/include/asm-mips64/serial.h	2003-12-18 03:57:25.000000000 +0000
+++ linux-mips-2.4.26-20040531/include/asm-mips64/serial.h	2004-07-02 00:41:05.000000000 +0000
@@ -146,13 +146,23 @@
 #define IP27_SERIAL_PORT_DEFNS
 #endif /* CONFIG_SGI_IP27 */
 
+/*
+ * The order matters here and should be as follows:
+ *
+ * 1. board-specific ports (please keep sorted)
+ * 2. STD_SERIAL_PORT_DEFNS
+ *
+ * otherwise serial line numbers may change across
+ * kernel builds if configuration changes. --macro
+ */
 #define SERIAL_PORT_DFNS				\
 	IP27_SERIAL_PORT_DEFNS				\
 	MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS		\
 	MOMENCO_JAGUAR_ATX_SERIAL_PORT_DEFNS		\
 	SEAD_SERIAL_PORT_DEFNS				\
-	STD_SERIAL_PORT_DEFNS				\
-	TITAN_SERIAL_PORT_DEFNS
+	TITAN_SERIAL_PORT_DEFNS				\
+							\
+	STD_SERIAL_PORT_DEFNS
 
 #define RS_TABLE_SIZE	64