···5151/*5252 * Current machine - only accessible during boot.5353 */5454-extern struct machine_desc *machine_desc;5454+extern const struct machine_desc *machine_desc;55555656/*5757 * Machine type table - also only accessible during boot5858 */5959-extern struct machine_desc __arch_info_begin[], __arch_info_end[];6060-#define for_each_machine_desc(p) \6161- for (p = __arch_info_begin; p < __arch_info_end; p++)6262-6363-static inline struct machine_desc *default_machine_desc(void)6464-{6565- /* the default machine is the last one linked in */6666- if (__arch_info_end - 1 < __arch_info_begin)6767- return NULL;6868- return __arch_info_end - 1;6969-}5959+extern const struct machine_desc __arch_info_begin[], __arch_info_end[];70607161/*7262 * Set of macros to define architecture features.···7181#define MACHINE_END \7282};73837474-extern struct machine_desc *setup_machine_fdt(void *dt);8484+extern const struct machine_desc *setup_machine_fdt(void *dt);75857686#endif
+19-48
arch/arc/kernel/devtree.c
···1818#include <asm/clk.h>1919#include <asm/mach_desc.h>20202121+static const void * __init arch_get_next_mach(const char *const **match)2222+{2323+ static const struct machine_desc *mdesc = __arch_info_begin;2424+ const struct machine_desc *m = mdesc;2525+2626+ if (m >= __arch_info_end)2727+ return NULL;2828+2929+ mdesc++;3030+ *match = m->dt_compat;3131+ return m;3232+}3333+2134/**2235 * setup_machine_fdt - Machine setup when an dtb was passed to the kernel2336 * @dt: virtual address pointer to dt blob···3825 * If a dtb was passed to the kernel, then use it to choose the correct3926 * machine_desc and to setup the system.4027 */4141-struct machine_desc * __init setup_machine_fdt(void *dt)2828+const struct machine_desc * __init setup_machine_fdt(void *dt)4229{4343- struct machine_desc *mdesc = NULL, *mdesc_best = NULL;4444- unsigned int score, mdesc_score = ~1;3030+ const struct machine_desc *mdesc;4531 unsigned long dt_root;4646- const char *model, *compat;4732 void *clk;4848- char manufacturer[16];4933 unsigned long len;50345135 if (!early_init_dt_scan(dt))5236 return NULL;53375454- dt_root = of_get_flat_dt_root();5555-5656- /*5757- * The kernel could be multi-platform enabled, thus could have many5858- * "baked-in" machine descriptors. Search thru all for the best5959- * "compatible" string match.6060- */6161- for_each_machine_desc(mdesc) {6262- score = of_flat_dt_match(dt_root, mdesc->dt_compat);6363- if (score > 0 && score < mdesc_score) {6464- mdesc_best = mdesc;6565- mdesc_score = score;6666- }6767- }6868- if (!mdesc_best) {6969- const char *prop;7070- long size;7171-7272- pr_err("\n unrecognized device tree list:\n[ ");7373-7474- prop = of_get_flat_dt_prop(dt_root, "compatible", &size);7575- if (prop) {7676- while (size > 0) {7777- printk("'%s' ", prop);7878- size -= strlen(prop) + 1;7979- prop += strlen(prop) + 1;8080- }8181- }8282- printk("]\n\n");8383-3838+ mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);3939+ if (!mdesc)8440 machine_halt();8585- }86418787- /* compat = "<manufacturer>,<model>" */8888- compat = mdesc_best->dt_compat[0];8989-9090- model = strchr(compat, ',');9191- if (model)9292- model++;9393-9494- strlcpy(manufacturer, compat, model ? model - compat : strlen(compat));9595-9696- pr_info("Board \"%s\" from %s (Manufacturer)\n", model, manufacturer);9797-4242+ dt_root = of_get_flat_dt_root();9843 clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len);9944 if (clk)10045 arc_set_core_freq(of_read_ulong(clk, len/4));10146102102- return mdesc_best;4747+ return mdesc;10348}
+1-1
arch/arc/kernel/setup.c
···3131int running_on_hw = 1; /* vs. on ISS */32323333char __initdata command_line[COMMAND_LINE_SIZE];3434-struct machine_desc *machine_desc;3434+const struct machine_desc *machine_desc;35353636struct task_struct *_current_task[NR_CPUS]; /* For stack switching */3737