summaryrefslogtreecommitdiff
path: root/include/common.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-08-03 12:22:12 -0600
committerTom Rini <trini@konsulko.com>2017-08-16 08:30:24 -0400
commit00caae6d47645e68d6e5277aceb69592b49381a6 (patch)
treec361aa0cea3093b93c1118266fe9e2b44ac6e453 /include/common.h
parentfd1e959e91d2b0b2e853d09dd9167dfff18a616c (diff)
env: Rename getenv/_f() to env_get()
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/include/common.h b/include/common.h
index 3f884d536e..7574ca754c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -311,12 +311,30 @@ int env_init (void);
void env_relocate (void);
int envmatch (uchar *, int);
-/* Avoid unfortunate conflict with libc's getenv() */
-#ifdef CONFIG_SANDBOX
-#define getenv uboot_getenv
-#endif
-char *getenv (const char *);
-int getenv_f (const char *name, char *buf, unsigned len);
+/**
+ * env_get() - Look up the value of an environment variable
+ *
+ * In U-Boot proper this can be called before relocation (which is when the
+ * environment is loaded from storage, i.e. GD_FLG_ENV_READY is 0). In that
+ * case this function calls env_get_f().
+ *
+ * @varname: Variable to look up
+ * @return value of variable, or NULL if not found
+ */
+char *env_get(const char *varname);
+
+/**
+ * env_get_f() - Look up the value of an environment variable (early)
+ *
+ * This function is called from env_get() if the environment has not been
+ * loaded yet (GD_FLG_ENV_READY flag is 0). Some environment locations will
+ * support reading the value (slowly) and some will not.
+ *
+ * @varname: Variable to look up
+ * @return value of variable, or NULL if not found
+ */
+int env_get_f(const char *name, char *buf, unsigned len);
+
ulong getenv_ulong(const char *name, int base, ulong default_val);
/**
@@ -722,7 +740,7 @@ int zzip(void *dst, unsigned long *lenp, unsigned char *src,
#include <net.h>
static inline struct in_addr getenv_ip(char *var)
{
- return string_to_ip(getenv(var));
+ return string_to_ip(env_get(var));
}
int pcmcia_init (void);