All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] make hang() a weak function
@ 2013-04-16 10:14 Andreas Bießmann
  2013-04-16 10:29 ` Stefan Roese
                   ` (3 more replies)
  0 siblings, 4 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 10:14 UTC (permalink / raw)
  To: u-boot

This patch also does some minor coding style cleanups.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

---
 arch/arm/lib/board.c            |    3 ++-
 arch/avr32/lib/board.c          |    3 ++-
 arch/blackfin/lib/board.c       |    3 ++-
 arch/m68k/lib/board.c           |    3 ++-
 arch/microblaze/lib/board.c     |    5 +++--
 arch/mips/lib/board.c           |    3 ++-
 arch/nds32/lib/board.c          |    3 ++-
 arch/nios2/lib/board.c          |    5 +++--
 arch/openrisc/lib/board.c       |    3 ++-
 arch/powerpc/lib/board.c        |    4 ++--
 arch/sandbox/lib/board.c        |    3 ++-
 arch/sh/lib/board.c             |    3 ++-
 arch/sparc/lib/board.c          |    3 ++-
 arch/x86/lib/board.c            |    3 ++-
 common/board_f.c                |    3 ++-
 common/spl/spl.c                |    3 ++-
 drivers/mtd/nand/mxc_nand_spl.c |    3 ++-
 17 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 0521178..4a00e16 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -707,8 +707,9 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;);
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index 57e07df..7e3380a 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -120,10 +120,11 @@ static int display_banner (void)
 	return 0;
 }
 
-void hang(void)
+void __hang(void)
 {
 	for (;;) ;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
 
 static int display_dram_config (void)
 {
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index 75b6c46..7769962 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -433,7 +433,7 @@ void board_init_r(gd_t * id, ulong dest_addr)
 		main_loop();
 }
 
-void hang(void)
+void __hang(void)
 {
 #ifdef CONFIG_STATUS_LED
 	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
@@ -446,3 +446,4 @@ void hang(void)
 		 */
 		asm("emuexcpt;");
 }
+void hang(void) __attribute__((weak, alias("__hang"));
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index adaccfe..93aeafb 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -665,8 +665,9 @@ void board_init_r (gd_t *id, ulong dest_addr)
 }
 
 
-void hang(void)
+void __hang(void)
 {
 	puts ("### ERROR ### Please RESET the board ###\n");
 	for (;;);
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index a7c2f76..e661704 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -195,8 +195,9 @@ void board_init_f(ulong not_used)
 	}
 }
 
-void hang (void)
+void __hang(void)
 {
-	puts ("### ERROR ### Please RESET the board ###\n");
+	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;) ;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index f19f198..ad18440 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -345,9 +345,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index a7d27fc..2433d8a 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -405,9 +405,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 1e495d4..517a3a1 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -168,9 +168,10 @@ void board_init (void)
 
 /***********************************************************************/
 
-void hang (void)
+void __hang(void)
 {
-	disable_interrupts ();
+	disable_interrupts();
 	puts("### ERROR ### Please reset board ###\n");
 	for (;;);
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
index 85aa189..c5437db 100644
--- a/arch/openrisc/lib/board.c
+++ b/arch/openrisc/lib/board.c
@@ -158,7 +158,7 @@ void board_init(void)
 
 /***********************************************************************/
 
-void hang(void)
+void __hang(void)
 {
 	disable_interrupts();
 	puts("### ERROR ### Please reset board ###\n");
@@ -166,3 +166,4 @@ void hang(void)
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 422b4a3..24bb948 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -1050,14 +1050,14 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
 	for (;;)
 		;
 }
-
+void hang(void) __attribute__((weak, alias("__hang")));
 
 #if 0	/* We could use plain global data, but the resulting code is bigger */
 /*
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index 3752fab..fe10e6c 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -277,9 +277,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index 6e43acf..60be847 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -203,9 +203,10 @@ void sh_generic_init(void)
 
 /***********************************************************************/
 
-void hang(void)
+void __hang(void)
 {
 	puts("Board ERROR\n");
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index 79fb4c8..ddd735c 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -411,7 +411,7 @@ void board_init_f(ulong bootflag)
 
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 #ifdef CONFIG_SHOW_BOOT_PROGRESS
@@ -419,5 +419,6 @@ void hang(void)
 #endif
 	for (;;) ;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
 
 /************************************************************************/
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index f372898..960f323 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -265,9 +265,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/common/board_f.c b/common/board_f.c
index 7698891..d811067 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -1005,8 +1005,9 @@ void board_init_f_r(void)
 }
 #endif /* CONFIG_X86 */
 
-void hang(void)
+void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;);
 }
+void hang(void) __attribute__((weak, alias("__hang")));
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 6715e0d..322b7b8 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -48,12 +48,13 @@ struct spl_image_info spl_image;
 /* Define board data structure */
 static bd_t bdata __attribute__ ((section(".data")));
 
-inline void hang(void)
+inline void __hang(void)
 {
 	puts("### ERROR ### Please RESET the board ###\n");
 	for (;;)
 		;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
 
 /*
  * Default function to determine if u-boot or the OS should
diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c
index 09f23c3..9738045 100644
--- a/drivers/mtd/nand/mxc_nand_spl.c
+++ b/drivers/mtd/nand/mxc_nand_spl.c
@@ -359,8 +359,9 @@ void nand_boot(void)
 /*
  * Called in case of an exception.
  */
-void hang(void)
+void __hang(void)
 {
 	/* Loop forever */
 	while (1) ;
 }
+void hang(void) __attribute__((weak, alias("__hang")));
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 10:14 [U-Boot] [PATCH] make hang() a weak function Andreas Bießmann
@ 2013-04-16 10:29 ` Stefan Roese
  2013-04-16 11:10 ` Graeme Russ
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 42+ messages in thread
From: Stefan Roese @ 2013-04-16 10:29 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On 16.04.2013 12:14, Andreas Bie?mann wrote:
> This patch also does some minor coding style cleanups.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> ---
>  arch/arm/lib/board.c            |    3 ++-
>  arch/avr32/lib/board.c          |    3 ++-
>  arch/blackfin/lib/board.c       |    3 ++-
>  arch/m68k/lib/board.c           |    3 ++-
>  arch/microblaze/lib/board.c     |    5 +++--
>  arch/mips/lib/board.c           |    3 ++-
>  arch/nds32/lib/board.c          |    3 ++-
>  arch/nios2/lib/board.c          |    5 +++--
>  arch/openrisc/lib/board.c       |    3 ++-
>  arch/powerpc/lib/board.c        |    4 ++--
>  arch/sandbox/lib/board.c        |    3 ++-
>  arch/sh/lib/board.c             |    3 ++-
>  arch/sparc/lib/board.c          |    3 ++-
>  arch/x86/lib/board.c            |    3 ++-
>  common/board_f.c                |    3 ++-
>  common/spl/spl.c                |    3 ++-
>  drivers/mtd/nand/mxc_nand_spl.c |    3 ++-
>  17 files changed, 36 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 0521178..4a00e16 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -707,8 +707,9 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;);
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));

Please include "linux/compiler.h" and use:

void __weak hang(void)
{
	puts("### ERROR ### Please RESET the board ###\n");
	for (;;);
}

instead. No __attribute__ needed and easier to read.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 10:14 [U-Boot] [PATCH] make hang() a weak function Andreas Bießmann
  2013-04-16 10:29 ` Stefan Roese
@ 2013-04-16 11:10 ` Graeme Russ
  2013-04-16 11:36 ` Albert ARIBAUD
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
  3 siblings, 0 replies; 42+ messages in thread
From: Graeme Russ @ 2013-04-16 11:10 UTC (permalink / raw)
  To: u-boot

Hi Andreas,


On Tue, Apr 16, 2013 at 8:14 PM, Andreas Bie?mann <
andreas.devel@googlemail.com> wrote:

> This patch also does some minor coding style cleanups.
>
>
Coding style cleanups belong in a separate patch - Rules are rules ;)

Regards,

Graeme

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 10:14 [U-Boot] [PATCH] make hang() a weak function Andreas Bießmann
  2013-04-16 10:29 ` Stefan Roese
  2013-04-16 11:10 ` Graeme Russ
@ 2013-04-16 11:36 ` Albert ARIBAUD
  2013-04-16 11:45   ` Andreas Bießmann
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
  3 siblings, 1 reply; 42+ messages in thread
From: Albert ARIBAUD @ 2013-04-16 11:36 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On Tue, 16 Apr 2013 12:14:09 +0200, Andreas Bie?mann
<andreas.devel@googlemail.com> wrote:

> This patch also does some minor coding style cleanups.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> ---
>  arch/arm/lib/board.c            |    3 ++-
>  arch/avr32/lib/board.c          |    3 ++-
>  arch/blackfin/lib/board.c       |    3 ++-
>  arch/m68k/lib/board.c           |    3 ++-
>  arch/microblaze/lib/board.c     |    5 +++--
>  arch/mips/lib/board.c           |    3 ++-
>  arch/nds32/lib/board.c          |    3 ++-
>  arch/nios2/lib/board.c          |    5 +++--
>  arch/openrisc/lib/board.c       |    3 ++-
>  arch/powerpc/lib/board.c        |    4 ++--
>  arch/sandbox/lib/board.c        |    3 ++-
>  arch/sh/lib/board.c             |    3 ++-
>  arch/sparc/lib/board.c          |    3 ++-
>  arch/x86/lib/board.c            |    3 ++-
>  common/board_f.c                |    3 ++-
>  common/spl/spl.c                |    3 ++-
>  drivers/mtd/nand/mxc_nand_spl.c |    3 ++-
>  17 files changed, 36 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 0521178..4a00e16 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -707,8 +707,9 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;);
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
> index 57e07df..7e3380a 100644
> --- a/arch/avr32/lib/board.c
> +++ b/arch/avr32/lib/board.c
> @@ -120,10 +120,11 @@ static int display_banner (void)
>  	return 0;
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	for (;;) ;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
>  
>  static int display_dram_config (void)
>  {
> diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
> index 75b6c46..7769962 100644
> --- a/arch/blackfin/lib/board.c
> +++ b/arch/blackfin/lib/board.c
> @@ -433,7 +433,7 @@ void board_init_r(gd_t * id, ulong dest_addr)
>  		main_loop();
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  #ifdef CONFIG_STATUS_LED
>  	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
> @@ -446,3 +446,4 @@ void hang(void)
>  		 */
>  		asm("emuexcpt;");
>  }
> +void hang(void) __attribute__((weak, alias("__hang"));
> diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
> index adaccfe..93aeafb 100644
> --- a/arch/m68k/lib/board.c
> +++ b/arch/m68k/lib/board.c
> @@ -665,8 +665,9 @@ void board_init_r (gd_t *id, ulong dest_addr)
>  }
>  
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts ("### ERROR ### Please RESET the board ###\n");
>  	for (;;);
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
> index a7c2f76..e661704 100644
> --- a/arch/microblaze/lib/board.c
> +++ b/arch/microblaze/lib/board.c
> @@ -195,8 +195,9 @@ void board_init_f(ulong not_used)
>  	}
>  }
>  
> -void hang (void)
> +void __hang(void)
>  {
> -	puts ("### ERROR ### Please RESET the board ###\n");
> +	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;) ;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
> index f19f198..ad18440 100644
> --- a/arch/mips/lib/board.c
> +++ b/arch/mips/lib/board.c
> @@ -345,9 +345,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
> index a7d27fc..2433d8a 100644
> --- a/arch/nds32/lib/board.c
> +++ b/arch/nds32/lib/board.c
> @@ -405,9 +405,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
> index 1e495d4..517a3a1 100644
> --- a/arch/nios2/lib/board.c
> +++ b/arch/nios2/lib/board.c
> @@ -168,9 +168,10 @@ void board_init (void)
>  
>  /***********************************************************************/
>  
> -void hang (void)
> +void __hang(void)
>  {
> -	disable_interrupts ();
> +	disable_interrupts();
>  	puts("### ERROR ### Please reset board ###\n");
>  	for (;;);
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
> index 85aa189..c5437db 100644
> --- a/arch/openrisc/lib/board.c
> +++ b/arch/openrisc/lib/board.c
> @@ -158,7 +158,7 @@ void board_init(void)
>  
>  /***********************************************************************/
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	disable_interrupts();
>  	puts("### ERROR ### Please reset board ###\n");
> @@ -166,3 +166,4 @@ void hang(void)
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
> index 422b4a3..24bb948 100644
> --- a/arch/powerpc/lib/board.c
> +++ b/arch/powerpc/lib/board.c
> @@ -1050,14 +1050,14 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
>  	for (;;)
>  		;
>  }
> -
> +void hang(void) __attribute__((weak, alias("__hang")));
>  
>  #if 0	/* We could use plain global data, but the resulting code is bigger */
>  /*
> diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
> index 3752fab..fe10e6c 100644
> --- a/arch/sandbox/lib/board.c
> +++ b/arch/sandbox/lib/board.c
> @@ -277,9 +277,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
> index 6e43acf..60be847 100644
> --- a/arch/sh/lib/board.c
> +++ b/arch/sh/lib/board.c
> @@ -203,9 +203,10 @@ void sh_generic_init(void)
>  
>  /***********************************************************************/
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("Board ERROR\n");
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
> index 79fb4c8..ddd735c 100644
> --- a/arch/sparc/lib/board.c
> +++ b/arch/sparc/lib/board.c
> @@ -411,7 +411,7 @@ void board_init_f(ulong bootflag)
>  
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  #ifdef CONFIG_SHOW_BOOT_PROGRESS
> @@ -419,5 +419,6 @@ void hang(void)
>  #endif
>  	for (;;) ;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
>  
>  /************************************************************************/
> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
> index f372898..960f323 100644
> --- a/arch/x86/lib/board.c
> +++ b/arch/x86/lib/board.c
> @@ -265,9 +265,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/common/board_f.c b/common/board_f.c
> index 7698891..d811067 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -1005,8 +1005,9 @@ void board_init_f_r(void)
>  }
>  #endif /* CONFIG_X86 */
>  
> -void hang(void)
> +void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;);
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 6715e0d..322b7b8 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -48,12 +48,13 @@ struct spl_image_info spl_image;
>  /* Define board data structure */
>  static bd_t bdata __attribute__ ((section(".data")));
>  
> -inline void hang(void)
> +inline void __hang(void)
>  {
>  	puts("### ERROR ### Please RESET the board ###\n");
>  	for (;;)
>  		;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));
>  
>  /*
>   * Default function to determine if u-boot or the OS should
> diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c
> index 09f23c3..9738045 100644
> --- a/drivers/mtd/nand/mxc_nand_spl.c
> +++ b/drivers/mtd/nand/mxc_nand_spl.c
> @@ -359,8 +359,9 @@ void nand_boot(void)
>  /*
>   * Called in case of an exception.
>   */
> -void hang(void)
> +void __hang(void)
>  {
>  	/* Loop forever */
>  	while (1) ;
>  }
> +void hang(void) __attribute__((weak, alias("__hang")));

Apart from Stefan's comments: considered standalone, doesn't this patch
have zero effect? I suspect you intend to use this in a later patch,
and if so, I would suggest grouping these in a series so that the
subsequent patch(es) explain this one.

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 11:36 ` Albert ARIBAUD
@ 2013-04-16 11:45   ` Andreas Bießmann
  2013-04-16 12:22     ` Wolfgang Denk
  0 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 11:45 UTC (permalink / raw)
  To: u-boot

Hi Albert,

