* [urgent] [loongson] machtype: Fixup of prom_init_machtype()
@ 2009-11-22 7:37 Wu Zhangjin
2009-11-22 13:20 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Wu Zhangjin @ 2009-11-22 7:37 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, Wu Zhangjin
From: Wu Zhangjin <wuzhangjin@gmail.com>
The old version cut off everything of arcs_cmdline after machtype=xxxx,
which is totally wrong, we need to copy out the machtype=xxxx and then
operate it.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
arch/mips/loongson/common/machtype.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/arch/mips/loongson/common/machtype.c b/arch/mips/loongson/common/machtype.c
index 2a46b4d..0ed52b3 100644
--- a/arch/mips/loongson/common/machtype.c
+++ b/arch/mips/loongson/common/machtype.c
@@ -15,6 +15,9 @@
#include <loongson.h>
#include <machine.h>
+/* please ensure the length of the machtype string is less than 50 */
+#define MACHTYPE_LEN 50
+
static const char *system_types[] = {
[MACH_LOONGSON_UNKNOWN] "unknown loongson machine",
[MACH_LEMOTE_FL2E] "lemote-fuloong-2e-box",
@@ -34,18 +37,19 @@ const char *get_system_type(void)
void __init prom_init_machtype(void)
{
- char *str, *p;
+ char *p, str[MACHTYPE_LEN];
int machtype = MACH_LEMOTE_FL2E;
mips_machtype = LOONGSON_MACHTYPE;
- str = strstr(arcs_cmdline, "machtype=");
- if (!str)
+ p = strstr(arcs_cmdline, "machtype=");
+ if (!p)
return;
- str += strlen("machtype=");
+ p += strlen("machtype=");
+ strncpy(str, p, MACHTYPE_LEN);
p = strstr(str, " ");
if (p)
- *p++ = '\0';
+ *p = '\0';
for (; system_types[machtype]; machtype++)
if (strstr(system_types[machtype], str)) {
--
1.6.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [urgent] [loongson] machtype: Fixup of prom_init_machtype()
2009-11-22 7:37 [urgent] [loongson] machtype: Fixup of prom_init_machtype() Wu Zhangjin
@ 2009-11-22 13:20 ` Ralf Baechle
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2009-11-22 13:20 UTC (permalink / raw)
To: Wu Zhangjin; +Cc: linux-mips
On Sun, Nov 22, 2009 at 03:37:53PM +0800, Wu Zhangjin wrote:
> The old version cut off everything of arcs_cmdline after machtype=xxxx,
> which is totally wrong, we need to copy out the machtype=xxxx and then
> operate it.
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Thanks, folded into the "MIPS: Loongson: Cleanup machtype support" patch.
Ralf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-22 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-22 7:37 [urgent] [loongson] machtype: Fixup of prom_init_machtype() Wu Zhangjin
2009-11-22 13:20 ` Ralf Baechle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.