From patchwork Mon Jan 19 20:41:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1644 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=1768855380; bh=1ELjRTR618dfnXZ9ZUV4YAjoO24ZK/lmJXBUw19bkec=; 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=KaMenEVjB2Ku24vq6EH4uODdS20+uamt7nVQIYyiOS1Sf4mFozbex67P5fwf+tpNr 3FiUEfEd1H2d67ijHgL6+fzEXchGi1e4Vh4TYQ5zrXfnud6+PINnUe41ad+U0EYq4x ivM5fXlpQqZjR+GLYXyDFxGRNhXiPfeHqT5u8l5LFvBjcFMVgfZ5z0ZhYMqSFAERPQ GcQrMm/0o0beXkZXMzGJ/T2BnHGyuoG9PwhFzTziYmpYtru5BW1zHaW0nt52ykQPkz XPQ9jJwP7/o7n/UpQ8TLCsOIYg+vpXI0uYS15BnqooG2RxzGliWw4oXGT/pnIWixLk MxdmER/TVr9YQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1FDF36951E for ; Mon, 19 Jan 2026 13:43:00 -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 PuKlGgbuXTMv for ; Mon, 19 Jan 2026 13:43:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855380; bh=1ELjRTR618dfnXZ9ZUV4YAjoO24ZK/lmJXBUw19bkec=; 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=KaMenEVjB2Ku24vq6EH4uODdS20+uamt7nVQIYyiOS1Sf4mFozbex67P5fwf+tpNr 3FiUEfEd1H2d67ijHgL6+fzEXchGi1e4Vh4TYQ5zrXfnud6+PINnUe41ad+U0EYq4x ivM5fXlpQqZjR+GLYXyDFxGRNhXiPfeHqT5u8l5LFvBjcFMVgfZ5z0ZhYMqSFAERPQ GcQrMm/0o0beXkZXMzGJ/T2BnHGyuoG9PwhFzTziYmpYtru5BW1zHaW0nt52ykQPkz XPQ9jJwP7/o7n/UpQ8TLCsOIYg+vpXI0uYS15BnqooG2RxzGliWw4oXGT/pnIWixLk MxdmER/TVr9YQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 019C469513 for ; Mon, 19 Jan 2026 13:43:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855379; bh=FIWBaHcz5yyLPasQiQDlHWibpbqsPXDVu/SR7P8sWUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTaoxAGuUB2BO/Cxqv1P84sKqRNizACkpbdq1yAZvK5HzhL87IWZPFsZHcVNfs9dc JyG2KuEnaD1zjiVmowVK32sasiSxCCT3FU/lgC1OmdkTVXfyTpVXBVMm7G61E/xy2a y23Gsztrf9HPLODJH6fqQj41i+x2StR/tB0/qoBvHbe6jgjgcGEe3ITEnIJbT4L8SD JOc5Z2nTwGQTSn4J+8rIsv34ySJqCLzBe7MnD5Br3vWcW3jpAmQ9d3reuknvNyTrwG lkEuJVzslArn7otvrUC64YlkCQ1HFrUYyjcQcqTwuaixck+qqZGJn6Pg+pQhIscN5j nGaYk59K8THgg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 31700693E3; Mon, 19 Jan 2026 13:42:59 -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 SDJshRXRD_Qh; Mon, 19 Jan 2026 13:42:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768855375; bh=PJSJQnqdbFhgC+jvRq8Dw/bkjpP8R3v4YuoPmHXG5ew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6QLsQ2B9xwitZ80OT8fl55hzrrvEwrAwWsot6PBnU75Vwdlm07X8hAyy8WQUQmr7 r8amTy6ObSQXg0DldtQLfjGSYBGcMm2xUGQBmwPg/VLZBaGu68WRshZZmQQxXDPLGc HDzDESccJ4p/VKz2zOfcO5+6HobpgGyq1xQQ1o34Z6Ebb2C45upyHPJKF1pNOiPvMa c4TLZ+feo+lRYMj80ATYDW5o7HtvFfe6/DC4OBR8I3wtIK77OJSlX2qfDglajsQ8zN R7NIs+Ls5KzgkKVnhjJNGhm4iEAQTGAw8xtIJglhPp05zBi8tbGbxKRAimkA/itd1i iFdEhvcWAOGhg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DCC43693BA; Mon, 19 Jan 2026 13:42:54 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 19 Jan 2026 13:41:07 -0700 Message-ID: <20260119204130.3972647-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260119204130.3972647-1-sjg@u-boot.org> References: <20260119204130.3972647-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: P3EPIZQHNSFTNERZ5Y4VZESP2V3M676E X-Message-ID-Hash: P3EPIZQHNSFTNERZ5Y4VZESP2V3M676E 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/27] expo: Use a configurable output function in expo_dump() 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 Refactor the dump context to use a configurable output function instead of directly writing to a membuf. This allows different output targets to be used. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/expo_dump.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/boot/expo_dump.c b/boot/expo_dump.c index b2ea60db50c..d357aa6a5be 100644 --- a/boot/expo_dump.c +++ b/boot/expo_dump.c @@ -15,36 +15,64 @@ #include #include "scene_internal.h" +/** + * typedef dump_out_func - Function type for dump output + * + * @priv: Private data for the output function + * @buf: Buffer containing data to output + * @len: Length of data in buffer + */ +typedef void (*dump_out_func)(void *priv, const char *buf, int len); + /** * struct dump_ctx - Context for dumping expo structures * - * @mb: Membuf to write output to + * @out: Output function to call for each piece of output + * @priv: Private data to pass to output function * @scn: Current scene being dumped (or NULL if not in a scene) * @indent: Current indentation level (number of spaces) */ struct dump_ctx { - struct membuf *mb; + dump_out_func out; + void *priv; struct scene *scn; int indent; }; +/** + * dump_out_membuf() - Output function that writes to a membuf + * + * @priv: Pointer to struct membuf + * @buf: Buffer containing data to output + * @len: Length of data in buffer + */ +static void dump_out_membuf(void *priv, const char *buf, int len) +{ + struct membuf *mb = priv; + + membuf_put(mb, buf, len); +} + /** * outf() - Output a formatted string with indentation * - * @ctx: Dump context containing membuf, scene, and indent level + * @ctx: Dump context containing output function, scene, and indent level * @fmt: Format string * @...: Arguments for format string */ static void outf(struct dump_ctx *ctx, const char *fmt, ...) { char buf[256]; + char indent_buf[64]; va_list args; int len; + len = snprintf(indent_buf, sizeof(indent_buf), "%*s", ctx->indent, ""); + ctx->out(ctx->priv, indent_buf, len); + va_start(args, fmt); - membuf_printf(ctx->mb, "%*s", ctx->indent, ""); len = vsnprintf(buf, sizeof(buf), fmt, args); - membuf_put(ctx->mb, buf, len); + ctx->out(ctx->priv, buf, len); va_end(args); } @@ -196,7 +224,8 @@ void scene_dump(struct membuf *mb, struct scene *scn, int indent) { struct dump_ctx ctx; - ctx.mb = mb; + ctx.out = dump_out_membuf; + ctx.priv = mb; ctx.scn = scn; ctx.indent = indent; @@ -262,7 +291,8 @@ void expo_dump(struct expo *exp, struct membuf *mb) { struct dump_ctx ctx; - ctx.mb = mb; + ctx.out = dump_out_membuf; + ctx.priv = mb; ctx.scn = NULL; ctx.indent = 0;