summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-08-14 21:16:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-08-16 08:40:33 +0200
commit016082f85e30d1bc24c3c9713476e5e8d8584668 (patch)
tree4ce0191421d7ca78d74f5a6da77051e6ca57130e /common
parentba3b39d5f0f5523b6895308d35874726009647fa (diff)
downloadbarebox-016082f85e30d1bc24c3c9713476e5e8d8584668.tar.gz
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')
-rw-r--r--common/globalvar.c12
-rw-r--r--common/reset_source.c4
2 files changed, 12 insertions, 4 deletions
diff --git a/common/globalvar.c b/common/globalvar.c
index abcd881..6fd1d88 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)
diff --git a/common/reset_source.c b/common/reset_source.c
index 2a7f9ff..fdc30f4 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -36,8 +36,8 @@ EXPORT_SYMBOL(set_reset_source);
/* ensure this runs after the 'global' device is already registerd */
static int init_reset_source(void)
{
- globalvar_add_simple("system.reset");
- set_reset_source(RESET_UKWN);
+ globalvar_add_simple("system.reset", reset_src_names[RESET_UKWN]);
+
return 0;
}