[U-Boot] [PATCH 2/3 v2] drivers/serial/serial.c: code maintainability improvments.

Signed-off-by: Michael Zaidman michael.zaidman@gmail.com --- drivers/serial/serial.c | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index dd5f332..ba88cb0 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -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

On Fri, 2 Apr 2010 12:10:42 +0300 Michael Zaidman michael.zaidman@gmail.com wrote:
Signed-off-by: Michael Zaidman michael.zaidman@gmail.com
Acked-by: Kim Phillips kim.phillips@freescale.com
Kim

Dear Michael Zaidman,
In message 1270199442-5980-1-git-send-email-michael.zaidman@gmail.com you wrote:
Signed-off-by: Michael Zaidman michael.zaidman@gmail.com
drivers/serial/serial.c | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Michael Zaidman,
In message 20100409220843.551E819F36@gemini.denx.de I wrote:
In message 1270199442-5980-1-git-send-email-michael.zaidman@gmail.com you wrote:
Signed-off-by: Michael Zaidman michael.zaidman@gmail.com
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

Hi Wolfgang,
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

Dear Michael Zaidman,
In message AANLkTikG9PZl9Zw0A542OAmFrSlZLRIMNe68jpo-aLGc@mail.gmail.com you wrote:
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.
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
participants (3)
-
Kim Phillips
-
Michael Zaidman
-
Wolfgang Denk