From 00caae6d47645e68d6e5277aceb69592b49381a6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 3 Aug 2017 12:22:12 -0600 Subject: 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 Signed-off-by: Simon Glass --- include/_exports.h | 2 +- include/asm-generic/global_data.h | 2 +- include/common.h | 32 +++++++++++++++++++++++++------- include/exports.h | 2 +- include/image.h | 2 +- 5 files changed, 29 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/_exports.h b/include/_exports.h index 9deed77..5416041 100644 --- a/include/_exports.h +++ b/include/_exports.h @@ -31,7 +31,7 @@ EXPORT_FUNC(vprintf, int, vprintf, const char *, va_list) EXPORT_FUNC(do_reset, int, do_reset, cmd_tbl_t *, int , int , char * const []) - EXPORT_FUNC(getenv, char *, getenv, const char*) + EXPORT_FUNC(env_get, char *, env_get, const char*) EXPORT_FUNC(env_set, int, env_set, const char *, const char *) EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul, const char *, char **, unsigned int) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 8b32d51..944f581 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -76,7 +76,7 @@ typedef struct global_data { struct device_node *of_root; #endif struct jt_funcs *jt; /* jump table */ - char env_buf[32]; /* buffer for getenv() before reloc. */ + char env_buf[32]; /* buffer for env_get() before reloc. */ #ifdef CONFIG_TRACE void *trace_buff; /* The trace buffer */ #endif diff --git a/include/common.h b/include/common.h index 3f884d5..7574ca7 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 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); diff --git a/include/exports.h b/include/exports.h index 6522d78..ebe81d9 100644 --- a/include/exports.h +++ b/include/exports.h @@ -27,7 +27,7 @@ unsigned long get_timer(unsigned long); int vprintf(const char *, va_list); unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base); int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); -char *getenv (const char *name); +char *env_get(const char *name); int env_set(const char *varname, const char *value); long simple_strtol(const char *cp, char **endp, unsigned int base); int strcmp(const char *cs, const char *ct); diff --git a/include/image.h b/include/image.h index c6f1513..c4fe4cf 100644 --- a/include/image.h +++ b/include/image.h @@ -373,7 +373,7 @@ typedef struct bootm_headers { bd_t *kbd; #endif - int verify; /* getenv("verify")[0] != 'n' */ + int verify; /* env_get("verify")[0] != 'n' */ #define BOOTM_STATE_START (0x00000001) #define BOOTM_STATE_FINDOS (0x00000002) -- cgit v1.1