On 04/16/2013 01:36 PM, Albert ARIBAUD wrote:
> Hi Andreas,
> 
> On Tue, 16 Apr 2013 12:14:09 +0200, Andreas Bie?mann
> <andreas.devel@googlemail.com> wrote:
> 
>> This patch also does some minor coding style cleanups.
>>
>> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>>
>> ---
>>  arch/arm/lib/board.c            |    3 ++-
>>  arch/avr32/lib/board.c          |    3 ++-
>>  arch/blackfin/lib/board.c       |    3 ++-
>>  arch/m68k/lib/board.c           |    3 ++-
>>  arch/microblaze/lib/board.c     |    5 +++--
>>  arch/mips/lib/board.c           |    3 ++-
>>  arch/nds32/lib/board.c          |    3 ++-
>>  arch/nios2/lib/board.c          |    5 +++--
>>  arch/openrisc/lib/board.c       |    3 ++-
>>  arch/powerpc/lib/board.c        |    4 ++--
>>  arch/sandbox/lib/board.c        |    3 ++-
>>  arch/sh/lib/board.c             |    3 ++-
>>  arch/sparc/lib/board.c          |    3 ++-
>>  arch/x86/lib/board.c            |    3 ++-
>>  common/board_f.c                |    3 ++-
>>  common/spl/spl.c                |    3 ++-
>>  drivers/mtd/nand/mxc_nand_spl.c |    3 ++-
>>  17 files changed, 36 insertions(+), 20 deletions(-)

<snip>

> 
> Apart from Stefan's comments: considered standalone, doesn't this patch
> have zero effect? I suspect you intend to use this in a later patch,
> and if so, I would suggest grouping these in a series so that the
> subsequent patch(es) explain this one.

I would like to use a specialized hang() for a not mainlined board, thus
there will no more patches using this currently.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 11:45   ` Andreas Bießmann
@ 2013-04-16 12:22     ` Wolfgang Denk
  2013-04-16 12:58       ` Andreas Bießmann
  0 siblings, 1 reply; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-16 12:22 UTC (permalink / raw)
  To: u-boot

Dear "Andreas Bie?mann",

In message <516D39CF.9020907@gmail.com> you wrote:
> 
> > Apart from Stefan's comments: considered standalone, doesn't this patch
> > have zero effect? I suspect you intend to use this in a later patch,
> > and if so, I would suggest grouping these in a series so that the
> > subsequent patch(es) explain this one.
> 
> I would like to use a specialized hang() for a not mainlined board, thus
> there will no more patches using this currently.

So it is dead code in mainline, and we will not add it.


Best regards,

Wolfgang Denk

-- 
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
Keep your eyes wide open before marriage, half shut afterwards.
                                                 -- Benjamin Franklin

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 12:22     ` Wolfgang Denk
@ 2013-04-16 12:58       ` Andreas Bießmann
  2013-04-16 13:05         ` Wolfgang Denk
  0 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 12:58 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

On 04/16/2013 02:22 PM, Wolfgang Denk wrote:
> Dear "Andreas Bie?mann",
> 
> In message <516D39CF.9020907@gmail.com> you wrote:
>>
>>> Apart from Stefan's comments: considered standalone, doesn't this patch
>>> have zero effect? I suspect you intend to use this in a later patch,
>>> and if so, I would suggest grouping these in a series so that the
>>> subsequent patch(es) explain this one.
>>
>> I would like to use a specialized hang() for a not mainlined board, thus
>> there will no more patches using this currently.
> 
> So it is dead code in mainline, and we will not add it.

Well, I don't think it is dead code cause the hang() is called in some ways.
This patch opens just the possibility to specialize the hang() by for
example a specific board. Maybe this could also be used for specific
hang() for different arches when we get closer to the common board files.
It is correct that we do not need this patch now and I can handle it
here in my own tree.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 12:58       ` Andreas Bießmann
@ 2013-04-16 13:05         ` Wolfgang Denk
  2013-04-16 13:32           ` Andreas Bießmann
  0 siblings, 1 reply; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-16 13:05 UTC (permalink / raw)
  To: u-boot

Dear Andreas,

In message <516D4B00.9030102@gmail.com> you wrote:
>
> > So it is dead code in mainline, and we will not add it.
> 
> Well, I don't think it is dead code cause the hang() is called in some ways.
> This patch opens just the possibility to specialize the hang() by for
> example a specific board. Maybe this could also be used for specific
> hang() for different arches when we get closer to the common board files.

I think it is dead code, and not needed nor useful in mainline.  I
cannot even see how it would be useful for you.  hang() is defined to
"hang" the CPU, i. e. to make sure the system will remain in the
current state.  To me this naturally translates into an infinite loop,
the implementation of which is completely hardware and architecture
independent.

Note that hang() is not supposed to do anything else, it just hangs
the system.  If you have a debugger attached, you will be able to do a
simple stack backtrace and see exactly where you are hanging, and why.

If you think you need to have specialized code, you are doing
something wrong.

> It is correct that we do not need this patch now and I can handle it
> here in my own tree.

Good.

Best regards,

Wolfgang Denk

-- 
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
God made machine language; all the rest is the work of man.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 13:05         ` Wolfgang Denk
@ 2013-04-16 13:32           ` Andreas Bießmann
  2013-04-16 13:35             ` Graeme Russ
  2013-04-16 14:17             ` Wolfgang Denk
  0 siblings, 2 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 13:32 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On 04/16/2013 03:05 PM, Wolfgang Denk wrote:
> Dear Andreas,
> 
> In message <516D4B00.9030102@gmail.com> you wrote:
>>
>>> So it is dead code in mainline, and we will not add it.
>>
>> Well, I don't think it is dead code cause the hang() is called in some ways.
>> This patch opens just the possibility to specialize the hang() by for
>> example a specific board. Maybe this could also be used for specific
>> hang() for different arches when we get closer to the common board files.
> 
> I think it is dead code, and not needed nor useful in mainline.  I
> cannot even see how it would be useful for you.  hang() is defined to
> "hang" the CPU, i. e. to make sure the system will remain in the
> current state.  To me this naturally translates into an infinite loop,
> the implementation of which is completely hardware and architecture
> independent.

Yes it is independent (or should at least). But there are still slightly
different versions:

---8<---
arch/blackfin/lib/board.c:void hang(void)
arch/blackfin/lib/board.c-{
arch/blackfin/lib/board.c-#ifdef CONFIG_STATUS_LED
arch/blackfin/lib/board.c-      status_led_set(STATUS_LED_BOOT,
STATUS_LED_OFF);
arch/blackfin/lib/board.c-      status_led_set(STATUS_LED_CRASH,
STATUS_LED_BLINKING);
--->8---

---8<---
arch/arm/lib/board.c:void __hang(void)
arch/arm/lib/board.c-{
arch/arm/lib/board.c-   puts("### ERROR ### Please RESET the board ###\n");
arch/arm/lib/board.c-   for (;;);
arch/arm/lib/board.c-}
--->8---

---8<---
arch/powerpc/lib/board.c:void __hang(void)
arch/powerpc/lib/board.c-{
arch/powerpc/lib/board.c-       puts("### ERROR ### Please RESET the
board ###\n");
arch/powerpc/lib/board.c-       bootstage_error(BOOTSTAGE_ID_NEED_RESET);
arch/powerpc/lib/board.c-       for (;;)
--->8---

> Note that hang() is not supposed to do anything else, it just hangs
> the system.  If you have a debugger attached, you will be able to do a
> simple stack backtrace and see exactly where you are hanging, and why.

Well, for this specific board I plan to panic() on wrong hardware
detection (which will in turn call hang()). My requirements say that I
have to visualize this state then, I thought it would be a good idea to
blink some lights in the endless loop in hang() for this specific board.

> If you think you need to have specialized code, you are doing
> something wrong.

Really? How would you solve this requirement?

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 13:32           ` Andreas Bießmann
@ 2013-04-16 13:35             ` Graeme Russ
  2013-04-16 14:15               ` Andreas Bießmann
  2013-04-16 14:17             ` Wolfgang Denk
  1 sibling, 1 reply; 42+ messages in thread
From: Graeme Russ @ 2013-04-16 13:35 UTC (permalink / raw)
  To: u-boot

Hi Andreas,


On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bie?mann <
andreas.devel@googlemail.com> wrote:
>
> Dear Wolfgang,
>
> On 04/16/2013 03:05 PM, Wolfgang Denk wrote:
> > Dear Andreas,
> >
> > In message <516D4B00.9030102@gmail.com> you wrote:
> >>
> >>> So it is dead code in mainline, and we will not add it.
> >>
> >> Well, I don't think it is dead code cause the hang() is called in some
ways.
> >> This patch opens just the possibility to specialize the hang() by for
> >> example a specific board. Maybe this could also be used for specific
> >> hang() for different arches when we get closer to the common board
files.
> >
> > I think it is dead code, and not needed nor useful in mainline.  I
> > cannot even see how it would be useful for you.  hang() is defined to
> > "hang" the CPU, i. e. to make sure the system will remain in the
> > current state.  To me this naturally translates into an infinite loop,
> > the implementation of which is completely hardware and architecture
> > independent.
>
> Yes it is independent (or should at least). But there are still slightly
> different versions:
>
> ---8<---
> arch/blackfin/lib/board.c:void hang(void)
> arch/blackfin/lib/board.c-{
> arch/blackfin/lib/board.c-#ifdef CONFIG_STATUS_LED
> arch/blackfin/lib/board.c-      status_led_set(STATUS_LED_BOOT,
> STATUS_LED_OFF);
> arch/blackfin/lib/board.c-      status_led_set(STATUS_LED_CRASH,
> STATUS_LED_BLINKING);
> --->8---
>
> ---8<---
> arch/arm/lib/board.c:void __hang(void)
> arch/arm/lib/board.c-{
> arch/arm/lib/board.c-   puts("### ERROR ### Please RESET the board
###\n");
> arch/arm/lib/board.c-   for (;;);
> arch/arm/lib/board.c-}
> --->8---
>
> ---8<---
> arch/powerpc/lib/board.c:void __hang(void)
> arch/powerpc/lib/board.c-{
> arch/powerpc/lib/board.c-       puts("### ERROR ### Please RESET the
> board ###\n");
> arch/powerpc/lib/board.c-       bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> arch/powerpc/lib/board.c-       for (;;)
> --->8---

I think that ultimately there should only be a single hang() function

> > Note that hang() is not supposed to do anything else, it just hangs
> > the system.  If you have a debugger attached, you will be able to do a
> > simple stack backtrace and see exactly where you are hanging, and why.
>
> Well, for this specific board I plan to panic() on wrong hardware
> detection (which will in turn call hang()). My requirements say that I
> have to visualize this state then, I thought it would be a good idea to
> blink some lights in the endless loop in hang() for this specific board.
>
> > If you think you need to have specialized code, you are doing
> > something wrong.
>
> Really? How would you solve this requirement?

Doesn't it make  sense to use panic()?

Regards,

Graeme

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 13:35             ` Graeme Russ
@ 2013-04-16 14:15               ` Andreas Bießmann
  2013-04-16 14:20                 ` Graeme Russ
  2013-04-16 14:23                 ` Wolfgang Denk
  0 siblings, 2 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 14:15 UTC (permalink / raw)
  To: u-boot

Hi Graeme,

On 04/16/2013 03:35 PM, Graeme Russ wrote:
> Hi Andreas,
> 
> On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bie?mann
> <andreas.devel at googlemail.com <mailto:andreas.devel@googlemail.com>> wrote:
>>
>> Dear Wolfgang,
>>
>> On 04/16/2013 03:05 PM, Wolfgang Denk wrote:
>> > Dear Andreas,
>> >
>> > In message <516D4B00.9030102@gmail.com
> <mailto:516D4B00.9030102@gmail.com>> you wrote:

<snip>

> I think that ultimately there should only be a single hang() function

Ok.

>> > Note that hang() is not supposed to do anything else, it just hangs
>> > the system.  If you have a debugger attached, you will be able to do a
>> > simple stack backtrace and see exactly where you are hanging, and why.
>>
>> Well, for this specific board I plan to panic() on wrong hardware
>> detection (which will in turn call hang()). My requirements say that I
>> have to visualize this state then, I thought it would be a good idea to
>> blink some lights in the endless loop in hang() for this specific board.
>>
>> > If you think you need to have specialized code, you are doing
>> > something wrong.
>>
>> Really? How would you solve this requirement?
> 
> Doesn't it make  sense to use panic()?

In my opinion it makes sense to panic(). In my special case I also need
to hang() when panic(). The next question is then how to visualize the
(end-)user of that device that we hang().

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 13:32           ` Andreas Bießmann
  2013-04-16 13:35             ` Graeme Russ
@ 2013-04-16 14:17             ` Wolfgang Denk
  1 sibling, 0 replies; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-16 14:17 UTC (permalink / raw)
  To: u-boot

Dear Andreas,

In message <516D52EE.1040402@gmail.com> you wrote:
> 
> Yes it is independent (or should at least). But there are still slightly
> different versions:

