diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-08-14 21:16:21 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-08-16 08:40:33 +0200 |
commit | 016082f85e30d1bc24c3c9713476e5e8d8584668 (patch) | |
tree | 4ce0191421d7ca78d74f5a6da77051e6ca57130e /common/globalvar.c | |
parent | ba3b39d5f0f5523b6895308d35874726009647fa (diff) | |
download | barebox-016082f85e30d1bc24c3c9713476e5e8d8584668.tar.gz barebox-016082f85e30d1bc24c3c9713476e5e8d8584668.tar.xz |
globalvar: Allow to set initial value
Calling globalvar_add_simple() and setting a value is more than common.
Add a parameter for the initial value.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/globalvar.c')
-rw-r--r-- | common/globalvar.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/common/globalvar.c b/common/globalvar.c index abcd881adf..6fd1d88522 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -2,6 +2,8 @@ #include <malloc.h> #include <globalvar.h> #include <init.h> +#include <environment.h> +#include <generated/utsrelease.h> static struct device_d global_device = { .name = "global", @@ -61,9 +63,15 @@ void globalvar_set_match(const char *match, const char *val) * * add a new globalvar named 'name' */ -int globalvar_add_simple(const char *name) +int globalvar_add_simple(const char *name, const char *value) { - return globalvar_add(name, NULL, NULL, 0); + int ret; + + ret = globalvar_add(name, NULL, NULL, 0); + if (ret && ret != -EEXIST) + return ret; + + return dev_set_param(&global_device, name, value); } static int globalvar_init(void) |