]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/arm: extend device_tree_for_each_node
authorStefano Stabellini <sstabellini@kernel.org>
Tue, 30 Apr 2019 20:52:19 +0000 (13:52 -0700)
committerStefano Stabellini <sstabellini@kernel.org>
Tue, 30 Apr 2019 20:52:19 +0000 (13:52 -0700)
Add two new paramters to device_tree_for_each_node: node and depth.
Node is the node to start the search from and depth is the min depth of
the search.

Passing 0, 0 triggers the old behavior.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
---
Changes in v2:
- new

xen/arch/arm/acpi/boot.c
xen/arch/arm/bootfdt.c
xen/include/xen/device_tree.h

index 9b29769a10301b614faa50ebe381e1ed0cccbe73..cfc85c2b617f4d75e8e37ffe69d4d90b725e394a 100644 (file)
@@ -248,7 +248,7 @@ int __init acpi_boot_table_init(void)
      */
     if ( param_acpi_off || ( !param_acpi_force
                              && device_tree_for_each_node(device_tree_flattened,
-                                                   dt_scan_depth1_nodes, NULL)))
+                                 0, 0, dt_scan_depth1_nodes, NULL)))
         goto disable;
 
     /*
index 891b4b66ffbbe2368950323b4588970ee8db36aa..e7b08edb7394a6ab6e6008a902ea2b93c3b9c9b5 100644 (file)
@@ -77,6 +77,8 @@ static u32 __init device_tree_get_u32(const void *fdt, int node,
 /**
  * device_tree_for_each_node - iterate over all device tree nodes
  * @fdt: flat device tree.
+ * @node: node to start the search from
+ * @depth: min depth of the search
  * @func: function to call for each node.
  * @data: data to pass to @func.
  *
@@ -86,17 +88,15 @@ static u32 __init device_tree_get_u32(const void *fdt, int node,
  * returns a value different from 0, that value is returned immediately.
  */
 int __init device_tree_for_each_node(const void *fdt,
+                                     int node, int depth,
                                      device_tree_node_func func,
                                      void *data)
 {
-    int node;
-    int depth;
     u32 address_cells[DEVICE_TREE_MAX_DEPTH];
     u32 size_cells[DEVICE_TREE_MAX_DEPTH];
-    int ret;
+    int ret, min_depth = depth;
 
-    for ( node = 0, depth = 0;
-          node >=0 && depth >= 0;
+    for ( ; node >=0 && depth >= min_depth;
           node = fdt_next_node(fdt, node, &depth) )
     {
         const char *name = fdt_get_name(fdt, node, NULL);
@@ -357,7 +357,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t paddr)
 
     add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false);
 
-    device_tree_for_each_node((void *)fdt, early_scan_node, NULL);
+    device_tree_for_each_node((void *)fdt, 0, 0, early_scan_node, NULL);
     early_print_info();
 
     return fdt_totalsize(fdt);
index 7408a6c48ca92a3960cf40b0f5f99d9ae5baf118..4ff78baa442c9f1e5c11f708544771699327ccd6 100644 (file)
@@ -159,8 +159,9 @@ typedef int (*device_tree_node_func)(const void *fdt,
 extern const void *device_tree_flattened;
 
 int device_tree_for_each_node(const void *fdt,
-                                     device_tree_node_func func,
-                                     void *data);
+                              int node, int depth,
+                              device_tree_node_func func,
+                              void *data);
 
 /**
  * dt_unflatten_host_device_tree - Unflatten the host device tree