[U-Boot-Users] [PATCH] Change env_get_char from a global function ptr to a function.

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sun Mar 30 20:08:47 CEST 2008


On 16:45 Fri 28 Mar     , Joakim Tjernlund wrote:
> This avoids an early global data reference.
> 
> ---
> I hope this still applies.
> 
>  api/api.c            |    1 -
>  common/cmd_bootm.c   |    3 ---
>  common/cmd_nvedit.c  |    3 ---
>  common/env_common.c  |   21 +++++++++++++++------
>  common/env_eeprom.c  |    1 -
>  common/env_nvram.c   |    1 -
>  common/fdt_support.c |    4 ----
>  common/ft_build.c    |    3 ---
>  include/common.h     |    1 +
>  9 files changed, 16 insertions(+), 22 deletions(-)
> 
> diff --git a/api/api.c b/api/api.c
> index 0598d90..c1b2b60 100644
> --- a/api/api.c
> +++ b/api/api.c
> @@ -40,7 +40,6 @@
>  
>  /* U-Boot routines needed */
>  extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
> -extern uchar (*env_get_char)(int);
>  extern uchar *env_get_addr(int);
>  
>  /*****************************************************************************
> diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> index 9546729..5062817 100644
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -1150,9 +1150,6 @@ do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
>  
>  #if defined(CONFIG_ARTOS) && defined(CONFIG_PPC)
>  
> -/* Function that returns a character from the environment */
> -extern uchar (*env_get_char)(int);
> -
>  static void
>  do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
>  		int	argc, char *argv[],
> diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
> index dd263b6..15dca5b 100644
> --- a/common/cmd_nvedit.c
> +++ b/common/cmd_nvedit.c
> @@ -68,9 +68,6 @@ DECLARE_GLOBAL_DATA_PTR;
>  /************************************************************************
>  ************************************************************************/
>  
> -/* Function that returns a character from the environment */
> -extern uchar (*env_get_char)(int);
> -
>  /* Function that returns a pointer to a value from the environment */
>  /* (Only memory version supported / needed). */
>  extern uchar *env_get_addr(int);
> diff --git a/common/env_common.c b/common/env_common.c
> index a494812..e87818b 100644
> --- a/common/env_common.c
> +++ b/common/env_common.c
> @@ -50,7 +50,6 @@ extern void env_relocate_spec (void);
>  extern uchar env_get_char_spec(int);
>  
>  static uchar env_get_char_init (int index);
> -uchar (*env_get_char)(int) = env_get_char_init;
>  
>  /************************************************************************
>   * Default settings to be used when no valid environment is found
> @@ -182,6 +181,21 @@ uchar env_get_char_memory (int index)
>  }
>  #endif
>  
> +uchar env_get_char (int index)
> +{
> +	uchar c;
> +
> +	/* if relocated to RAM */
> +	if (gd->flags & GD_FLG_RELOC)
> +	{
> +		c = env_get_char_memory(index);
> +	} else {
> +		c = env_get_char_init(index);
> +	}
Please remove occolade
Best Regards,
J.




More information about the U-Boot mailing list