Some callers may wish to add items later as they are discovered. Split
the setup code into its own function, to permit this.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 boot/bootflow_menu.c | 24 ++++++++++++++++++++++--
 include/bootflow.h   | 15 +++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index 7e131de3f6d..4fe5d985064 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -252,7 +252,7 @@ int bootflow_menu_apply_theme(struct expo *exp, ofnode node)
        return 0;
 }
 
-int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
+int bootflow_menu_setup(struct bootstd_priv *std, bool text_mode,
                        struct expo **expp)
 {
        struct udevice *dev;
@@ -260,7 +260,6 @@ int bootflow_menu_start(struct bootstd_priv *std, bool 
text_mode,
        int ret;
 
        LOGR("bmn", bootflow_menu_new(&exp));
-       LOGR("bma", bootflow_menu_add_all(exp));
 
        if (ofnode_valid(std->theme)) {
                ret = bootflow_menu_apply_theme(exp, std->theme);
@@ -283,6 +282,27 @@ int bootflow_menu_start(struct bootstd_priv *std, bool 
text_mode,
        if (text_mode)
                expo_set_text_mode(exp, text_mode);
 
+       *expp = exp;
+
+       return 0;
+}
+
+int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
+                       struct expo **expp)
+{
+       struct expo *exp;
+       int ret;
+
+       LOGR("bmn", bootflow_menu_setup(std, text_mode, &exp));
+
+       LOGR("bma", bootflow_menu_add_all(exp));
+
+       if (ofnode_valid(std->theme)) {
+               ret = expo_apply_theme(exp, std->theme);
+               if (ret)
+                       return log_msg_ret("thm", ret);
+       }
+
        LOGR("bmd", expo_calc_dims(exp));
 
        *expp = exp;
diff --git a/include/bootflow.h b/include/bootflow.h
index 8362cbe2e69..c0e19feb9cc 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -656,9 +656,24 @@ struct bootflow_img *bootflow_img_add(struct bootflow 
*bflow, const char *fname,
  */
 int bootflow_get_seq(const struct bootflow *bflow);
 
+/**
+ * bootflow_menu_setup() - Set up a menu for bootflows
+ *
+ * Set up the expo, initially empty
+ *
+ * @std: bootstd information
+ * @text_mode: true to show the menu in text mode, false to use video display
+ * @expp: Returns the expo created, on success
+ * Return: 0 if OK, -ve on error
+ */
+int bootflow_menu_setup(struct bootstd_priv *std, bool text_mode,
+                       struct expo **expp);
+
 /**
  * bootflow_menu_start() - Start up a menu for bootflows
  *
+ * Set up the expo and add items
+ *
  * @std: bootstd information
  * @text_mode: true to show the menu in text mode, false to use video display
  * @expp: Returns the expo created, on success
-- 
2.43.0

Reply via email to