summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-02-18 08:36:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-18 08:36:45 +0100
commitb8ed83076ffdc2c6831061003afaecf8ba802aab (patch)
treea77534284a19b24945c097a317bf8c41e1d499ff /common
parent801119922cb086ea7fc9f9194253a180d40581cb (diff)
parent73dda8a0f7b5f3fdec45b8cb9e936fac79105ab7 (diff)
downloadbarebox-b8ed83076ffdc2c6831061003afaecf8ba802aab.tar.gz
Merge branch 'for-next/parameter'
Diffstat (limited to 'common')
-rw-r--r--common/globalvar.c19
-rw-r--r--common/state/state.h4
-rw-r--r--common/state/state_variables.c23
3 files changed, 23 insertions, 23 deletions
diff --git a/common/globalvar.c b/common/globalvar.c
index a826e1b..c87f2c9 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -175,21 +175,24 @@ static int nvvar_device_dispatch(const char *name, struct device_d **dev,
return 1;
}
-static int nv_set(struct device_d *dev, struct param_d *p, const char *val)
+static int nv_set(struct device_d *dev, struct param_d *p, const char *name, const char *val)
{
int ret;
if (!val) {
- free(p->value);
+ if (p)
+ free(p->value);
return 0;
}
- ret = dev_set_param(&global_device, p->name, val);
+ ret = dev_set_param(&global_device, name, val);
if (ret)
return ret;
- free(p->value);
- p->value = xstrdup(val);
+ if (p) {
+ free(p->value);
+ p->value = xstrdup(val);
+ }
return 0;
}
@@ -203,7 +206,7 @@ static int nv_param_set(struct device_d *dev, struct param_d *p, const char *val
{
int ret;
- ret = nv_set(dev, p, val);
+ ret = nv_set(dev, p, p->name, val);
if (ret)
return ret;
@@ -234,7 +237,7 @@ static int __nvvar_add(const char *name, const char *value)
return ret;
if (value)
- return nv_set(&nv_device, p, value);
+ return nv_set(&nv_device, p, name, value);
ret = nvvar_device_dispatch(name, &dev, &pname);
if (ret > 0)
@@ -242,7 +245,7 @@ static int __nvvar_add(const char *name, const char *value)
else
value = dev_get_param(&global_device, name);
- if (value) {
+ if (value && p) {
free(p->value);
p->value = xstrdup(value);
}
diff --git a/common/state/state.h b/common/state/state.h
index 912d6d4..1881d92 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -159,7 +159,6 @@ struct state_variable {
*/
struct state_uint32 {
struct state_variable var;
- struct param_d *param;
uint32_t value;
uint32_t value_default;
};
@@ -169,7 +168,6 @@ struct state_uint32 {
*/
struct state_enum32 {
struct state_variable var;
- struct param_d *param;
uint32_t value;
uint32_t value_default;
const char **names;
@@ -181,7 +179,6 @@ struct state_enum32 {
*/
struct state_mac {
struct state_variable var;
- struct param_d *param;
uint8_t value[6];
uint8_t value_default[6];
};
@@ -191,7 +188,6 @@ struct state_mac {
*/
struct state_string {
struct state_variable var;
- struct param_d *param;
char *value;
const char *value_default;
char raw[];
diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index 6a00c82..66c66f3 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -116,7 +116,6 @@ static struct state_variable *state_uint8_create(struct state *state,
return ERR_CAST(param);
}
- su32->param = param;
su32->var.type = vtype;
su32->var.size = sizeof(uint8_t);
#ifdef __LITTLE_ENDIAN
@@ -146,7 +145,6 @@ static struct state_variable *state_uint32_create(struct state *state,
return ERR_CAST(param);
}
- su32->param = param;
su32->var.type = vtype;
su32->var.size = sizeof(uint32_t);
su32->var.raw = &su32->value;
@@ -226,6 +224,7 @@ static struct state_variable *state_enum32_create(struct state *state,
const struct variable_type *vtype)
{
struct state_enum32 *enum32;
+ struct param_d *param;
int ret, i, num_names;
enum32 = xzalloc(sizeof(*enum32));
@@ -253,11 +252,11 @@ static struct state_variable *state_enum32_create(struct state *state,
enum32->names[i] = xstrdup(name);
}
- enum32->param = dev_add_param_enum(&state->dev, name, state_set_dirty,
+ param = dev_add_param_enum(&state->dev, name, state_set_dirty,
NULL, &enum32->value, enum32->names,
num_names, &enum32->var);
- if (IS_ERR(enum32->param)) {
- ret = PTR_ERR(enum32->param);
+ if (IS_ERR(param)) {
+ ret = PTR_ERR(param);
goto out;
}
@@ -310,6 +309,7 @@ static struct state_variable *state_mac_create(struct state *state,
const struct variable_type *vtype)
{
struct state_mac *mac;
+ struct param_d *param;
int ret;
mac = xzalloc(sizeof(*mac));
@@ -319,10 +319,10 @@ static struct state_variable *state_mac_create(struct state *state,
mac->var.raw = mac->value;
mac->var.state = state;
- mac->param = dev_add_param_mac(&state->dev, name, state_set_dirty,
+ param = dev_add_param_mac(&state->dev, name, state_set_dirty,
NULL, mac->value, &mac->var);
- if (IS_ERR(mac->param)) {
- ret = PTR_ERR(mac->param);
+ if (IS_ERR(param)) {
+ ret = PTR_ERR(param);
goto out;
}
@@ -413,6 +413,7 @@ static struct state_variable *state_string_create(struct state *state,
{
struct state_string *string;
uint32_t start_size[2];
+ struct param_d *param;
int ret;
ret = of_property_read_u32_array(node, "reg", start_size,
@@ -432,11 +433,11 @@ static struct state_variable *state_string_create(struct state *state,
string->var.raw = &string->raw;
string->var.state = state;
- string->param = dev_add_param_string(&state->dev, name,
+ param = dev_add_param_string(&state->dev, name,
state_string_set, state_string_get,
&string->value, &string->var);
- if (IS_ERR(string->param)) {
- ret = PTR_ERR(string->param);
+ if (IS_ERR(param)) {
+ ret = PTR_ERR(param);
goto out;
}