Skip to contentSkip to conversation

make hang() a weak function

PATCH New Andreas Bießmann 9 participants 42 messages Apr 16, 2013 – May 2, 2013

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

PATCH 1/1 make hang() a weak function

This patch also does some minor coding style cleanups.

---
 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(-)
arch/arm/lib/board.c +2 -1
index 0521178..4a00e16 100644
@@ -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")));
arch/avr32/lib/board.c +2 -1
index 57e07df..7e3380a 100644
@@ -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)
 {
arch/blackfin/lib/board.c +2 -1
index 75b6c46..7769962 100644
@@ -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"));
arch/m68k/lib/board.c +2 -1
index adaccfe..93aeafb 100644
@@ -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")));
arch/microblaze/lib/board.c +3 -2
index a7c2f76..e661704 100644
@@ -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")));
arch/mips/lib/board.c +2 -1
index f19f198..ad18440 100644
@@ -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")));
arch/nds32/lib/board.c +2 -1
index a7d27fc..2433d8a 100644
@@ -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")));
arch/nios2/lib/board.c +3 -2
index 1e495d4..517a3a1 100644
@@ -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")));
arch/openrisc/lib/board.c +2 -1
index 85aa189..c5437db 100644
@@ -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")));
arch/powerpc/lib/board.c +2 -2
index 422b4a3..24bb948 100644
@@ -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 */
 /*
arch/sandbox/lib/board.c +2 -1
index 3752fab..fe10e6c 100644
@@ -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")));
arch/sh/lib/board.c +2 -1
index 6e43acf..60be847 100644
@@ -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")));
arch/sparc/lib/board.c +2 -1
index 79fb4c8..ddd735c 100644
@@ -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")));
 
 /************************************************************************/
arch/x86/lib/board.c +2 -1
index f372898..960f323 100644
@@ -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")));
common/board_f.c +2 -1
index 7698891..d811067 100644
@@ -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")));
common/spl/spl.c +2 -1
index 6715e0d..322b7b8 100644
@@ -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
drivers/mtd/nand/mxc_nand_spl.c +2 -1
index 09f23c3..9738045 100644
@@ -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")));
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 make hang() a weak function

Hi Andreas,

Quoted 29 lines · Andreas Bie?mann

This patch also does some minor coding style cleanups.

---
 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(-)
arch/arm/lib/board.c +0 -0
index 0521178..4a00e16 100644

arch/arm/lib/board.c void board_init_r(gd_t *id, ulong dest_addr) · line 715

Quoted 10 lines
arch/arm/lib/board.c +2 -1
@@ -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

#2 lore raw

PATCH 1/1 make hang() a weak function

In reply to Andreas Bießmann

Hi Andreas,

Quoted 3 lines · Andreas Bie?mann

This patch also does some minor coding style cleanups.

Coding style cleanups belong in a separate patch - Rules are rules ;)

Regards,

Graeme

#3 lore raw

PATCH 1/1 make hang() a weak function

In reply to Andreas Bießmann

Hi Andreas,

Quoted 300 lines · Andreas Bie?mann

This patch also does some minor coding style cleanups.

---
 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(-)
