Skip to content

Commit

Permalink
Change env_get_char from a global function ptr to a function.
Browse files Browse the repository at this point in the history
This avoids an early global data reference.

Signed-off-by: Joakim Tjernlund <[email protected]>
  • Loading branch information
joakim-tjernlund authored and wdenx committed Apr 17, 2008
1 parent 3dfd4aa commit c0559be
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*****************************************************************************
Expand Down
3 changes: 0 additions & 3 deletions common/cmd_nvedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 13 additions & 6 deletions common/env_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -182,6 +181,19 @@ 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);

return (c);
}

uchar *env_get_addr (int index)
{
if (gd->env_valid) {
Expand Down Expand Up @@ -215,11 +227,6 @@ void env_relocate (void)
DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
#endif

/*
* After relocation to RAM, we can always use the "memory" functions
*/
env_get_char = env_get_char_memory;

if (gd->env_valid == 0) {
#if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */
puts ("Using default environment\n\n");
Expand Down
1 change: 0 additions & 1 deletion common/env_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ env_t *env_ptr = NULL;

char * env_name_spec = "EEPROM";

extern uchar (*env_get_char)(int);
extern uchar env_get_char_memory (int index);


Expand Down
1 change: 0 additions & 1 deletion common/env_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ char * env_name_spec = "NVRAM";
extern uchar default_environment[];
extern int default_environment_size;

extern uchar (*env_get_char)(int);
extern uchar env_get_char_memory (int index);

#ifdef CONFIG_AMIGAONEG3SE
Expand Down
2 changes: 0 additions & 2 deletions common/ft_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ void *ft_get_prop(void *bphp, const char *propname, int *szp)

/********************************************************************/

/* Function that returns a character from the environment */
extern uchar(*env_get_char) (int);

void ft_setup(void *blob, bd_t * bd, ulong initrd_start, ulong initrd_end)
{
Expand Down
1 change: 1 addition & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ extern ulong load_addr; /* Default Load Address */
/* common/cmd_nvedit.c */
int env_init (void);
void env_relocate (void);
uchar env_get_char (int);
int envmatch (uchar *, int);
char *getenv (char *);
int getenv_r (char *name, char *buf, unsigned len);
Expand Down

0 comments on commit c0559be

Please sign in to comment.