[PATCH 33/42] commands: state: allow loading state with -l

Sascha Hauer s.hauer at pengutronix.de
Fri Mar 31 00:03:37 PDT 2017


At least for testing purposes it's useful to be able to
manually load a state. Add -l option for this.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/state.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/commands/state.c b/commands/state.c
index 4b51759e3e..aded6e71e2 100644
--- a/commands/state.c
+++ b/commands/state.c
@@ -21,20 +21,23 @@ static int do_state(int argc, char *argv[])
 {
 	int opt, ret = 0;
 	struct state *state = NULL;
-	int do_save = 0;
+	int do_save = 0, do_load = 0;
 	const char *statename = "state";
 
-	while ((opt = getopt(argc, argv, "s")) > 0) {
+	while ((opt = getopt(argc, argv, "sl")) > 0) {
 		switch (opt) {
 		case 's':
 			do_save = 1;
 			break;
+		case 'l':
+			do_load = 1;
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
 	}
 
-	if (!do_save) {
+	if (!do_save && !do_load) {
 		state_info();
 		return 0;
 	}
@@ -48,7 +51,9 @@ static int do_state(int argc, char *argv[])
 		return -ENOENT;
 	}
 
-	if (do_save)
+	if (do_load)
+		ret = state_load(state);
+	else if (do_save)
 		ret = state_save(state);
 
 	return ret;
-- 
2.11.0




More information about the barebox mailing list