From patchwork Sun Dec 7 20:16:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 823 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765138658; bh=9Q68lHe5+hNPRoTkaf2ANYc+cyLHdn2nVl9wAL3SWPY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uKYejpOkVJNIcbikOjN1qzEOYvGf6f9pfevd6OoZmMzLfRo1eAJy4IZ6JbNQgwHEC LvrehH3/nbstyCjZVpJqzrwDoRlHaojCCHdgw0DN5sfkRhxHKyxmM1IwfJKI0EtKcB 8pmfjulW2msjqbBabE70XXa4Q/RNvn3sCv9CtXasY2sTuHdDhmYmpI27XKyeNLhy0m oMRCZorBq4EopYBCWi5H//JODTnGl3yOCLQ/FP1vjwmfaXRW57yN+/L0HLVZnmbHk4 CROg/Ox6ZD5173SrvlIf7WvQKpfghEDV4s7m9AhUyxtVVOp9BR6vVuzw7il2UDE4ky C63LWxrdsP2Cg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A583268902 for ; Sun, 7 Dec 2025 13:17:38 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 1zOmMY56OGa1 for ; Sun, 7 Dec 2025 13:17:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765138658; bh=9Q68lHe5+hNPRoTkaf2ANYc+cyLHdn2nVl9wAL3SWPY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uKYejpOkVJNIcbikOjN1qzEOYvGf6f9pfevd6OoZmMzLfRo1eAJy4IZ6JbNQgwHEC LvrehH3/nbstyCjZVpJqzrwDoRlHaojCCHdgw0DN5sfkRhxHKyxmM1IwfJKI0EtKcB 8pmfjulW2msjqbBabE70XXa4Q/RNvn3sCv9CtXasY2sTuHdDhmYmpI27XKyeNLhy0m oMRCZorBq4EopYBCWi5H//JODTnGl3yOCLQ/FP1vjwmfaXRW57yN+/L0HLVZnmbHk4 CROg/Ox6ZD5173SrvlIf7WvQKpfghEDV4s7m9AhUyxtVVOp9BR6vVuzw7il2UDE4ky C63LWxrdsP2Cg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D9D2689A8 for ; Sun, 7 Dec 2025 13:17:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765138657; bh=SkVFt/YOyiIP3z2NPCe7Umf7qrld7yVAfK+dhCIrKeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U7XVagr5lLOrpcTBdLMP/Z1O4ZVSkMg0v6oRVdoRD6EdhxfwULuNrcfoR4EhxWADN brmNwKrExFqejAxlGaXGu2jMASfBdKv1CQ9hAOyGdypqmR297gYtvANsOX4+wsHr+v 6783EguQpNPZ77JOhiglIu4pl6em224ggUMUTOY2KWdxM20LMQWstEbk9bySaH2Tqj snm0JQ/0CtBAEYmhQQIxA97X1iX/GEpytPNObzHfr6VO/iB/cGe1Nmxg3ALXn3w8QA m6O5QSNddAdIA+Gdb8L/1Esbk85XJz1KPaHMvMkcbHqVY3SjXOil6Ri3bZXb3vqos6 y08LTV+MaMs5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5342A68997; Sun, 7 Dec 2025 13:17:37 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id tIx997YxaPdL; Sun, 7 Dec 2025 13:17:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765138651; bh=yLOhuOoVNFHye/TV5XF3h5be+v0dFNqsV02bFMtlZ3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGaP7K/gR/DNISk53sW0KymeLw6Yx6pAWyXbfuG8gGCr+zwgKsEj2RLFkdwUJueRC F8uQNQRGumYL0YM89wbtQ88sGSATC8yneFGEikNcGkpuFsdE+fgBzYmNKz8LyOFIWB QL3ujmRnbnhHiSnF6nRVC1J1pqK+fdN9105+oFQ1iym4ssVzKrzYxIRhCpT7OK1B0p mQx2tsBcv1hMlwcmsLAMCBrXpJLUJhsRnkLs4FlzRV8iCh2yMlRjYrAn91GGDDMpeR mFgtNOefNSr1VE54CE74LUgR9R3NexfxC9WxIImxnp+bqKaARLLODSWVvPP5S8JBcx sLkZtIA4f15RA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3499D688EF; Sun, 7 Dec 2025 13:17:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 7 Dec 2025 13:16:08 -0700 Message-ID: <20251207201628.2882382-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251207201628.2882382-1-sjg@u-boot.org> References: <20251207201628.2882382-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YSDIYL6WROK7PSADWEO6CZKCUCAFSJ7G X-Message-ID-Hash: YSDIYL6WROK7PSADWEO6CZKCUCAFSJ7G X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/22] expo: Use better names for child objects in expo_build List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Use the parent object name as a prefix for child objects, so they have descriptive names like "cpu-speed.title" instead of generic "title". This makes debugging easier when multiple objects exist. Update add_txt_str() and add_txt_str_list() to take separate property name and object name parameters. Also set the scene's prompt_id when building from devicetree. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/expo_build.c | 52 +++++++++++++++++++++++++++++++---------------- test/boot/expo.c | 4 ++-- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/boot/expo_build.c b/boot/expo_build.c index f8ae5bcbbf7..60a9cd71b7e 100644 --- a/boot/expo_build.c +++ b/boot/expo_build.c @@ -38,12 +38,13 @@ struct build_info { * @info: Build information * @node: Node describing scene * @scn: Scene to add to - * @find_name: Name to look for (e.g. "title"). This will find a property called - * "title" if it exists, else will look up the string for "title-id" + * @find_name: Property to look for (e.g. "title"). This will find a property + * called "title" if it exists, else will look up the string for "title-id" + * @obj_name: Name for the object (e.g. "cpu-speed.title") * Return: ID of added string, or -ve on error */ int add_txt_str(struct build_info *info, ofnode node, struct scene *scn, - const char *find_name, uint obj_id) + const char *find_name, const char *obj_name, uint obj_id) { const char *text; int ret; @@ -66,7 +67,7 @@ int add_txt_str(struct build_info *info, ofnode node, struct scene *scn, return log_msg_ret("id", -EINVAL); } - ret = scene_txt_str(scn, find_name, obj_id, 0, text, NULL); + ret = scene_txt_str(scn, obj_name, obj_id, 0, text, NULL); if (ret < 0) return log_msg_ret("add", ret); @@ -79,13 +80,15 @@ int add_txt_str(struct build_info *info, ofnode node, struct scene *scn, * @info: Build information * @node: Node describing scene * @scn: Scene to add to - * @find_name: Name to look for (e.g. "title"). This will find a string-list + * @find_name: Property to look for (e.g. "title"). This will find a string-list * property called "title" if it exists, else will look up the string in the * "title-id" string list. + * @obj_name: Name for the object (e.g. "cpu-speed.title") * Return: ID of added string, or -ve on error */ int add_txt_str_list(struct build_info *info, ofnode node, struct scene *scn, - const char *find_name, int index, uint obj_id) + const char *find_name, const char *obj_name, int index, + uint obj_id) { const char *text; int ret; @@ -107,7 +110,7 @@ int add_txt_str_list(struct build_info *info, ofnode node, struct scene *scn, return log_msg_ret("id", -EINVAL); } - ret = scene_txt_str(scn, find_name, obj_id, 0, text, NULL); + ret = scene_txt_str(scn, obj_name, obj_id, 0, text, NULL); if (ret < 0) return log_msg_ret("add", ret); @@ -220,6 +223,7 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn, int ret, size, i, num_items; uint title_id, menu_id; const char *name; + char buf[80]; name = ofnode_get_name(node); @@ -229,7 +233,8 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn, menu_id = ret; /* Set the title */ - ret = add_txt_str(info, node, scn, "title", 0); + snprintf(buf, sizeof(buf), "%s.title", name); + ret = add_txt_str(info, node, scn, "title", buf, 0); if (ret < 0) return log_msg_ret("tit", ret); title_id = ret; @@ -254,22 +259,28 @@ static int menu_build(struct build_info *info, ofnode node, struct scene *scn, struct scene_menitem *item; uint label, key, desc; - ret = add_txt_str_list(info, node, scn, "item-label", i, 0); + snprintf(buf, sizeof(buf), "%s.item-%x.label", name, i); + ret = add_txt_str_list(info, node, scn, "item-label", buf, i, + 0); if (ret < 0 && ret != -ENOENT) return log_msg_ret("lab", ret); label = max(0, ret); - ret = add_txt_str_list(info, node, scn, "key-label", i, 0); + snprintf(buf, sizeof(buf), "%s.item-%x.key", name, i); + ret = add_txt_str_list(info, node, scn, "key-label", buf, i, 0); if (ret < 0 && ret != -ENOENT) return log_msg_ret("key", ret); key = max(0, ret); - ret = add_txt_str_list(info, node, scn, "desc-label", i, 0); + snprintf(buf, sizeof(buf), "%s.item-%x.desc", name, i); + ret = add_txt_str_list(info, node, scn, "desc-label", buf, i, + 0); if (ret < 0 && ret != -ENOENT) return log_msg_ret("lab", ret); desc = max(0, ret); - ret = scene_menuitem(scn, menu_id, simple_xtoa(i), + snprintf(buf, sizeof(buf), "%s.item-%x", name, i); + ret = scene_menuitem(scn, menu_id, buf, fdt32_to_cpu(item_ids[i]), key, label, desc, 0, 0, &item); if (ret < 0) @@ -316,6 +327,7 @@ static int textline_build(struct build_info *info, ofnode node, struct scene_obj_textline *ted; uint edit_id; const char *name; + char buf[80]; u32 max_chars; int ret; @@ -330,8 +342,9 @@ static int textline_build(struct build_info *info, ofnode node, if (ret < 0) return log_msg_ret("ted", ret); - /* Set the title */ - ret = add_txt_str(info, node, scn, "title", 0); + /* Set the label */ + snprintf(buf, sizeof(buf), "%s.label", name); + ret = add_txt_str(info, node, scn, "title", buf, 0); if (ret < 0) return log_msg_ret("tit", ret); ted->label_id = ret; @@ -342,7 +355,8 @@ static int textline_build(struct build_info *info, ofnode node, if (ret) return log_msg_ret("id", -ENOENT); - ret = scene_txt_str(scn, "edit", edit_id, 0, abuf_data(&ted->buf), + snprintf(buf, sizeof(buf), "%s.edit", name); + ret = scene_txt_str(scn, buf, edit_id, 0, abuf_data(&ted->buf), NULL); if (ret < 0) return log_msg_ret("add", ret); @@ -414,6 +428,7 @@ static int scene_build(struct build_info *info, ofnode scn_node, const char *name; struct scene *scn; uint id, title_id; + char buf[80]; ofnode node; int ret; @@ -428,15 +443,18 @@ static int scene_build(struct build_info *info, ofnode scn_node, if (ret < 0) return log_msg_ret("scn", ret); - ret = add_txt_str(info, scn_node, scn, "title", 0); + snprintf(buf, sizeof(buf), "%s.title", name); + ret = add_txt_str(info, scn_node, scn, "title", buf, 0); if (ret < 0) return log_msg_ret("tit", ret); title_id = ret; scn->title_id = title_id; - ret = add_txt_str(info, scn_node, scn, "prompt", 0); + snprintf(buf, sizeof(buf), "%s.prompt", name); + ret = add_txt_str(info, scn_node, scn, "prompt", buf, 0); if (ret < 0) return log_msg_ret("pr", ret); + scn->prompt_id = ret; ofnode_for_each_subnode(node, scn_node) { info->err_node = node; diff --git a/test/boot/expo.c b/test/boot/expo.c index 66fd5a2873f..f98a1e46854 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -888,7 +888,7 @@ static int expo_test_build(struct unit_test_state *uts) ut_assertnonnull(txt); obj = &txt->obj; ut_asserteq_ptr(scn, obj->scene); - ut_asserteq_str("title", obj->name); + ut_asserteq_str("main.title", obj->name); ut_asserteq(scn->title_id, obj->id); ut_asserteq(SCENEOBJT_TEXT, obj->type); ut_asserteq(0, obj->flags); @@ -913,7 +913,7 @@ static int expo_test_build(struct unit_test_state *uts) /* check the items */ item = list_first_entry(&menu->item_head, struct scene_menitem, sibling); - ut_asserteq_str("00", item->name); + ut_asserteq_str("cpu-speed.item-0", item->name); ut_asserteq(ID_CPU_SPEED_1, item->id); ut_asserteq(0, item->key_id); ut_asserteq(0, item->desc_id);