Yes, I know :-(

> ---8<---
> arch/powerpc/lib/board.c:void __hang(void)
> arch/powerpc/lib/board.c-{
> arch/powerpc/lib/board.c-       puts("### ERROR ### Please RESET the
> board ###\n");
> arch/powerpc/lib/board.c-       bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> arch/powerpc/lib/board.c-       for (;;)
> --->8---

This is probably what the generic code should look like.

> > Note that hang() is not supposed to do anything else, it just hangs
> > the system.  If you have a debugger attached, you will be able to do a
> > simple stack backtrace and see exactly where you are hanging, and why.
> 
> Well, for this specific board I plan to panic() on wrong hardware
> detection (which will in turn call hang()). My requirements say that I
> have to visualize this state then, I thought it would be a good idea to
> blink some lights in the endless loop in hang() for this specific board.
> 
> > If you think you need to have specialized code, you are doing
> > something wrong.
> 
> Really? How would you solve this requirement?

Turn on the blinking in panic(), before calling hang().  This requires
that you have some way to blink a LED when the CPU is hanging in an
endlss loop, though.

In general, panic() and hang() are for fatal errors where no way of
recovery is possible and where you cannot make any assumptions about
remaining (or even allowed) functionality. The puts() and
bootstage_*() calls above are already stretching the design pretty
far.  We should not add more functionality here.

Best regards,

Wolfgang Denk

-- 
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
That said, there may be good reasons for what you did beyond obsequi-
ous sycophantic parody. Perhaps you might be so kind as to elucidate.
         -- Tom Christiansen in <5ldjbm$jtk$1@csnews.cs.colorado.edu>

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 14:15               ` Andreas Bießmann
@ 2013-04-16 14:20                 ` Graeme Russ
  2013-04-16 14:23                 ` Wolfgang Denk
  1 sibling, 0 replies; 42+ messages in thread
From: Graeme Russ @ 2013-04-16 14:20 UTC (permalink / raw)
  To: u-boot

Hi Andreas,


On Wed, Apr 17, 2013 at 12:15 AM, Andreas Bie?mann <
andreas.devel@googlemail.com> wrote:
>
> Hi Graeme,
>
> On 04/16/2013 03:35 PM, Graeme Russ wrote:
> > Hi Andreas,
> >
> > On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bie?mann
> > <andreas.devel at googlemail.com <mailto:andreas.devel@googlemail.com>>
wrote:
> >>
> >> Dear Wolfgang,
> >>
> >> On 04/16/2013 03:05 PM, Wolfgang Denk wrote:
> >> > Dear Andreas,
> >> >
> >> > In message <516D4B00.9030102@gmail.com
> > <mailto:516D4B00.9030102@gmail.com>> you wrote:
>
> <snip>
>
> > I think that ultimately there should only be a single hang() function
>
> Ok.
>
> >> > Note that hang() is not supposed to do anything else, it just hangs
> >> > the system.  If you have a debugger attached, you will be able to do
a
> >> > simple stack backtrace and see exactly where you are hanging, and
why.
> >>
> >> Well, for this specific board I plan to panic() on wrong hardware
> >> detection (which will in turn call hang()). My requirements say that I
> >> have to visualize this state then, I thought it would be a good idea to
> >> blink some lights in the endless loop in hang() for this specific
board.
> >>
> >> > If you think you need to have specialized code, you are doing
> >> > something wrong.
> >>
> >> Really? How would you solve this requirement?
> >
> > Doesn't it make  sense to use panic()?
>
> In my opinion it makes sense to panic(). In my special case I also need
> to hang() when panic(). The next question is then how to visualize the
> (end-)user of that device that we hang().

In panic()?

My thought would be along the lines of:
 - Detect something fatal
 - Call panic()
 - Do something to alert the user - puts(), start a LED blinking, etc.
 - Stay in panic() if you need CPU cycles to  keep alerting the user (LED
blinking for example)
 - Call hang() if you've done everything you can

Regards,

Graeme

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 14:15               ` Andreas Bießmann
  2013-04-16 14:20                 ` Graeme Russ
@ 2013-04-16 14:23                 ` Wolfgang Denk
  2013-04-16 14:40                   ` Andreas Bießmann
  1 sibling, 1 reply; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-16 14:23 UTC (permalink / raw)
  To: u-boot

Dear Andreas,

In message <516D5D0A.20403@gmail.com> you wrote:
> 
> In my opinion it makes sense to panic(). In my special case I also need
> to hang() when panic(). The next question is then how to visualize the
> (end-)user of that device that we hang().

The intention behind hang() is to stop doing anything, i. e. to idle
the board.  Nothing else.

We can argue if this is always a good thing to do.  For example, in
some situations it may be possible to switch off the board instead.
Or, as in your case, to run some code to visualize the state.

I fully agree that these are perfectly reasonable use cases for fatal
error handling in U-Boot.  But then, these are not functions to be
implemented in the context of hang().  Hang is a synonym for "place
the CPU into an infinite loop and stop doing anything else".

If you call hang() you agree to hang the system.

If you want to do something else, then please do not call hang(), but
some other function.

Best regards,

Wolfgang Denk

-- 
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
Overdrawn?  But I still have checks left!

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 14:23                 ` Wolfgang Denk
@ 2013-04-16 14:40                   ` Andreas Bießmann
  2013-04-16 15:14                     ` Wolfgang Denk
  0 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 14:40 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On 04/16/2013 04:23 PM, Wolfgang Denk wrote:
> Dear Andreas,
> 
> In message <516D5D0A.20403@gmail.com> you wrote:
>>
>> In my opinion it makes sense to panic(). In my special case I also need
>> to hang() when panic(). The next question is then how to visualize the
>> (end-)user of that device that we hang().
> 
> The intention behind hang() is to stop doing anything, i. e. to idle
> the board.  Nothing else.
> 
> We can argue if this is always a good thing to do.  For example, in
> some situations it may be possible to switch off the board instead.
> Or, as in your case, to run some code to visualize the state.
> 
> I fully agree that these are perfectly reasonable use cases for fatal
> error handling in U-Boot.  But then, these are not functions to be
> implemented in the context of hang().  Hang is a synonym for "place
> the CPU into an infinite loop and stop doing anything else".
> 
> If you call hang() you agree to hang the system.

I got your point.

> If you want to do something else, then please do not call hang(), but
> some other function.

I will find a solution for my very specific state of the device.

But how about other places in u-boot hang()ing the device? How can we
tell the user that state without a terminal? If one plugs a uart cable
he might see some cause of the hang() but this is not acceptable for
some groups of users.
Is it wise to completely stop a device without showing the state to the
user?
This question is a bit hypothetical cause we should eliminate the root
causes for hang()s before going to market. However I would like to hear
your thoughts about that.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 14:40                   ` Andreas Bießmann
@ 2013-04-16 15:14                     ` Wolfgang Denk
  2013-04-16 15:34                       ` Andreas Bießmann
  0 siblings, 1 reply; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-16 15:14 UTC (permalink / raw)
  To: u-boot

Dear Andreas,

In message <516D62E1.7090306@gmail.com> you wrote:
>
> But how about other places in u-boot hang()ing the device? How can we
> tell the user that state without a terminal? If one plugs a uart cable
> he might see some cause of the hang() but this is not acceptable for
> some groups of users.
> Is it wise to completely stop a device without showing the state to the
> user?

If you want to tell the user, this should be done _before_ calling
hang() - if you decide to hang() your board.  Keep in mind that you
don't have to define CONFIG_PANIC_HANG.

Also, as done in arch/powerpc/lib/board.c we usually print an error
message on the console device, and we can call bootstage_error(),
which could initialte such actions.

> This question is a bit hypothetical cause we should eliminate the root
> causes for hang()s before going to market. However I would like to hear
> your thoughts about that.

You cannot eliminate all causes that will lead a board to run into
hang().  There may be simply broken hardware, for example...

Best regards,

Wolfgang Denk

-- 
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
F u cn rd ths u cnt spl wrth a dm!

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 15:14                     ` Wolfgang Denk
@ 2013-04-16 15:34                       ` Andreas Bießmann
  2013-04-16 16:00                         ` Wolfgang Denk
  0 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 15:34 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On 04/16/2013 05:14 PM, Wolfgang Denk wrote:
> Dear Andreas,
> 
> In message <516D62E1.7090306@gmail.com> you wrote:
>>
>> But how about other places in u-boot hang()ing the device? How can we
>> tell the user that state without a terminal? If one plugs a uart cable
>> he might see some cause of the hang() but this is not acceptable for
>> some groups of users.
>> Is it wise to completely stop a device without showing the state to the
>> user?
> 
> If you want to tell the user, this should be done _before_ calling
> hang() - if you decide to hang() your board.  

Well, that is my point. We have about 40 places where we may hang() a
arm device:

---8<---
abiessmann@punisher % git grep "hang(" drivers/ arch/arm/ | wc -l
40
--->8---

You say (or at least I understand you so), that I have to hack all these
places with some application specific stuff to inform the user of the
device that we will stop processing now. Why don't we add an interface
to easily change the behavior of hang application specific.

> Keep in mind that you
> don't have to define CONFIG_PANIC_HANG.

Thats true, but in some cases we just want to hang on panic.

> Also, as done in arch/powerpc/lib/board.c we usually print an error
> message on the console device, and we can call bootstage_error(),
> which could initialte such actions.

Ahhh ... I got it. So this is the interface I want! All we need is
bootstage_error() in all hang() variants and thats it.

>> This question is a bit hypothetical cause we should eliminate the root
>> causes for hang()s before going to market. However I would like to hear
>> your thoughts about that.
> 
> You cannot eliminate all causes that will lead a board to run into
> hang().  There may be simply broken hardware, for example...

Thats true.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 15:34                       ` Andreas Bießmann
@ 2013-04-16 16:00                         ` Wolfgang Denk
  2013-04-16 16:14                           ` Andreas Bießmann
  0 siblings, 1 reply; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-16 16:00 UTC (permalink / raw)
  To: u-boot

Dear Andreas,

In message <516D6F71.8090304@gmail.com> you wrote:
> 
> You say (or at least I understand you so), that I have to hack all these
> places with some application specific stuff to inform the user of the
> device that we will stop processing now. Why don't we add an interface
> to easily change the behavior of hang application specific.

Because hang() is a trivial function that does just what the name
says.  If you don't want this, then don't use this.  If you need
additional functionality, then use a function that provides such.

> > Keep in mind that you
> > don't have to define CONFIG_PANIC_HANG.
> 
> Thats true, but in some cases we just want to hang on panic.

Indeed.  Normally this is the most useful thing to do.

> > Also, as done in arch/powerpc/lib/board.c we usually print an error
> > message on the console device, and we can call bootstage_error(),
> > which could initialte such actions.
> 
> Ahhh ... I got it. So this is the interface I want! All we need is
> bootstage_error() in all hang() variants and thats it.

As you have to touch all these places anyway, please rather move
hang() out of all architecture specific code and place it in the
global lib/.

Best regards,

Wolfgang Denk

-- 
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
Misquotation is, in fact, the pride and privilege of the  learned.  A
widely-read  man  never  quotes  accurately,  for  the rather obvious
reason that he has read too widely.
                - Hesketh Pearson _Common Misquotations_ introduction

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH] make hang() a weak function
  2013-04-16 16:00                         ` Wolfgang Denk
@ 2013-04-16 16:14                           ` Andreas Bießmann
  0 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-16 16:14 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On 16.04.13 18:00, Wolfgang Denk wrote:
> Dear Andreas,
> 
> In message <516D6F71.8090304@gmail.com> you wrote:

>>> Also, as done in arch/powerpc/lib/board.c we usually print an error
>>> message on the console device, and we can call bootstage_error(),
>>> which could initialte such actions.
>>
>> Ahhh ... I got it. So this is the interface I want! All we need is
>> bootstage_error() in all hang() variants and thats it.
> 
> As you have to touch all these places anyway, please rather move
> hang() out of all architecture specific code and place it in the
> global lib/.

will do.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 0/5] consolidate hang()
  2013-04-16 10:14 [U-Boot] [PATCH] make hang() a weak function Andreas Bießmann
                   ` (2 preceding siblings ...)
  2013-04-16 11:36 ` Albert ARIBAUD
@ 2013-04-17 11:02 ` Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c Andreas Bießmann
                     ` (6 more replies)
  3 siblings, 7 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:02 UTC (permalink / raw)
  To: u-boot

This series started with intention to make a hung board visualize the
(end-)user that it does hang(). The first approach was to make all the
different hang() functions weak and provide board specific versions to
implement the 'visualization' there.
After some discussion it turned out, that there is still an interface to
visualize such states to the user: the 'bootstage' stuff.

BTW:
This is my first try sending a series with patman. All I can say is:
patman is really cool ;)

The 'microblaze: fix style in board.c' is an leftover from the first approach.

The 'nios2: fix style in board.c' is an leftover from the first approach.

The 'lib: consolidate hang()' is build tested on arm and avr32. It may
produces errors on other arches like ppc cause the previous SPL inlined hang()
function was also removed.  We need to discuss if we always pull in the
libgeneric unconditional into SPL or provide a second hang() for those boards
which do not link against libgeneric in SPL.

Changes in v2:
 * delete all hang() and provide generic lib/hang.c

Andreas Bie?mann (5):
  microblaze: fix style in board.c
  nios2: fix style in board.c.
  mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT
  tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
  lib: consolidate hang()

 arch/arm/cpu/arm926ejs/mxs/spl_boot.c |    8 +----
 arch/arm/cpu/arm926ejs/spear/spl.c    |    7 ----
 arch/arm/lib/board.c                  |    7 +---
 arch/avr32/lib/board.c                |    6 +---
 arch/blackfin/lib/board.c             |   15 +-------
 arch/m68k/lib/board.c                 |    7 ----
 arch/microblaze/lib/board.c           |   63 +++++++++++++++------------------
 arch/mips/lib/board.c                 |    8 +----
 arch/nds32/lib/board.c                |    8 +----
 arch/nios2/lib/board.c                |   47 ++++++++++--------------
 arch/openrisc/lib/board.c             |   13 +------
 arch/powerpc/lib/board.c              |   10 +-----
 arch/sandbox/lib/board.c              |    8 +----
 arch/sh/lib/board.c                   |   10 +-----
 arch/sparc/lib/board.c                |   10 +-----
 arch/x86/lib/board.c                  |    8 +----
 common/board_f.c                      |    6 ----
 common/spl/spl.c                      |    7 ----
 drivers/mtd/nand/mxc_nand_spl.c       |   10 +-----
 include/configs/mx31pdk.h             |    1 +
 include/configs/tx25.h                |    1 +
 lib/Makefile                          |    1 +
 lib/hang.c                            |   47 ++++++++++++++++++++++++
 23 files changed, 109 insertions(+), 199 deletions(-)
 create mode 100644 lib/hang.c

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
@ 2013-04-17 11:02   ` Andreas Bießmann
  2013-04-17 11:44     ` Michal Simek
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 2/5] nios2: " Andreas Bießmann
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:02 UTC (permalink / raw)
  To: u-boot

Make microblaze's board.c checkpatch clean.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

---
Changes in v2: None

 arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index a7c2f76..846ffe1 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -71,15 +71,15 @@ void board_init_f(ulong not_used)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
-	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
-	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
+	gd = (gd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
+	bd = (bd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET
 						- GENERATED_BD_INFO_SIZE);
 #if defined(CONFIG_CMD_FLASH)
 	ulong flash_size = 0;
 #endif
 	asm ("nop");	/* FIXME gd is not initialize - wait */
-	memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
-	memset ((void *)bd, 0, GENERATED_BD_INFO_SIZE);
+	memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
+	memset((void *)bd, 0, GENERATED_BD_INFO_SIZE);
 	gd->bd = bd;
 	gd->baudrate = CONFIG_BAUDRATE;
 	bd->bi_baudrate = CONFIG_BAUDRATE;
@@ -105,57 +105,56 @@ void board_init_f(ulong not_used)
 	 * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
 	 * as our monitory code is run from SDRAM
 	 */
-	mem_malloc_init (CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
+	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
 
 	serial_initialize();
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		WATCHDOG_RESET ();
-		if ((*init_fnc_ptr) () != 0) {
-			hang ();
-		}
+		WATCHDOG_RESET();
+		if ((*init_fnc_ptr) () != 0)
+			hang();
 	}
 
 #ifdef CONFIG_OF_CONTROL
 	/* For now, put this check after the console is ready */
-	if (fdtdec_prepare_fdt()) {
-		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
-			"doc/README.fdt-control");
-	} else
+	if (fdtdec_prepare_fdt())
+		panic(
+		"** CONFIG_OF_CONTROL defined but no FDT - please see doc/README.fdt-control");
+	else
 		printf("DTB: 0x%x\n", (u32)gd->fdt_blob);
 #endif
 
-	puts ("SDRAM :\n");
-	printf ("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
-	printf ("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
-	printf ("\tU-Boot Start:0x%08x\n", CONFIG_SYS_TEXT_BASE);
+	puts("SDRAM :\n");
+	printf("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
+	printf("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
+	printf("\tU-Boot Start:0x%08x\n", CONFIG_SYS_TEXT_BASE);
 
 #if defined(CONFIG_CMD_FLASH)
-	puts ("Flash: ");
+	puts("Flash: ");
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
 	flash_size = flash_init();
 	if (bd->bi_flashstart && flash_size > 0) {
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
-		print_size (flash_size, "");
+		print_size(flash_size, "");
 		/*
 		 * Compute and print flash CRC if flashchecksum is set to 'y'
 		 *
 		 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
 		 */
 		if (getenv_yesno("flashchecksum") == 1) {
-			printf ("  CRC: %08X",
-				crc32(0, (const u8 *)bd->bi_flashstart,
-							flash_size)
+			printf("  CRC: %08X",
+			       crc32(0, (const u8 *)bd->bi_flashstart,
+				     flash_size)
 			);
 		}
-		putc ('\n');
+		putc('\n');
 # else	/* !CONFIG_SYS_FLASH_CHECKSUM */
-		print_size (flash_size, "\n");
+		print_size(flash_size, "\n");
 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
 		bd->bi_flashsize = flash_size;
 		bd->bi_flashoffset = bd->bi_flashstart + flash_size;
 	} else {
-		puts ("Flash init FAILED");
+		puts("Flash init FAILED");
 		bd->bi_flashstart = 0;
 		bd->bi_flashsize = 0;
 		bd->bi_flashoffset = 0;
@@ -163,10 +162,10 @@ void board_init_f(ulong not_used)
 #endif
 
 	/* relocate environment function pointers etc. */
-	env_relocate ();
+	env_relocate();
 
 	/* Initialize stdio devices */
-	stdio_init ();
+	stdio_init();
 
 	/* Initialize the jump table for applications */
 	jumptable_init();
@@ -190,13 +189,14 @@ void board_init_f(ulong not_used)
 
 	/* main_loop */
 	for (;;) {
-		WATCHDOG_RESET ();
-		main_loop ();
+		WATCHDOG_RESET();
+		main_loop();
 	}
 }
 
-void hang (void)
+void hang(void)
 {
-	puts ("### ERROR ### Please RESET the board ###\n");
-	for (;;) ;
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 2/5] nios2: fix style in board.c.
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c Andreas Bießmann
@ 2013-04-17 11:02   ` Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT Andreas Bießmann
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:02 UTC (permalink / raw)
  To: u-boot

Make nios2's board.c checkpatch clean.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

---
Changes in v2: None

 arch/nios2/lib/board.c |   43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 1e495d4..0f2bc7e 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -64,7 +64,6 @@ typedef int (init_fnc_t) (void);
  ***********************************************************************/
 
 init_fnc_t *init_sequence[] = {
-
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 	board_early_init_f,	/* Call board-specific init code early.*/
 #endif
@@ -83,7 +82,7 @@ init_fnc_t *init_sequence[] = {
 
 
 /***********************************************************************/
-void board_init (void)
+void board_init(void)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
@@ -93,7 +92,7 @@ void board_init (void)
 	/* Pointer is writable since we allocated a register for it. */
 	gd = &gd_data;
 	/* compiler optimization barrier needed for GCC >= 3.4 */
-	__asm__ __volatile__("": : :"memory");
+	__asm__ __volatile__("" : : : "memory");
 
 	gd->bd = &bd_data;
 	gd->baudrate = CONFIG_BAUDRATE;
@@ -106,25 +105,24 @@ void board_init (void)
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
 #endif
 #if	defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
-	bd->bi_sramstart= CONFIG_SYS_SRAM_BASE;
+	bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
 	bd->bi_sramsize	= CONFIG_SYS_SRAM_SIZE;
 #endif
 	bd->bi_baudrate	= CONFIG_BAUDRATE;
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		WATCHDOG_RESET ();
-		if ((*init_fnc_ptr) () != 0) {
-			hang ();
-		}
+		WATCHDOG_RESET();
+		if ((*init_fnc_ptr) () != 0)
+			hang();
 	}
 
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 
 	/* The Malloc area is immediately below the monitor copy in RAM */
 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
 
 #ifndef CONFIG_SYS_NO_FLASH
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 	bd->bi_flashsize = flash_init();
 #endif
 
@@ -138,39 +136,40 @@ void board_init (void)
 	mmc_initialize(bd);
 #endif
 
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 	env_relocate();
 
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 	stdio_init();
 	jumptable_init();
 	console_init_r();
 
-	WATCHDOG_RESET ();
-	interrupt_init ();
+	WATCHDOG_RESET();
+	interrupt_init();
 
 #if defined(CONFIG_BOARD_LATE_INIT)
-	board_late_init ();
+	board_late_init();
 #endif
 
 #if defined(CONFIG_CMD_NET)
-	puts ("Net:   ");
-	eth_initialize (bd);
+	puts("Net:   ");
+	eth_initialize(bd);
 #endif
 
 	/* main_loop */
 	for (;;) {
-		WATCHDOG_RESET ();
-		main_loop ();
+		WATCHDOG_RESET();
+		main_loop();
 	}
 }
 
 
 /***********************************************************************/
 
-void hang (void)
+void hang(void)
 {
-	disable_interrupts ();
+	disable_interrupts();
 	puts("### ERROR ### Please reset board ###\n");
-	for (;;);
+	for (;;)
+		;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 2/5] nios2: " Andreas Bießmann
@ 2013-04-17 11:02   ` Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 4/5] tx25: " Andreas Bießmann
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:02 UTC (permalink / raw)
  To: u-boot

In order to use the generic hang() later on pull libgeneric in SPL.
This has no impact on the SPL size.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
Changes in v2: None

 include/configs/mx31pdk.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/mx31pdk.h b/include/configs/mx31pdk.h
index 1754595..82ea4fa 100644
--- a/include/configs/mx31pdk.h
+++ b/include/configs/mx31pdk.h
@@ -50,6 +50,7 @@
 #define CONFIG_SPL_LDSCRIPT	"arch/$(ARCH)/cpu/u-boot-spl.lds"
 #define CONFIG_SPL_MAX_SIZE	2048
 #define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
 
 #define CONFIG_SPL_TEXT_BASE	0x87dc0000
 #define CONFIG_SYS_TEXT_BASE	0x87e00000
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 4/5] tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
                     ` (2 preceding siblings ...)
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT Andreas Bießmann
@ 2013-04-17 11:02   ` Andreas Bießmann
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 5/5] lib: consolidate hang() Andreas Bießmann
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:02 UTC (permalink / raw)
  To: u-boot

In order to use the generic hang() later on pull libgeneric in SPL.
This has no impact on the SPL size.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
Changes in v2: None

 include/configs/tx25.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/tx25.h b/include/configs/tx25.h
index e72f8f6..d61a218 100644
--- a/include/configs/tx25.h
+++ b/include/configs/tx25.h
@@ -37,6 +37,7 @@
 #define CONFIG_SPL_LDSCRIPT		"arch/$(ARCH)/cpu/u-boot-spl.lds"
 #define CONFIG_SPL_MAX_SIZE		2048
 #define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
 
 #define CONFIG_SPL_TEXT_BASE		0x810c0000
 #define CONFIG_SYS_TEXT_BASE		0x81200000
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 5/5] lib: consolidate hang()
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
                     ` (3 preceding siblings ...)
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 4/5] tx25: " Andreas Bießmann
@ 2013-04-17 11:02   ` Andreas Bießmann
  2013-04-17 12:58     ` Benoît Thébaudeau
  2013-04-18 19:40   ` [U-Boot] [PATCH v2 0/5] " Wolfgang Denk
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
  6 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:02 UTC (permalink / raw)
  To: u-boot

Delete all occurrences of hang() and provide a generic function.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

---
Changes in v2:
 * delete all hang() and provide generic lib/hang.c

 arch/arm/cpu/arm926ejs/mxs/spl_boot.c |    8 +-----
 arch/arm/cpu/arm926ejs/spear/spl.c    |    7 -----
 arch/arm/lib/board.c                  |    7 +----
 arch/avr32/lib/board.c                |    6 +----
 arch/blackfin/lib/board.c             |   15 +----------
 arch/m68k/lib/board.c                 |    7 -----
 arch/microblaze/lib/board.c           |    7 -----
 arch/mips/lib/board.c                 |    8 +-----
 arch/nds32/lib/board.c                |    8 +-----
 arch/nios2/lib/board.c                |   12 +--------
 arch/openrisc/lib/board.c             |   13 +--------
 arch/powerpc/lib/board.c              |   10 +------
 arch/sandbox/lib/board.c              |    8 +-----
 arch/sh/lib/board.c                   |   10 +------
 arch/sparc/lib/board.c                |   10 +------
 arch/x86/lib/board.c                  |    8 +-----
 common/board_f.c                      |    6 -----
 common/spl/spl.c                      |    7 -----
 drivers/mtd/nand/mxc_nand_spl.c       |   10 +------
 lib/Makefile                          |    1 +
 lib/hang.c                            |   47 +++++++++++++++++++++++++++++++++
 21 files changed, 62 insertions(+), 153 deletions(-)
 create mode 100644 lib/hang.c

diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
index 7e70440..6e6ae30 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
@@ -25,6 +25,7 @@
 
 #include <common.h>
 #include <config.h>
+#include <linux/compiler.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
@@ -148,10 +149,3 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
 	for (;;)
 		;
 }
-
-void hang(void) __attribute__ ((noreturn));
-void hang(void)
-{
-	for (;;)
-		;
-}
diff --git a/arch/arm/cpu/arm926ejs/spear/spl.c b/arch/arm/cpu/arm926ejs/spear/spl.c
index 48e6efb..0101c5d 100644
--- a/arch/arm/cpu/arm926ejs/spear/spl.c
+++ b/arch/arm/cpu/arm926ejs/spear/spl.c
@@ -31,13 +31,6 @@
 #include <asm/arch/spr_misc.h>
 #include <asm/arch/spr_syscntl.h>
 
-inline void hang(void)
-{
-	serial_puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
-
 static void ddr_clock_init(void)
 {
 	struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 0521178..39a6cf9 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -53,6 +53,7 @@
 #include <fdtdec.h>
 #include <post.h>
 #include <logbuff.h>
+#include <linux/compiler.h>
 #include <asm/sections.h>
 
 #ifdef CONFIG_BITBANGMII
@@ -706,9 +707,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;);
-}
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index 57e07df..42a013c 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -26,6 +26,7 @@
 #include <version.h>
 #include <net.h>
 #include <atmel_mci.h>
+#include <linux/compiler.h>
 
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
@@ -120,11 +121,6 @@ static int display_banner (void)
 	return 0;
 }
 
-void hang(void)
-{
-	for (;;) ;
-}
-
 static int display_dram_config (void)
 {
 	int i;
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index 75b6c46..6b8686b 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -19,6 +19,7 @@
 #include <net.h>
 #include <status_led.h>
 #include <version.h>
+#include <linux/compiler.h>
 
 #include <asm/cplb.h>
 #include <asm/mach-common/bits/mpu.h>
@@ -432,17 +433,3 @@ void board_init_r(gd_t * id, ulong dest_addr)
 	for (;;)
 		main_loop();
 }
-
-void hang(void)
-{
-#ifdef CONFIG_STATUS_LED
-	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
-	status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
-#endif
-	puts("### ERROR ### Please RESET the board ###\n");
-	while (1)
-		/* If a JTAG emulator is hooked up, we'll automatically trigger
-		 * a breakpoint in it.  If one isn't, this is just a NOP.
-		 */
-		asm("emuexcpt;");
-}
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index adaccfe..b2e3068 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -663,10 +663,3 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-
-void hang(void)
-{
-	puts ("### ERROR ### Please RESET the board ###\n");
-	for (;;);
-}
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index 846ffe1..2b92ec7 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -193,10 +193,3 @@ void board_init_f(ulong not_used)
 		main_loop();
 	}
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index f19f198..8f8d8bc 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -32,6 +32,7 @@
 #include <nand.h>
 #include <onenand_uboot.h>
 #include <spi.h>
+#include <linux/_compiler.h>
 
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
@@ -344,10 +345,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index a7d27fc..f9d9f25 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -36,6 +36,7 @@
 #include <nand.h>
 #include <onenand_uboot.h>
 #include <mmc.h>
+#include <linux/compiler.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -404,10 +405,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 0f2bc7e..5db47d7 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -30,6 +30,7 @@
 #include <malloc.h>
 #include <mmc.h>
 #include <net.h>
+#include <linux/compiler.h>
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
@@ -162,14 +163,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
index 85aa189..c74b64a 100644
--- a/arch/openrisc/lib/board.c
+++ b/arch/openrisc/lib/board.c
@@ -34,6 +34,7 @@
 #include <malloc.h>
 #include <mmc.h>
 #include <net.h>
+#include <linux/compiler.h>
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
@@ -154,15 +155,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-
-	for (;;)
-		;
-}
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 422b4a3..f306d7d 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -26,6 +26,7 @@
 #include <command.h>
 #include <malloc.h>
 #include <stdio_dev.h>
+#include <linux/compiler.h>
 #ifdef CONFIG_8xx
 #include <mpc8xx.h>
 #endif
@@ -1050,15 +1051,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
-	for (;;)
-		;
-}
-
-
 #if 0	/* We could use plain global data, but the resulting code is bigger */
 /*
  * Pointer to initial global data area
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index 3752fab..bfab0eb 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -44,6 +44,7 @@
 #include <timestamp.h>
 #include <version.h>
 #include <serial.h>
+#include <linux/compiler.h>
 
 #include <os.h>
 
@@ -276,10 +277,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index 6e43acf..be65793 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -27,6 +27,7 @@
 #include <net.h>
 #include <mmc.h>
 #include <environment.h>
+#include <linux/compiler.h>
 
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
@@ -200,12 +201,3 @@ void sh_generic_init(void)
 		main_loop();
 	}
 }
-
-/***********************************************************************/
-
-void hang(void)
-{
-	puts("Board ERROR\n");
-	for (;;)
-		;
-}
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index 79fb4c8..51bf8cf 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -30,6 +30,7 @@
 #include <malloc.h>
 #include <stdio_dev.h>
 #include <config.h>
+#include <linux/compiler.h>
 #if defined(CONFIG_CMD_IDE)
 #include <ide.h>
 #endif
@@ -411,13 +412,4 @@ void board_init_f(ulong bootflag)
 
 }
 
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-#ifdef CONFIG_SHOW_BOOT_PROGRESS
-	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
-#endif
-	for (;;) ;
-}
-
 /************************************************************************/
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index f372898..2c00004 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -35,6 +35,7 @@
 #include <fdtdec.h>
 #include <watchdog.h>
 #include <stdio_dev.h>
+#include <linux/compiler.h>
 #include <asm/u-boot-x86.h>
 #include <asm/relocate.h>
 #include <asm/processor.h>
@@ -264,10 +265,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/common/board_f.c b/common/board_f.c
index 00ca811..7eaf6b9 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -1003,9 +1003,3 @@ void board_init_f_r(void)
 	hang();
 }
 #endif /* CONFIG_X86 */
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;);
-}
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 6715e0d..7ce2d5f 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -48,13 +48,6 @@ struct spl_image_info spl_image;
 /* Define board data structure */
 static bd_t bdata __attribute__ ((section(".data")));
 
-inline void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
-
 /*
  * Default function to determine if u-boot or the OS should
  * be started. This implementation always returns 1.
diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c
index 09f23c3..1687bfd 100644
--- a/drivers/mtd/nand/mxc_nand_spl.c
+++ b/drivers/mtd/nand/mxc_nand_spl.c
@@ -26,6 +26,7 @@
 
 #include <common.h>
 #include <nand.h>
+#include <linux/compiler.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/io.h>
 #include "mxc_nand.h"
@@ -355,12 +356,3 @@ void nand_boot(void)
 		hang();
 	}
 }
-
-/*
- * Called in case of an exception.
- */
-void hang(void)
-{
-	/* Loop forever */
-	while (1) ;
-}
diff --git a/lib/Makefile b/lib/Makefile
index e901cc7..655ed7f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -71,6 +71,7 @@ COBJS-$(CONFIG_BCH) += bch.o
 COBJS-y += crc32.o
 COBJS-y += ctype.o
 COBJS-y += div64.o
+COBJS-y += hang.o
 COBJS-y += linux_string.o
 COBJS-y += string.o
 COBJS-y += time.o
diff --git a/lib/hang.c b/lib/hang.c
new file mode 100644
index 0000000..9b6d485
--- /dev/null
+++ b/lib/hang.c
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2013
+ * Andreas Bie?mann <andreas.devel@googlemail.com>
+ *
+ * This file consolidates all the different hang() functions implemented in
+ * u-boot.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <bootstage.h>
+
+/**
+ * hang - stop processing by staying in an endless loop
+ *
+ * The purpose of this function is to stop further execution of code cause
+ * something went completely wrong.  To catch this and give some feedback to
+ * the user the one needs to catch the bootstage_error (see
+ * show_boot_progress()) in the board code.
+ */
+void hang(void)
+{
+#if !defined(CONFIG_SPL_BUILD) || \
+	(defined(CONFIG_SPL_BUID) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT))
+	puts("### ERROR ### Please RESET the board ###\n");
+#endif
+	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
+	for (;;)
+		;
+}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c Andreas Bießmann
@ 2013-04-17 11:44     ` Michal Simek
  2013-04-17 11:54       ` Andreas Bießmann
  0 siblings, 1 reply; 42+ messages in thread
From: Michal Simek @ 2013-04-17 11:44 UTC (permalink / raw)
  To: u-boot

On 04/17/2013 01:02 PM, Andreas Bie?mann wrote:
> Make microblaze's board.c checkpatch clean.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> ---
> Changes in v2: None
> 
>  arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
>  1 file changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
> index a7c2f76..846ffe1 100644
> --- a/arch/microblaze/lib/board.c
> +++ b/arch/microblaze/lib/board.c
> @@ -71,15 +71,15 @@ void board_init_f(ulong not_used)
>  {
>  	bd_t *bd;
>  	init_fnc_t **init_fnc_ptr;
> -	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
> -	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
> +	gd = (gd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
> +	bd = (bd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET
>  						- GENERATED_BD_INFO_SIZE);
>  #if defined(CONFIG_CMD_FLASH)
>  	ulong flash_size = 0;
>  #endif
>  	asm ("nop");	/* FIXME gd is not initialize - wait */
> -	memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
> -	memset ((void *)bd, 0, GENERATED_BD_INFO_SIZE);
> +	memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
> +	memset((void *)bd, 0, GENERATED_BD_INFO_SIZE);
>  	gd->bd = bd;
>  	gd->baudrate = CONFIG_BAUDRATE;
>  	bd->bi_baudrate = CONFIG_BAUDRATE;
> @@ -105,57 +105,56 @@ void board_init_f(ulong not_used)
>  	 * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
>  	 * as our monitory code is run from SDRAM
>  	 */
> -	mem_malloc_init (CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
> +	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
>  
>  	serial_initialize();
>  
>  	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
> -		WATCHDOG_RESET ();
> -		if ((*init_fnc_ptr) () != 0) {
> -			hang ();
> -		}
> +		WATCHDOG_RESET();
> +		if ((*init_fnc_ptr) () != 0)
> +			hang();
>  	}
>  
>  #ifdef CONFIG_OF_CONTROL
>  	/* For now, put this check after the console is ready */
> -	if (fdtdec_prepare_fdt()) {
> -		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
> -			"doc/README.fdt-control");
> -	} else
> +	if (fdtdec_prepare_fdt())
> +		panic(
> +		"** CONFIG_OF_CONTROL defined but no FDT - please see doc/README.fdt-control");

This is quite weird coding style.
I know that the previous one doesn't pass but this is also weird.

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID:
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c
  2013-04-17 11:44     ` Michal Simek
@ 2013-04-17 11:54       ` Andreas Bießmann
  2013-04-17 11:56         ` Michal Simek
  0 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-17 11:54 UTC (permalink / raw)
  To: u-boot

Dear Michal Simek,

On 04/17/2013 01:44 PM, Michal Simek wrote:
> On 04/17/2013 01:02 PM, Andreas Bie?mann wrote:
>> Make microblaze's board.c checkpatch clean.
>>
>> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>>
>> ---
>> Changes in v2: None
>>
>>  arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
>>  1 file changed, 32 insertions(+), 32 deletions(-)
>>
>> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
>> index a7c2f76..846ffe1 100644
>> --- a/arch/microblaze/lib/board.c
>> +++ b/arch/microblaze/lib/board.c
>> @@ -71,15 +71,15 @@ void board_init_f(ulong not_used)


>>  #ifdef CONFIG_OF_CONTROL
>>  	/* For now, put this check after the console is ready */
>> -	if (fdtdec_prepare_fdt()) {
>> -		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
>> -			"doc/README.fdt-control");
>> -	} else
>> +	if (fdtdec_prepare_fdt())
>> +		panic(
>> +		"** CONFIG_OF_CONTROL defined but no FDT - please see doc/README.fdt-control");
> 
> This is quite weird coding style.
> I know that the previous one doesn't pass but this is also weird.

I tried to not change the content. How about:
| +	if (fdtdec_prepare_fdt())
| +		panic("** No FDT - please see doc/README.fdt-control");

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c
  2013-04-17 11:54       ` Andreas Bießmann
@ 2013-04-17 11:56         ` Michal Simek
  0 siblings, 0 replies; 42+ messages in thread
From: Michal Simek @ 2013-04-17 11:56 UTC (permalink / raw)
  To: u-boot

On 04/17/2013 01:54 PM, Andreas Bie?mann wrote:
> Dear Michal Simek,
> 
> On 04/17/2013 01:44 PM, Michal Simek wrote:
>> On 04/17/2013 01:02 PM, Andreas Bie?mann wrote:
>>> Make microblaze's board.c checkpatch clean.
>>>
>>> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>>>
>>> ---
>>> Changes in v2: None
>>>
>>>  arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
>>>  1 file changed, 32 insertions(+), 32 deletions(-)
>>>
>>> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
>>> index a7c2f76..846ffe1 100644
>>> --- a/arch/microblaze/lib/board.c
>>> +++ b/arch/microblaze/lib/board.c
>>> @@ -71,15 +71,15 @@ void board_init_f(ulong not_used)
> 
> 
>>>  #ifdef CONFIG_OF_CONTROL
>>>  	/* For now, put this check after the console is ready */
>>> -	if (fdtdec_prepare_fdt()) {
>>> -		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
>>> -			"doc/README.fdt-control");
>>> -	} else
>>> +	if (fdtdec_prepare_fdt())
>>> +		panic(
>>> +		"** CONFIG_OF_CONTROL defined but no FDT - please see doc/README.fdt-control");
>>
>> This is quite weird coding style.
>> I know that the previous one doesn't pass but this is also weird.
> 
> I tried to not change the content. How about:
> | +	if (fdtdec_prepare_fdt())
> | +		panic("** No FDT - please see doc/README.fdt-control");

