libfdt: Improve size savings in FDT_RO_PROBE slightly

In the case where we have set FDT_ASSUME_MASK to disable
ASSUME_VALID_DTB checks, we can improve the FDT_RO_PROBE macro slightly.
The first thing that fdt_ro_probe_() does when we can_assume(VALID_DTB)
is true is to return whatever the contents of the totalsize field of the
DTB is. Since the FDT_RO_PROBE macro only cares about a negative value
there, we can optimize this check such that we are to assume it's a
valid DTB, we don't need to do anything here.

Signed-off-by: Tom Rini <trini@konsulko.com>
Message-ID: <20251210022002.3004223-3-trini@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Tom Rini 2025-12-09 15:50:52 -06:00 committed by David Gibson
parent b126924732
commit 39cae0bd00

View file

@ -11,11 +11,13 @@
#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
int32_t fdt_ro_probe_(const void *fdt); int32_t fdt_ro_probe_(const void *fdt);
#define FDT_RO_PROBE(fdt) \ #define FDT_RO_PROBE(fdt) \
{ \ { \
int32_t totalsize_; \ if (!can_assume(VALID_DTB)) { \
if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \ int32_t totalsize_; \
return totalsize_; \ if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \
return totalsize_; \
} \
} }
int fdt_check_node_offset_(const void *fdt, int offset); int fdt_check_node_offset_(const void *fdt, int offset);