Skip to contentSkip to conversation

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

PATCH In review [email protected] 2 participants 2 messages Apr 12, 2024 – Apr 16, 2024 Device tree

lore
Share & tools
lore
#0 lore raw

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

From: Daero Lee <[email protected]>

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.

---
 drivers/of/of_reserved_mem.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/of/of_reserved_mem.c +2 -5
index 8236ecae2953..cb86a28379c7 100644
@@ -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) {
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · On Fri, Apr 12, 2024 at 11:09:38PM +0900, [email protected] wrote:

From: Daero Lee <[email protected]>

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/[email protected]/