linux-mips
[Top] [All Lists]

[PATCH -queue 1/2] [loongson] Cleanup the machtype support

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH -queue 1/2] [loongson] Cleanup the machtype support
From: Wu Zhangjin <wuzhangjin@gmail.com>
Date: Fri, 6 Nov 2009 18:35:33 +0800
Cc: linux-mips@linux-mips.org, Wu Zhangjin <wuzhangjin@gmail.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:in-reply-to:references; bh=dHdF0lr83O7PBM9D1BXChl4X9xhnovCCOBawyPlNbeg=; b=taq501b9LMLRAYjKfy5E5HH1qjxLa97SNAdKg+DY/Pwt9fNDgTsnTmHpSbTlG4eiy+ mHvyBfC12h4kh3U0m08fTJ5SpWKA60J75omutV6TbyT9vs4MkQ2TV9luyYOFzAM1x4z1 aawGk/Vde1QWAG+bt7k67qd+jedDDNEdQyBx0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=QqDn68oJ3kvy5ZDRfdq2KxCFdkkMwPa9DZr5HhOM6rgjxcUD/O63MEbj1vXYcz2hoe Te8vxaXGkwanq64MpaqJEi/1YLbQWaym2pAVAfuOZoxyieDT1OJ5ohlBER2qcglT2X+4 jC+Pf3jRMGieSrp2W/6V1MeXQqV1s+RvMQPt4=
In-reply-to: <cover.1257503025.git.wuzhangjin@gmail.com>
In-reply-to: <cover.1257503696.git.wuzhangjin@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.1257503025.git.wuzhangjin@gmail.com>
References: <cover.1257503696.git.wuzhangjin@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
We need to initialize mips_machtype as early as we can, So, we can
choose corresponding code for different machines via it.

This patch moves the initialization of mips_machtype to prom_init().

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/include/asm/mach-loongson/loongson.h |    1 +
 arch/mips/loongson/common/cmdline.c            |    4 +++-
 arch/mips/loongson/common/machtype.c           |   17 ++++++++++-------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/arch/mips/include/asm/mach-loongson/loongson.h 
b/arch/mips/include/asm/mach-loongson/loongson.h
index e6869aa..efb2344 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -29,6 +29,7 @@ extern unsigned long memsize, highmemsize;
 /* loongson-specific command line, env and memory initialization */
 extern void __init prom_init_memory(void);
 extern void __init prom_init_cmdline(void);
+extern void __init prom_init_machtype(void);
 extern void __init prom_init_env(void);
 
 /* irq operation functions */
diff --git a/arch/mips/loongson/common/cmdline.c 
b/arch/mips/loongson/common/cmdline.c
index 75f1b24..7ad47f2 100644
--- a/arch/mips/loongson/common/cmdline.c
+++ b/arch/mips/loongson/common/cmdline.c
@@ -9,7 +9,7 @@
  * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
  * Author: Fuxin Zhang, zhangfx@lemote.com
  *
- * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
+ * Copyright (C) 2009 Lemote Inc.
  * Author: Wu Zhangjin, wuzj@lemote.com
  *
  * This program is free software; you can redistribute  it and/or modify it
@@ -49,4 +49,6 @@ void __init prom_init_cmdline(void)
                strcat(arcs_cmdline, " console=ttyS0,115200");
        if ((strstr(arcs_cmdline, "root=")) == NULL)
                strcat(arcs_cmdline, " root=/dev/hda1");
+
+       prom_init_machtype();
 }
diff --git a/arch/mips/loongson/common/machtype.c 
b/arch/mips/loongson/common/machtype.c
index 7b34824..87b502f 100644
--- a/arch/mips/loongson/common/machtype.c
+++ b/arch/mips/loongson/common/machtype.c
@@ -27,24 +27,27 @@ static const char *system_types[] = {
 
 const char *get_system_type(void)
 {
-       if (mips_machtype == MACH_UNKNOWN)
-               mips_machtype = LOONGSON_MACHTYPE;
-
        return system_types[mips_machtype];
 }
 
-static __init int machtype_setup(char *str)
+void __init prom_init_machtype(void)
 {
+       char *str, *p;
        int machtype = MACH_LEMOTE_FL2E;
 
+       mips_machtype = LOONGSON_MACHTYPE;
+
+       str = strstr(arcs_cmdline, "machtype=");
        if (!str)
-               return -EINVAL;
+               return;
+       str += strlen("machtype=");
+       p = strstr(str, " ");
+       if (p)
+               *p++ = '\0';
 
        for (; system_types[machtype]; machtype++)
                if (strstr(system_types[machtype], str)) {
                        mips_machtype = machtype;
                        break;
                }
-       return 0;
 }
-__setup("machtype=", machtype_setup);
-- 
1.6.2.1


<Prev in Thread] Current Thread [Next in Thread>