summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-05-04 12:01:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-02-06 08:46:11 +0100
commit6a77d1cfb6596ed0a269ab52028f7e4bb22c99e2 (patch)
treeb304e7e6ac97c4aa51e7c59d2ee01b97eba07e00 /common/state
parent6d3e10c67822816d3ff2021dcfba5e7a83906586 (diff)
downloadbarebox-6a77d1cfb6596ed0a269ab52028f7e4bb22c99e2.tar.gz
state: Add 'init_from_defaults' parameter
The init_from_defaults parameter allows to detect if a state has been initialized from default values, i.e. state_load failed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state')
-rw-r--r--common/state/state.c7
-rw-r--r--common/state/state.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/common/state/state.c b/common/state/state.c
index 5a1a1af..cb97932 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -99,6 +99,7 @@ static int state_do_load(struct state *state, enum state_flags flags)
goto out;
}
+ state->init_from_defaults = 0;
state->dirty = 0;
out:
@@ -179,10 +180,14 @@ static struct state *state_new(const char *name)
state->dirty = 1;
dev_add_param_bool(&state->dev, "dirty", state_set_deny, NULL, &state->dirty,
NULL);
+
state->save_on_shutdown = 1;
dev_add_param_bool(&state->dev, "save_on_shutdown", NULL, NULL,
&state->save_on_shutdown, NULL);
+ dev_add_param_bool(&state->dev, "init_from_defaults", state_set_deny, NULL,
+ &state->init_from_defaults, NULL);
+
list_add_tail(&state->list, &state_list);
return state;
@@ -643,6 +648,8 @@ struct state *state_new_from_node(struct device_node *node, char *path,
goto out_release_state;
}
+ state->init_from_defaults = 1;
+
ret = of_register_fixup(of_state_fixup, state);
if (ret) {
goto out_release_state;
diff --git a/common/state/state.h b/common/state/state.h
index fcc6b9f..da1c6ac 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -107,7 +107,9 @@ struct state {
uint32_t magic;
struct list_head variables; /* Sorted list of variables */
+
unsigned int dirty;
+ unsigned int init_from_defaults;
unsigned int save_on_shutdown;
struct state_backend_format *format;