Skip to contentSkip to conversation

drivers/serial/serial.c: code maintainability improvments.

PATCH New Michael Zaidman 3 participants 6 messages Apr 2, 2010 – Jun 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/3 drivers/serial/serial.c: code maintainability improvments.

---
 drivers/serial/serial.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
drivers/serial/serial.c +17 -10
index dd5f332..ba88cb0 100644
@@ -45,24 +45,27 @@ DECLARE_GLOBAL_DATA_PTR;
 #else
 #error	"No console index specified."
 #endif /* CONFIG_SERIAL_MULTI */
-#elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 4)
+#elif CONFIG_CONS_INDEX < 1
 #error	"Invalid console index value."
 #endif
 
-#if CONFIG_CONS_INDEX == 1 && !defined(CONFIG_SYS_NS16550_COM1)
-#error	"Console port 1 defined but not configured."
-#elif CONFIG_CONS_INDEX == 2 && !defined(CONFIG_SYS_NS16550_COM2)
-#error	"Console port 2 defined but not configured."
-#elif CONFIG_CONS_INDEX == 3 && !defined(CONFIG_SYS_NS16550_COM3)
-#error	"Console port 3 defined but not configured."
-#elif CONFIG_CONS_INDEX == 4 && !defined(CONFIG_SYS_NS16550_COM4)
-#error	"Console port 4 defined but not configured."
+#define CONSOLE_PORT_SANITY_CHECK(port) \
+	CONFIG_CONS_INDEX == port && !defined(CONFIG_SYS_NS16550_COM##port)
+
+#if	CONSOLE_PORT_SANITY_CHECK(1)
+#error	Console port 1 defined but not configured.
+#elif	CONSOLE_PORT_SANITY_CHECK(2)
+#error	Console port 2 defined but not configured.
+#elif	CONSOLE_PORT_SANITY_CHECK(3)
+#error	Console port 3 defined but not configured.
+#elif	CONSOLE_PORT_SANITY_CHECK(4)
+#error	Console port 4 defined but not configured.
 #endif
 
 /* Note: The port number specified in the functions is 1 based.
  *	 the array is 0 based.
  */
-static NS16550_t serial_ports[4] = {
+static NS16550_t serial_ports[] = {
 #ifdef CONFIG_SYS_NS16550_COM1
 	(NS16550_t)CONFIG_SYS_NS16550_COM1,
 #else
@@ -85,6 +88,8 @@ static NS16550_t serial_ports[4] = {
 #endif
 };
 
+#define MAX_SER_PORTS (sizeof(serial_ports) / sizeof(NS16550_t))
+
 #define PORT	serial_ports[port-1]
 #if defined(CONFIG_CONS_INDEX)
 #define CONSOLE	(serial_ports[CONFIG_CONS_INDEX-1])
@@ -160,6 +165,8 @@ int serial_init (void)
 {
 	int clock_divisor;
 
+	BUILD_BUG_ON(CONFIG_CONS_INDEX > MAX_SER_PORTS);
+
 #ifdef CONFIG_NS87308
 	initialise_ns87308();
 #endif
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v2 2/3 drivers/serial/serial.c: code maintainability improvments.

In reply to Michael Zaidman

Dear Michael Zaidman,

Quoted 4 lines · In message <[email protected]> you…
---
 drivers/serial/serial.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You know that feeling when you're leaning back  on  a  stool  and  it
starts to tip over? Well, that's how I feel all the time.
- Steven Wright
#3 lore raw

PATCH v2 2/3 drivers/serial/serial.c: code maintainability improvments.

Dear Michael Zaidman,

Quoted 8 lines · In message <[email protected]> I wrote:
Quoted 4 lines · In message <[email protected]> you…
---
 drivers/serial/serial.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

Applied, thanks.

Forget it, undone.

This patch cannot be applied alone (it's causing lots of "undefined reference to `BUILD_BUG_ON'" errors), and the preceding patch was still under discussion / waiting for a repost.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A girl with a future avoids the man with a past.
                                   -- Evan Esar, "The Humor of Humor"
#4 lore raw

PATCH v2 2/3 drivers/serial/serial.c: code maintainability improvments.

Hi Wolfgang,

Quoted 5 lines

This patch cannot be applied alone (it's causing lots of "undefined reference to `BUILD_BUG_ON'" errors), and the preceding patch was still under discussion / waiting for a repost.

Since no feedback was received for the
http://lists.denx.de/pipermail/u-boot/2010-May/071443.html proposal it looks like no one is willing to discuss this subject anymore.

Are there still any known obstructions do not accept the
http://lists.denx.de/pipermail/u-boot/2010-April/069391.html as is? This will solve all undefined references to `BUILD_BUG_ON' problem.

Thanks,
Michael

#5 lore raw

PATCH v2 2/3 drivers/serial/serial.c: code maintainability improvments.

Dear Michael Zaidman,

Quoted 4 lines · In message <[email protected]> you…

Since no feedback was received for the
http://lists.denx.de/pipermail/u-boot/2010-May/071443.html proposal it looks like no one is willing to discuss this subject anymore.

Probably not in this verbal form. You will often notice that verbal descriptions of what could be done receive little or no echo, while a patch will.

Quoted 3 lines

Are there still any known obstructions do not accept the
http://lists.denx.de/pipermail/u-boot/2010-April/069391.html as is? This will solve all undefined references to `BUILD_BUG_ON' problem.

I suggest you roll your proposal into code and submit patches - then we have a much better base to discuss.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Earth -- mother of the most beautiful women in the universe.
	-- Apollo, "Who Mourns for Adonais?" stardate 3468.1