expo: Split bootflow_menu_run() into two pieces

Split the starting piece of this function into bootflow_menu_start()
and the polling part into bootflow_menu_poll() so that it is possible
for the caller to be in control of the event loop.

Move the expo_destroy() call into the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index f266223..efac27a 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -14,6 +14,8 @@
 #include <console.h>
 #include <dm.h>
 #include <env.h>
+#include <expo.h>
+#include <log.h>
 #include <mapmem.h>
 
 /**
@@ -105,24 +107,32 @@
 					       bool text_mode,
 					       struct bootflow **bflowp)
 {
+	struct expo *exp;
 	struct bootflow *bflow;
 	int ret;
 
-	ret = bootflow_menu_run(std, text_mode, &bflow);
-	if (ret) {
-		if (ret == -EPIPE) {
-			printf("Nothing chosen\n");
-			std->cur_bootflow = NULL;
-		} else {
-			printf("Menu failed (err=%d)\n", ret);
-		}
+	ret = bootflow_menu_start(std, text_mode, &exp);
+	if (ret)
+		return log_msg_ret("bhs", ret);
 
-		return ret;
-	}
+	do {
+		ret = bootflow_menu_poll(exp, &bflow);
+	} while (ret == -EAGAIN);
 
-	printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name);
-	std->cur_bootflow = bflow;
-	*bflowp = bflow;
+	if (ret == -EPIPE) {
+		printf("Nothing chosen\n");
+		std->cur_bootflow = NULL;
+	} else if (ret) {
+		printf("Menu failed (err=%d)\n", ret);
+	} else {
+		printf("Selected: %s\n", bflow->os_name ? bflow->os_name :
+		       bflow->name);
+		std->cur_bootflow = bflow;
+		*bflowp = bflow;
+	}
+	expo_destroy(exp);
+	if (ret)
+		return ret;
 
 	return 0;
 }