Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arc: use common of_flat_dt_match_machine

Convert arc to use the common of_flat_dt_match_machine function.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>

+23 -62
+3 -13
arch/arc/include/asm/mach_desc.h
··· 51 51 /* 52 52 * Current machine - only accessible during boot. 53 53 */ 54 - extern struct machine_desc *machine_desc; 54 + extern const struct machine_desc *machine_desc; 55 55 56 56 /* 57 57 * Machine type table - also only accessible during boot 58 58 */ 59 - extern struct machine_desc __arch_info_begin[], __arch_info_end[]; 60 - #define for_each_machine_desc(p) \ 61 - for (p = __arch_info_begin; p < __arch_info_end; p++) 62 - 63 - static inline struct machine_desc *default_machine_desc(void) 64 - { 65 - /* the default machine is the last one linked in */ 66 - if (__arch_info_end - 1 < __arch_info_begin) 67 - return NULL; 68 - return __arch_info_end - 1; 69 - } 59 + extern const struct machine_desc __arch_info_begin[], __arch_info_end[]; 70 60 71 61 /* 72 62 * Set of macros to define architecture features. ··· 71 81 #define MACHINE_END \ 72 82 }; 73 83 74 - extern struct machine_desc *setup_machine_fdt(void *dt); 84 + extern const struct machine_desc *setup_machine_fdt(void *dt); 75 85 76 86 #endif
+19 -48
arch/arc/kernel/devtree.c
··· 18 18 #include <asm/clk.h> 19 19 #include <asm/mach_desc.h> 20 20 21 + static const void * __init arch_get_next_mach(const char *const **match) 22 + { 23 + static const struct machine_desc *mdesc = __arch_info_begin; 24 + const struct machine_desc *m = mdesc; 25 + 26 + if (m >= __arch_info_end) 27 + return NULL; 28 + 29 + mdesc++; 30 + *match = m->dt_compat; 31 + return m; 32 + } 33 + 21 34 /** 22 35 * setup_machine_fdt - Machine setup when an dtb was passed to the kernel 23 36 * @dt: virtual address pointer to dt blob ··· 38 25 * If a dtb was passed to the kernel, then use it to choose the correct 39 26 * machine_desc and to setup the system. 40 27 */ 41 - struct machine_desc * __init setup_machine_fdt(void *dt) 28 + const struct machine_desc * __init setup_machine_fdt(void *dt) 42 29 { 43 - struct machine_desc *mdesc = NULL, *mdesc_best = NULL; 44 - unsigned int score, mdesc_score = ~1; 30 + const struct machine_desc *mdesc; 45 31 unsigned long dt_root; 46 - const char *model, *compat; 47 32 void *clk; 48 - char manufacturer[16]; 49 33 unsigned long len; 50 34 51 35 if (!early_init_dt_scan(dt)) 52 36 return NULL; 53 37 54 - dt_root = of_get_flat_dt_root(); 55 - 56 - /* 57 - * The kernel could be multi-platform enabled, thus could have many 58 - * "baked-in" machine descriptors. Search thru all for the best 59 - * "compatible" string match. 60 - */ 61 - for_each_machine_desc(mdesc) { 62 - score = of_flat_dt_match(dt_root, mdesc->dt_compat); 63 - if (score > 0 && score < mdesc_score) { 64 - mdesc_best = mdesc; 65 - mdesc_score = score; 66 - } 67 - } 68 - if (!mdesc_best) { 69 - const char *prop; 70 - long size; 71 - 72 - pr_err("\n unrecognized device tree list:\n[ "); 73 - 74 - prop = of_get_flat_dt_prop(dt_root, "compatible", &size); 75 - if (prop) { 76 - while (size > 0) { 77 - printk("'%s' ", prop); 78 - size -= strlen(prop) + 1; 79 - prop += strlen(prop) + 1; 80 - } 81 - } 82 - printk("]\n\n"); 83 - 38 + mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); 39 + if (!mdesc) 84 40 machine_halt(); 85 - } 86 41 87 - /* compat = "<manufacturer>,<model>" */ 88 - compat = mdesc_best->dt_compat[0]; 89 - 90 - model = strchr(compat, ','); 91 - if (model) 92 - model++; 93 - 94 - strlcpy(manufacturer, compat, model ? model - compat : strlen(compat)); 95 - 96 - pr_info("Board \"%s\" from %s (Manufacturer)\n", model, manufacturer); 97 - 42 + dt_root = of_get_flat_dt_root(); 98 43 clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len); 99 44 if (clk) 100 45 arc_set_core_freq(of_read_ulong(clk, len/4)); 101 46 102 - return mdesc_best; 47 + return mdesc; 103 48 }
+1 -1
arch/arc/kernel/setup.c
··· 31 31 int running_on_hw = 1; /* vs. on ISS */ 32 32 33 33 char __initdata command_line[COMMAND_LINE_SIZE]; 34 - struct machine_desc *machine_desc; 34 + const struct machine_desc *machine_desc; 35 35 36 36 struct task_struct *_current_task[NR_CPUS]; /* For stack switching */ 37 37