* [PATCH 1/8] Revert "globalvar: Fix value of new globalvar when nvvar exists"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 2/8] Revert "nv: Fix setting of nv.dev.<devname>.<param> variables" Sascha Hauer
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit f8a177478c1b79e369ecc65501d9d15ff573339f.
---
common/globalvar.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index c528b24062..c48e7df067 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -403,11 +403,11 @@ int globalvar_add_simple(const char *name, const char *value)
return PTR_ERR(param);
}
- globalvar_nv_sync(name);
-
if (value)
dev_set_param(&global_device, name, value);
+ globalvar_nv_sync(name);
+
return 0;
}
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/8] Revert "nv: Fix setting of nv.dev.<devname>.<param> variables"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
2017-06-14 7:26 ` [PATCH 1/8] Revert "globalvar: Fix value of new globalvar when nvvar exists" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 3/8] Revert "globalvar: make nv_device static" Sascha Hauer
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit eaf884ba55def055fd81ff3291a1a534fc8bd8f9.
---
common/globalvar.c | 65 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 23 deletions(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index c48e7df067..1385559fd7 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -120,21 +120,28 @@ void dev_param_init_from_nv(struct device_d *dev, const char *name)
}
/**
- * nvvar_device_set - set device parameter dev.<dev>.<param>
+ * nvvar_device_dispatch - dispatch dev.<dev>.<param> name into device and parameter name
* @name: The incoming name in the form dev.<dev>.<param>
- * val: The value <dev>.<param> should be set to
+ * @dev: The returned device_d * belonging to <dev>
+ * @pname: the parameter name
*
- * Given a dev.<dev>.<param> string this function sets the corresponding parameter
- * in the struct device_d * named <param> to @val.
+ * Given a dev.<dev>.<param> string this function finds the device_d * belonging to
+ * <dev> and the parameter name from <param>.
*
- * Return: 0 for success, negative error code for failure
+ * Return: When incoming string does not belong to the device namespace (does not begin
+ * with "dev." this function returns 0. A value > 0 is returned when the incoming string
+ * is in the device namespace and the string can be dispatched into a device_d * and a
+ * parameter name. A negative error code is returned when the incoming string belongs to
+ * the device namespace, but cannot be dispatched.
*/
-static int nvvar_device_set(const char *name, const char *val)
+static int nvvar_device_dispatch(const char *name, struct device_d **dev,
+ const char **pname)
{
- struct device_d *dev;
char *devname;
- const char *dot, *pname;
- int dotpos, ret;
+ const char *dot;
+ int dotpos;
+
+ *dev = NULL;
if (strncmp(name, "dev.", 4))
return 0;
@@ -148,20 +155,15 @@ static int nvvar_device_set(const char *name, const char *val)
dotpos = dot - name;
devname = xstrndup(name, dotpos);
- dev = get_device_by_name(devname);
+ *dev = get_device_by_name(devname);
free(devname);
- if (dev == &nv_device || dev == &global_device)
+ if (*dev == &nv_device || *dev == &global_device)
return -EINVAL;
- pname = dot + 1;
-
- ret = dev_set_param(dev, pname, val);
- if (ret)
- pr_err("Cannot init param from nv: %s.%s=%s: %s\n",
- dev_name(dev), pname, val, strerror(-ret));
+ *pname = dot + 1;
- return 0;
+ return 1;
}
static int nv_set(struct param_d *p, const char *val)
@@ -172,10 +174,6 @@ static int nv_set(struct param_d *p, const char *val)
if (!val)
val = "";
- ret = nvvar_device_set(p->name, val);
- if (ret)
- return ret;
-
g = get_param_by_name(&global_device, p->name);
if (g) {
ret = dev_set_param(&global_device, p->name, val);
@@ -375,6 +373,27 @@ void globalvar_set_match(const char *match, const char *val)
}
}
+static int globalvar_simple_set(struct param_d *p, const char *val)
+{
+ struct device_d *rdev;
+ const char *pname = NULL;
+ int ret;
+
+ ret = nvvar_device_dispatch(p->name, &rdev, &pname);
+ if (ret < 0)
+ return ret;
+
+ if (ret && rdev) {
+ ret = dev_set_param(rdev, pname, val);
+ if (ret)
+ pr_err("Cannot init param from global: %s.%s=%s: %s\n",
+ dev_name(rdev), pname, val, strerror(-ret));
+ }
+
+ /* Pass to the generic function we have overwritten */
+ return dev_param_set_generic(p, val);
+}
+
static void globalvar_nv_sync(const char *name)
{
const char *val;
@@ -396,7 +415,7 @@ int globalvar_add_simple(const char *name, const char *value)
{
struct param_d *param;
- param = dev_add_param(&global_device, name, NULL, NULL,
+ param = dev_add_param(&global_device, name, globalvar_simple_set, NULL,
0);
if (IS_ERR(param)) {
if (PTR_ERR(param) != -EEXIST)
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/8] Revert "globalvar: make nv_device static"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
2017-06-14 7:26 ` [PATCH 1/8] Revert "globalvar: Fix value of new globalvar when nvvar exists" Sascha Hauer
2017-06-14 7:26 ` [PATCH 2/8] Revert "nv: Fix setting of nv.dev.<devname>.<param> variables" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 4/8] Revert "globalvar: don't use nv_device if CONFIG_NVVAR is disabled" Sascha Hauer
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit f655902cfad63b9ba5cea7d0c9fc9c3632143e02.
---
common/globalvar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index 1385559fd7..9bb363f3a5 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -19,7 +19,7 @@ struct device_d global_device = {
.id = DEVICE_ID_SINGLE,
};
-static struct device_d nv_device = {
+struct device_d nv_device = {
.name = "nv",
.id = DEVICE_ID_SINGLE,
};
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/8] Revert "globalvar: don't use nv_device if CONFIG_NVVAR is disabled"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
` (2 preceding siblings ...)
2017-06-14 7:26 ` [PATCH 3/8] Revert "globalvar: make nv_device static" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 5/8] Revert "param: remove unnecessary device_d * argument" Sascha Hauer
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit b378e8c9427b45d856d052a6df4a879a2cee670c.
---
common/globalvar.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index 9bb363f3a5..d33bc64a13 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -99,9 +99,6 @@ void dev_param_init_from_nv(struct device_d *dev, const char *name)
const char *val;
int ret = 0;
- if (!IS_ENABLED(CONFIG_NVVAR))
- return;
-
if (dev == &nv_device)
return;
if (dev == &global_device)
@@ -398,9 +395,6 @@ static void globalvar_nv_sync(const char *name)
{
const char *val;
- if (!IS_ENABLED(CONFIG_NVVAR))
- return;
-
val = dev_get_param(&nv_device, name);
if (val)
dev_set_param(&global_device, name, val);
@@ -534,8 +528,6 @@ int nvvar_save(void)
const char *env = default_environment_path_get();
int ret;
#define TMPDIR "/.env.tmp"
- if (!IS_ENABLED(CONFIG_NVVAR))
- return -ENOSYS;
if (!nv_dirty || !env)
return 0;
@@ -596,9 +588,7 @@ static int nv_global_param_complete(struct device_d *dev, struct string_list *sl
int nv_global_complete(struct string_list *sl, char *instr)
{
nv_global_param_complete(&global_device, sl, instr, 0);
-
- if (IS_ENABLED(CONFIG_NVVAR))
- nv_global_param_complete(&nv_device, sl, instr, 0);
+ nv_global_param_complete(&nv_device, sl, instr, 0);
return 0;
}
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/8] Revert "param: remove unnecessary device_d * argument"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
` (3 preceding siblings ...)
2017-06-14 7:26 ` [PATCH 4/8] Revert "globalvar: don't use nv_device if CONFIG_NVVAR is disabled" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 6/8] Revert "globalvar: make globalvar functions more consistent" Sascha Hauer
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit 0071bacb4c7cab21c9fab8540f5aa9922a270a85.
---
common/globalvar.c | 14 +++++++-------
include/param.h | 11 ++++++-----
lib/parameter.c | 44 ++++++++++++++++++++++----------------------
3 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index d33bc64a13..2f65ca805f 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -163,7 +163,7 @@ static int nvvar_device_dispatch(const char *name, struct device_d **dev,
return 1;
}
-static int nv_set(struct param_d *p, const char *val)
+static int nv_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_d *g;
int ret;
@@ -184,16 +184,16 @@ static int nv_set(struct param_d *p, const char *val)
return 0;
}
-static const char *nv_param_get(struct param_d *p)
+static const char *nv_param_get(struct device_d *dev, struct param_d *p)
{
return p->value ? p->value : "";
}
-static int nv_param_set(struct param_d *p, const char *val)
+static int nv_param_set(struct device_d *dev, struct param_d *p, const char *val)
{
int ret;
- ret = nv_set(p, val);
+ ret = nv_set(dev, p, val);
if (ret)
return ret;
@@ -216,7 +216,7 @@ static int __nvvar_add(const char *name, const char *value)
}
if (value)
- return nv_set(p, value);
+ return nv_set(&nv_device, p, value);
value = dev_get_param(&global_device, name);
if (value) {
@@ -370,7 +370,7 @@ void globalvar_set_match(const char *match, const char *val)
}
}
-static int globalvar_simple_set(struct param_d *p, const char *val)
+static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct device_d *rdev;
const char *pname = NULL;
@@ -388,7 +388,7 @@ static int globalvar_simple_set(struct param_d *p, const char *val)
}
/* Pass to the generic function we have overwritten */
- return dev_param_set_generic(p, val);
+ return dev_param_set_generic(dev, p, val);
}
static void globalvar_nv_sync(const char *name)
diff --git a/include/param.h b/include/param.h
index dea9d88244..449d3d78e9 100644
--- a/include/param.h
+++ b/include/param.h
@@ -24,8 +24,8 @@ enum param_type {
};
struct param_d {
- const char* (*get)(struct param_d *param);
- int (*set)(struct param_d *param, const char *val);
+ const char* (*get)(struct device_d *, struct param_d *param);
+ int (*set)(struct device_d *, struct param_d *param, const char *val);
void (*info)(struct param_d *param);
unsigned int flags;
char *name;
@@ -43,8 +43,8 @@ int dev_set_param(struct device_d *dev, const char *name, const char *val);
struct param_d *get_param_by_name(struct device_d *dev, const char *name);
struct param_d *dev_add_param(struct device_d *dev, const char *name,
- int (*set)(struct param_d *p, const char *val),
- const char *(*get)(struct param_d *p),
+ int (*set)(struct device_d *dev, struct param_d *p, const char *val),
+ const char *(*get)(struct device_d *, struct param_d *p),
unsigned long flags);
struct param_d *dev_add_param_string(struct device_d *dev, const char *name,
@@ -83,7 +83,8 @@ void dev_remove_param(struct param_d *p);
void dev_remove_parameters(struct device_d *dev);
-int dev_param_set_generic(struct param_d *p, const char *val);
+int dev_param_set_generic(struct device_d *dev, struct param_d *p,
+ const char *val);
#else
static inline const char *dev_get_param(struct device_d *dev, const char *name)
diff --git a/lib/parameter.c b/lib/parameter.c
index ab36b15591..a21b8fa4a4 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -76,7 +76,7 @@ const char *dev_get_param(struct device_d *dev, const char *name)
return NULL;
}
- return param->get(param);
+ return param->get(dev, param);
}
/**
@@ -107,7 +107,7 @@ int dev_set_param(struct device_d *dev, const char *name, const char *val)
return -EACCES;
}
- ret = param->set(param, val);
+ ret = param->set(dev, param, val);
if (ret)
errno = -ret;
@@ -125,7 +125,7 @@ int dev_set_param(struct device_d *dev, const char *name, const char *val)
* used during deregistration of the parameter to free the alloctated
* memory.
*/
-int dev_param_set_generic(struct param_d *p,
+int dev_param_set_generic(struct device_d *dev, struct param_d *p,
const char *val)
{
free(p->value);
@@ -137,7 +137,7 @@ int dev_param_set_generic(struct param_d *p,
return p->value ? 0 : -ENOMEM;
}
-static const char *param_get_generic(struct param_d *p)
+static const char *param_get_generic(struct device_d *dev, struct param_d *p)
{
return p->value ? p->value : "";
}
@@ -151,8 +151,8 @@ static int compare(struct list_head *a, struct list_head *b)
}
static int __dev_add_param(struct param_d *param, struct device_d *dev, const char *name,
- int (*set)(struct param_d *p, const char *val),
- const char *(*get)(struct param_d *p),
+ int (*set)(struct device_d *dev, struct param_d *p, const char *val),
+ const char *(*get)(struct device_d *dev, struct param_d *p),
unsigned long flags)
{
if (get_param_by_name(dev, name))
@@ -194,8 +194,8 @@ static int __dev_add_param(struct param_d *param, struct device_d *dev, const ch
* not use static arrays when using the generic functions.
*/
struct param_d *dev_add_param(struct device_d *dev, const char *name,
- int (*set)(struct param_d *p, const char *val),
- const char *(*get)(struct param_d *param),
+ int (*set)(struct device_d *dev, struct param_d *p, const char *val),
+ const char *(*get)(struct device_d *dev, struct param_d *param),
unsigned long flags)
{
struct param_d *param;
@@ -248,7 +248,7 @@ static inline struct param_string *to_param_string(struct param_d *p)
return container_of(p, struct param_string, param);
}
-static int param_string_set(struct param_d *p, const char *val)
+static int param_string_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_string *ps = to_param_string(p);
int ret;
@@ -273,7 +273,7 @@ static int param_string_set(struct param_d *p, const char *val)
return ret;
}
-static const char *param_string_get(struct param_d *p)
+static const char *param_string_get(struct device_d *dev, struct param_d *p)
{
struct param_string *ps = to_param_string(p);
int ret;
@@ -327,7 +327,7 @@ static inline struct param_int *to_param_int(struct param_d *p)
return container_of(p, struct param_int, param);
}
-static int param_int_set(struct param_d *p, const char *val)
+static int param_int_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_int *pi = to_param_int(p);
u8 value_save[pi->dsize];
@@ -368,7 +368,7 @@ static int param_int_set(struct param_d *p, const char *val)
return ret;
}
-static const char *param_int_get(struct param_d *p)
+static const char *param_int_get(struct device_d *dev, struct param_d *p)
{
struct param_int *pi = to_param_int(p);
int ret;
@@ -487,7 +487,7 @@ static inline struct param_enum *to_param_enum(struct param_d *p)
return container_of(p, struct param_enum, param);
}
-static int param_enum_set(struct param_d *p, const char *val)
+static int param_enum_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_enum *pe = to_param_enum(p);
int value_save = *pe->value;
@@ -515,7 +515,7 @@ static int param_enum_set(struct param_d *p, const char *val)
return ret;
}
-static const char *param_enum_get(struct param_d *p)
+static const char *param_enum_get(struct device_d *dev, struct param_d *p)
{
struct param_enum *pe = to_param_enum(p);
int ret;
@@ -599,7 +599,7 @@ static inline struct param_bitmask *to_param_bitmask(struct param_d *p)
return container_of(p, struct param_bitmask, param);
}
-static int param_bitmask_set(struct param_d *p, const char *val)
+static int param_bitmask_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_bitmask *pb = to_param_bitmask(p);
void *value_save;
@@ -645,7 +645,7 @@ out:
return ret;
}
-static const char *param_bitmask_get(struct param_d *p)
+static const char *param_bitmask_get(struct device_d *dev, struct param_d *p)
{
struct param_bitmask *pb = to_param_bitmask(p);
int ret, bit;
@@ -734,7 +734,7 @@ static inline struct param_ip *to_param_ip(struct param_d *p)
return container_of(p, struct param_ip, param);
}
-static int param_ip_set(struct param_d *p, const char *val)
+static int param_ip_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_ip *pi = to_param_ip(p);
IPaddr_t ip_save = *pi->ip;
@@ -757,7 +757,7 @@ static int param_ip_set(struct param_d *p, const char *val)
return ret;
}
-static const char *param_ip_get(struct param_d *p)
+static const char *param_ip_get(struct device_d *dev, struct param_d *p)
{
struct param_ip *pi = to_param_ip(p);
int ret;
@@ -816,7 +816,7 @@ static inline struct param_mac *to_param_mac(struct param_d *p)
return container_of(p, struct param_mac, param);
}
-static int param_mac_set(struct param_d *p, const char *val)
+static int param_mac_set(struct device_d *dev, struct param_d *p, const char *val)
{
struct param_mac *pm = to_param_mac(p);
char mac_save[6];
@@ -845,7 +845,7 @@ out:
return ret;
}
-static const char *param_mac_get(struct param_d *p)
+static const char *param_mac_get(struct device_d *dev, struct param_d *p)
{
struct param_mac *pm = to_param_mac(p);
int ret;
@@ -894,7 +894,7 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name,
*/
void dev_remove_param(struct param_d *p)
{
- p->set(p, NULL);
+ p->set(p->dev, p, NULL);
list_del(&p->list);
free(p->name);
free(p);
@@ -910,7 +910,7 @@ void dev_remove_parameters(struct device_d *dev)
struct param_d *p, *n;
list_for_each_entry_safe(p, n, &dev->parameters, list) {
- p->set(p, NULL);
+ p->set(dev, p, NULL);
list_del(&p->list);
free(p->name);
free(p);
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/8] Revert "globalvar: make globalvar functions more consistent"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
` (4 preceding siblings ...)
2017-06-14 7:26 ` [PATCH 5/8] Revert "param: remove unnecessary device_d * argument" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 7/8] Revert "globalvar: remove code for unqualified globalvars" Sascha Hauer
2017-06-14 7:26 ` [PATCH 8/8] Revert "nv: Do not create globalvars from nvvars" Sascha Hauer
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit 1b4a05c9263ae26083526acfabdea1ef96531a1d.
---
arch/arm/boards/beaglebone/board.c | 2 +-
arch/arm/boards/crystalfontz-cfa10036/hwdetect.c | 2 +-
arch/arm/boards/phytec-som-imx6/board.c | 2 +-
arch/arm/boards/vscom-baltos/board.c | 7 +-
arch/ppc/boards/pcm030/eeprom.c | 4 +-
common/boot.c | 2 +-
common/bootchooser.c | 4 +-
common/bootm.c | 2 +-
common/console_common.c | 6 +-
common/globalvar.c | 28 ++++--
common/password.c | 2 +-
common/reset_source.c | 2 +-
drivers/mtd/peb.c | 6 +-
include/globalvar.h | 109 +++--------------------
14 files changed, 55 insertions(+), 123 deletions(-)
diff --git a/arch/arm/boards/beaglebone/board.c b/arch/arm/boards/beaglebone/board.c
index 18a9a10a86..5717c45020 100644
--- a/arch/arm/boards/beaglebone/board.c
+++ b/arch/arm/boards/beaglebone/board.c
@@ -87,7 +87,7 @@ static int beaglebone_devices_init(void)
defaultenv_append_directory(defaultenv_beaglebone);
- globalvar_add_simple_string_fixed("board.variant", black ? "boneblack" : "bone");
+ globalvar_add_simple("board.variant", black ? "boneblack" : "bone");
printf("detected 'BeagleBone %s'\n", black ? "Black" : "White");
diff --git a/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c b/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c
index d0907c11f0..c94cb355e2 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c
+++ b/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c
@@ -105,7 +105,7 @@ void cfa10036_detect_hw(void)
return;
}
- globalvar_add_simple_string_fixed("board.variant", board_name);
+ globalvar_add_simple("board.variant", board_name);
pr_info("Booting on a CFA10036 with %s\n", board_name);
}
diff --git a/arch/arm/boards/phytec-som-imx6/board.c b/arch/arm/boards/phytec-som-imx6/board.c
index 31b2761024..ed9453bdda 100644
--- a/arch/arm/boards/phytec-som-imx6/board.c
+++ b/arch/arm/boards/phytec-som-imx6/board.c
@@ -152,7 +152,7 @@ static int physom_imx6_devices_init(void)
phyflex_err006282_workaround();
pfla02_module_revision = get_module_rev();
- globalvar_add_simple_uint32_fixed("board.revision", pfla02_module_revision, "%u");
+ globalvar_add_simple_int("board.revision", &pfla02_module_revision, "%u");
pr_info("Module Revision: %u\n", pfla02_module_revision);
barebox_set_hostname("phyFLEX-i.MX6");
diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c
index 1a4dc30936..39f40a6061 100644
--- a/arch/arm/boards/vscom-baltos/board.c
+++ b/arch/arm/boards/vscom-baltos/board.c
@@ -64,7 +64,7 @@ static int baltos_read_eeprom(void)
{
struct bsp_vs_hwparam hw_param;
size_t size;
- char *buf;
+ char *buf, var_buf[32];
int rc;
unsigned char mac_addr[6];
@@ -107,7 +107,8 @@ static int baltos_read_eeprom(void)
hw_param.SystemId = 0;
}
- globalvar_add_simple_uint32_fixed("board.id", hw_param.SystemId, "%u");
+ sprintf(var_buf, "%d", hw_param.SystemId);
+ globalvar_add_simple("board.id", var_buf);
/* enable mPCIe slot */
gpio_direction_output(100, 1);
@@ -130,7 +131,7 @@ static int baltos_devices_init(void)
if (!of_machine_is_compatible("vscom,onrisc"))
return 0;
- globalvar_add_simple_string_fixed("board.variant", "baltos");
+ globalvar_add_simple("board.variant", "baltos");
if (bootsource_get() == BOOTSOURCE_MMC)
omap_set_bootmmc_devname("mmc0");
diff --git a/arch/ppc/boards/pcm030/eeprom.c b/arch/ppc/boards/pcm030/eeprom.c
index 34bce85b94..aa00f361cd 100644
--- a/arch/ppc/boards/pcm030/eeprom.c
+++ b/arch/ppc/boards/pcm030/eeprom.c
@@ -53,7 +53,7 @@ static void pcm030_read_factory_data(const struct pcm030_eeprom *buf)
continue;
board = xstrndup(&buf->product[u], l);
u += l + 1;
- globalvar_add_simple_string_fixed("model.type", board);
+ globalvar_add_simple("model.type", board);
free(board);
}
@@ -62,7 +62,7 @@ static void pcm030_read_factory_data(const struct pcm030_eeprom *buf)
continue;
serial = xstrndup(&buf->product[u], l);
u += l + 1;
- globalvar_add_simple_string_fixed("model.serial", serial);
+ globalvar_add_simple("model.serial", serial);
free(serial);
}
diff --git a/common/boot.c b/common/boot.c
index a2d27d1593..cef3d5e514 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -123,7 +123,7 @@ void boot_set_watchdog_timeout(unsigned int timeout)
static int init_boot_watchdog_timeout(void)
{
- return globalvar_add_simple_uint32("boot.watchdog_timeout",
+ return globalvar_add_simple_int("boot.watchdog_timeout",
&boot_watchdog_timeout, "%u");
}
late_initcall(init_boot_watchdog_timeout);
diff --git a/common/bootchooser.c b/common/bootchooser.c
index f6d99d130b..455f290fa2 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -907,8 +907,8 @@ static int bootchooser_init(void)
globalvar_add_simple_bool("bootchooser.retry", &retry);
globalvar_add_simple_string("bootchooser.targets", &available_targets);
globalvar_add_simple_string("bootchooser.state_prefix", &state_prefix);
- globalvar_add_simple_uint32("bootchooser.default_attempts", &global_default_attempts, "%u");
- globalvar_add_simple_uint32("bootchooser.default_priority", &global_default_priority, "%u");
+ globalvar_add_simple_int("bootchooser.default_attempts", &global_default_attempts, "%u");
+ globalvar_add_simple_int("bootchooser.default_priority", &global_default_priority, "%u");
globalvar_add_simple_bitmask("bootchooser.reset_attempts", &reset_attempts,
reset_attempts_names, ARRAY_SIZE(reset_attempts_names));
globalvar_add_simple_bitmask("bootchooser.reset_priorities", &reset_priorities,
diff --git a/common/bootm.c b/common/bootm.c
index 92cfeb6c32..81625d9157 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -668,7 +668,7 @@ static int bootm_init(void)
if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES))
bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
- globalvar_add_simple_uint32("bootm.verbose", &bootm_verbosity, "%u");
+ globalvar_add_simple_int("bootm.verbose", &bootm_verbosity, "%u");
globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode,
bootm_verify_names, ARRAY_SIZE(bootm_verify_names));
diff --git a/common/console_common.c b/common/console_common.c
index b36b3ff083..d051458de4 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -148,10 +148,10 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...)
static int loglevel_init(void)
{
if (IS_ENABLED(CONFIG_LOGBUF))
- globalvar_add_simple_uint32("log_max_messages",
- &barebox_log_max_messages, "%u");
+ globalvar_add_simple_int("log_max_messages",
+ &barebox_log_max_messages, "%d");
- return globalvar_add_simple_uint32("loglevel", &barebox_loglevel, "%u");
+ return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d");
}
device_initcall(loglevel_init);
diff --git a/common/globalvar.c b/common/globalvar.c
index 2f65ca805f..32ca6a24db 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -424,7 +424,7 @@ int globalvar_add_simple(const char *name, const char *value)
return 0;
}
-int __globalvar_add_simple_string(const char *name, char **value)
+int globalvar_add_simple_string(const char *name, char **value)
{
struct param_d *p;
@@ -439,14 +439,28 @@ int __globalvar_add_simple_string(const char *name, char **value)
return 0;
}
-int __globalvar_add_simple_int(const char *name, void *value,
- enum param_type type,
- const char *format)
+int globalvar_add_simple_int(const char *name, int *value,
+ const char *format)
{
struct param_d *p;
- p = __dev_add_param_int(&global_device, name, NULL, NULL,
- value, type, format, NULL);
+ p = dev_add_param_int(&global_device, name, NULL, NULL,
+ value, format, NULL);
+
+ if (IS_ERR(p))
+ return PTR_ERR(p);
+
+ globalvar_nv_sync(name);
+
+ return 0;
+}
+
+int globalvar_add_simple_bool(const char *name, int *value)
+{
+ struct param_d *p;
+
+ p = dev_add_param_bool(&global_device, name, NULL, NULL,
+ value, NULL);
if (IS_ERR(p))
return PTR_ERR(p);
@@ -508,7 +522,7 @@ static int globalvar_init(void)
if (IS_ENABLED(CONFIG_NVVAR))
register_device(&nv_device);
- globalvar_add_simple_string_fixed("version", UTS_RELEASE);
+ globalvar_add_simple("version", UTS_RELEASE);
return 0;
}
diff --git a/common/password.c b/common/password.c
index 5e6bfc53e7..74d328f4b2 100644
--- a/common/password.c
+++ b/common/password.c
@@ -443,7 +443,7 @@ static int login_global_init(void)
{
login_fail_command = xstrdup("boot");
- globalvar_add_simple_uint32("login.timeout", &login_timeout, "%u");
+ globalvar_add_simple_int("login.timeout", &login_timeout, "%d");
globalvar_add_simple_string("login.fail_command", &login_fail_command);
return 0;
diff --git a/common/reset_source.c b/common/reset_source.c
index e18bf6db68..06e2ca85f5 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -54,7 +54,7 @@ EXPORT_SYMBOL(reset_source_set_priority);
static int reset_source_init(void)
{
- globalvar_add_simple_enum_ro("system.reset", (unsigned int *)&reset_source,
+ globalvar_add_simple_enum("system.reset", (unsigned int *)&reset_source,
reset_src_names, ARRAY_SIZE(reset_src_names));
return 0;
diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c
index 0e64fe1671..c35b63f2fd 100644
--- a/drivers/mtd/peb.c
+++ b/drivers/mtd/peb.c
@@ -76,11 +76,11 @@ static int mtd_peb_emulate_erase_failure(void)
#ifdef CONFIG_MTD_PEB_DEBUG
static int mtd_peb_debug_init(void)
{
- globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_bitflip",
+ globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_bitflip",
&__mtd_peb_emulate_bitflip, "%u");
- globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_write_failure",
+ globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_write_failure",
&__mtd_peb_emulate_write_failure, "%u");
- globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_erase_failures",
+ globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_erase_failures",
&__mtd_peb_emulate_erase_failures, "%u");
globalvar_add_simple_bool("mtd_peb.mtd_peb_chk_io",
&__mtd_peb_chk_io);
diff --git a/include/globalvar.h b/include/globalvar.h
index aea43b193d..df43f1fe66 100644
--- a/include/globalvar.h
+++ b/include/globalvar.h
@@ -15,9 +15,10 @@ void globalvar_remove(const char *name);
char *globalvar_get_match(const char *match, const char *separator);
void globalvar_set_match(const char *match, const char *val);
-int __globalvar_add_simple_string(const char *name, char **value);
-int __globalvar_add_simple_int(const char *name, void *value,
- enum param_type type, const char *format);
+int globalvar_add_simple_string(const char *name, char **value);
+int globalvar_add_simple_int(const char *name, int *value,
+ const char *format);
+int globalvar_add_simple_bool(const char *name, int *value);
int globalvar_add_simple_enum(const char *name, int *value,
const char * const *names, int max);
int globalvar_add_simple_bitmask(const char *name, unsigned long *value,
@@ -38,13 +39,19 @@ static inline int globalvar_add_simple(const char *name, const char *value)
return 0;
}
-static inline int __globalvar_add_simple_int(const char *name, void *value,
- enum param_type type, const char *format)
+static inline int globalvar_add_simple_string(const char *name, char **value)
{
return 0;
}
-static inline int __globalvar_add_simple_string(const char *name, char **value)
+static inline int globalvar_add_simple_int(const char *name,
+ int *value, const char *format)
+{
+ return 0;
+}
+
+static inline int globalvar_add_simple_bool(const char *name,
+ int *value)
{
return 0;
}
@@ -108,96 +115,6 @@ static inline void dev_param_init_from_nv(struct device_d *dev, const char *name
#endif
-#define DECLARE_GLOBALVAR_INT(intname, inttype, paramtype) \
- static inline int globalvar_add_simple_##intname(const char *name, \
- inttype *value, \
- const char *format) \
- { \
- return __globalvar_add_simple_int(name, value, \
- paramtype, \
- format); \
- }
-
-DECLARE_GLOBALVAR_INT(uint32, uint32_t, PARAM_TYPE_UINT32)
-DECLARE_GLOBALVAR_INT(int32, int32_t, PARAM_TYPE_INT32)
-DECLARE_GLOBALVAR_INT(uint64, uint64_t, PARAM_TYPE_UINT64)
-DECLARE_GLOBALVAR_INT(int64, int64_t, PARAM_TYPE_INT64)
-
-static inline int globalvar_add_simple_bool(const char *name, uint32_t *value)
-{
- return __globalvar_add_simple_int(name, value, PARAM_TYPE_BOOL, "%u");
-}
-
-static inline int globalvar_add_simple_string(const char *name, char **value)
-{
- return __globalvar_add_simple_string(name, value);
-}
-
-#define DECLARE_GLOBALVAR_INT_RO(intname, inttype, paramtype) \
- static inline int globalvar_add_simple_##intname##_ro(const char *name, \
- inttype *value, \
- const char *format) \
- { \
- return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,\
- param_set_readonly, \
- NULL, value, \
- paramtype, \
- format, NULL)); \
- }
-
-DECLARE_GLOBALVAR_INT_RO(uint32, uint32_t, PARAM_TYPE_UINT32)
-DECLARE_GLOBALVAR_INT_RO(int32, int32_t, PARAM_TYPE_INT32)
-DECLARE_GLOBALVAR_INT_RO(uint64, uint64_t, PARAM_TYPE_UINT64)
-DECLARE_GLOBALVAR_INT_RO(int64, int64_t, PARAM_TYPE_INT64)
-
-static inline int globalvar_add_simple_bool_ro(const char *name, uint32_t *value)
-{
- return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,
- param_set_readonly, NULL,
- value, PARAM_TYPE_BOOL, "%u",
- NULL));
-}
-
-static inline int globalvar_add_simple_string_ro(const char *name, char **value)
-{
- return __globalvar_add_simple_string(name, value);
-}
-
-#define DECLARE_GLOBALVAR_INT_FIXED(intname, inttype, paramtype) \
- static inline int globalvar_add_simple_##intname##_fixed(const char *name, \
- inttype value, \
- const char *format) \
- { \
- return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, \
- ERR_PTR(-EROFS), NULL, \
- &value, paramtype, \
- format, NULL)); \
- }
-
-DECLARE_GLOBALVAR_INT_FIXED(uint32, uint32_t, PARAM_TYPE_UINT32)
-DECLARE_GLOBALVAR_INT_FIXED(int32, int32_t, PARAM_TYPE_INT32)
-DECLARE_GLOBALVAR_INT_FIXED(uint64, uint64_t, PARAM_TYPE_UINT64)
-DECLARE_GLOBALVAR_INT_FIXED(int64, int64_t, PARAM_TYPE_INT64)
-
-static inline int globalvar_add_simple_bool_fixed(const char *name, uint32_t value)
-{
- return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, ERR_PTR(-EROFS),
- NULL, &value, PARAM_TYPE_BOOL, "%u",
- NULL));
-}
-
-static inline int globalvar_add_simple_string_fixed(const char *name, char *value)
-{
- return PTR_ERR_OR_ZERO(dev_add_param_string_fixed(&global_device, name, value));
-}
-
-static inline int globalvar_add_simple_enum_ro(const char *name, int *value,
- const char * const *names, int max)
-{
- return PTR_ERR_OR_ZERO(dev_add_param_enum_ro(&global_device, name, value, names,
- max));
-}
-
void nv_var_set_clean(void);
int nvvar_save(void);
int nv_global_complete(struct string_list *sl, char *instr);
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/8] Revert "globalvar: remove code for unqualified globalvars"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
` (5 preceding siblings ...)
2017-06-14 7:26 ` [PATCH 6/8] Revert "globalvar: make globalvar functions more consistent" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
2017-06-14 7:26 ` [PATCH 8/8] Revert "nv: Do not create globalvars from nvvars" Sascha Hauer
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit e4f81050e098074792730b61563538d9e394e3d6.
---
common/globalvar.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
include/param.h | 1 +
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index 32ca6a24db..1b3082a1b7 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -410,7 +410,7 @@ int globalvar_add_simple(const char *name, const char *value)
struct param_d *param;
param = dev_add_param(&global_device, name, globalvar_simple_set, NULL,
- 0);
+ PARAM_GLOBALVAR_UNQUALIFIED);
if (IS_ERR(param)) {
if (PTR_ERR(param) != -EEXIST)
return PTR_ERR(param);
@@ -424,9 +424,30 @@ int globalvar_add_simple(const char *name, const char *value)
return 0;
}
+static int globalvar_remove_unqualified(const char *name)
+{
+ struct param_d *p;
+
+ p = get_param_by_name(&global_device, name);
+ if (!p)
+ return 0;
+
+ if (!(p->flags & PARAM_GLOBALVAR_UNQUALIFIED))
+ return -EEXIST;
+
+ dev_remove_param(p);
+
+ return 0;
+}
+
int globalvar_add_simple_string(const char *name, char **value)
{
struct param_d *p;
+ int ret;
+
+ ret = globalvar_remove_unqualified(name);
+ if (ret)
+ return ret;
p = dev_add_param_string(&global_device, name, NULL, NULL,
value, NULL);
@@ -443,6 +464,11 @@ int globalvar_add_simple_int(const char *name, int *value,
const char *format)
{
struct param_d *p;
+ int ret;
+
+ ret = globalvar_remove_unqualified(name);
+ if (ret)
+ return ret;
p = dev_add_param_int(&global_device, name, NULL, NULL,
value, format, NULL);
@@ -458,6 +484,11 @@ int globalvar_add_simple_int(const char *name, int *value,
int globalvar_add_simple_bool(const char *name, int *value)
{
struct param_d *p;
+ int ret;
+
+ ret = globalvar_remove_unqualified(name);
+ if (ret)
+ return ret;
p = dev_add_param_bool(&global_device, name, NULL, NULL,
value, NULL);
@@ -474,6 +505,11 @@ int globalvar_add_simple_enum(const char *name, int *value,
const char * const *names, int max)
{
struct param_d *p;
+ int ret;
+
+ ret = globalvar_remove_unqualified(name);
+ if (ret)
+ return ret;
p = dev_add_param_enum(&global_device, name, NULL, NULL,
value, names, max, NULL);
@@ -503,6 +539,11 @@ int globalvar_add_simple_bitmask(const char *name, unsigned long *value,
int globalvar_add_simple_ip(const char *name, IPaddr_t *ip)
{
struct param_d *p;
+ int ret;
+
+ ret = globalvar_remove_unqualified(name);
+ if (ret)
+ return ret;
p = dev_add_param_ip(&global_device, name, NULL, NULL,
ip, NULL);
diff --git a/include/param.h b/include/param.h
index 449d3d78e9..2592a09c3a 100644
--- a/include/param.h
+++ b/include/param.h
@@ -6,6 +6,7 @@
#include <linux/list.h>
#define PARAM_FLAG_RO (1 << 0)
+#define PARAM_GLOBALVAR_UNQUALIFIED (1 << 1)
struct device_d;
typedef uint32_t IPaddr_t;
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/8] Revert "nv: Do not create globalvars from nvvars"
2017-06-14 7:26 revert nvvar changes Sascha Hauer
` (6 preceding siblings ...)
2017-06-14 7:26 ` [PATCH 7/8] Revert "globalvar: remove code for unqualified globalvars" Sascha Hauer
@ 2017-06-14 7:26 ` Sascha Hauer
7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2017-06-14 7:26 UTC (permalink / raw)
To: Barebox List
This reverts commit 35d8e858bea17ec4796069c9c27fd0b134125eaf.
---
common/globalvar.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/common/globalvar.c b/common/globalvar.c
index 1b3082a1b7..fdfaf76fae 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -165,18 +165,14 @@ static int nvvar_device_dispatch(const char *name, struct device_d **dev,
static int nv_set(struct device_d *dev, struct param_d *p, const char *val)
{
- struct param_d *g;
int ret;
if (!val)
val = "";
- g = get_param_by_name(&global_device, p->name);
- if (g) {
- ret = dev_set_param(&global_device, p->name, val);
- if (ret)
- return ret;
- }
+ ret = dev_set_param(&global_device, p->name, val);
+ if (ret)
+ return ret;
free(p->value);
p->value = xstrdup(val);
@@ -203,6 +199,7 @@ 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;
+ int ret;
if (!IS_ENABLED(CONFIG_NVVAR))
return -ENOSYS;
@@ -215,6 +212,11 @@ static int __nvvar_add(const char *name, const char *value)
return PTR_ERR(p);
}
+ /* Create corresponding globalvar if it doesn't exist yet */
+ ret = globalvar_add_simple(name, value);
+ if (ret && ret != -EEXIST)
+ return ret;
+
if (value)
return nv_set(&nv_device, p, value);
@@ -391,15 +393,6 @@ static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const c
return dev_param_set_generic(dev, p, val);
}
-static void globalvar_nv_sync(const char *name)
-{
- const char *val;
-
- val = dev_get_param(&nv_device, name);
- if (val)
- dev_set_param(&global_device, name, val);
-}
-
/*
* globalvar_add_simple
*
@@ -416,12 +409,10 @@ int globalvar_add_simple(const char *name, const char *value)
return PTR_ERR(param);
}
- if (value)
- dev_set_param(&global_device, name, value);
-
- globalvar_nv_sync(name);
+ if (!value)
+ return 0;
- return 0;
+ return dev_set_param(&global_device, name, value);
}
static int globalvar_remove_unqualified(const char *name)
@@ -440,6 +431,15 @@ static int globalvar_remove_unqualified(const char *name)
return 0;
}
+static void globalvar_nv_sync(const char *name)
+{
+ const char *val;
+
+ val = dev_get_param(&nv_device, name);
+ if (val)
+ dev_set_param(&global_device, name, val);
+}
+
int globalvar_add_simple_string(const char *name, char **value)
{
struct param_d *p;
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread