diff mbox series

of: of_reserved_mem: remove repeated call to get no-map property

Message ID 20240412140938.137803-1-skseofh@gmail.com
State Under Review
Headers show
Series of: of_reserved_mem: remove repeated call to get no-map property | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied fail build log

Commit Message

DaeRo Lee April 12, 2024, 2:09 p.m. UTC
From: Daero Lee <skseofh@gmail.com>

In __reserved_mem_alloc_size, of_get_flat_dt_prop is called and checked
whether the "no-map" property exists for the node. In
fdt_init_reserved_mem, the only caller of __reserved_mem_alloc_size,
we checked this again for the same node. Therefore, repeated
of_get_flat_dt_prop call was removed and 'nomap' was passed as an input
parameter to the callee function.

Signed-off-by: Daero Lee <skseofh@gmail.com>
---
 drivers/of/of_reserved_mem.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Comments

Rob Herring (Arm) April 16, 2024, 1:15 p.m. UTC | #1
On Fri, Apr 12, 2024 at 11:09:38PM +0900, skseofh@gmail.com wrote:
> From: Daero Lee <skseofh@gmail.com>
> 
> In __reserved_mem_alloc_size, of_get_flat_dt_prop is called and checked
> whether the "no-map" property exists for the node. In
> fdt_init_reserved_mem, the only caller of __reserved_mem_alloc_size,
> we checked this again for the same node. Therefore, repeated
> of_get_flat_dt_prop call was removed and 'nomap' was passed as an input
> parameter to the callee function.

This code is all about to get rearranged[1], so holding off on this.

Rob

[1] https://lore.kernel.org/lkml/20240328211543.191876-1-quic_obabatun@quicinc.com/
diff mbox series

Patch

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 8236ecae2953..cb86a28379c7 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -254,14 +254,13 @@  static int __init __reserved_mem_alloc_in_range(phys_addr_t size,
  *	'size', 'alignment'  and 'alloc-ranges' properties.
  */
 static int __init __reserved_mem_alloc_size(unsigned long node,
-	const char *uname, phys_addr_t *res_base, phys_addr_t *res_size)
+	const char *uname, phys_addr_t *res_base, phys_addr_t *res_size, bool nomap)
 {
 	int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32);
 	phys_addr_t start = 0, end = 0;
 	phys_addr_t base = 0, align = 0, size;
 	int len;
 	const __be32 *prop;
-	bool nomap;
 	int ret;
 
 	prop = of_get_flat_dt_prop(node, "size", &len);
@@ -284,8 +283,6 @@  static int __init __reserved_mem_alloc_size(unsigned long node,
 		align = dt_mem_next_cell(dt_root_addr_cells, &prop);
 	}
 
-	nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL;
-
 	/* Need adjust the alignment to satisfy the CMA requirement */
 	if (IS_ENABLED(CONFIG_CMA)
 	    && of_flat_dt_is_compatible(node, "shared-dma-pool")
@@ -451,7 +448,7 @@  void __init fdt_init_reserved_mem(void)
 
 		if (rmem->size == 0)
 			err = __reserved_mem_alloc_size(node, rmem->name,
-						 &rmem->base, &rmem->size);
+						 &rmem->base, &rmem->size, nomap);
 		if (err == 0) {
 			err = __reserved_mem_init_node(rmem);
 			if (err != 0 && err != -ENOENT) {