yep. Much better.

Not sure how you want to handle this patch. If in the series with hang()
then write there my
Reviewed-by: Michal Simek <monstr@monstr.eu>

If you want to add to my microblaze custodian tree, please let me know.

I think I had done this some time ago but never push this to mainline.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID:
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 5/5] lib: consolidate hang()
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 5/5] lib: consolidate hang() Andreas Bießmann
@ 2013-04-17 12:58     ` Benoît Thébaudeau
  0 siblings, 0 replies; 42+ messages in thread
From: Benoît Thébaudeau @ 2013-04-17 12:58 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On Wednesday, April 17, 2013 1:02:48 PM, Andreas Bie?mann wrote:
> Delete all occurrences of hang() and provide a generic function.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> ---
> Changes in v2:
>  * delete all hang() and provide generic lib/hang.c
> 
>  arch/arm/cpu/arm926ejs/mxs/spl_boot.c |    8 +-----
>  arch/arm/cpu/arm926ejs/spear/spl.c    |    7 -----
>  arch/arm/lib/board.c                  |    7 +----
>  arch/avr32/lib/board.c                |    6 +----
>  arch/blackfin/lib/board.c             |   15 +----------
>  arch/m68k/lib/board.c                 |    7 -----
>  arch/microblaze/lib/board.c           |    7 -----
>  arch/mips/lib/board.c                 |    8 +-----
>  arch/nds32/lib/board.c                |    8 +-----
>  arch/nios2/lib/board.c                |   12 +--------
>  arch/openrisc/lib/board.c             |   13 +--------
>  arch/powerpc/lib/board.c              |   10 +------
>  arch/sandbox/lib/board.c              |    8 +-----
>  arch/sh/lib/board.c                   |   10 +------
>  arch/sparc/lib/board.c                |   10 +------
>  arch/x86/lib/board.c                  |    8 +-----
>  common/board_f.c                      |    6 -----
>  common/spl/spl.c                      |    7 -----
>  drivers/mtd/nand/mxc_nand_spl.c       |   10 +------
>  lib/Makefile                          |    1 +
>  lib/hang.c                            |   47
>  +++++++++++++++++++++++++++++++++
>  21 files changed, 62 insertions(+), 153 deletions(-)
>  create mode 100644 lib/hang.c
> 
> diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> index 7e70440..6e6ae30 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> +++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> @@ -25,6 +25,7 @@
>  
>  #include <common.h>
>  #include <config.h>
> +#include <linux/compiler.h>
>  #include <asm/io.h>
>  #include <asm/arch/imx-regs.h>
>  #include <asm/arch/sys_proto.h>
> @@ -148,10 +149,3 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
>  	for (;;)
>  		;
>  }
> -
> -void hang(void) __attribute__ ((noreturn));
> -void hang(void)
> -{
> -	for (;;)
> -		;
> -}
> diff --git a/arch/arm/cpu/arm926ejs/spear/spl.c
> b/arch/arm/cpu/arm926ejs/spear/spl.c
> index 48e6efb..0101c5d 100644
> --- a/arch/arm/cpu/arm926ejs/spear/spl.c
> +++ b/arch/arm/cpu/arm926ejs/spear/spl.c
> @@ -31,13 +31,6 @@
>  #include <asm/arch/spr_misc.h>
>  #include <asm/arch/spr_syscntl.h>
>  
> -inline void hang(void)
> -{
> -	serial_puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> -
>  static void ddr_clock_init(void)
>  {
>  	struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 0521178..39a6cf9 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -53,6 +53,7 @@
>  #include <fdtdec.h>
>  #include <post.h>
>  #include <logbuff.h>
> +#include <linux/compiler.h>
>  #include <asm/sections.h>
>  
>  #ifdef CONFIG_BITBANGMII
> @@ -706,9 +707,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;);
> -}
> diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
> index 57e07df..42a013c 100644
> --- a/arch/avr32/lib/board.c
> +++ b/arch/avr32/lib/board.c
> @@ -26,6 +26,7 @@
>  #include <version.h>
>  #include <net.h>
>  #include <atmel_mci.h>
> +#include <linux/compiler.h>
>  
>  #ifdef CONFIG_BITBANGMII
>  #include <miiphy.h>
> @@ -120,11 +121,6 @@ static int display_banner (void)
>  	return 0;
>  }
>  
> -void hang(void)
> -{
> -	for (;;) ;
> -}
> -
>  static int display_dram_config (void)
>  {
>  	int i;
> diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
> index 75b6c46..6b8686b 100644
> --- a/arch/blackfin/lib/board.c
> +++ b/arch/blackfin/lib/board.c
> @@ -19,6 +19,7 @@
>  #include <net.h>
>  #include <status_led.h>
>  #include <version.h>
> +#include <linux/compiler.h>
>  
>  #include <asm/cplb.h>
>  #include <asm/mach-common/bits/mpu.h>
> @@ -432,17 +433,3 @@ void board_init_r(gd_t * id, ulong dest_addr)
>  	for (;;)
>  		main_loop();
>  }
> -
> -void hang(void)
> -{
> -#ifdef CONFIG_STATUS_LED
> -	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
> -	status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
> -#endif
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	while (1)
> -		/* If a JTAG emulator is hooked up, we'll automatically trigger
> -		 * a breakpoint in it.  If one isn't, this is just a NOP.
> -		 */
> -		asm("emuexcpt;");
> -}
> diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
> index adaccfe..b2e3068 100644
> --- a/arch/m68k/lib/board.c
> +++ b/arch/m68k/lib/board.c
> @@ -663,10 +663,3 @@ void board_init_r (gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -
> -void hang(void)
> -{
> -	puts ("### ERROR ### Please RESET the board ###\n");
> -	for (;;);
> -}
> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
> index 846ffe1..2b92ec7 100644
> --- a/arch/microblaze/lib/board.c
> +++ b/arch/microblaze/lib/board.c
> @@ -193,10 +193,3 @@ void board_init_f(ulong not_used)
>  		main_loop();
>  	}
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
> index f19f198..8f8d8bc 100644
> --- a/arch/mips/lib/board.c
> +++ b/arch/mips/lib/board.c
> @@ -32,6 +32,7 @@
>  #include <nand.h>
>  #include <onenand_uboot.h>
>  #include <spi.h>
> +#include <linux/_compiler.h>
>  
>  #ifdef CONFIG_BITBANGMII
>  #include <miiphy.h>
> @@ -344,10 +345,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
> index a7d27fc..f9d9f25 100644
> --- a/arch/nds32/lib/board.c
> +++ b/arch/nds32/lib/board.c
> @@ -36,6 +36,7 @@
>  #include <nand.h>
>  #include <onenand_uboot.h>
>  #include <mmc.h>
> +#include <linux/compiler.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -404,10 +405,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
> index 0f2bc7e..5db47d7 100644
> --- a/arch/nios2/lib/board.c
> +++ b/arch/nios2/lib/board.c
> @@ -30,6 +30,7 @@
>  #include <malloc.h>
>  #include <mmc.h>
>  #include <net.h>
> +#include <linux/compiler.h>
>  #ifdef CONFIG_STATUS_LED
>  #include <status_led.h>
>  #endif
> @@ -162,14 +163,3 @@ void board_init(void)
>  		main_loop();
>  	}
>  }
> -
> -
> -/***********************************************************************/
> -
> -void hang(void)
> -{
> -	disable_interrupts();
> -	puts("### ERROR ### Please reset board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
> index 85aa189..c74b64a 100644
> --- a/arch/openrisc/lib/board.c
> +++ b/arch/openrisc/lib/board.c
> @@ -34,6 +34,7 @@
>  #include <malloc.h>
>  #include <mmc.h>
>  #include <net.h>
> +#include <linux/compiler.h>
>  #ifdef CONFIG_STATUS_LED
>  #include <status_led.h>
>  #endif
> @@ -154,15 +155,3 @@ void board_init(void)
>  		main_loop();
>  	}
>  }
> -
> -
> -/***********************************************************************/
> -
> -void hang(void)
> -{
> -	disable_interrupts();
> -	puts("### ERROR ### Please reset board ###\n");
> -
> -	for (;;)
> -		;
> -}
> diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
> index 422b4a3..f306d7d 100644
> --- a/arch/powerpc/lib/board.c
> +++ b/arch/powerpc/lib/board.c
> @@ -26,6 +26,7 @@
>  #include <command.h>
>  #include <malloc.h>
>  #include <stdio_dev.h>
> +#include <linux/compiler.h>
>  #ifdef CONFIG_8xx
>  #include <mpc8xx.h>
>  #endif
> @@ -1050,15 +1051,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> -	for (;;)
> -		;
> -}
> -
> -
>  #if 0	/* We could use plain global data, but the resulting code is bigger */
>  /*
>   * Pointer to initial global data area
> diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
> index 3752fab..bfab0eb 100644
> --- a/arch/sandbox/lib/board.c
> +++ b/arch/sandbox/lib/board.c
> @@ -44,6 +44,7 @@
>  #include <timestamp.h>
>  #include <version.h>
>  #include <serial.h>
> +#include <linux/compiler.h>
>  
>  #include <os.h>
>  
> @@ -276,10 +277,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
> index 6e43acf..be65793 100644
> --- a/arch/sh/lib/board.c
> +++ b/arch/sh/lib/board.c
> @@ -27,6 +27,7 @@
>  #include <net.h>
>  #include <mmc.h>
>  #include <environment.h>
> +#include <linux/compiler.h>
>  
>  #ifdef CONFIG_BITBANGMII
>  #include <miiphy.h>
> @@ -200,12 +201,3 @@ void sh_generic_init(void)
>  		main_loop();
>  	}
>  }
> -
> -/***********************************************************************/
> -
> -void hang(void)
> -{
> -	puts("Board ERROR\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
> index 79fb4c8..51bf8cf 100644
> --- a/arch/sparc/lib/board.c
> +++ b/arch/sparc/lib/board.c
> @@ -30,6 +30,7 @@
>  #include <malloc.h>
>  #include <stdio_dev.h>
>  #include <config.h>
> +#include <linux/compiler.h>
>  #if defined(CONFIG_CMD_IDE)
>  #include <ide.h>
>  #endif
> @@ -411,13 +412,4 @@ void board_init_f(ulong bootflag)
>  
>  }
>  
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -#ifdef CONFIG_SHOW_BOOT_PROGRESS
> -	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> -#endif
> -	for (;;) ;
> -}
> -
>  /************************************************************************/
> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
> index f372898..2c00004 100644
> --- a/arch/x86/lib/board.c
> +++ b/arch/x86/lib/board.c
> @@ -35,6 +35,7 @@
>  #include <fdtdec.h>
>  #include <watchdog.h>
>  #include <stdio_dev.h>
> +#include <linux/compiler.h>
>  #include <asm/u-boot-x86.h>
>  #include <asm/relocate.h>
>  #include <asm/processor.h>
> @@ -264,10 +265,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/common/board_f.c b/common/board_f.c
> index 00ca811..7eaf6b9 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -1003,9 +1003,3 @@ void board_init_f_r(void)
>  	hang();
>  }
>  #endif /* CONFIG_X86 */
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;);
> -}
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 6715e0d..7ce2d5f 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -48,13 +48,6 @@ struct spl_image_info spl_image;
>  /* Define board data structure */
>  static bd_t bdata __attribute__ ((section(".data")));
>  
> -inline void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> -
>  /*
>   * Default function to determine if u-boot or the OS should
>   * be started. This implementation always returns 1.
> diff --git a/drivers/mtd/nand/mxc_nand_spl.c
> b/drivers/mtd/nand/mxc_nand_spl.c
> index 09f23c3..1687bfd 100644
> --- a/drivers/mtd/nand/mxc_nand_spl.c
> +++ b/drivers/mtd/nand/mxc_nand_spl.c
> @@ -26,6 +26,7 @@
>  
>  #include <common.h>
>  #include <nand.h>
> +#include <linux/compiler.h>
>  #include <asm/arch/imx-regs.h>
>  #include <asm/io.h>
>  #include "mxc_nand.h"
> @@ -355,12 +356,3 @@ void nand_boot(void)
>  		hang();
>  	}
>  }
> -
> -/*
> - * Called in case of an exception.
> - */
> -void hang(void)
> -{
> -	/* Loop forever */
> -	while (1) ;
> -}
> diff --git a/lib/Makefile b/lib/Makefile
> index e901cc7..655ed7f 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -71,6 +71,7 @@ COBJS-$(CONFIG_BCH) += bch.o
>  COBJS-y += crc32.o
>  COBJS-y += ctype.o
>  COBJS-y += div64.o
> +COBJS-y += hang.o
>  COBJS-y += linux_string.o
>  COBJS-y += string.o
>  COBJS-y += time.o
> diff --git a/lib/hang.c b/lib/hang.c
> new file mode 100644
> index 0000000..9b6d485
> --- /dev/null
> +++ b/lib/hang.c
> @@ -0,0 +1,47 @@
> +/*
> + * (C) Copyright 2013
> + * Andreas Bie?mann <andreas.devel@googlemail.com>
> + *
> + * This file consolidates all the different hang() functions implemented in
> + * u-boot.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <bootstage.h>
> +
> +/**
> + * hang - stop processing by staying in an endless loop
> + *
> + * The purpose of this function is to stop further execution of code cause
> + * something went completely wrong.  To catch this and give some feedback to
> + * the user the one needs to catch the bootstage_error (see
> + * show_boot_progress()) in the board code.
> + */
> +void hang(void)
> +{
> +#if !defined(CONFIG_SPL_BUILD) || \
> +	(defined(CONFIG_SPL_BUID) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT))

This can be simplified as:
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)

> +	puts("### ERROR ### Please RESET the board ###\n");
> +#endif
> +	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> +	for (;;)
> +		;
> +}
> --
> 1.7.10.4

Apart from that, this series looks good.

Best regards,
Beno?t

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v2 0/5] consolidate hang()
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
                     ` (4 preceding siblings ...)
  2013-04-17 11:02   ` [U-Boot] [PATCH v2 5/5] lib: consolidate hang() Andreas Bießmann
@ 2013-04-18 19:40   ` Wolfgang Denk
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
  6 siblings, 0 replies; 42+ messages in thread
