From 016082f85e30d1bc24c3c9713476e5e8d8584668 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 14 Aug 2013 21:16:21 +0200 Subject: 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 --- common/globalvar.c | 12 ++++++++++-- common/reset_source.c | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'common') 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 #include #include +#include +#include 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 2a7f9ff6cc..fdc30f4853 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; } -- cgit v1.2.3