arch/arm/lib/board.c +2 -1
index 0521178..4a00e16 100644
@@ -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")));
arch/avr32/lib/board.c +2 -1
index 57e07df..7e3380a 100644
@@ -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)
 {
arch/blackfin/lib/board.c +2 -1
index 75b6c46..7769962 100644
@@ -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"));
arch/m68k/lib/board.c +2 -1
index adaccfe..93aeafb 100644
@@ -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")));
arch/microblaze/lib/board.c +3 -2
index a7c2f76..e661704 100644
@@ -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")));
arch/mips/lib/board.c +2 -1
index f19f198..ad18440 100644
@@ -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")));
arch/nds32/lib/board.c +2 -1
index a7d27fc..2433d8a 100644
@@ -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")));
arch/nios2/lib/board.c +3 -2
index 1e495d4..517a3a1 100644
@@ -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")));
arch/openrisc/lib/board.c +2 -1
index 85aa189..c5437db 100644
@@ -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")));
arch/powerpc/lib/board.c +2 -2
index 422b4a3..24bb948 100644
@@ -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 */
 /*
arch/sandbox/lib/board.c +2 -1
index 3752fab..fe10e6c 100644
@@ -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")));
arch/sh/lib/board.c +2 -1
index 6e43acf..60be847 100644
@@ -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")));
arch/sparc/lib/board.c +2 -1
index 79fb4c8..ddd735c 100644
@@ -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")));
 
 /************************************************************************/
arch/x86/lib/board.c +2 -1
index f372898..960f323 100644
@@ -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")));
common/board_f.c +2 -1
index 7698891..d811067 100644
@@ -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")));
common/spl/spl.c +2 -1
index 6715e0d..322b7b8 100644
@@ -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
drivers/mtd/nand/mxc_nand_spl.c +0 -0
index 09f23c3..9738045 100644

drivers/mtd/nand/mxc_nand_spl.c void nand_boot(void) · line 367

Quoted 10 lines
drivers/mtd/nand/mxc_nand_spl.c +2 -1
@@ -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,

Signature · 1 line
Albert.
#4 lore raw

PATCH 1/1 make hang() a weak function

Hi Albert,

Quoted 28 lines · Albert ARIBAUD

Hi Andreas,

Quoted 23 lines · Andreas Bie?mann

This patch also does some minor coding style cleanups.

---
 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>

Quoted 5 lines

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

#5 lore raw

PATCH 1/1 make hang() a weak function

Dear "Andreas Bie?mann",

Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 5 lines

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

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Keep your eyes wide open before marriage, half shut afterwards.
                                                 -- Benjamin Franklin
#6 lore raw

PATCH 1/1 make hang() a weak function

Dear Wolfgang Denk,

Quoted 9 lines · Wolfgang Denk

Dear "Andreas Bie?mann",

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 5 lines

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.

Quoted 4 lines
Quoted 2 lines

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

#7 lore raw

PATCH 1/1 make hang() a weak function

Dear Andreas,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 2 lines

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.

Quoted 2 lines

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

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
God made machine language; all the rest is the work of man.
#8 lore raw

PATCH 1/1 make hang() a weak function

Dear Wolfgang,

Quoted 11 lines · Wolfgang Denk

Dear Andreas,

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 2 lines

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.

Quoted 6 lines

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---

Quoted 3 lines

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.

Quoted 2 lines

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

#9 lore raw

PATCH 1/1 make hang() a weak function

Hi Andreas,

Quoted 11 lines · Andreas Bie?mann

Dear Wolfgang,

Quoted 7 lines · Wolfgang Denk

Dear Andreas,

Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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.

Quoted 21 lines
Quoted 7 lines

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---

Quoted 4 lines

---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");

Quoted 4 lines

arch/arm/lib/board.c- for (;;);
arch/arm/lib/board.c-}
--->8---

Quoted 8 lines

---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

Quoted 9 lines
Quoted 3 lines

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.

Quoted 4 lines
Quoted 2 lines

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

#10 lore raw

PATCH 1/1 make hang() a weak function

Hi Graeme,

Quoted 12 lines · Graeme Russ

Hi Andreas,

Quoted 7 lines · On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bie?mann <andreas.devel at…

Dear Wolfgang,

Quoted 3 lines · Wolfgang Denk

Dear Andreas,

In message <[email protected]

<mailto:[email protected]>> you wrote:

<snip>

Quoted 1 line

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

Ok.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

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.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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

#11 lore raw

PATCH 1/1 make hang() a weak function

Hi Andreas,

Quoted 8 lines · Andreas Bie?mann

Hi Graeme,

Quoted 4 lines · Graeme Russ

Hi Andreas,

On Tue, Apr 16, 2013 at 11:32 PM, Andreas Bie?mann <andreas.devel at googlemail.com <mailto:[email protected]>>

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines

Dear Wolfgang,

Quoted 2 lines · Wolfgang Denk

Dear Andreas,

Quoted 11 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

In message <[email protected]

<mailto:[email protected]>> you wrote:

<snip>

Quoted 1 line

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

Ok.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

simple stack backtrace and see exactly where you are hanging, and

why.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

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.

Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

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

#12 lore raw

PATCH 1/1 make hang() a weak function

In reply to Andreas Bießmann

Dear Andreas,

Quoted 4 lines · In message <[email protected]> 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

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Overdrawn?  But I still have checks left!
#13 lore raw

PATCH 1/1 make hang() a weak function

Dear Wolfgang,

Quoted 15 lines · Wolfgang Denk

Dear Andreas,

Quoted 4 lines · In message <[email protected]> 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.

Quoted 6 lines

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.

Quoted 2 lines

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