From: Wolfgang Denk @ 2013-04-18 19:40 UTC (permalink / raw)
  To: u-boot

Dear Andreas,

In message <1366196568-23008-1-git-send-email-andreas.devel@googlemail.com> you wrote:
>
> Andreas Bie?mann (5):
>   microblaze: fix style in board.c
>   nios2: fix style in board.c.
>   mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT
>   tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
>   lib: consolidate hang()

Compile-tested for Power architecture.  No new warnings / errors
found.

Tested-by: Wolfgang Denk <wd@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>

Best regards,

Wolfgang Denk

-- 
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
I have the simplest tastes.  I am always satisfied with the best.
                                                       -- Oscar Wilde

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 0/5] consolidate hang()
  2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
                     ` (5 preceding siblings ...)
  2013-04-18 19:40   ` [U-Boot] [PATCH v2 0/5] " Wolfgang Denk
@ 2013-04-19  8:48   ` Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 1/5] microblaze: fix style in board.c Andreas Bießmann
                       ` (6 more replies)
  6 siblings, 7 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  8:48 UTC (permalink / raw)
  To: u-boot

This series started with intention to make a hung board visualize the
(end-)user that it does hang(). The first approach was to make all the
different hang() functions weak and provide board specific versions to
implement the 'visualization' there.
After some discussion it turned out, that there is still an interface to
visualize such states to the user: the 'bootstage' stuff.

