nv: simplify nvvar_add
We do not need to have an extra code path when the variable already exists, instead setting an existing variable can be done in the variable creation code path aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
62ae0274df
commit
ffc6031313
|
@ -231,7 +231,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, *gp;
|
||||
struct param_d *p;
|
||||
int ret;
|
||||
int devspace;
|
||||
struct device_d *dev;
|
||||
|
@ -246,19 +246,12 @@ static int __nvvar_add(const char *name, const char *value)
|
|||
|
||||
devspace = ret;
|
||||
|
||||
gp = get_param_by_name(&nv_device, name);
|
||||
if (gp) {
|
||||
if (!devspace) {
|
||||
ret = dev_set_param(&global_device, name, value);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = dev_set_param(&nv_device, name, value);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
/* Get param. If it doesn't exist yet, create it */
|
||||
p = get_param_by_name(&nv_device, name);
|
||||
if (!p) {
|
||||
p = dev_add_param(&nv_device, name, nv_param_set, nv_param_get, 0);
|
||||
if (IS_ERR(p))
|
||||
return PTR_ERR(p);
|
||||
}
|
||||
|
||||
if (!devspace) {
|
||||
|
@ -267,10 +260,6 @@ static int __nvvar_add(const char *name, const char *value)
|
|||
return ret;
|
||||
}
|
||||
|
||||
p = dev_add_param(&nv_device, name, nv_param_set, nv_param_get, 0);
|
||||
if (IS_ERR(p))
|
||||
return PTR_ERR(p);
|
||||
|
||||
if (!value) {
|
||||
if (devspace) {
|
||||
if (dev)
|
||||
|
|
Loading…
Reference in New Issue