* - the device tree is not empty (it has more than just a /chosen node)
* and ACPI has not been force enabled (acpi=force)
*/
- if ( param_acpi_off || ( !param_acpi_force
- && device_tree_for_each_node(device_tree_flattened,
- dt_scan_depth1_nodes, NULL)))
+ if ( param_acpi_off)
+ goto disable;
+ if ( !param_acpi_force &&
+ device_tree_for_each_node(device_tree_flattened, 0,
+ dt_scan_depth1_nodes, NULL) )
goto disable;
/*
}
/**
- * device_tree_for_each_node - iterate over all device tree nodes
+ * device_tree_for_each_node - iterate over all device tree sub-nodes
* @fdt: flat device tree.
- * @func: function to call for each node.
+ * @node: parent node to start the search from
+ * @func: function to call for each sub-node.
* @data: data to pass to @func.
*
* Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored.
* Returns 0 if all nodes were iterated over successfully. If @func
* returns a value different from 0, that value is returned immediately.
*/
-int __init device_tree_for_each_node(const void *fdt,
+int __init device_tree_for_each_node(const void *fdt, int node,
device_tree_node_func func,
void *data)
{
- int node;
- int depth;
+ /*
+ * We only care about relative depth increments, assume depth of
+ * node is 0 for simplicity.
+ */
+ int depth = 0;
+ const int min_depth = depth;
+ const int first_node = node;
u32 address_cells[DEVICE_TREE_MAX_DEPTH];
u32 size_cells[DEVICE_TREE_MAX_DEPTH];
int ret;
- for ( node = 0, depth = 0;
- node >=0 && depth >= 0;
- node = fdt_next_node(fdt, node, &depth) )
- {
+ do {
const char *name = fdt_get_name(fdt, node, NULL);
u32 as, ss;
size_cells[depth] = device_tree_get_u32(fdt, node,
"#size-cells", ss);
- ret = func(fdt, node, name, depth, as, ss, data);
- if ( ret != 0 )
- return ret;
- }
+ /* skip the first node */
+ if ( node != first_node )
+ {
+ ret = func(fdt, node, name, depth, as, ss, data);
+ if ( ret != 0 )
+ return ret;
+ }
+
+ node = fdt_next_node(fdt, node, &depth);
+ } while ( node >= 0 && depth > min_depth );
+
return 0;
}
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, early_scan_node, NULL);
early_print_info();
return fdt_totalsize(fdt);