From: Michael Tretter <m.tretter@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Marco Felsch <m.felsch@pengutronix.de>
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH v2 4/9] PBL: fdt: refactor helper for reading nr of cells
Date: Wed, 28 May 2025 16:11:22 +0200 [thread overview]
Message-ID: <20250528-rk3588-optee-v2-4-63070238dd13@pengutronix.de> (raw)
In-Reply-To: <20250528-rk3588-optee-v2-0-63070238dd13@pengutronix.de>
Since libfdt now contains fdt_addresses, the fdt_find_mem function can
use the already existing helpers to read #size-cells and #address-cells.
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Changes in v2:
- none
---
pbl/fdt.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/pbl/fdt.c b/pbl/fdt.c
index 8e4d1295074a6b8dc4ad07ad2ada5882148c9ce6..3b1783152a8cb81f3eda1187b2f7bf998c4addf4 100644
--- a/pbl/fdt.c
+++ b/pbl/fdt.c
@@ -17,8 +17,8 @@ static const __be32 *fdt_parse_reg(const __be32 *reg, uint32_t n,
void fdt_find_mem(const void *fdt, unsigned long *membase, unsigned long *memsize)
{
- const __be32 *nap, *nsp, *reg;
- uint32_t na, ns;
+ const __be32 *reg;
+ int na, ns;
uint64_t memsize64, membase64;
int node, size;
@@ -28,26 +28,23 @@ void fdt_find_mem(const void *fdt, unsigned long *membase, unsigned long *memsiz
goto err;
}
- /* Find the #address-cells and #size-cells properties */
node = fdt_path_offset(fdt, "/");
if (node < 0) {
pr_err("Cannot find root node\n");
goto err;
}
- nap = fdt_getprop(fdt, node, "#address-cells", &size);
- if (!nap || (size != 4)) {
+ na = fdt_address_cells(fdt, node);
+ if (na < 0) {
pr_err("Cannot find #address-cells property");
goto err;
}
- na = fdt32_to_cpu(*nap);
- nsp = fdt_getprop(fdt, node, "#size-cells", &size);
- if (!nsp || (size != 4)) {
+ ns = fdt_size_cells(fdt, node);
+ if (ns < 0) {
pr_err("Cannot find #size-cells property");
goto err;
}
- ns = fdt32_to_cpu(*nsp);
/* Find the memory range */
node = fdt_node_offset_by_prop_value(fdt, -1, "device_type",
--
2.39.5
next prev parent reply other threads:[~2025-05-28 14:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 14:11 [PATCH v2 0/9] ARM: rockchip: fix dynamic shared memory in OP-TEE Michael Tretter
2025-05-28 14:11 ` [PATCH v2 1/9] ARM: rockchip: fix formatting Michael Tretter
2025-05-28 14:11 ` [PATCH v2 2/9] ARM: rockchip: dmc: use RK3588_INT_REG_START for rk3588 Michael Tretter
2025-05-28 14:11 ` [PATCH v2 3/9] lib: fdt: add fdt_addresses Michael Tretter
2025-05-28 14:11 ` Michael Tretter [this message]
2025-05-28 14:11 ` [PATCH v2 5/9] PBL: fdt: add fdt_fixup_mem to fixup memory nodes Michael Tretter
2025-05-28 14:11 ` [PATCH v2 6/9] ARM: add CONFIG_SCRATCH_SIZE Michael Tretter
2025-05-28 15:34 ` Marco Felsch
2025-05-28 14:11 ` [PATCH v2 7/9] ARM: rockchip: dmc: add rk3588_ram_sizes to get full ram size Michael Tretter
2025-05-28 14:11 ` [PATCH v2 8/9] ARM: rockchip: pass device tree to TF-A Michael Tretter
2025-05-28 15:39 ` Marco Felsch
2025-05-28 14:11 ` [PATCH v2 9/9] ARM: rockchip: fixup memory in device tree for TF-A Michael Tretter
2025-05-28 15:40 ` Marco Felsch
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=20250528-rk3588-optee-v2-4-63070238dd13@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.felsch@pengutronix.de \
--cc=s.hauer@pengutronix.de \
/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