#14 lore raw

PATCH 1/1 make hang() a weak function

Dear Andreas,

Quoted 7 lines · In message <[email protected]> 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.

Quoted 3 lines

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

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
F u cn rd ths u cnt spl wrth a dm!
#15 lore raw

PATCH 1/1 make hang() a weak function

Dear Wolfgang,

Quoted 11 lines · Wolfgang Denk

Dear Andreas,

Quoted 7 lines · In message <[email protected]> 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?

Quoted 2 lines

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.

Quoted 2 lines

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.

Quoted 3 lines

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.

Quoted 6 lines
Quoted 3 lines

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

#16 lore raw

PATCH 1/1 make hang() a weak function

Dear Andreas,

Quoted 5 lines · In message <[email protected]> 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.

Quoted 4 lines
Quoted 2 lines

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.

Quoted 6 lines
Quoted 3 lines

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

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
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
#17 lore raw

PATCH 1/1 make hang() a weak function

Dear Wolfgang,

Quoted 8 lines · Wolfgang Denk

Dear Andreas,

Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 3 lines

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.

Quoted 6 lines
Quoted 2 lines

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

#18 lore raw

PATCH 1/1 make hang() a weak function

In reply to Andreas Bießmann

Dear Andreas,

Quoted 3 lines · In message <[email protected]> you wrote:

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

Yes, I know :-(

Quoted 8 lines

---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.

Quoted 9 lines
Quoted 3 lines

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.

Quoted 4 lines
Quoted 2 lines

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

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
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 <[email protected]>
#19 lore raw

v2 cover consolidate hang()

In reply to Andreas Bießmann

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
Signature · 1 line
1.7.10.4
#20 lore raw

PATCH v2 1/5 microblaze: fix style in board.c

Make microblaze's board.c checkpatch clean.

---
Changes in v2: None

 arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)
arch/microblaze/lib/board.c +32 -32
index a7c2f76..846ffe1 100644
@@ -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 (;;)
+		;
 }
Signature · 1 line
1.7.10.4
maintainer
#21 lore raw

PATCH v2 1/5 microblaze: fix style in board.c

Quoted 52 lines · Andreas Bie?mann

Make microblaze's board.c checkpatch clean.

---
Changes in v2: None

 arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)
arch/microblaze/lib/board.c +8 -9
index a7c2f76..846ffe1 100644
@@ -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();
 	}

arch/microblaze/lib/board.c void board_init_f(ulong not_used) · line 122

Quoted 10 lines
arch/microblaze/lib/board.c +3 -4
 
 #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

Signature · 5 lines
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
#22 lore raw

PATCH v2 1/5 microblaze: fix style in board.c

Dear Michal Simek,

Quoted 18 lines · Michal Simek
Quoted 15 lines · Andreas Bie?mann

Make microblaze's board.c checkpatch clean.

---
Changes in v2: None

 arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)
arch/microblaze/lib/board.c +0 -0
index a7c2f76..846ffe1 100644
@@ -71,15 +71,15 @@ void board_init_f(ulong not_used)
Quoted 12 lines

arch/microblaze/lib/board.c void board_init_f(ulong not_used) · line 122

Quoted 9 lines
arch/microblaze/lib/board.c +3 -4
 #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

maintainer
#23 lore raw

PATCH v2 1/5 microblaze: fix style in board.c

Quoted 34 lines · Andreas Bie?mann

Dear Michal Simek,

Quoted 18 lines · Michal Simek
Quoted 15 lines · Andreas Bie?mann

Make microblaze's board.c checkpatch clean.

---
Changes in v2: None

 arch/microblaze/lib/board.c |   64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)
arch/microblaze/lib/board.c +0 -0
index a7c2f76..846ffe1 100644
@@ -71,15 +71,15 @@ void board_init_f(ulong not_used)
Quoted 12 lines

arch/microblaze/lib/board.c void board_init_f(ulong not_used) · line 122

Quoted 9 lines
arch/microblaze/lib/board.c +3 -4
 #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.

Quoted 3 lines

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

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

Signature · 5 lines
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
#24 lore raw

PATCH v2 2/5 nios2: fix style in board.c.

In reply to Andreas Bießmann

Make nios2's board.c checkpatch clean.

---
Changes in v2: None

 arch/nios2/lib/board.c |   43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)
arch/nios2/lib/board.c +21 -22
index 1e495d4..0f2bc7e 100644
@@ -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 (;;)
+		;
 }
