summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>2008-07-06 12:30:09 +0200
committerWolfgang Denk <wd@denx.de>2008-07-09 23:59:30 +0200
commitb502611b51f02718c2d1117d4981dabceb5af6de (patch)
tree64f54df2c15bfbe3cfda0e7c3cba2ad334817220
parent27269417ade432189b234d9fbac98b54e37b978c (diff)
Change env_get_char from a global function ptr to a function
This avoids an early global data reference. Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
-rw-r--r--common/env_common.c19
-rw-r--r--include/environment.h4
2 files changed, 15 insertions, 8 deletions
diff --git a/common/env_common.c b/common/env_common.c
index e6df9a5883..5ac14e89c4 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
@@ -183,6 +182,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) {
@@ -216,11 +228,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");
diff --git a/include/environment.h b/include/environment.h
index bf9f669127..dcb7c5a385 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -107,8 +107,8 @@ typedef struct environment_s {
unsigned char data[ENV_SIZE]; /* Environment data */
} env_t;
-/* Pointer to function that returns a character from the environment */
-extern unsigned char (*env_get_char)(int);
+/* Function that returns a character from the environment */
+unsigned char env_get_char (int);
/* Function that returns a pointer to a value from the environment */
unsigned char *env_get_addr(int);