Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / arch / mips / kernel / mips_machine.c
blob411a058d2c536c7709edfcb9476b4fa185034942
1 /*
2 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 */
9 #include <linux/mm.h>
10 #include <linux/string.h>
11 #include <linux/slab.h>
13 #include <asm/mips_machine.h>
15 static struct mips_machine *mips_machine __initdata;
16 static char *mips_machine_name = "Unknown";
18 #define for_each_machine(mach) \
19 for ((mach) = (struct mips_machine *)&__mips_machines_start; \
20 (mach) && \
21 (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
22 (mach)++)
24 __init void mips_set_machine_name(const char *name)
26 char *p;
28 if (name == NULL)
29 return;
31 p = kstrdup(name, GFP_KERNEL);
32 if (!p)
33 pr_err("MIPS: no memory for machine_name\n");
35 mips_machine_name = p;
38 char *mips_get_machine_name(void)
40 return mips_machine_name;
43 __init int mips_machtype_setup(char *id)
45 struct mips_machine *mach;
47 for_each_machine(mach) {
48 if (mach->mach_id == NULL)
49 continue;
51 if (strcmp(mach->mach_id, id) == 0) {
52 mips_machtype = mach->mach_type;
53 return 0;
57 pr_err("MIPS: no machine found for id '%s', supported machines:\n", id);
58 pr_err("%-24s %s\n", "id", "name");
59 for_each_machine(mach)
60 pr_err("%-24s %s\n", mach->mach_id, mach->mach_name);
62 return 1;
65 __setup("machtype=", mips_machtype_setup);
67 __init void mips_machine_setup(void)
69 struct mips_machine *mach;
71 for_each_machine(mach) {
72 if (mips_machtype == mach->mach_type) {
73 mips_machine = mach;
74 break;
78 if (!mips_machine)
79 return;
81 mips_set_machine_name(mips_machine->mach_name);
82 pr_info("MIPS: machine is %s\n", mips_machine_name);
84 if (mips_machine->mach_setup)
85 mips_machine->mach_setup();