BTW:
This is my first try sending a series with patman. All I can say is:
patman is really cool ;)

The 'microblaze: fix style in board.c' is an leftover from the first approach.

The 'nios2: fix style in board.c' is an leftover from the first approach.

The 'lib: consolidate hang()' is build tested on arm and avr32. It may
produces errors on other arches like ppc cause the previous SPL inlined hang()
function was also removed.  We need to discuss if we always pull in the
libgeneric unconditional into SPL or provide a second hang() for those boards
which do not link against libgeneric in SPL.

Since v2 got a complete (compile-)test on powerpc by Wolfgang I think we can
stick with the current solution.  v3 includes some minor changes mentioned in
the changelog of respective patches.

Changes in v3:
 * shorten error string for 'no FDT'
 * remove unnecessarily added linux/compiler.h
 * fix typo in new hang() docu
 * use simplified macro for SPL_LIBCOMMON_SUPPORT as suggested by Beno?t

Changes in v2:
 * delete all hang() and provide generic lib/hang.c

Andreas Bie?mann (5):
  microblaze: fix style in board.c
  nios2: fix style in board.c.
  mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT
  tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
  lib: consolidate hang()

 arch/arm/cpu/arm926ejs/mxs/spl_boot.c |    7 ----
 arch/arm/cpu/arm926ejs/spear/spl.c    |    7 ----
 arch/arm/lib/board.c                  |    6 ----
 arch/avr32/lib/board.c                |    5 ---
 arch/blackfin/lib/board.c             |   14 --------
 arch/m68k/lib/board.c                 |    7 ----
 arch/microblaze/lib/board.c           |   62 ++++++++++++++-------------------
 arch/mips/lib/board.c                 |    7 ----
 arch/nds32/lib/board.c                |    7 ----
 arch/nios2/lib/board.c                |   46 +++++++++---------------
 arch/openrisc/lib/board.c             |   12 -------
 arch/powerpc/lib/board.c              |    9 -----
 arch/sandbox/lib/board.c              |    7 ----
 arch/sh/lib/board.c                   |    9 -----
 arch/sparc/lib/board.c                |    9 -----
 arch/x86/lib/board.c                  |    7 ----
 common/board_f.c                      |    6 ----
 common/spl/spl.c                      |    7 ----
 drivers/mtd/nand/mxc_nand_spl.c       |    9 -----
 include/configs/mx31pdk.h             |    1 +
 include/configs/tx25.h                |    1 +
 lib/Makefile                          |    1 +
 lib/hang.c                            |   46 ++++++++++++++++++++++++
 23 files changed, 93 insertions(+), 199 deletions(-)
 create mode 100644 lib/hang.c

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 1/5] microblaze: fix style in board.c
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
@ 2013-04-19  8:48     ` Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 2/5] nios2: " Andreas Bießmann
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  8:48 UTC (permalink / raw)
  To: u-boot

Make microblaze's board.c checkpatch clean.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>


Reviewed-by: Michal Simek <monstr@monstr.eu>
---
Changes in v3:
 * shorten error string for 'no FDT'

Changes in v2: None

 arch/microblaze/lib/board.c |   63 +++++++++++++++++++++----------------------
 1 file changed, 31 insertions(+), 32 deletions(-)

diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index a7c2f76..4c4f36b 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -71,15 +71,15 @@ void board_init_f(ulong not_used)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
-	gd = (gd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
-	bd = (bd_t *) (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
+	gd = (gd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
+	bd = (bd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET
 						- GENERATED_BD_INFO_SIZE);
 #if defined(CONFIG_CMD_FLASH)
 	ulong flash_size = 0;
 #endif
 	asm ("nop");	/* FIXME gd is not initialize - wait */
-	memset ((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
-	memset ((void *)bd, 0, GENERATED_BD_INFO_SIZE);
+	memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
+	memset((void *)bd, 0, GENERATED_BD_INFO_SIZE);
 	gd->bd = bd;
 	gd->baudrate = CONFIG_BAUDRATE;
 	bd->bi_baudrate = CONFIG_BAUDRATE;
@@ -105,57 +105,55 @@ void board_init_f(ulong not_used)
 	 * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
 	 * as our monitory code is run from SDRAM
 	 */
-	mem_malloc_init (CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
+	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
 
 	serial_initialize();
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		WATCHDOG_RESET ();
-		if ((*init_fnc_ptr) () != 0) {
-			hang ();
-		}
+		WATCHDOG_RESET();
+		if ((*init_fnc_ptr) () != 0)
+			hang();
 	}
 
 #ifdef CONFIG_OF_CONTROL
 	/* For now, put this check after the console is ready */
-	if (fdtdec_prepare_fdt()) {
-		panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
-			"doc/README.fdt-control");
-	} else
+	if (fdtdec_prepare_fdt())
+		panic("** No FDT - please see doc/README.fdt-control");
+	else
 		printf("DTB: 0x%x\n", (u32)gd->fdt_blob);
 #endif
 
-	puts ("SDRAM :\n");
-	printf ("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
-	printf ("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
-	printf ("\tU-Boot Start:0x%08x\n", CONFIG_SYS_TEXT_BASE);
+	puts("SDRAM :\n");
+	printf("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
+	printf("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
+	printf("\tU-Boot Start:0x%08x\n", CONFIG_SYS_TEXT_BASE);
 
 #if defined(CONFIG_CMD_FLASH)
-	puts ("Flash: ");
+	puts("Flash: ");
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
 	flash_size = flash_init();
 	if (bd->bi_flashstart && flash_size > 0) {
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
-		print_size (flash_size, "");
+		print_size(flash_size, "");
 		/*
 		 * Compute and print flash CRC if flashchecksum is set to 'y'
 		 *
 		 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
 		 */
 		if (getenv_yesno("flashchecksum") == 1) {
-			printf ("  CRC: %08X",
-				crc32(0, (const u8 *)bd->bi_flashstart,
-							flash_size)
+			printf("  CRC: %08X",
+			       crc32(0, (const u8 *)bd->bi_flashstart,
+				     flash_size)
 			);
 		}
-		putc ('\n');
+		putc('\n');
 # else	/* !CONFIG_SYS_FLASH_CHECKSUM */
-		print_size (flash_size, "\n");
+		print_size(flash_size, "\n");
 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
 		bd->bi_flashsize = flash_size;
 		bd->bi_flashoffset = bd->bi_flashstart + flash_size;
 	} else {
-		puts ("Flash init FAILED");
+		puts("Flash init FAILED");
 		bd->bi_flashstart = 0;
 		bd->bi_flashsize = 0;
 		bd->bi_flashoffset = 0;
@@ -163,10 +161,10 @@ void board_init_f(ulong not_used)
 #endif
 
 	/* relocate environment function pointers etc. */
-	env_relocate ();
+	env_relocate();
 
 	/* Initialize stdio devices */
-	stdio_init ();
+	stdio_init();
 
 	/* Initialize the jump table for applications */
 	jumptable_init();
@@ -190,13 +188,14 @@ void board_init_f(ulong not_used)
 
 	/* main_loop */
 	for (;;) {
-		WATCHDOG_RESET ();
-		main_loop ();
+		WATCHDOG_RESET();
+		main_loop();
 	}
 }
 
-void hang (void)
+void hang(void)
 {
-	puts ("### ERROR ### Please RESET the board ###\n");
-	for (;;) ;
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 2/5] nios2: fix style in board.c.
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 1/5] microblaze: fix style in board.c Andreas Bießmann
@ 2013-04-19  8:48     ` Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT Andreas Bießmann
                       ` (4 subsequent siblings)
  6 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  8:48 UTC (permalink / raw)
  To: u-boot

Make nios2's board.c checkpatch clean.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

---
Changes in v3: None
Changes in v2: None

 arch/nios2/lib/board.c |   43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 1e495d4..0f2bc7e 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -64,7 +64,6 @@ typedef int (init_fnc_t) (void);
  ***********************************************************************/
 
 init_fnc_t *init_sequence[] = {
-
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 	board_early_init_f,	/* Call board-specific init code early.*/
 #endif
@@ -83,7 +82,7 @@ init_fnc_t *init_sequence[] = {
 
 
 /***********************************************************************/
-void board_init (void)
+void board_init(void)
 {
 	bd_t *bd;
 	init_fnc_t **init_fnc_ptr;
@@ -93,7 +92,7 @@ void board_init (void)
 	/* Pointer is writable since we allocated a register for it. */
 	gd = &gd_data;
 	/* compiler optimization barrier needed for GCC >= 3.4 */
-	__asm__ __volatile__("": : :"memory");
+	__asm__ __volatile__("" : : : "memory");
 
 	gd->bd = &bd_data;
 	gd->baudrate = CONFIG_BAUDRATE;
@@ -106,25 +105,24 @@ void board_init (void)
 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
 #endif
 #if	defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
-	bd->bi_sramstart= CONFIG_SYS_SRAM_BASE;
+	bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
 	bd->bi_sramsize	= CONFIG_SYS_SRAM_SIZE;
 #endif
 	bd->bi_baudrate	= CONFIG_BAUDRATE;
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		WATCHDOG_RESET ();
-		if ((*init_fnc_ptr) () != 0) {
-			hang ();
-		}
+		WATCHDOG_RESET();
+		if ((*init_fnc_ptr) () != 0)
+			hang();
 	}
 
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 
 	/* The Malloc area is immediately below the monitor copy in RAM */
 	mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
 
 #ifndef CONFIG_SYS_NO_FLASH
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 	bd->bi_flashsize = flash_init();
 #endif
 
@@ -138,39 +136,40 @@ void board_init (void)
 	mmc_initialize(bd);
 #endif
 
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 	env_relocate();
 
-	WATCHDOG_RESET ();
+	WATCHDOG_RESET();
 	stdio_init();
 	jumptable_init();
 	console_init_r();
 
-	WATCHDOG_RESET ();
-	interrupt_init ();
+	WATCHDOG_RESET();
+	interrupt_init();
 
 #if defined(CONFIG_BOARD_LATE_INIT)
-	board_late_init ();
+	board_late_init();
 #endif
 
 #if defined(CONFIG_CMD_NET)
-	puts ("Net:   ");
-	eth_initialize (bd);
+	puts("Net:   ");
+	eth_initialize(bd);
 #endif
 
 	/* main_loop */
 	for (;;) {
-		WATCHDOG_RESET ();
-		main_loop ();
+		WATCHDOG_RESET();
+		main_loop();
 	}
 }
 
 
 /***********************************************************************/
 
-void hang (void)
+void hang(void)
 {
-	disable_interrupts ();
+	disable_interrupts();
 	puts("### ERROR ### Please reset board ###\n");
-	for (;;);
+	for (;;)
+		;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 1/5] microblaze: fix style in board.c Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 2/5] nios2: " Andreas Bießmann
@ 2013-04-19  8:48     ` Andreas Bießmann
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 4/5] tx25: " Andreas Bießmann
                       ` (3 subsequent siblings)
  6 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  8:48 UTC (permalink / raw)
  To: u-boot

In order to use the generic hang() later on pull libgeneric in SPL.
This has no impact on the SPL size.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
Changes in v3: None
Changes in v2: None

 include/configs/mx31pdk.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/mx31pdk.h b/include/configs/mx31pdk.h
index 1754595..82ea4fa 100644
--- a/include/configs/mx31pdk.h
+++ b/include/configs/mx31pdk.h
@@ -50,6 +50,7 @@
 #define CONFIG_SPL_LDSCRIPT	"arch/$(ARCH)/cpu/u-boot-spl.lds"
 #define CONFIG_SPL_MAX_SIZE	2048
 #define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
 
 #define CONFIG_SPL_TEXT_BASE	0x87dc0000
 #define CONFIG_SYS_TEXT_BASE	0x87e00000
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 4/5] tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
                       ` (2 preceding siblings ...)
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT Andreas Bießmann
@ 2013-04-19  8:48     ` Andreas Bießmann
  2013-04-19  9:00       ` Benoît Thébaudeau
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 5/5] lib: consolidate hang() Andreas Bießmann
                       ` (2 subsequent siblings)
  6 siblings, 1 reply; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  8:48 UTC (permalink / raw)
  To: u-boot

In order to use the generic hang() later on pull libgeneric in SPL.
This has no impact on the SPL size.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
Changes in v3: None
Changes in v2: None

 include/configs/tx25.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/tx25.h b/include/configs/tx25.h
index e72f8f6..d61a218 100644
--- a/include/configs/tx25.h
+++ b/include/configs/tx25.h
@@ -37,6 +37,7 @@
 #define CONFIG_SPL_LDSCRIPT		"arch/$(ARCH)/cpu/u-boot-spl.lds"
 #define CONFIG_SPL_MAX_SIZE		2048
 #define CONFIG_SPL_NAND_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
 
 #define CONFIG_SPL_TEXT_BASE		0x810c0000
 #define CONFIG_SYS_TEXT_BASE		0x81200000
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 5/5] lib: consolidate hang()
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
                       ` (3 preceding siblings ...)
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 4/5] tx25: " Andreas Bießmann
@ 2013-04-19  8:48     ` Andreas Bießmann
  2013-04-19  8:57       ` Albert ARIBAUD
  2013-05-02 16:05       ` Tom Rini
  2013-04-25 21:44     ` [U-Boot] [PATCH v3 0/5] " Simon Glass
  2013-05-02 16:06     ` Tom Rini
  6 siblings, 2 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  8:48 UTC (permalink / raw)
  To: u-boot

Delete all occurrences of hang() and provide a generic function.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

---
Changes in v3:
 * remove unnecessarily added linux/compiler.h
 * fix typo in new hang() docu
 * use simplified macro for SPL_LIBCOMMON_SUPPORT as suggested by Beno?t

Changes in v2:
 * delete all hang() and provide generic lib/hang.c

 arch/arm/cpu/arm926ejs/mxs/spl_boot.c |    7 -----
 arch/arm/cpu/arm926ejs/spear/spl.c    |    7 -----
 arch/arm/lib/board.c                  |    6 -----
 arch/avr32/lib/board.c                |    5 ----
 arch/blackfin/lib/board.c             |   14 ----------
 arch/m68k/lib/board.c                 |    7 -----
 arch/microblaze/lib/board.c           |    7 -----
 arch/mips/lib/board.c                 |    7 -----
 arch/nds32/lib/board.c                |    7 -----
 arch/nios2/lib/board.c                |   11 --------
 arch/openrisc/lib/board.c             |   12 ---------
 arch/powerpc/lib/board.c              |    9 -------
 arch/sandbox/lib/board.c              |    7 -----
 arch/sh/lib/board.c                   |    9 -------
 arch/sparc/lib/board.c                |    9 -------
 arch/x86/lib/board.c                  |    7 -----
 common/board_f.c                      |    6 -----
 common/spl/spl.c                      |    7 -----
 drivers/mtd/nand/mxc_nand_spl.c       |    9 -------
 lib/Makefile                          |    1 +
 lib/hang.c                            |   46 +++++++++++++++++++++++++++++++++
 21 files changed, 47 insertions(+), 153 deletions(-)
 create mode 100644 lib/hang.c

diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
index 7e70440..ed525e5 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
@@ -148,10 +148,3 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
 	for (;;)
 		;
 }
-
-void hang(void) __attribute__ ((noreturn));
-void hang(void)
-{
-	for (;;)
-		;
-}
diff --git a/arch/arm/cpu/arm926ejs/spear/spl.c b/arch/arm/cpu/arm926ejs/spear/spl.c
index 48e6efb..0101c5d 100644
--- a/arch/arm/cpu/arm926ejs/spear/spl.c
+++ b/arch/arm/cpu/arm926ejs/spear/spl.c
@@ -31,13 +31,6 @@
 #include <asm/arch/spr_misc.h>
 #include <asm/arch/spr_syscntl.h>
 
-inline void hang(void)
-{
-	serial_puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
-
 static void ddr_clock_init(void)
 {
 	struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 0521178..09ab4ad 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -706,9 +706,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;);
-}
diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
index 57e07df..ccf862a 100644
--- a/arch/avr32/lib/board.c
+++ b/arch/avr32/lib/board.c
@@ -120,11 +120,6 @@ static int display_banner (void)
 	return 0;
 }
 
-void hang(void)
-{
-	for (;;) ;
-}
-
 static int display_dram_config (void)
 {
 	int i;
diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
index 75b6c46..ccea3b9 100644
--- a/arch/blackfin/lib/board.c
+++ b/arch/blackfin/lib/board.c
@@ -432,17 +432,3 @@ void board_init_r(gd_t * id, ulong dest_addr)
 	for (;;)
 		main_loop();
 }
-
-void hang(void)
-{
-#ifdef CONFIG_STATUS_LED
-	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
-	status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
-#endif
-	puts("### ERROR ### Please RESET the board ###\n");
-	while (1)
-		/* If a JTAG emulator is hooked up, we'll automatically trigger
-		 * a breakpoint in it.  If one isn't, this is just a NOP.
-		 */
-		asm("emuexcpt;");
-}
diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
index adaccfe..b2e3068 100644
--- a/arch/m68k/lib/board.c
+++ b/arch/m68k/lib/board.c
@@ -663,10 +663,3 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-
-void hang(void)
-{
-	puts ("### ERROR ### Please RESET the board ###\n");
-	for (;;);
-}
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index 4c4f36b..f0987ad 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -192,10 +192,3 @@ void board_init_f(ulong not_used)
 		main_loop();
 	}
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index f19f198..fac7915 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -344,10 +344,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
index a7d27fc..57af1be 100644
--- a/arch/nds32/lib/board.c
+++ b/arch/nds32/lib/board.c
@@ -404,10 +404,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
index 0f2bc7e..f430ef0 100644
--- a/arch/nios2/lib/board.c
+++ b/arch/nios2/lib/board.c
@@ -162,14 +162,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
index 85aa189..630e45f 100644
--- a/arch/openrisc/lib/board.c
+++ b/arch/openrisc/lib/board.c
@@ -154,15 +154,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-
-	for (;;)
-		;
-}
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
index 422b4a3..41b2294 100644
--- a/arch/powerpc/lib/board.c
+++ b/arch/powerpc/lib/board.c
@@ -1050,15 +1050,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	/* NOTREACHED - no way out of command loop except booting */
 }
 
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
-	for (;;)
-		;
-}
-
-
 #if 0	/* We could use plain global data, but the resulting code is bigger */
 /*
  * Pointer to initial global data area
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index 3752fab..50ec7f9 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -276,10 +276,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index 6e43acf..0789ed0 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -200,12 +200,3 @@ void sh_generic_init(void)
 		main_loop();
 	}
 }
-
-/***********************************************************************/
-
-void hang(void)
-{
-	puts("Board ERROR\n");
-	for (;;)
-		;
-}
diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
index 79fb4c8..fbc535f 100644
--- a/arch/sparc/lib/board.c
+++ b/arch/sparc/lib/board.c
@@ -411,13 +411,4 @@ void board_init_f(ulong bootflag)
 
 }
 
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-#ifdef CONFIG_SHOW_BOOT_PROGRESS
-	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
-#endif
-	for (;;) ;
-}
-
 /************************************************************************/
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index f372898..228c2c8 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -264,10 +264,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	/* NOTREACHED - no way out of command loop except booting */
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
diff --git a/common/board_f.c b/common/board_f.c
index 00ca811..7eaf6b9 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -1003,9 +1003,3 @@ void board_init_f_r(void)
 	hang();
 }
 #endif /* CONFIG_X86 */
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;);
-}
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 6715e0d..7ce2d5f 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -48,13 +48,6 @@ struct spl_image_info spl_image;
 /* Define board data structure */
 static bd_t bdata __attribute__ ((section(".data")));
 
-inline void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
-
 /*
  * Default function to determine if u-boot or the OS should
  * be started. This implementation always returns 1.
diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c
index 09f23c3..edc589e 100644
--- a/drivers/mtd/nand/mxc_nand_spl.c
+++ b/drivers/mtd/nand/mxc_nand_spl.c
@@ -355,12 +355,3 @@ void nand_boot(void)
 		hang();
 	}
 }
-
-/*
- * Called in case of an exception.
- */
-void hang(void)
-{
-	/* Loop forever */
-	while (1) ;
-}
diff --git a/lib/Makefile b/lib/Makefile
index e901cc7..655ed7f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -71,6 +71,7 @@ COBJS-$(CONFIG_BCH) += bch.o
 COBJS-y += crc32.o
 COBJS-y += ctype.o
 COBJS-y += div64.o
+COBJS-y += hang.o
 COBJS-y += linux_string.o
 COBJS-y += string.o
 COBJS-y += time.o
diff --git a/lib/hang.c b/lib/hang.c
new file mode 100644
index 0000000..ef82f7f
--- /dev/null
+++ b/lib/hang.c
@@ -0,0 +1,46 @@
+/*
+ * (C) Copyright 2013
+ * Andreas Bie?mann <andreas.devel@googlemail.com>
+ *
+ * This file consolidates all the different hang() functions implemented in
+ * u-boot.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <bootstage.h>
+
+/**
+ * hang - stop processing by staying in an endless loop
+ *
+ * The purpose of this function is to stop further execution of code cause
+ * something went completely wrong.  To catch this and give some feedback to
+ * the user one needs to catch the bootstage_error (see show_boot_progress())
+ * in the board code.
+ */
+void hang(void)
+{
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
+	puts("### ERROR ### Please RESET the board ###\n");
+#endif
+	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
+	for (;;)
+		;
+}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 5/5] lib: consolidate hang()
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 5/5] lib: consolidate hang() Andreas Bießmann
@ 2013-04-19  8:57       ` Albert ARIBAUD
  2013-05-02 16:05       ` Tom Rini
  1 sibling, 0 replies; 42+ messages in thread
From: Albert ARIBAUD @ 2013-04-19  8:57 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On Fri, 19 Apr 2013 10:48:50 +0200, Andreas Bie?mann
<andreas.devel@googlemail.com> wrote:

> Delete all occurrences of hang() and provide a generic function.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> 
> ---
> Changes in v3:
>  * remove unnecessarily added linux/compiler.h
>  * fix typo in new hang() docu
>  * use simplified macro for SPL_LIBCOMMON_SUPPORT as suggested by Beno?t
> 
> Changes in v2:
>  * delete all hang() and provide generic lib/hang.c
> 
>  arch/arm/cpu/arm926ejs/mxs/spl_boot.c |    7 -----
>  arch/arm/cpu/arm926ejs/spear/spl.c    |    7 -----
>  arch/arm/lib/board.c                  |    6 -----
>  arch/avr32/lib/board.c                |    5 ----
>  arch/blackfin/lib/board.c             |   14 ----------
>  arch/m68k/lib/board.c                 |    7 -----
>  arch/microblaze/lib/board.c           |    7 -----
>  arch/mips/lib/board.c                 |    7 -----
>  arch/nds32/lib/board.c                |    7 -----
>  arch/nios2/lib/board.c                |   11 --------
>  arch/openrisc/lib/board.c             |   12 ---------
>  arch/powerpc/lib/board.c              |    9 -------
>  arch/sandbox/lib/board.c              |    7 -----
>  arch/sh/lib/board.c                   |    9 -------
>  arch/sparc/lib/board.c                |    9 -------
>  arch/x86/lib/board.c                  |    7 -----
>  common/board_f.c                      |    6 -----
>  common/spl/spl.c                      |    7 -----
>  drivers/mtd/nand/mxc_nand_spl.c       |    9 -------
>  lib/Makefile                          |    1 +
>  lib/hang.c                            |   46 +++++++++++++++++++++++++++++++++
>  21 files changed, 47 insertions(+), 153 deletions(-)
>  create mode 100644 lib/hang.c
> 
> diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> index 7e70440..ed525e5 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> +++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
> @@ -148,10 +148,3 @@ inline void board_init_r(gd_t *id, ulong dest_addr)
>  	for (;;)
>  		;
>  }
> -
> -void hang(void) __attribute__ ((noreturn));
> -void hang(void)
> -{
> -	for (;;)
> -		;
> -}
> diff --git a/arch/arm/cpu/arm926ejs/spear/spl.c b/arch/arm/cpu/arm926ejs/spear/spl.c
> index 48e6efb..0101c5d 100644
> --- a/arch/arm/cpu/arm926ejs/spear/spl.c
> +++ b/arch/arm/cpu/arm926ejs/spear/spl.c
> @@ -31,13 +31,6 @@
>  #include <asm/arch/spr_misc.h>
>  #include <asm/arch/spr_syscntl.h>
>  
> -inline void hang(void)
> -{
> -	serial_puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> -
>  static void ddr_clock_init(void)
>  {
>  	struct misc_regs *misc_p = (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 0521178..09ab4ad 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -706,9 +706,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;);
> -}
> diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c
> index 57e07df..ccf862a 100644
> --- a/arch/avr32/lib/board.c
> +++ b/arch/avr32/lib/board.c
> @@ -120,11 +120,6 @@ static int display_banner (void)
>  	return 0;
>  }
>  
> -void hang(void)
> -{
> -	for (;;) ;
> -}
> -
>  static int display_dram_config (void)
>  {
>  	int i;
> diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c
> index 75b6c46..ccea3b9 100644
> --- a/arch/blackfin/lib/board.c
> +++ b/arch/blackfin/lib/board.c
> @@ -432,17 +432,3 @@ void board_init_r(gd_t * id, ulong dest_addr)
>  	for (;;)
>  		main_loop();
>  }
> -
> -void hang(void)
> -{
> -#ifdef CONFIG_STATUS_LED
> -	status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
> -	status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
> -#endif
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	while (1)
> -		/* If a JTAG emulator is hooked up, we'll automatically trigger
> -		 * a breakpoint in it.  If one isn't, this is just a NOP.
> -		 */
> -		asm("emuexcpt;");
> -}
> diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c
> index adaccfe..b2e3068 100644
> --- a/arch/m68k/lib/board.c
> +++ b/arch/m68k/lib/board.c
> @@ -663,10 +663,3 @@ void board_init_r (gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -
> -void hang(void)
> -{
> -	puts ("### ERROR ### Please RESET the board ###\n");
> -	for (;;);
> -}
> diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
> index 4c4f36b..f0987ad 100644
> --- a/arch/microblaze/lib/board.c
> +++ b/arch/microblaze/lib/board.c
> @@ -192,10 +192,3 @@ void board_init_f(ulong not_used)
>  		main_loop();
>  	}
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
> index f19f198..fac7915 100644
> --- a/arch/mips/lib/board.c
> +++ b/arch/mips/lib/board.c
> @@ -344,10 +344,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c
> index a7d27fc..57af1be 100644
> --- a/arch/nds32/lib/board.c
> +++ b/arch/nds32/lib/board.c
> @@ -404,10 +404,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
> index 0f2bc7e..f430ef0 100644
> --- a/arch/nios2/lib/board.c
> +++ b/arch/nios2/lib/board.c
> @@ -162,14 +162,3 @@ void board_init(void)
>  		main_loop();
>  	}
>  }
> -
> -
> -/***********************************************************************/
> -
> -void hang(void)
> -{
> -	disable_interrupts();
> -	puts("### ERROR ### Please reset board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
> index 85aa189..630e45f 100644
> --- a/arch/openrisc/lib/board.c
> +++ b/arch/openrisc/lib/board.c
> @@ -154,15 +154,3 @@ void board_init(void)
>  		main_loop();
>  	}
>  }
> -
> -
> -/***********************************************************************/
> -
> -void hang(void)
> -{
> -	disable_interrupts();
> -	puts("### ERROR ### Please reset board ###\n");
> -
> -	for (;;)
> -		;
> -}
> diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c
> index 422b4a3..41b2294 100644
> --- a/arch/powerpc/lib/board.c
> +++ b/arch/powerpc/lib/board.c
> @@ -1050,15 +1050,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
>  
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> -	for (;;)
> -		;
> -}
> -
> -
>  #if 0	/* We could use plain global data, but the resulting code is bigger */
>  /*
>   * Pointer to initial global data area
> diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
> index 3752fab..50ec7f9 100644
> --- a/arch/sandbox/lib/board.c
> +++ b/arch/sandbox/lib/board.c
> @@ -276,10 +276,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
> index 6e43acf..0789ed0 100644
> --- a/arch/sh/lib/board.c
> +++ b/arch/sh/lib/board.c
> @@ -200,12 +200,3 @@ void sh_generic_init(void)
>  		main_loop();
>  	}
>  }
> -
> -/***********************************************************************/
> -
> -void hang(void)
> -{
> -	puts("Board ERROR\n");
> -	for (;;)
> -		;
> -}
> diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c
> index 79fb4c8..fbc535f 100644
> --- a/arch/sparc/lib/board.c
> +++ b/arch/sparc/lib/board.c
> @@ -411,13 +411,4 @@ void board_init_f(ulong bootflag)
>  
>  }
>  
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -#ifdef CONFIG_SHOW_BOOT_PROGRESS
> -	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> -#endif
> -	for (;;) ;
> -}
> -
>  /************************************************************************/
> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
> index f372898..228c2c8 100644
> --- a/arch/x86/lib/board.c
> +++ b/arch/x86/lib/board.c
> @@ -264,10 +264,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  
>  	/* NOTREACHED - no way out of command loop except booting */
>  }
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> diff --git a/common/board_f.c b/common/board_f.c
> index 00ca811..7eaf6b9 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -1003,9 +1003,3 @@ void board_init_f_r(void)
>  	hang();
>  }
>  #endif /* CONFIG_X86 */
> -
> -void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;);
> -}
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 6715e0d..7ce2d5f 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -48,13 +48,6 @@ struct spl_image_info spl_image;
>  /* Define board data structure */
>  static bd_t bdata __attribute__ ((section(".data")));
>  
> -inline void hang(void)
> -{
> -	puts("### ERROR ### Please RESET the board ###\n");
> -	for (;;)
> -		;
> -}
> -
>  /*
>   * Default function to determine if u-boot or the OS should
>   * be started. This implementation always returns 1.
> diff --git a/drivers/mtd/nand/mxc_nand_spl.c b/drivers/mtd/nand/mxc_nand_spl.c
> index 09f23c3..edc589e 100644
> --- a/drivers/mtd/nand/mxc_nand_spl.c
> +++ b/drivers/mtd/nand/mxc_nand_spl.c
> @@ -355,12 +355,3 @@ void nand_boot(void)
>  		hang();
>  	}
>  }
> -
> -/*
> - * Called in case of an exception.
> - */
> -void hang(void)
> -{
> -	/* Loop forever */
> -	while (1) ;
> -}
> diff --git a/lib/Makefile b/lib/Makefile
> index e901cc7..655ed7f 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -71,6 +71,7 @@ COBJS-$(CONFIG_BCH) += bch.o
>  COBJS-y += crc32.o
>  COBJS-y += ctype.o
>  COBJS-y += div64.o
> +COBJS-y += hang.o
>  COBJS-y += linux_string.o
>  COBJS-y += string.o
>  COBJS-y += time.o
> diff --git a/lib/hang.c b/lib/hang.c
> new file mode 100644
> index 0000000..ef82f7f
> --- /dev/null
> +++ b/lib/hang.c
> @@ -0,0 +1,46 @@
> +/*
> + * (C) Copyright 2013
> + * Andreas Bie?mann <andreas.devel@googlemail.com>
> + *
> + * This file consolidates all the different hang() functions implemented in
> + * u-boot.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <bootstage.h>
> +
> +/**
> + * hang - stop processing by staying in an endless loop
> + *
> + * The purpose of this function is to stop further execution of code cause
> + * something went completely wrong.  To catch this and give some feedback to
> + * the user one needs to catch the bootstage_error (see show_boot_progress())
> + * in the board code.
> + */
> +void hang(void)
> +{
> +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
> +	puts("### ERROR ### Please RESET the board ###\n");
> +#endif
> +	bootstage_error(BOOTSTAGE_ID_NEED_RESET);
> +	for (;;)
> +		;
> +}

For ARM:

Acked-by: Albert ARIBAUD <albert.u.boot@aribaud.net>

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 4/5] tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 4/5] tx25: " Andreas Bießmann
@ 2013-04-19  9:00       ` Benoît Thébaudeau
  2013-04-19  9:43         ` Andreas Bießmann
  0 siblings, 1 reply; 42+ messages in thread
From: Benoît Thébaudeau @ 2013-04-19  9:00 UTC (permalink / raw)
  To: u-boot

Dear Andreas Bie?mann,

On Friday, April 19, 2013 10:48:49 AM, Andreas Bie?mann wrote:
> In order to use the generic hang() later on pull libgeneric in SPL.
> This has no impact on the SPL size.
> 
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
> ---
> Changes in v3: None
> Changes in v2: None
> 
>  include/configs/tx25.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/configs/tx25.h b/include/configs/tx25.h
> index e72f8f6..d61a218 100644
> --- a/include/configs/tx25.h
> +++ b/include/configs/tx25.h
> @@ -37,6 +37,7 @@
>  #define CONFIG_SPL_LDSCRIPT		"arch/$(ARCH)/cpu/u-boot-spl.lds"
>  #define CONFIG_SPL_MAX_SIZE		2048
>  #define CONFIG_SPL_NAND_SUPPORT
> +#define CONFIG_SPL_LIBGENERIC_SUPPORT
>  
>  #define CONFIG_SPL_TEXT_BASE		0x810c0000
>  #define CONFIG_SYS_TEXT_BASE		0x81200000
> --
> 1.7.10.4
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

v3 5/5 seems to be missing?

Best regards,
Beno?t

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 4/5] tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
  2013-04-19  9:00       ` Benoît Thébaudeau
