]> www.infradead.org Git - nvme.git/commitdiff
of/fdt: avoid re-parsing '#{address,size}-cells' in of_fdt_limit_memory
authorRob Herring <robh@kernel.org>
Thu, 30 Aug 2018 16:20:20 +0000 (11:20 -0500)
committerRob Herring (Arm) <robh@kernel.org>
Fri, 31 May 2024 13:33:54 +0000 (08:33 -0500)
Now that we initialize dt_root_addr_cells and dt_root_size_cells earlier,
use them and simplify of_fdt_limit_memory.

Link: https://lore.kernel.org/all/20180830190523.31474-3-robh@kernel.org/
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/fdt.c

index 00bb8c9b62fad242ae379ca95994adcb08f5fa14..68103ad230eebd93654423ba716e8da8767b038c 100644 (file)
@@ -52,28 +52,7 @@ void __init of_fdt_limit_memory(int limit)
        int memory;
        int len;
        const void *val;
-       int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
-       int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
-       const __be32 *addr_prop;
-       const __be32 *size_prop;
-       int root_offset;
-       int cell_size;
-
-       root_offset = fdt_path_offset(initial_boot_params, "/");
-       if (root_offset < 0)
-               return;
-
-       addr_prop = fdt_getprop(initial_boot_params, root_offset,
-                               "#address-cells", NULL);
-       if (addr_prop)
-               nr_address_cells = fdt32_to_cpu(*addr_prop);
-
-       size_prop = fdt_getprop(initial_boot_params, root_offset,
-                               "#size-cells", NULL);
-       if (size_prop)
-               nr_size_cells = fdt32_to_cpu(*size_prop);
-
-       cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells);
+       int cell_size = sizeof(uint32_t)*(dt_root_addr_cells + dt_root_size_cells);
 
        memory = fdt_path_offset(initial_boot_params, "/memory");
        if (memory > 0) {