[PATCH 01/10] of/fdt: Introduce dt_root_addr_size_cells() and dt_root_addr_size_bytes()
From: Yuntao Wang
Date: Wed Nov 12 2025 - 09:37:24 EST
Currently, many places use the result of the expression
`(dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32)` for various
checks.
To improve code maintainability and reduce the chance of errors, extract
this expression into two helper functions.
Signed-off-by: Yuntao Wang <yuntao.wang@xxxxxxxxx>
---
include/linux/of_fdt.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index b8d6c0c20876..9ce2433865ae 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -30,6 +30,17 @@ extern void *of_fdt_unflatten_tree(const unsigned long *blob,
/* TBD: Temporary export of fdt globals - remove when code fully merged */
extern int __initdata dt_root_addr_cells;
extern int __initdata dt_root_size_cells;
+
+static inline int dt_root_addr_size_cells(void)
+{
+ return dt_root_addr_cells + dt_root_size_cells;
+}
+
+static inline int dt_root_addr_size_bytes(void)
+{
+ return dt_root_addr_size_cells() * sizeof(__be32);
+}
+
extern void *initial_boot_params;
extern phys_addr_t initial_boot_params_pa;
--
2.51.0