@ 2013-04-19  9:43         ` Andreas Bießmann
  0 siblings, 0 replies; 42+ messages in thread
From: Andreas Bießmann @ 2013-04-19  9:43 UTC (permalink / raw)
  To: u-boot

Dear Beno?t Th?baudeau,

On 04/19/2013 11:00 AM, Beno?t Th?baudeau wrote:
> Dear Andreas Bie?mann,
> 
> On Friday, April 19, 2013 10:48:49 AM, Andreas Bie?mann wrote:
>> In order to use the generic hang() later on pull libgeneric in SPL.
>> This has no impact on the SPL size.
>>
>> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>> ---
>> Changes in v3: None
>> Changes in v2: None
>>

> v3 5/5 seems to be missing?

moderator approval due to long cc list, should hit the ml soon.

Best regards

Andreas Bie?mann

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 0/5] consolidate hang()
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
                       ` (4 preceding siblings ...)
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 5/5] lib: consolidate hang() Andreas Bießmann
@ 2013-04-25 21:44     ` Simon Glass
  2013-05-02 16:06     ` Tom Rini
  6 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2013-04-25 21:44 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On Fri, Apr 19, 2013 at 1:48 AM, Andreas Bie?mann
<andreas.devel@googlemail.com> wrote:
> This series started with intention to make a hung board visualize the
> (end-)user that it does hang(). The first approach was to make all the
> different hang() functions weak and provide board specific versions to
> implement the 'visualization' there.
> After some discussion it turned out, that there is still an interface to
> visualize such states to the user: the 'bootstage' stuff.
>
> BTW:
> This is my first try sending a series with patman. All I can say is:
> patman is really cool ;)
>
> The 'microblaze: fix style in board.c' is an leftover from the first approach.
>
> The 'nios2: fix style in board.c' is an leftover from the first approach.
>
> The 'lib: consolidate hang()' is build tested on arm and avr32. It may
> produces errors on other arches like ppc cause the previous SPL inlined hang()
> function was also removed.  We need to discuss if we always pull in the
> libgeneric unconditional into SPL or provide a second hang() for those boards
> which do not link against libgeneric in SPL.
>
> Since v2 got a complete (compile-)test on powerpc by Wolfgang I think we can
> stick with the current solution.  v3 includes some minor changes mentioned in
> the changelog of respective patches.

