]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
expo: Split setting up the menu from adding items
authorSimon Glass <sjg@chromium.org>
Fri, 2 May 2025 14:46:56 +0000 (08:46 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 30 May 2025 08:49:33 +0000 (09:49 +0100)
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 <sjg@chromium.org>
boot/bootflow_menu.c
include/bootflow.h

index 6bca17142adf2b46dca45b778e1c68db2bccd92f..56a34ac8ed58b9d0701b98f3ffeee28ea58fa79f 100644 (file)
@@ -210,7 +210,6 @@ int bootflow_menu_add_all(struct expo *exp)
                ret = bootflow_menu_add(exp, bflow, i, &scn);
                if (ret)
                        return log_msg_ret("bao", ret);
-
        }
 
        ret = scene_arrange(scn);
@@ -257,7 +256,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;
@@ -267,9 +266,6 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
        ret = bootflow_menu_new(&exp);
        if (ret)
                return log_msg_ret("bmn", ret);
-       ret = bootflow_menu_add_all(exp);
-       if (ret)
-               return log_msg_ret("bma", ret);
 
        if (ofnode_valid(std->theme)) {
                ret = bootflow_menu_apply_theme(exp, std->theme);
@@ -292,6 +288,31 @@ 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;
+
+       ret = bootflow_menu_setup(std, text_mode, &exp);
+       if (ret)
+               return log_msg_ret("bmd", ret);
+
+       ret = bootflow_menu_add_all(exp);
+       if (ret)
+               return log_msg_ret("bma", ret);
+
+       if (ofnode_valid(std->theme)) {
+               ret = expo_apply_theme(exp, std->theme);
+               if (ret)
+                       return log_msg_ret("thm", ret);
+       }
+
        ret = expo_calc_dims(exp);
        if (ret)
                return log_msg_ret("bmd", ret);
index 75d88d47884f095986d593cca7b3da738fc9328d..8dcc8f96e118391c1fe487ac9abdac3aeb2a40fd 100644 (file)
@@ -655,9 +655,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