Signature · 1 line
1.7.10.4
#25 lore raw

PATCH v2 3/5 mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT

In reply to Andreas Bießmann

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

---
Changes in v2: None

 include/configs/mx31pdk.h |    1 +
 1 file changed, 1 insertion(+)
include/configs/mx31pdk.h +1 -0
index 1754595..82ea4fa 100644
@@ -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
Signature · 1 line
1.7.10.4
#26 lore raw

PATCH v2 4/5 tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT

In reply to Andreas Bießmann

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

---
Changes in v2: None

 include/configs/tx25.h |    1 +
 1 file changed, 1 insertion(+)
include/configs/tx25.h +1 -0
index e72f8f6..d61a218 100644
@@ -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
Signature · 1 line
1.7.10.4
#27 lore raw

PATCH v2 5/5 lib: consolidate hang()

In reply to Andreas Bießmann

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

---
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
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +1 -7
index 7e70440..6e6ae30 100644
@@ -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 (;;)
-		;
-}
arch/arm/cpu/arm926ejs/spear/spl.c +0 -7
index 48e6efb..0101c5d 100644
@@ -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;
arch/arm/lib/board.c +1 -6
index 0521178..39a6cf9 100644
@@ -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 (;;);
-}
arch/avr32/lib/board.c +1 -5
index 57e07df..42a013c 100644
@@ -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;
arch/blackfin/lib/board.c +1 -14
index 75b6c46..6b8686b 100644
@@ -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;");
-}
arch/m68k/lib/board.c +0 -7
index adaccfe..b2e3068 100644
@@ -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 (;;);
-}
arch/microblaze/lib/board.c +0 -7
index 846ffe1..2b92ec7 100644
@@ -193,10 +193,3 @@ void board_init_f(ulong not_used)
 		main_loop();
 	}
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
arch/mips/lib/board.c +1 -7
index f19f198..8f8d8bc 100644
@@ -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 (;;)
-		;
-}
arch/nds32/lib/board.c +1 -7
index a7d27fc..f9d9f25 100644
@@ -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 (;;)
-		;
-}
arch/nios2/lib/board.c +1 -11
index 0f2bc7e..5db47d7 100644
@@ -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 (;;)
-		;
-}
arch/openrisc/lib/board.c +1 -12
index 85aa189..c74b64a 100644
@@ -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 (;;)
-		;
-}
arch/powerpc/lib/board.c +1 -9
index 422b4a3..f306d7d 100644
@@ -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
arch/sandbox/lib/board.c +1 -7
index 3752fab..bfab0eb 100644
@@ -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 (;;)
-		;
-}
arch/sh/lib/board.c +1 -9
index 6e43acf..be65793 100644
@@ -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 (;;)
-		;
-}
arch/sparc/lib/board.c +1 -9
index 79fb4c8..51bf8cf 100644
@@ -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 (;;) ;
-}
-
 /************************************************************************/
arch/x86/lib/board.c +1 -7
index f372898..2c00004 100644
@@ -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 (;;)
-		;
-}
common/board_f.c +0 -6
index 00ca811..7eaf6b9 100644
@@ -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 (;;);
-}
common/spl/spl.c +0 -7
index 6715e0d..7ce2d5f 100644
@@ -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.
drivers/mtd/nand/mxc_nand_spl.c +1 -9
index 09f23c3..1687bfd 100644
@@ -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) ;
-}
lib/Makefile +1 -0
index e901cc7..655ed7f 100644
@@ -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
lib/hang.c new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#28 lore raw

PATCH v2 5/5 lib: consolidate hang()

Hi Andreas,

Quoted 515 lines · Andreas Bie?mann

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

