diff options
author | John Crispin <blogic@openwrt.org> | 2013-04-11 01:34:59 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2013-05-07 19:19:07 -0400 |
commit | 9169a5d01114c930a0494f9160da8c334d71680d (patch) | |
tree | c050c4650a3395076beeba4fb0a7aa33a4252830 /arch/mips/kernel | |
parent | d41d547a419ca2d4df867a40a553abfe0c3df1d6 (diff) |
MIPS: move mips_{set,get}_machine_name() to a more generic place
Previously this functionality was only available to users of the mips_machine
api. Moving the code to prom.c allows us to also add a OF wrapper.
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/5164/
Diffstat (limited to 'arch/mips/kernel')
-rw-r--r-- | arch/mips/kernel/Makefile | 4 | ||||
-rw-r--r-- | arch/mips/kernel/mips_machine.c | 22 | ||||
-rw-r--r-- | arch/mips/kernel/proc.c | 2 | ||||
-rw-r--r-- | arch/mips/kernel/prom.c | 33 |
4 files changed, 36 insertions, 25 deletions
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index de75fb50562b..cdb87b2a423d 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | extra-y := head.o vmlinux.lds | 5 | extra-y := head.o vmlinux.lds |
6 | 6 | ||
7 | obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ | 7 | obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ |
8 | ptrace.o reset.o setup.o signal.o syscall.o \ | 8 | prom.o ptrace.o reset.o setup.o signal.o syscall.o \ |
9 | time.o topology.o traps.o unaligned.o watch.o vdso.o | 9 | time.o topology.o traps.o unaligned.o watch.o vdso.o |
10 | 10 | ||
11 | ifdef CONFIG_FUNCTION_TRACER | 11 | ifdef CONFIG_FUNCTION_TRACER |
@@ -86,8 +86,6 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | |||
86 | obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o | 86 | obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o |
87 | obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o | 87 | obj-$(CONFIG_MIPS_MACHINE) += mips_machine.o |
88 | 88 | ||
89 | obj-$(CONFIG_OF) += prom.o | ||
90 | |||
91 | CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -x c /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) | 89 | CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -x c /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) |
92 | 90 | ||
93 | obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o | 91 | obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o |
diff --git a/arch/mips/kernel/mips_machine.c b/arch/mips/kernel/mips_machine.c index 411a058d2c53..876097529697 100644 --- a/arch/mips/kernel/mips_machine.c +++ b/arch/mips/kernel/mips_machine.c | |||
@@ -11,9 +11,9 @@ | |||
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | 12 | ||
13 | #include <asm/mips_machine.h> | 13 | #include <asm/mips_machine.h> |
14 | #include <asm/prom.h> | ||
14 | 15 | ||
15 | static struct mips_machine *mips_machine __initdata; | 16 | static struct mips_machine *mips_machine __initdata; |
16 | static char *mips_machine_name = "Unknown"; | ||
17 | 17 | ||
18 | #define for_each_machine(mach) \ | 18 | #define for_each_machine(mach) \ |
19 | for ((mach) = (struct mips_machine *)&__mips_machines_start; \ | 19 | for ((mach) = (struct mips_machine *)&__mips_machines_start; \ |
@@ -21,25 +21,6 @@ static char *mips_machine_name = "Unknown"; | |||
21 | (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \ | 21 | (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \ |
22 | (mach)++) | 22 | (mach)++) |
23 | 23 | ||
24 | __init void mips_set_machine_name(const char *name) | ||
25 | { | ||
26 | char *p; | ||
27 | |||
28 | if (name == NULL) | ||
29 | return; | ||
30 | |||
31 | p = kstrdup(name, GFP_KERNEL); | ||
32 | if (!p) | ||
33 | pr_err("MIPS: no memory for machine_name\n"); | ||
34 | |||
35 | mips_machine_name = p; | ||
36 | } | ||
37 | |||
38 | char *mips_get_machine_name(void) | ||
39 | { | ||
40 | return mips_machine_name; | ||
41 | } | ||
42 | |||
43 | __init int mips_machtype_setup(char *id) | 24 | __init int mips_machtype_setup(char *id) |
44 | { | 25 | { |
45 | struct mips_machine *mach; | 26 | struct mips_machine *mach; |
@@ -79,7 +60,6 @@ __init void mips_machine_setup(void) | |||
79 | return; | 60 | return; |
80 | 61 | ||
81 | mips_set_machine_name(mips_machine->mach_name); | 62 | mips_set_machine_name(mips_machine->mach_name); |
82 | pr_info("MIPS: machine is %s\n", mips_machine_name); | ||
83 | 63 | ||
84 | if (mips_machine->mach_setup) | 64 | if (mips_machine->mach_setup) |
85 | mips_machine->mach_setup(); | 65 | mips_machine->mach_setup(); |
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index 7a54f74b7818..1dd137bab5c5 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <asm/cpu-features.h> | 12 | #include <asm/cpu-features.h> |
13 | #include <asm/mipsregs.h> | 13 | #include <asm/mipsregs.h> |
14 | #include <asm/processor.h> | 14 | #include <asm/processor.h> |
15 | #include <asm/mips_machine.h> | 15 | #include <asm/prom.h> |
16 | 16 | ||
17 | unsigned int vced_count, vcei_count; | 17 | unsigned int vced_count, vcei_count; |
18 | 18 | ||
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 028f6f837ef9..5712bb532245 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c | |||
@@ -23,6 +23,23 @@ | |||
23 | #include <asm/page.h> | 23 | #include <asm/page.h> |
24 | #include <asm/prom.h> | 24 | #include <asm/prom.h> |
25 | 25 | ||
26 | static char mips_machine_name[64] = "Unknown"; | ||
27 | |||
28 | __init void mips_set_machine_name(const char *name) | ||
29 | { | ||
30 | if (name == NULL) | ||
31 | return; | ||
32 | |||
33 | strncpy(mips_machine_name, name, sizeof(mips_machine_name)); | ||
34 | pr_info("MIPS: machine is %s\n", mips_get_machine_name()); | ||
35 | } | ||
36 | |||
37 | char *mips_get_machine_name(void) | ||
38 | { | ||
39 | return mips_machine_name; | ||
40 | } | ||
41 | |||
42 | #ifdef CONFIG_OF | ||
26 | int __init early_init_dt_scan_memory_arch(unsigned long node, | 43 | int __init early_init_dt_scan_memory_arch(unsigned long node, |
27 | const char *uname, int depth, | 44 | const char *uname, int depth, |
28 | void *data) | 45 | void *data) |
@@ -50,6 +67,18 @@ void __init early_init_dt_setup_initrd_arch(unsigned long start, | |||
50 | } | 67 | } |
51 | #endif | 68 | #endif |
52 | 69 | ||
70 | int __init early_init_dt_scan_model(unsigned long node, const char *uname, | ||
71 | int depth, void *data) | ||
72 | { | ||
73 | if (!depth) { | ||
74 | char *model = of_get_flat_dt_prop(node, "model", NULL); | ||
75 | |||
76 | if (model) | ||
77 | mips_set_machine_name(model); | ||
78 | } | ||
79 | return 0; | ||
80 | } | ||
81 | |||
53 | void __init early_init_devtree(void *params) | 82 | void __init early_init_devtree(void *params) |
54 | { | 83 | { |
55 | /* Setup flat device-tree pointer */ | 84 | /* Setup flat device-tree pointer */ |
@@ -65,6 +94,9 @@ void __init early_init_devtree(void *params) | |||
65 | /* Scan memory nodes */ | 94 | /* Scan memory nodes */ |
66 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | 95 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
67 | of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); | 96 | of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); |
97 | |||
98 | /* try to load the mips machine name */ | ||
99 | of_scan_flat_dt(early_init_dt_scan_model, NULL); | ||
68 | } | 100 | } |
69 | 101 | ||
70 | void __init __dt_setup_arch(struct boot_param_header *bph) | 102 | void __init __dt_setup_arch(struct boot_param_header *bph) |
@@ -79,3 +111,4 @@ void __init __dt_setup_arch(struct boot_param_header *bph) | |||
79 | 111 | ||
80 | early_init_devtree(initial_boot_params); | 112 | early_init_devtree(initial_boot_params); |
81 | } | 113 | } |
114 | #endif | ||