From: David Gibson <david@gibson.dropbear.id.au>
To: Tom Rini <trini@konsulko.com>
Cc: devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH 3/3] libfdt: fdt_get_name: Add can_assume(VALID_DTB) check
Date: Wed, 10 Dec 2025 17:47:58 +1100 [thread overview]
Message-ID: <aTkXnnYkjvPbN3Yd@zatzit> (raw)
In-Reply-To: <20251210022002.3004223-4-trini@konsulko.com>
[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]
On Tue, Dec 09, 2025 at 03:50:53PM -0600, Tom Rini wrote:
11;rgb:ffff/ffff/ffff> In this function from fdt_ro.c we have (reasonably) some checks of the
> DTB before we begin work. However, we do this in a way that we cannot
> make use of the normal FDT_RO_PROBE macro and instead have a direct call
> to fdt_ro_probe_(). Add a test for !can_assume(VALID_DTB) here first so
> that in cases where we are assuming a valid DTB we can omit the checks.
>
> Signed-off-by: Tom Rini <trini@konsulko.com>
Applied, thanks.
> ---
> This is another case which we see in U-Boot SPL, and for the last 6
> years now have had the equivalent check. This change ends up being a
> noticeable size win for us.
> ---
> libfdt/fdt_ro.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
> index b78c4e48f1cb..63494fb7ad90 100644
> --- a/libfdt/fdt_ro.c
> +++ b/libfdt/fdt_ro.c
> @@ -306,8 +306,8 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
> const char *nameptr;
> int err;
>
> - if (((err = fdt_ro_probe_(fdt)) < 0)
> - || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0))
> + if (!can_assume(VALID_DTB) && (((err = fdt_ro_probe_(fdt)) < 0)
> + || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)))
> goto fail;
>
> nameptr = nh->name;
> --
> 2.43.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2025-12-10 6:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 21:50 [PATCH 0/3] libfdt: A few more size improvements Tom Rini
2025-12-09 21:50 ` [PATCH 1/3] libfdt: libfdt_internal.h correct final comment in ASSUME block Tom Rini
2025-12-10 6:42 ` David Gibson
2025-12-09 21:50 ` [PATCH 2/3] libfdt: Improve size savings in FDT_RO_PROBE slightly Tom Rini
2025-12-10 6:46 ` David Gibson
2025-12-09 21:50 ` [PATCH 3/3] libfdt: fdt_get_name: Add can_assume(VALID_DTB) check Tom Rini
2025-12-10 6:47 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aTkXnnYkjvPbN3Yd@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=devicetree-compiler@vger.kernel.org \
--cc=trini@konsulko.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).