---
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
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +1 -7
index 7e70440..6e6ae30 100644
@@ -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 (;;)
-		;
-}
arch/arm/cpu/arm926ejs/spear/spl.c +0 -7
index 48e6efb..0101c5d 100644
@@ -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;
arch/arm/lib/board.c +1 -6
index 0521178..39a6cf9 100644
@@ -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 (;;);
-}
arch/avr32/lib/board.c +1 -5
index 57e07df..42a013c 100644
@@ -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;
arch/blackfin/lib/board.c +1 -14
index 75b6c46..6b8686b 100644
@@ -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;");
-}
arch/m68k/lib/board.c +0 -7
index adaccfe..b2e3068 100644
@@ -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 (;;);
-}
arch/microblaze/lib/board.c +0 -7
index 846ffe1..2b92ec7 100644
@@ -193,10 +193,3 @@ void board_init_f(ulong not_used)
 		main_loop();
 	}
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
arch/mips/lib/board.c +1 -7
index f19f198..8f8d8bc 100644
@@ -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 (;;)
-		;
-}
arch/nds32/lib/board.c +1 -7
index a7d27fc..f9d9f25 100644
@@ -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 (;;)
-		;
-}
arch/nios2/lib/board.c +1 -11
index 0f2bc7e..5db47d7 100644
@@ -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 (;;)
-		;
-}
arch/openrisc/lib/board.c +1 -12
index 85aa189..c74b64a 100644
@@ -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 (;;)
-		;
-}
arch/powerpc/lib/board.c +1 -9
index 422b4a3..f306d7d 100644
@@ -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
arch/sandbox/lib/board.c +1 -7
index 3752fab..bfab0eb 100644
@@ -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 (;;)
-		;
-}
arch/sh/lib/board.c +1 -9
index 6e43acf..be65793 100644
@@ -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 (;;)
-		;
-}
arch/sparc/lib/board.c +1 -9
index 79fb4c8..51bf8cf 100644
@@ -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 (;;) ;
-}
-
 /************************************************************************/
arch/x86/lib/board.c +1 -7
index f372898..2c00004 100644
@@ -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 (;;)
-		;
-}
common/board_f.c +0 -6
index 00ca811..7eaf6b9 100644
@@ -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 (;;);
-}
common/spl/spl.c +0 -7
index 6715e0d..7ce2d5f 100644
@@ -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.
drivers/mtd/nand/mxc_nand_spl.c +1 -9
index 09f23c3..1687bfd 100644
@@ -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) ;
-}
lib/Makefile +1 -0
index e901cc7..655ed7f 100644
@@ -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
lib/hang.c new file +31 -0
new file mode 100644
index 0000000..9b6d485
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2013
+ * Andreas Bie?mann <[email protected]>
+ *
+ * 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

lib/hang.c line 41

Quoted 10 lines
lib/hang.c new file +10 -0
+ *
+ * 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)

Quoted 8 lines
lib/hang.c new file +6 -1
+	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

#29 lore raw

v2 cover consolidate hang()

In reply to Andreas Bießmann

Dear Andreas,

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

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.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have the simplest tastes.  I am always satisfied with the best.
                                                       -- Oscar Wilde
#30 lore raw

v3 cover consolidate hang()

In reply to Andreas Bießmann

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
Signature · 1 line
1.7.10.4
#31 lore raw

PATCH v3 1/5 microblaze: fix style in board.c

Make microblaze's board.c checkpatch clean.

---
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(-)
arch/microblaze/lib/board.c +31 -32
index a7c2f76..4c4f36b 100644
@@ -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 (;;)
+		;
 }
Signature · 1 line
1.7.10.4
#32 lore raw

PATCH v3 2/5 nios2: fix style in board.c.

In reply to Andreas Bießmann

Make nios2's board.c checkpatch clean.

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

 arch/nios2/lib/board.c |   43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)
arch/nios2/lib/board.c +21 -22
index 1e495d4..0f2bc7e 100644
@@ -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 (;;)
+		;
 }
Signature · 1 line
1.7.10.4
#33 lore raw

PATCH v3 3/5 mx31pdk: add CONFIG_SPL_LIBGENERIC_SUPPORT

In reply to Andreas Bießmann

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

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

 include/configs/mx31pdk.h |    1 +
 1 file changed, 1 insertion(+)
include/configs/mx31pdk.h +1 -0
index 1754595..82ea4fa 100644
@@ -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
Signature · 1 line
1.7.10.4
#34 lore raw

PATCH v3 4/5 tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT

In reply to Andreas Bießmann

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

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

 include/configs/tx25.h |    1 +
 1 file changed, 1 insertion(+)
include/configs/tx25.h +1 -0
index e72f8f6..d61a218 100644
@@ -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
Signature · 1 line
1.7.10.4
#35 lore raw

PATCH v3 4/5 tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT

Dear Andreas Bie?mann,

Quoted 26 lines · Andreas Bie?mann

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

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

 include/configs/tx25.h |    1 +
 1 file changed, 1 insertion(+)
include/configs/tx25.h +1 -1
index e72f8f6..d61a218 100644
@@ -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

