summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-11-24 08:22:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-11-24 08:23:29 +0100
commitd49bdc8316bcb39630330307c601d7885e9f3560 (patch)
tree2d892ba4dd0db7fdb6a598ac51ab03309ab3205a
parent834527a5f9bfa378647f1602a41742a01b5a1b18 (diff)
downloadbarebox-d49bdc8316bcb39630330307c601d7885e9f3560.tar.gz
nvvar: Initialze from underlying device parameter
When a nvvar is added with a NULL parameter then it's initialized with the value of the underlying global variable. Do this aswell when the nvvar is a device parameter. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/globalvar.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/common/globalvar.c b/common/globalvar.c
index 29d158e..9e98f63 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -199,6 +199,8 @@ static int nv_param_set(struct device_d *dev, struct param_d *p, const char *val
static int __nvvar_add(const char *name, const char *value)
{
struct param_d *p;
+ struct device_d *dev = NULL;
+ const char *pname;
int ret;
if (!IS_ENABLED(CONFIG_NVVAR))
@@ -220,7 +222,12 @@ static int __nvvar_add(const char *name, const char *value)
if (value)
return nv_set(&nv_device, p, value);
- value = dev_get_param(&global_device, name);
+ ret = nvvar_device_dispatch(name, &dev, &pname);
+ if (ret > 0)
+ value = dev_get_param(dev, pname);
+ else
+ value = dev_get_param(&global_device, name);
+
if (value) {
free(p->value);
p->value = xstrdup(value);