From 08854f41809293b283b96c642562cd4119d6b5db Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 27 Aug 2013 21:39:46 -0500 Subject: metag: use unflatten_and_copy_device_tree Use the common unflatten_and_copy_device_tree to copy the built-in FDT out of init section. Signed-off-by: Rob Herring Cc: James Hogan --- arch/metag/kernel/devtree.c | 16 ---------------- arch/metag/kernel/setup.c | 4 +--- 2 files changed, 1 insertion(+), 19 deletions(-) (limited to 'arch/metag') diff --git a/arch/metag/kernel/devtree.c b/arch/metag/kernel/devtree.c index 7cd02529636e..049af569cd49 100644 --- a/arch/metag/kernel/devtree.c +++ b/arch/metag/kernel/devtree.c @@ -94,21 +94,5 @@ struct machine_desc * __init setup_machine_fdt(void *dt) of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); return mdesc_best; -} -/** - * copy_fdt - Copy device tree into non-init memory. - * - * We must copy the flattened device tree blob into non-init memory because the - * unflattened device tree will reference the strings in it directly. - */ -void __init copy_fdt(void) -{ - void *alloc = early_init_dt_alloc_memory_arch( - be32_to_cpu(initial_boot_params->totalsize), 0x40); - if (alloc) { - memcpy(alloc, initial_boot_params, - be32_to_cpu(initial_boot_params->totalsize)); - initial_boot_params = alloc; - } } diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c index c396cd0b425f..2c697d343088 100644 --- a/arch/metag/kernel/setup.c +++ b/arch/metag/kernel/setup.c @@ -408,9 +408,7 @@ void __init setup_arch(char **cmdline_p) cpu_2_hwthread_id[smp_processor_id()] = hard_processor_id(); hwthread_id_2_cpu[hard_processor_id()] = smp_processor_id(); - /* Copy device tree blob into non-init memory before unflattening */ - copy_fdt(); - unflatten_device_tree(); + unflatten_and_copy_device_tree(); #ifdef CONFIG_SMP smp_init_cpus(); -- cgit v1.2.3 From e5d659935e8aa4ee8d72b1cce9ad6d6f0213909e Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 25 Sep 2013 15:46:14 -0500 Subject: metag: use early_init_dt_scan Convert metag to use new early_init_dt_scan function. Signed-off-by: Rob Herring Cc: James Hogan --- arch/metag/kernel/devtree.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'arch/metag') diff --git a/arch/metag/kernel/devtree.c b/arch/metag/kernel/devtree.c index 049af569cd49..68c2fee788c8 100644 --- a/arch/metag/kernel/devtree.c +++ b/arch/metag/kernel/devtree.c @@ -43,18 +43,16 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) */ struct machine_desc * __init setup_machine_fdt(void *dt) { - struct boot_param_header *devtree = dt; struct machine_desc *mdesc, *mdesc_best = NULL; unsigned int score, mdesc_score = ~1; unsigned long dt_root; const char *model; /* check device tree validity */ - if (be32_to_cpu(devtree->magic) != OF_DT_HEADER) + if (!early_init_dt_scan(dt)) return NULL; /* Search the mdescs for the 'best' compatible value match */ - initial_boot_params = devtree; dt_root = of_get_flat_dt_root(); for_each_machine_desc(mdesc) { @@ -90,9 +88,6 @@ struct machine_desc * __init setup_machine_fdt(void *dt) model = ""; pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); - /* Retrieve various information from the /chosen node */ - of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); - return mdesc_best; } -- cgit v1.2.3 From 29eb45a9ab4839a1e9cef2bcf369b918c9c4fcad Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 30 Aug 2013 17:06:53 -0500 Subject: of: remove early_init_dt_setup_initrd_arch All arches do essentially the same thing now for early_init_dt_setup_initrd_arch, so it can now be removed. Signed-off-by: Rob Herring Acked-by: Vineet Gupta Cc: Russell King Cc: Mark Salter Cc: Aurelien Jacquiot Cc: James Hogan Cc: Michal Simek Cc: Ralf Baechle Cc: Jonas Bonn Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Chris Zankel Cc: Max Filippov Acked-by: Grant Likely --- arch/metag/mm/init.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'arch/metag') diff --git a/arch/metag/mm/init.c b/arch/metag/mm/init.c index 123919534b80..249fff66add3 100644 --- a/arch/metag/mm/init.c +++ b/arch/metag/mm/init.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -405,11 +404,3 @@ void free_initrd_mem(unsigned long start, unsigned long end) "initrd"); } #endif - -#ifdef CONFIG_OF_FLATTREE -void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) -{ - pr_err("%s(%llx, %llx)\n", - __func__, start, end); -} -#endif /* CONFIG_OF_FLATTREE */ -- cgit v1.2.3 From 986c494b3c05bac5eace21f8e3a42f2afbfcbd34 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 25 Sep 2013 15:49:28 -0500 Subject: metag: use common of_flat_dt_match_machine Convert metag to use the common of_flat_dt_get_machine_name function. Signed-off-by: Rob Herring [james.hogan: fix missing arch_get_next_mach and const mismatch] Reported-by: Guenter Roeck Signed-off-by: James Hogan --- arch/metag/include/asm/mach/arch.h | 2 +- arch/metag/include/asm/prom.h | 2 +- arch/metag/kernel/devtree.c | 60 ++++++++++++-------------------------- arch/metag/kernel/setup.c | 2 +- 4 files changed, 22 insertions(+), 44 deletions(-) (limited to 'arch/metag') diff --git a/arch/metag/include/asm/mach/arch.h b/arch/metag/include/asm/mach/arch.h index 12c5664fea6e..433f94624fa2 100644 --- a/arch/metag/include/asm/mach/arch.h +++ b/arch/metag/include/asm/mach/arch.h @@ -53,7 +53,7 @@ struct machine_desc { /* * Current machine - only accessible during boot. */ -extern struct machine_desc *machine_desc; +extern const struct machine_desc *machine_desc; /* * Machine type table - also only accessible during boot diff --git a/arch/metag/include/asm/prom.h b/arch/metag/include/asm/prom.h index d2aa35d2228e..9f67cbf3dcb7 100644 --- a/arch/metag/include/asm/prom.h +++ b/arch/metag/include/asm/prom.h @@ -17,7 +17,7 @@ #include #define HAVE_ARCH_DEVTREE_FIXUPS -extern struct machine_desc *setup_machine_fdt(void *dt); +extern const struct machine_desc *setup_machine_fdt(void *dt); extern void copy_fdt(void); #endif /* __ASM_METAG_PROM_H */ diff --git a/arch/metag/kernel/devtree.c b/arch/metag/kernel/devtree.c index 68c2fee788c8..18dd7aea9fdc 100644 --- a/arch/metag/kernel/devtree.c +++ b/arch/metag/kernel/devtree.c @@ -34,6 +34,19 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) return alloc_bootmem_align(size, align); } +static const void * __init arch_get_next_mach(const char *const **match) +{ + static const struct machine_desc *mdesc = __arch_info_begin; + const struct machine_desc *m = mdesc; + + if (m >= __arch_info_end) + return NULL; + + mdesc++; + *match = m->dt_compat; + return m; +} + /** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt: virtual address pointer to dt blob @@ -41,53 +54,18 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) * If a dtb was passed to the kernel, then use it to choose the correct * machine_desc and to setup the system. */ -struct machine_desc * __init setup_machine_fdt(void *dt) +const struct machine_desc * __init setup_machine_fdt(void *dt) { - struct machine_desc *mdesc, *mdesc_best = NULL; - unsigned int score, mdesc_score = ~1; - unsigned long dt_root; - const char *model; + const struct machine_desc *mdesc; /* check device tree validity */ if (!early_init_dt_scan(dt)) return NULL; - /* Search the mdescs for the 'best' compatible value match */ - dt_root = of_get_flat_dt_root(); - - for_each_machine_desc(mdesc) { - score = of_flat_dt_match(dt_root, mdesc->dt_compat); - if (score > 0 && score < mdesc_score) { - mdesc_best = mdesc; - mdesc_score = score; - } - } - if (!mdesc_best) { - const char *prop; - long size; - - pr_err("\nError: unrecognized/unsupported device tree compatible list:\n[ "); - - prop = of_get_flat_dt_prop(dt_root, "compatible", &size); - if (prop) { - while (size > 0) { - printk("'%s' ", prop); - size -= strlen(prop) + 1; - prop += strlen(prop) + 1; - } - } - printk("]\n\n"); - + mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); + if (!mdesc) dump_machine_table(); /* does not return */ - } - - model = of_get_flat_dt_prop(dt_root, "model", NULL); - if (!model) - model = of_get_flat_dt_prop(dt_root, "compatible", NULL); - if (!model) - model = ""; - pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); - - return mdesc_best; + pr_info("Machine name: %s\n", mdesc->name); + return mdesc; } diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c index 2c697d343088..92cc119594d3 100644 --- a/arch/metag/kernel/setup.c +++ b/arch/metag/kernel/setup.c @@ -115,7 +115,7 @@ extern u32 __dtb_start[]; extern struct console dash_console; #endif -struct machine_desc *machine_desc __initdata; +const struct machine_desc *machine_desc __initdata; /* * Map a Linux CPU number to a hardware thread ID -- cgit v1.2.3 From 7b009939af9bc7b698d7ddec03d53604efff881c Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sun, 8 Sep 2013 14:27:53 -0500 Subject: metag: move setup_machine_fdt declaration from prom.h Move setup_machine_fdt out of prom.h and into asm/setup.h in preparation to remove prom.h. Signed-off-by: Rob Herring Acked-by: Grant Likely Cc: James Hogan Cc: linux-metag@vger.kernel.org --- arch/metag/include/asm/prom.h | 2 -- arch/metag/include/asm/setup.h | 1 + arch/metag/kernel/setup.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) (limited to 'arch/metag') diff --git a/arch/metag/include/asm/prom.h b/arch/metag/include/asm/prom.h index 9f67cbf3dcb7..e19022c5a0cb 100644 --- a/arch/metag/include/asm/prom.h +++ b/arch/metag/include/asm/prom.h @@ -14,10 +14,8 @@ #ifndef __ASM_METAG_PROM_H #define __ASM_METAG_PROM_H -#include #define HAVE_ARCH_DEVTREE_FIXUPS -extern const struct machine_desc *setup_machine_fdt(void *dt); extern void copy_fdt(void); #endif /* __ASM_METAG_PROM_H */ diff --git a/arch/metag/include/asm/setup.h b/arch/metag/include/asm/setup.h index e13083b15dd0..e9fdee9452b1 100644 --- a/arch/metag/include/asm/setup.h +++ b/arch/metag/include/asm/setup.h @@ -3,6 +3,7 @@ #include +extern const struct machine_desc *setup_machine_fdt(void *dt); void per_cpu_trap_init(unsigned long); extern void __init dump_machine_table(void); #endif /* _ASM_METAG_SETUP_H */ diff --git a/arch/metag/kernel/setup.c b/arch/metag/kernel/setup.c index 92cc119594d3..8c4b3976bebf 100644 --- a/arch/metag/kernel/setup.c +++ b/arch/metag/kernel/setup.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 32df8dca503f82c816f8be85a8d0a394a8b88c2c Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sat, 7 Sep 2013 14:11:58 -0500 Subject: of: remove HAVE_ARCH_DEVTREE_FIXUPS HAVE_ARCH_DEVTREE_FIXUPS appears to always be needed except for sparc, but it is only used for /proc/device-teee and sparc does not enable /proc/device-tree. So this option is redundant. Remove the option and always enable it. This has the side effect of fixing /proc/device-tree on arches such as arm64 which failed to define this option. Signed-off-by: Rob Herring Acked-by: Vineet Gupta Acked-by: Grant Likely Cc: Russell King Cc: James Hogan Cc: Michal Simek Cc: Jonas Bonn Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Chris Zankel Cc: Max Filippov --- arch/metag/include/asm/prom.h | 1 - 1 file changed, 1 deletion(-) (limited to 'arch/metag') diff --git a/arch/metag/include/asm/prom.h b/arch/metag/include/asm/prom.h index e19022c5a0cb..d4be144a8613 100644 --- a/arch/metag/include/asm/prom.h +++ b/arch/metag/include/asm/prom.h @@ -14,7 +14,6 @@ #ifndef __ASM_METAG_PROM_H #define __ASM_METAG_PROM_H -#define HAVE_ARCH_DEVTREE_FIXUPS extern void copy_fdt(void); -- cgit v1.2.3 From 5116b1defad7cec648384c2d1bc0b7460d305c93 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sat, 7 Sep 2013 14:33:54 -0500 Subject: of: remove empty arch prom.h headers Now that prom.h is optional, all the empty prom.h headers can be removed. Signed-off-by: Rob Herring Acked-by: Vineet Gupta Acked-by: Catalin Marinas Acked-by: Grant Likely Cc: Will Deacon Cc: Mark Salter Cc: Aurelien Jacquiot Cc: James Hogan Cc: Jonas Bonn Cc: Chris Zankel Cc: Max Filippov --- arch/metag/include/asm/prom.h | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 arch/metag/include/asm/prom.h (limited to 'arch/metag') diff --git a/arch/metag/include/asm/prom.h b/arch/metag/include/asm/prom.h deleted file mode 100644 index d4be144a8613..000000000000 --- a/arch/metag/include/asm/prom.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * arch/metag/include/asm/prom.h - * - * Copyright (C) 2012 Imagination Technologies Ltd. - * - * Based on ARM version: - * Copyright (C) 2009 Canonical Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - */ -#ifndef __ASM_METAG_PROM_H -#define __ASM_METAG_PROM_H - - -extern void copy_fdt(void); - -#endif /* __ASM_METAG_PROM_H */ -- cgit v1.2.3