diff options
Diffstat (limited to 'arch/mips/au1000/common/prom.c')
-rw-r--r-- | arch/mips/au1000/common/prom.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c index ae7d8c57bf3f..b4b010a2fe36 100644 --- a/arch/mips/au1000/common/prom.c +++ b/arch/mips/au1000/common/prom.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * BRIEF MODULE DESCRIPTION | 3 | * BRIEF MODULE DESCRIPTION |
4 | * PROM library initialisation code, assuming YAMON is the boot loader. | 4 | * PROM library initialisation code, supports YAMON and U-Boot. |
5 | * | 5 | * |
6 | * Copyright 2000, 2001, 2006 MontaVista Software Inc. | 6 | * Copyright 2000, 2001, 2006 MontaVista Software Inc. |
7 | * Author: MontaVista Software, Inc. | 7 | * Author: MontaVista Software, Inc. |
@@ -46,12 +46,6 @@ | |||
46 | extern int prom_argc; | 46 | extern int prom_argc; |
47 | extern char **prom_argv, **prom_envp; | 47 | extern char **prom_argv, **prom_envp; |
48 | 48 | ||
49 | typedef struct | ||
50 | { | ||
51 | char *name; | ||
52 | char *val; | ||
53 | } t_env_var; | ||
54 | |||
55 | 49 | ||
56 | char * prom_getcmdline(void) | 50 | char * prom_getcmdline(void) |
57 | { | 51 | { |
@@ -84,13 +78,21 @@ char *prom_getenv(char *envname) | |||
84 | { | 78 | { |
85 | /* | 79 | /* |
86 | * Return a pointer to the given environment variable. | 80 | * Return a pointer to the given environment variable. |
81 | * YAMON uses "name", "value" pairs, while U-Boot uses "name=value". | ||
87 | */ | 82 | */ |
88 | 83 | ||
89 | t_env_var *env = (t_env_var *)prom_envp; | 84 | char **env = prom_envp; |
90 | 85 | int i = strlen(envname); | |
91 | while (env->name) { | 86 | int yamon = (*env && strchr(*env, '=') == NULL); |
92 | if (strcmp(envname, env->name) == 0) | 87 | |
93 | return env->val; | 88 | while (*env) { |
89 | if (yamon) { | ||
90 | if (strcmp(envname, *env++) == 0) | ||
91 | return *env; | ||
92 | } else { | ||
93 | if (strncmp(envname, *env, i) == 0 && (*env)[i] == '=') | ||
94 | return *env + i + 1; | ||
95 | } | ||
94 | env++; | 96 | env++; |
95 | } | 97 | } |
96 | return NULL; | 98 | return NULL; |