Skip to content

Commit b6363fe

Browse files
robherringctmarinas
authored andcommitted
arm64: Simplify checking for populated DT
Use of the of_scan_flat_dt() function predates libfdt and is discouraged as libfdt provides a nicer set of APIs. Rework dt_scan_depth1_nodes to use libfdt calls directly, and rename it to dt_is_stub() to reflect exactly what it checking. Cc: Will Deacon <[email protected]> Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent d658220 commit b6363fe

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

arch/arm64/kernel/acpi.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/irq_work.h>
2323
#include <linux/memblock.h>
2424
#include <linux/of_fdt.h>
25+
#include <linux/libfdt.h>
2526
#include <linux/smp.h>
2627
#include <linux/serial_core.h>
2728
#include <linux/pgtable.h>
@@ -62,29 +63,22 @@ static int __init parse_acpi(char *arg)
6263
}
6364
early_param("acpi", parse_acpi);
6465

65-
static int __init dt_scan_depth1_nodes(unsigned long node,
66-
const char *uname, int depth,
67-
void *data)
66+
static bool __init dt_is_stub(void)
6867
{
69-
/*
70-
* Ignore anything not directly under the root node; we'll
71-
* catch its parent instead.
72-
*/
73-
if (depth != 1)
74-
return 0;
68+
int node;
7569

76-
if (strcmp(uname, "chosen") == 0)
77-
return 0;
70+
fdt_for_each_subnode(node, initial_boot_params, 0) {
71+
const char *name = fdt_get_name(initial_boot_params, node, NULL);
72+
if (strcmp(name, "chosen") == 0)
73+
continue;
74+
if (strcmp(name, "hypervisor") == 0 &&
75+
of_flat_dt_is_compatible(node, "xen,xen"))
76+
continue;
7877

79-
if (strcmp(uname, "hypervisor") == 0 &&
80-
of_flat_dt_is_compatible(node, "xen,xen"))
81-
return 0;
78+
return false;
79+
}
8280

83-
/*
84-
* This node at depth 1 is neither a chosen node nor a xen node,
85-
* which we do not expect.
86-
*/
87-
return 1;
81+
return true;
8882
}
8983

9084
/*
@@ -205,8 +199,7 @@ void __init acpi_boot_table_init(void)
205199
* and ACPI has not been [force] enabled (acpi=on|force)
206200
*/
207201
if (param_acpi_off ||
208-
(!param_acpi_on && !param_acpi_force &&
209-
of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
202+
(!param_acpi_on && !param_acpi_force && !dt_is_stub()))
210203
goto done;
211204

212205
/*

0 commit comments

Comments
 (0)