summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-04-20 08:42:43 +0000
committerTom Rini <trini@ti.com>2013-05-01 11:17:21 -0400
commit76b8f79c299ee8029c64c14a65cb0615bad77319 (patch)
tree083278d0544b8f486c3224fcff4703ebaafd40c5 /include
parentd14da91307d8378ea9a99044165e83b79dec67a1 (diff)
downloadu-boot-imx-76b8f79c299ee8029c64c14a65cb0615bad77319.zip
u-boot-imx-76b8f79c299ee8029c64c14a65cb0615bad77319.tar.gz
u-boot-imx-76b8f79c299ee8029c64c14a65cb0615bad77319.tar.bz2
Add getenv_hex() to return an environment variable as hex
This conversion is required in a number of places in U-Boot. Add a standard function to provide this feature, so we avoid all the different variations in the way it is coded. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/common.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index 76c79ae..28aa4b9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -352,6 +352,19 @@ int envmatch (uchar *, int);
char *getenv (const char *);
int getenv_f (const char *name, char *buf, unsigned len);
ulong getenv_ulong(const char *name, int base, ulong default_val);
+
+/**
+ * getenv_hex() - Return an environment variable as a hex value
+ *
+ * Decode an environment as a hex number (it may or may not have a 0x
+ * prefix). If the environment variable cannot be found, or does not start
+ * with hex digits, the default value is returned.
+ *
+ * @varname: Variable to decode
+ * @default_val: Value to return on error
+ */
+ulong getenv_hex(const char *varname, ulong default_val);
+
/*
* Read an environment variable as a boolean
* Return -1 if variable does not exist (default to true)