diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-11-06 05:35:33 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:08 -0500 |
commit | 04cfb90a92a2f9f7b56b2f85c528be7d1561e0e5 (patch) | |
tree | 332e2aae4ebc66274e61f4174f922635e4d386af /arch/mips/loongson/common/machtype.c | |
parent | b6ee75ed4fa201873d3a2b32dfce2dbd701a2de4 (diff) |
MIPS: Loongson: Cleanup machtype support
To choose code for different machines by the value of machtype it needs to
be initialized as early as possible. So move initialization of
mips_machtype to prom_init().
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/loongson/common/machtype.c')
-rw-r--r-- | arch/mips/loongson/common/machtype.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/arch/mips/loongson/common/machtype.c b/arch/mips/loongson/common/machtype.c index 7b348248de7..7545fe69089 100644 --- a/arch/mips/loongson/common/machtype.c +++ b/arch/mips/loongson/common/machtype.c | |||
@@ -15,6 +15,9 @@ | |||
15 | #include <loongson.h> | 15 | #include <loongson.h> |
16 | #include <machine.h> | 16 | #include <machine.h> |
17 | 17 | ||
18 | /* please ensure the length of the machtype string is less than 50 */ | ||
19 | #define MACHTYPE_LEN 50 | ||
20 | |||
18 | static const char *system_types[] = { | 21 | static const char *system_types[] = { |
19 | [MACH_LOONGSON_UNKNOWN] "unknown loongson machine", | 22 | [MACH_LOONGSON_UNKNOWN] "unknown loongson machine", |
20 | [MACH_LEMOTE_FL2E] "lemote-fuloong-2e-box", | 23 | [MACH_LEMOTE_FL2E] "lemote-fuloong-2e-box", |
@@ -27,24 +30,28 @@ static const char *system_types[] = { | |||
27 | 30 | ||
28 | const char *get_system_type(void) | 31 | const char *get_system_type(void) |
29 | { | 32 | { |
30 | if (mips_machtype == MACH_UNKNOWN) | ||
31 | mips_machtype = LOONGSON_MACHTYPE; | ||
32 | |||
33 | return system_types[mips_machtype]; | 33 | return system_types[mips_machtype]; |
34 | } | 34 | } |
35 | 35 | ||
36 | static __init int machtype_setup(char *str) | 36 | void __init prom_init_machtype(void) |
37 | { | 37 | { |
38 | char *p, str[MACHTYPE_LEN]; | ||
38 | int machtype = MACH_LEMOTE_FL2E; | 39 | int machtype = MACH_LEMOTE_FL2E; |
39 | 40 | ||
40 | if (!str) | 41 | mips_machtype = LOONGSON_MACHTYPE; |
41 | return -EINVAL; | 42 | |
43 | p = strstr(arcs_cmdline, "machtype="); | ||
44 | if (!p) | ||
45 | return; | ||
46 | p += strlen("machtype="); | ||
47 | strncpy(str, p, MACHTYPE_LEN); | ||
48 | p = strstr(str, " "); | ||
49 | if (p) | ||
50 | *p = '\0'; | ||
42 | 51 | ||
43 | for (; system_types[machtype]; machtype++) | 52 | for (; system_types[machtype]; machtype++) |
44 | if (strstr(system_types[machtype], str)) { | 53 | if (strstr(system_types[machtype], str)) { |
45 | mips_machtype = machtype; | 54 | mips_machtype = machtype; |
46 | break; | 55 | break; |
47 | } | 56 | } |
48 | return 0; | ||
49 | } | 57 | } |
50 | __setup("machtype=", machtype_setup); | ||