Quoted 4 lines

_______________________________________________
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

#36 lore raw

PATCH v3 4/5 tx25: add CONFIG_SPL_LIBGENERIC_SUPPORT

Dear Beno?t Th?baudeau,

Quoted 6 lines · Beno?t Th?baudeau

Dear Andreas Bie?mann,

Quoted 3 lines · Andreas Bie?mann

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

Quoted 7 lines
Quoted 5 lines

---
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

#37 lore raw

PATCH v3 5/5 lib: consolidate hang()

In reply to Andreas Bießmann

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

---
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
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +0 -7
index 7e70440..ed525e5 100644
@@ -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 (;;)
-		;
-}
arch/arm/cpu/arm926ejs/spear/spl.c +0 -7
index 48e6efb..0101c5d 100644
@@ -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;
arch/arm/lib/board.c +0 -6
index 0521178..09ab4ad 100644
@@ -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 (;;);
-}
arch/avr32/lib/board.c +0 -5
index 57e07df..ccf862a 100644
@@ -120,11 +120,6 @@ static int display_banner (void)
 	return 0;
 }
 
-void hang(void)
-{
-	for (;;) ;
-}
-
 static int display_dram_config (void)
 {
 	int i;
arch/blackfin/lib/board.c +0 -14
index 75b6c46..ccea3b9 100644
@@ -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;");
-}
arch/m68k/lib/board.c +0 -7
index adaccfe..b2e3068 100644
@@ -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 (;;);
-}
arch/microblaze/lib/board.c +0 -7
index 4c4f36b..f0987ad 100644
@@ -192,10 +192,3 @@ void board_init_f(ulong not_used)
 		main_loop();
 	}
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
arch/mips/lib/board.c +0 -7
index f19f198..fac7915 100644
@@ -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 (;;)
-		;
-}
arch/nds32/lib/board.c +0 -7
index a7d27fc..57af1be 100644
@@ -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 (;;)
-		;
-}
arch/nios2/lib/board.c +0 -11
index 0f2bc7e..f430ef0 100644
@@ -162,14 +162,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-	for (;;)
-		;
-}
arch/openrisc/lib/board.c +0 -12
index 85aa189..630e45f 100644
@@ -154,15 +154,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-
-	for (;;)
-		;
-}
arch/powerpc/lib/board.c +0 -9
index 422b4a3..41b2294 100644
@@ -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
arch/sandbox/lib/board.c +0 -7
index 3752fab..50ec7f9 100644
@@ -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 (;;)
-		;
-}
arch/sh/lib/board.c +0 -9
index 6e43acf..0789ed0 100644
@@ -200,12 +200,3 @@ void sh_generic_init(void)
 		main_loop();
 	}
 }
-
-/***********************************************************************/
-
-void hang(void)
-{
-	puts("Board ERROR\n");
-	for (;;)
-		;
-}
arch/sparc/lib/board.c +0 -9
index 79fb4c8..fbc535f 100644
@@ -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 (;;) ;
-}
-
 /************************************************************************/
arch/x86/lib/board.c +0 -7
index f372898..228c2c8 100644
@@ -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 (;;)
-		;
-}
common/board_f.c +0 -6
index 00ca811..7eaf6b9 100644
@@ -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 (;;);
-}
common/spl/spl.c +0 -7
index 6715e0d..7ce2d5f 100644
@@ -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.
drivers/mtd/nand/mxc_nand_spl.c +0 -9
index 09f23c3..edc589e 100644
@@ -355,12 +355,3 @@ void nand_boot(void)
 		hang();
 	}
 }
-
-/*
- * Called in case of an exception.
- */
-void hang(void)
-{
-	/* Loop forever */
-	while (1) ;
-}
lib/Makefile +1 -0
index e901cc7..655ed7f 100644
@@ -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
lib/hang.c new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#38 lore raw

PATCH v3 5/5 lib: consolidate hang()

Hi Andreas,

Quoted 409 lines · Andreas Bie?mann

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

---
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
arch/arm/cpu/arm926ejs/mxs/spl_boot.c +0 -7
index 7e70440..ed525e5 100644
@@ -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 (;;)
-		;
-}
arch/arm/cpu/arm926ejs/spear/spl.c +0 -7
index 48e6efb..0101c5d 100644
@@ -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;
arch/arm/lib/board.c +0 -6
index 0521178..09ab4ad 100644
@@ -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 (;;);
-}
arch/avr32/lib/board.c +0 -5
index 57e07df..ccf862a 100644
@@ -120,11 +120,6 @@ static int display_banner (void)
 	return 0;
 }
 
