[U-Boot] [PATCH] make hang() a weak function

Albert ARIBAUD albert.u.boot at aribaud.net
Tue Apr 16 13:36:21 CEST 2013


Hi Andreas,

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

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

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

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list