summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorRob Herring <rob.herring@calxeda.com>2014-08-14 16:50:48 +0900
committerBeomho Seo <beomho.seo@samsung.com>2014-08-14 17:41:25 +0900
commit6cb6b0f6a56b9fd8184a549bd1ebd2ce05149c8b (patch)
tree8739183382d90c5bc7687f9eec83b060e81aba4a /arch
parente6616cbf56d2dcb1d329861272fd7d54a3ae413f (diff)
downloadlinux-3.10-6cb6b0f6a56b9fd8184a549bd1ebd2ce05149c8b.tar.gz
linux-3.10-6cb6b0f6a56b9fd8184a549bd1ebd2ce05149c8b.tar.bz2
linux-3.10-6cb6b0f6a56b9fd8184a549bd1ebd2ce05149c8b.zip
arm: use common of_flat_dt_match_machine
Convert arm to use the common of_flat_dt_match_machine function. Change-Id: I10ae33da26089ddc43008aa2a133ab7d301b4401 Signed-off-by: Rob Herring <rob.herring@calxeda.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: linux-arm-kernel@lists.infradead.org
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/kernel/devtree.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 5859c8bc727..c1eb600c655 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -169,6 +169,19 @@ void __init arm_dt_init_cpu_maps(void)
}
}
+static void * __init arch_get_next_mach(const char *const **match)
+{
+ static struct machine_desc *mdesc = __arch_info_begin;
+ 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_phys: physical address of dt blob
@@ -180,9 +193,6 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
{
struct boot_param_header *devtree;
struct machine_desc *mdesc, *mdesc_best = NULL;
- unsigned int score, mdesc_score = ~1;
- unsigned long dt_root;
- const char *model;
#ifdef CONFIG_ARCH_MULTIPLATFORM
DT_MACHINE_START(GENERIC_DT, "Generic DT based system")
@@ -200,23 +210,19 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
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) {
- 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) {
+
+ mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
+
+ if (!mdesc) {
const char *prop;
long size;
+ unsigned long dt_root;
early_print("\nError: unrecognized/unsupported "
"device tree compatible list:\n[ ");
+ dt_root = of_get_flat_dt_root();
prop = of_get_flat_dt_prop(dt_root, "compatible", &size);
while (size > 0) {
early_print("'%s' ", prop);
@@ -228,13 +234,6 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
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 = "<unknown>";
- 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);
/* Initialize {size,address}-cells info */
@@ -243,7 +242,7 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
of_scan_flat_dt(early_init_dt_scan_memory, NULL);
/* Change machine number to match the mdesc we're using */
- __machine_arch_type = mdesc_best->nr;
+ __machine_arch_type = mdesc->nr;
- return mdesc_best;
+ return mdesc;
}