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 | |
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')
-rw-r--r-- | arch/mips/loongson/common/cmdline.c | 4 | ||||
-rw-r--r-- | arch/mips/loongson/common/machtype.c | 23 |
2 files changed, 18 insertions, 9 deletions
diff --git a/arch/mips/loongson/common/cmdline.c b/arch/mips/loongson/common/cmdline.c index 75f1b243ee4e..7ad47f227477 100644 --- a/arch/mips/loongson/common/cmdline.c +++ b/arch/mips/loongson/common/cmdline.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology | 9 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology |
10 | * Author: Fuxin Zhang, zhangfx@lemote.com | 10 | * Author: Fuxin Zhang, zhangfx@lemote.com |
11 | * | 11 | * |
12 | * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology | 12 | * Copyright (C) 2009 Lemote Inc. |
13 | * Author: Wu Zhangjin, wuzj@lemote.com | 13 | * Author: Wu Zhangjin, wuzj@lemote.com |
14 | * | 14 | * |
15 | * This program is free software; you can redistribute it and/or modify it | 15 | * This program is free software; you can redistribute it and/or modify it |
@@ -49,4 +49,6 @@ void __init prom_init_cmdline(void) | |||
49 | strcat(arcs_cmdline, " console=ttyS0,115200"); | 49 | strcat(arcs_cmdline, " console=ttyS0,115200"); |
50 | if ((strstr(arcs_cmdline, "root=")) == NULL) | 50 | if ((strstr(arcs_cmdline, "root=")) == NULL) |
51 | strcat(arcs_cmdline, " root=/dev/hda1"); | 51 | strcat(arcs_cmdline, " root=/dev/hda1"); |
52 | |||
53 | prom_init_machtype(); | ||
52 | } | 54 | } |
diff --git a/arch/mips/loongson/common/machtype.c b/arch/mips/loongson/common/machtype.c index 7b348248de7d..7545fe69089f 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); | ||