-void hang(void)
-{
-	for (;;) ;
-}
-
 static int display_dram_config (void)
 {
 	int i;
arch/blackfin/lib/board.c +0 -14
index 75b6c46..ccea3b9 100644
@@ -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;");
-}
arch/m68k/lib/board.c +0 -7
index adaccfe..b2e3068 100644
@@ -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 (;;);
-}
arch/microblaze/lib/board.c +0 -7
index 4c4f36b..f0987ad 100644
@@ -192,10 +192,3 @@ void board_init_f(ulong not_used)
 		main_loop();
 	}
 }
-
-void hang(void)
-{
-	puts("### ERROR ### Please RESET the board ###\n");
-	for (;;)
-		;
-}
arch/mips/lib/board.c +0 -7
index f19f198..fac7915 100644
@@ -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 (;;)
-		;
-}
arch/nds32/lib/board.c +0 -7
index a7d27fc..57af1be 100644
@@ -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 (;;)
-		;
-}
arch/nios2/lib/board.c +0 -11
index 0f2bc7e..f430ef0 100644
@@ -162,14 +162,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-	for (;;)
-		;
-}
arch/openrisc/lib/board.c +0 -12
index 85aa189..630e45f 100644
@@ -154,15 +154,3 @@ void board_init(void)
 		main_loop();
 	}
 }
-
-
-/***********************************************************************/
-
-void hang(void)
-{
-	disable_interrupts();
-	puts("### ERROR ### Please reset board ###\n");
-
-	for (;;)
-		;
-}
arch/powerpc/lib/board.c +0 -9
index 422b4a3..41b2294 100644
@@ -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
arch/sandbox/lib/board.c +0 -7
index 3752fab..50ec7f9 100644
@@ -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 (;;)
-		;
-}
arch/sh/lib/board.c +0 -9
index 6e43acf..0789ed0 100644
@@ -200,12 +200,3 @@ void sh_generic_init(void)
 		main_loop();
 	}
 }
-
-/***********************************************************************/
-
-void hang(void)
-{
-	puts("Board ERROR\n");
-	for (;;)
-		;
-}
arch/sparc/lib/board.c +0 -9
index 79fb4c8..fbc535f 100644
@@ -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 (;;) ;
-}
-
 /************************************************************************/
arch/x86/lib/board.c +0 -7
index f372898..228c2c8 100644
@@ -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 (;;)
-		;
-}
common/board_f.c +0 -6
index 00ca811..7eaf6b9 100644
@@ -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 (;;);
-}
common/spl/spl.c +0 -7
index 6715e0d..7ce2d5f 100644
@@ -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.
drivers/mtd/nand/mxc_nand_spl.c +0 -9
index 09f23c3..edc589e 100644
@@ -355,12 +355,3 @@ void nand_boot(void)
 		hang();
 	}
 }
-
-/*
- * Called in case of an exception.
- */
-void hang(void)
-{
-	/* Loop forever */
-	while (1) ;
-}
lib/Makefile +1 -0
index e901cc7..655ed7f 100644
@@ -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
lib/hang.c new file +36 -0
new file mode 100644
index 0000000..ef82f7f
@@ -0,0 +1,46 @@
+/*
+ * (C) Copyright 2013
+ * Andreas Bie?mann <[email protected]>
+ *
+ * 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.

lib/hang.c line 46

Quoted 10 lines
lib/hang.c new file +10 -0
+ */
+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:

Amicalement,

Signature · 1 line
Albert.
#39 lore raw

PATCH v3 5/5 lib: consolidate hang()

In reply to Andreas Bießmann
Quoted 3 lines · Andreas Bie??mann

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

With the following:

lib/hang.c +2 -1
index ef82f7f..fc1286c 100644
@@ -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!

Signature · 8 lines
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>
#40 lore raw

v3 cover consolidate hang()

In reply to Andreas Bießmann

Hi Andreas,

Quoted 21 lines · Andreas Bie?mann

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.

Quoted 3 lines

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.

Quoted 17 lines

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()

#41 lore raw

v3 cover consolidate hang()

In reply to Andreas Bießmann
Quoted 6 lines · Andreas Bie??mann

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!

Signature · 8 lines
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>