This series tested on snow with CONFIG_SYS_GENERIC_BOARD enabled. No
warnings or problems noted and hang() still works.

Tested-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

>
> Changes in v3:
>  * shorten error string for 'no FDT'
>  * remove unnecessarily added linux/compiler.h
>  * fix typo in new hang() docu
>  * use simplified macro for SPL_LIBCOMMON_SUPPORT as suggested by Beno?t
>
> Changes in v2:
>  * delete all hang() and provide generic lib/hang.c
>
> Andreas Bie?mann (5):
>   microblaze: fix style in board.c
>   nios2: fix style in board.c.
>   mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT
>   tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT
>   lib: consolidate hang()
>

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 5/5] lib: consolidate hang()
  2013-04-19  8:48     ` [U-Boot] [PATCH v3 5/5] lib: consolidate hang() Andreas Bießmann
  2013-04-19  8:57       ` Albert ARIBAUD
@ 2013-05-02 16:05       ` Tom Rini
  1 sibling, 0 replies; 42+ messages in thread
From: Tom Rini @ 2013-05-02 16:05 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 19, 2013 at 10:48:50AM +0200, Andreas Bie??mann wrote:

> Delete all occurrences of hang() and provide a generic function.
> 
> Signed-off-by: Andreas Bie??mann <andreas.devel@googlemail.com>

With the following:

diff --git a/lib/hang.c b/lib/hang.c
index ef82f7f..fc1286c 100644
--- a/lib/hang.c
+++ b/lib/hang.c
@@ -37,7 +37,8 @@
  */
 void hang(void)
 {
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
+#if !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && \
+		defined(CONFIG_SPL_SERIAL_SUPPORT))
 	puts("### ERROR ### Please RESET the board ###\n");
 #endif
 	bootstage_error(BOOTSTAGE_ID_NEED_RESET);

To fix build breakage when LIBCOMMON is set, but SERIAL is not and thus
we had a build failure, applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130502/5efae8f0/attachment.pgp>

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [U-Boot] [PATCH v3 0/5] consolidate hang()
  2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
                       ` (5 preceding siblings ...)
  2013-04-25 21:44     ` [U-Boot] [PATCH v3 0/5] " Simon Glass
@ 2013-05-02 16:06     ` Tom Rini
  6 siblings, 0 replies; 42+ messages in thread
From: Tom Rini @ 2013-05-02 16:06 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 19, 2013 at 10:48:45AM +0200, Andreas Bie??mann wrote:

> This series started with intention to make a hung board visualize the
> (end-)user that it does hang(). The first approach was to make all the
> different hang() functions weak and provide board specific versions to
> implement the 'visualization' there.
> After some discussion it turned out, that there is still an interface to
> visualize such states to the user: the 'bootstage' stuff.

With a change to 5/5, applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130502/ea388d06/attachment.pgp>

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2013-05-02 16:06 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-16 10:14 [U-Boot] [PATCH] make hang() a weak function Andreas Bießmann
2013-04-16 10:29 ` Stefan Roese
2013-04-16 11:10 ` Graeme Russ
2013-04-16 11:36 ` Albert ARIBAUD
2013-04-16 11:45   ` Andreas Bießmann
2013-04-16 12:22     ` Wolfgang Denk
2013-04-16 12:58       ` Andreas Bießmann
2013-04-16 13:05         ` Wolfgang Denk
2013-04-16 13:32           ` Andreas Bießmann
2013-04-16 13:35             ` Graeme Russ
2013-04-16 14:15               ` Andreas Bießmann
2013-04-16 14:20                 ` Graeme Russ
2013-04-16 14:23                 ` Wolfgang Denk
2013-04-16 14:40                   ` Andreas Bießmann
2013-04-16 15:14                     ` Wolfgang Denk
2013-04-16 15:34                       ` Andreas Bießmann
2013-04-16 16:00                         ` Wolfgang Denk
2013-04-16 16:14                           ` Andreas Bießmann
2013-04-16 14:17             ` Wolfgang Denk
2013-04-17 11:02 ` [U-Boot] [PATCH v2 0/5] consolidate hang() Andreas Bießmann
2013-04-17 11:02   ` [U-Boot] [PATCH v2 1/5] microblaze: fix style in board.c Andreas Bießmann
2013-04-17 11:44     ` Michal Simek
2013-04-17 11:54       ` Andreas Bießmann
2013-04-17 11:56         ` Michal Simek
2013-04-17 11:02   ` [U-Boot] [PATCH v2 2/5] nios2: " Andreas Bießmann
2013-04-17 11:02   ` [U-Boot] [PATCH v2 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT Andreas Bießmann
2013-04-17 11:02   ` [U-Boot] [PATCH v2 4/5] tx25: " Andreas Bießmann
2013-04-17 11:02   ` [U-Boot] [PATCH v2 5/5] lib: consolidate hang() Andreas Bießmann
2013-04-17 12:58     ` Benoît Thébaudeau
2013-04-18 19:40   ` [U-Boot] [PATCH v2 0/5] " Wolfgang Denk
2013-04-19  8:48   ` [U-Boot] [PATCH v3 " Andreas Bießmann
2013-04-19  8:48     ` [U-Boot] [PATCH v3 1/5] microblaze: fix style in board.c Andreas Bießmann
2013-04-19  8:48     ` [U-Boot] [PATCH v3 2/5] nios2: " Andreas Bießmann
2013-04-19  8:48     ` [U-Boot] [PATCH v3 3/5] mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT Andreas Bießmann
2013-04-19  8:48     ` [U-Boot] [PATCH v3 4/5] tx25: " Andreas Bießmann
2013-04-19  9:00       ` Benoît Thébaudeau
2013-04-19  9:43         ` Andreas Bießmann
2013-04-19  8:48     ` [U-Boot] [PATCH v3 5/5] lib: consolidate hang() Andreas Bießmann
2013-04-19  8:57       ` Albert ARIBAUD
2013-05-02 16:05       ` Tom Rini
2013-04-25 21:44     ` [U-Boot] [PATCH v3 0/5] " Simon Glass
2013-05-02 16:06     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.