summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-08-03 08:08:23 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-08-03 08:08:23 +0200
commitb927df0329a97dcfe9ba22b45375be2dc416dcd6 (patch)
treeca8f7db434757d07c08e55a47aa308e3c01fa176 /common/state
parent14e04d019b70cb8711b005bc316ac6a52d61db39 (diff)
parenteaacdd58766490b2b7d54b640945da478decbeb9 (diff)
downloadbarebox-b927df0329a97dcfe9ba22b45375be2dc416dcd6.tar.gz
barebox-b927df0329a97dcfe9ba22b45375be2dc416dcd6.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'common/state')
-rw-r--r--common/state/state.c15
-rw-r--r--common/state/state.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/common/state/state.c b/common/state/state.c
index 3997f8150c..9b1d4edef1 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <fs.h>
#include <crc.h>
+#include <init.h>
#include <linux/err.h>
#include <linux/list.h>
@@ -54,6 +55,9 @@ static struct state *state_new(const char *name)
state->dirty = 1;
dev_add_param_bool(&state->dev, "dirty", NULL, 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);
list_add_tail(&state->list, &state_list);
@@ -571,3 +575,14 @@ void state_info(void)
printf("(no backend)\n");
}
}
+
+static void state_shutdown(void)
+{
+ struct state *state;
+
+ list_for_each_entry(state, &state_list, list) {
+ if (state->save_on_shutdown)
+ state_save(state);
+ }
+}
+predevshutdown_exitcall(state_shutdown);
diff --git a/common/state/state.h b/common/state/state.h
index 7f9651abd8..32146ca1bb 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -100,6 +100,7 @@ struct state {
struct list_head variables; /* Sorted list of variables */
unsigned int dirty;
+ unsigned int save_on_shutdown;
struct state_backend backend;
};