Skip to content

Commit 060f78c

Browse files
committed
powerpc: use libfdt accessors for header data
With libfdt support, we can take advantage of helper accessors in libfdt for accessing the FDT header data. This makes the code more readable and makes the FDT blob structure more opaque to the kernel. This also prepares for removing struct boot_param_header completely. Signed-off-by: Rob Herring <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Tested-by: Grant Likely <[email protected]> Tested-by: Stephen Chivers <[email protected]>
1 parent c0556d3 commit 060f78c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

arch/powerpc/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Makefile for the linux kernel.
33
#
44

5+
CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt
56
CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
67

78
subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror

arch/powerpc/kernel/prom.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/memblock.h>
3434
#include <linux/of.h>
3535
#include <linux/of_fdt.h>
36+
#include <linux/libfdt.h>
3637

3738
#include <asm/prom.h>
3839
#include <asm/rtas.h>
@@ -117,14 +118,14 @@ static void __init move_device_tree(void)
117118
DBG("-> move_device_tree\n");
118119

119120
start = __pa(initial_boot_params);
120-
size = be32_to_cpu(initial_boot_params->totalsize);
121+
size = fdt_totalsize(initial_boot_params);
121122

122123
if ((memory_limit && (start + size) > PHYSICAL_START + memory_limit) ||
123124
overlaps_crashkernel(start, size) ||
124125
overlaps_initrd(start, size)) {
125126
p = __va(memblock_alloc(size, PAGE_SIZE));
126127
memcpy(p, initial_boot_params, size);
127-
initial_boot_params = (struct boot_param_header *)p;
128+
initial_boot_params = p;
128129
DBG("Moved device tree to 0x%p\n", p);
129130
}
130131

@@ -324,9 +325,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
324325
* version 2 of the kexec param format adds the phys cpuid of
325326
* booted proc.
326327
*/
327-
if (be32_to_cpu(initial_boot_params->version) >= 2) {
328+
if (fdt_version(initial_boot_params) >= 2) {
328329
if (be32_to_cpu(intserv[i]) ==
329-
be32_to_cpu(initial_boot_params->boot_cpuid_phys)) {
330+
fdt_boot_cpuid_phys(initial_boot_params)) {
330331
found = boot_cpu_count;
331332
found_thread = i;
332333
}
@@ -599,7 +600,7 @@ static void __init early_reserve_mem(void)
599600
__be64 *reserve_map;
600601

601602
reserve_map = (__be64 *)(((unsigned long)initial_boot_params) +
602-
be32_to_cpu(initial_boot_params->off_mem_rsvmap));
603+
fdt_off_mem_rsvmap(initial_boot_params));
603604

604605
/* Look for the new "reserved-regions" property in the DT */
605606
early_reserve_mem_dt();

0 commit comments

Comments
 (0)