aboutsummaryrefslogtreecommitdiff
path: root/boot/expo_build.c
diff options
context:
space:
mode:
authorSimon Glass2023-08-14 16:40:24 -0600
committerTom Rini2023-08-25 13:54:33 -0400
commit431b21fd407f4a76cdc182ee40184311562e5505 (patch)
tree99ef63aabd3648b7448c17803aacb331100ece95 /boot/expo_build.c
parentf2eb6ad50a3e610897d6386bb3192c049dc6fd12 (diff)
expo: Refactor menu_build() to return the object created
The caller reads the ID but menu_build() does this again. Add the ID as a parameter to avoid this. Return the object created so that the caller can adjust it. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/expo_build.c')
-rw-r--r--boot/expo_build.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/boot/expo_build.c b/boot/expo_build.c
index 22f62eb54bc..e8c4a40d3f0 100644
--- a/boot/expo_build.c
+++ b/boot/expo_build.c
@@ -214,22 +214,21 @@ static void list_strings(struct build_info *info)
* @info: Build information
* @node: Node containing the menu description
* @scn: Scene to add the menu to
+ * @id: ID for the menu
+ * @objp: Returns the object pointer
* Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format
* error, -ENOENT if there is a references to a non-existent string
*/
-static int menu_build(struct build_info *info, ofnode node, struct scene *scn)
+static int menu_build(struct build_info *info, ofnode node, struct scene *scn,
+ uint id, struct scene_obj **objp)
{
struct scene_obj_menu *menu;
uint title_id, menu_id;
const u32 *item_ids;
int ret, size, i;
const char *name;
- u32 id;
name = ofnode_get_name(node);
- ret = ofnode_read_u32(node, "id", &id);
- if (ret)
- return log_msg_ret("id", -EINVAL);
ret = scene_menu(scn, name, id, &menu);
if (ret < 0)
@@ -275,12 +274,13 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn)
if (ret < 0)
return log_msg_ret("mi", ret);
}
+ *objp = &menu->obj;
return 0;
}
/**
- * menu_build() - Build an expo object and add it to a scene
+ * obj_build() - Build an expo object and add it to a scene
*
* See doc/developer/expo.rst for a description of the format
*
@@ -292,6 +292,7 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn)
*/
static int obj_build(struct build_info *info, ofnode node, struct scene *scn)
{
+ struct scene_obj *obj;
const char *type;
u32 id;
int ret;
@@ -306,7 +307,7 @@ static int obj_build(struct build_info *info, ofnode node, struct scene *scn)
return log_msg_ret("typ", -EINVAL);
if (!strcmp("menu", type))
- ret = menu_build(info, node, scn);
+ ret = menu_build(info, node, scn, id, &obj);
else
ret = -EINVAL;
if (ret)