diff options
author | Rob Herring <rob.herring@calxeda.com> | 2013-09-25 16:49:28 -0400 |
---|---|---|
committer | Rob Herring <rob.herring@calxeda.com> | 2013-10-09 21:03:57 -0400 |
commit | 986c494b3c05bac5eace21f8e3a42f2afbfcbd34 (patch) | |
tree | 039ce7d9c78bc1f4f8616202c90d107da82cd95f /arch | |
parent | f2b99bccae87de82a5d03838abe85d604ee7e525 (diff) |
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 <rob.herring@calxeda.com>
[james.hogan: fix missing arch_get_next_mach and const mismatch]
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/metag/include/asm/mach/arch.h | 2 | ||||
-rw-r--r-- | arch/metag/include/asm/prom.h | 2 | ||||
-rw-r--r-- | arch/metag/kernel/devtree.c | 60 | ||||
-rw-r--r-- | arch/metag/kernel/setup.c | 2 |
4 files changed, 22 insertions, 44 deletions
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 { | |||
53 | /* | 53 | /* |
54 | * Current machine - only accessible during boot. | 54 | * Current machine - only accessible during boot. |
55 | */ | 55 | */ |
56 | extern struct machine_desc *machine_desc; | 56 | extern const struct machine_desc *machine_desc; |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Machine type table - also only accessible during boot | 59 | * 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 @@ | |||
17 | #include <asm/setup.h> | 17 | #include <asm/setup.h> |
18 | #define HAVE_ARCH_DEVTREE_FIXUPS | 18 | #define HAVE_ARCH_DEVTREE_FIXUPS |
19 | 19 | ||
20 | extern struct machine_desc *setup_machine_fdt(void *dt); | 20 | extern const struct machine_desc *setup_machine_fdt(void *dt); |
21 | extern void copy_fdt(void); | 21 | extern void copy_fdt(void); |
22 | 22 | ||
23 | #endif /* __ASM_METAG_PROM_H */ | 23 | #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) | |||
34 | return alloc_bootmem_align(size, align); | 34 | return alloc_bootmem_align(size, align); |
35 | } | 35 | } |
36 | 36 | ||
37 | static const void * __init arch_get_next_mach(const char *const **match) | ||
38 | { | ||
39 | static const struct machine_desc *mdesc = __arch_info_begin; | ||
40 | const struct machine_desc *m = mdesc; | ||
41 | |||
42 | if (m >= __arch_info_end) | ||
43 | return NULL; | ||
44 | |||
45 | mdesc++; | ||
46 | *match = m->dt_compat; | ||
47 | return m; | ||
48 | } | ||
49 | |||
37 | /** | 50 | /** |
38 | * setup_machine_fdt - Machine setup when an dtb was passed to the kernel | 51 | * setup_machine_fdt - Machine setup when an dtb was passed to the kernel |
39 | * @dt: virtual address pointer to dt blob | 52 | * @dt: virtual address pointer to dt blob |
@@ -41,53 +54,18 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | |||
41 | * If a dtb was passed to the kernel, then use it to choose the correct | 54 | * If a dtb was passed to the kernel, then use it to choose the correct |
42 | * machine_desc and to setup the system. | 55 | * machine_desc and to setup the system. |
43 | */ | 56 | */ |
44 | struct machine_desc * __init setup_machine_fdt(void *dt) | 57 | const struct machine_desc * __init setup_machine_fdt(void *dt) |
45 | { | 58 | { |
46 | struct machine_desc *mdesc, *mdesc_best = NULL; | 59 | const struct machine_desc *mdesc; |
47 | unsigned int score, mdesc_score = ~1; | ||
48 | unsigned long dt_root; | ||
49 | const char *model; | ||
50 | 60 | ||
51 | /* check device tree validity */ | 61 | /* check device tree validity */ |
52 | if (!early_init_dt_scan(dt)) | 62 | if (!early_init_dt_scan(dt)) |
53 | return NULL; | 63 | return NULL; |
54 | 64 | ||
55 | /* Search the mdescs for the 'best' compatible value match */ | 65 | mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); |
56 | dt_root = of_get_flat_dt_root(); | 66 | if (!mdesc) |
57 | |||
58 | for_each_machine_desc(mdesc) { | ||
59 | score = of_flat_dt_match(dt_root, mdesc->dt_compat); | ||
60 | if (score > 0 && score < mdesc_score) { | ||
61 | mdesc_best = mdesc; | ||
62 | mdesc_score = score; | ||
63 | } | ||
64 | } | ||
65 | if (!mdesc_best) { | ||
66 | const char *prop; | ||
67 | long size; | ||
68 | |||
69 | pr_err("\nError: unrecognized/unsupported device tree compatible list:\n[ "); | ||
70 | |||
71 | prop = of_get_flat_dt_prop(dt_root, "compatible", &size); | ||
72 | if (prop) { | ||
73 | while (size > 0) { | ||
74 | printk("'%s' ", prop); | ||
75 | size -= strlen(prop) + 1; | ||
76 | prop += strlen(prop) + 1; | ||
77 | } | ||
78 | } | ||
79 | printk("]\n\n"); | ||
80 | |||
81 | dump_machine_table(); /* does not return */ | 67 | dump_machine_table(); /* does not return */ |
82 | } | 68 | pr_info("Machine name: %s\n", mdesc->name); |
83 | |||
84 | model = of_get_flat_dt_prop(dt_root, "model", NULL); | ||
85 | if (!model) | ||
86 | model = of_get_flat_dt_prop(dt_root, "compatible", NULL); | ||
87 | if (!model) | ||
88 | model = "<unknown>"; | ||
89 | pr_info("Machine: %s, model: %s\n", mdesc_best->name, model); | ||
90 | |||
91 | return mdesc_best; | ||
92 | 69 | ||
70 | return mdesc; | ||
93 | } | 71 | } |
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[]; | |||
115 | extern struct console dash_console; | 115 | extern struct console dash_console; |
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | struct machine_desc *machine_desc __initdata; | 118 | const struct machine_desc *machine_desc __initdata; |
119 | 119 | ||
120 | /* | 120 | /* |
121 | * Map a Linux CPU number to a hardware thread ID | 121 | * Map a Linux CPU number to a hardware thread ID |