Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Tue, 24 Nov 2009
 12:36:29 -0700
Received: from mail1.lsil.com (mail1.lsil.com [147.145.40.21])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id nAOJaQ1w029306	for
 <andy.sharp@lsi.com>; Tue, 24 Nov 2009 11:36:29 -0800
Received: from psmtp.com (na3sys009amx182.postini.com [74.125.149.163])	by
 mail1.lsil.com (8.12.11/8.12.11) with SMTP id nAOJa9Is022598	for
 <andy.sharp@lsi.com>; Tue, 24 Nov 2009 11:36:25 -0800 (PST)
Received: from source ([78.24.191.182]) by na3sys009amx182.postini.com
 ([74.125.148.14]) with SMTP;	Tue, 24 Nov 2009 14:36:26 EST
Received: from localhost.localdomain ([127.0.0.1]:34341 "EHLO
	eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL)	by eddie.linux-mips.org with
 ESMTP id S1493548AbZKXTfp (ORCPT	<rfc822;andy.sharp@lsi.com>); Tue, 24 Nov
 2009 20:35:45 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 24 Nov 2009 20:35:28
 +0100 (CET)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:41284 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP	id
 S1493540AbZKXTfY (ORCPT <rfc822;linux-mips@linux-mips.org>);	Tue, 24 Nov 2009
 20:35:24 +0100
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])	by
 h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id nAOJZfgR008768	for
 <linux-mips@linux-mips.org>; Tue, 24 Nov 2009 19:35:41 GMT
Received: (from ralf@localhost)	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id
 nAOJZfB4008766	for linux-mips@linux-mips.org; Tue, 24 Nov 2009 19:35:41 GMT
From: Ralf Baechle <ralf@linux-mips.org>
To: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Tue, 24 Nov 2009 12:35:41 -0700
Subject: [PATCH] Cleanup signal code initialization
Thread-Topic: [PATCH] Cleanup signal code initialization
Thread-Index: AcptPWt2mSCE3elLTKWtKHrmw5F20g==
Message-ID: <20091124193541.GA32216@linux-mips.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <ralf@linux-mips.org> [22/1] 
x-pstn-neptune: 2/1/0.50/64
user-agent: Mutt/1.5.19 (2009-01-05)
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---
Looking at the COP2 handling in traps.c I was reminded of the other
uglyness in there.  This is once patch to clean it up.

 arch/mips/include/asm/fpu.h |    8 ----
 arch/mips/kernel/signal.c   |   46 ++++++++++++++++++++++++++
 arch/mips/kernel/signal32.c |   24 +++++++++++++
 arch/mips/kernel/traps.c    |   76 ---------------------------------------=
----
 4 files changed, 70 insertions(+), 84 deletions(-)

diff --git a/arch/mips/include/asm/fpu.h b/arch/mips/include/asm/fpu.h
index 8a3ef24..7fcef8e 100644
--- a/arch/mips/include/asm/fpu.h
+++ b/arch/mips/include/asm/fpu.h
@@ -28,15 +28,7 @@
 struct sigcontext;
 struct sigcontext32;
=20
-extern asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
-extern asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
-
-extern asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc)=
;
-extern asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *=
sc);
-
 extern void fpu_emulator_init_fpu(void);
-extern int fpu_emulator_save_context(struct sigcontext __user *sc);
-extern int fpu_emulator_restore_context(struct sigcontext __user *sc);
 extern void _init_fpu(void);
 extern void _save_fp(struct task_struct *);
 extern void _restore_fp(struct task_struct *);
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 6254041..d0c68b5 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -35,6 +35,15 @@
=20
 #include "signal-common.h"
=20
+static int (*save_fp_context)(struct sigcontext __user *sc);
+static int (*restore_fp_context)(struct sigcontext __user *sc);
+
+extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
+extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
+
+extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *=
sc);
+extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __use=
r *sc);
+
 /*
  * Horribly complicated - with the bloody RM9000 workarounds enabled
  * the signal trampolines is moving to the end of the structure so we can
@@ -709,3 +718,40 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,=
 void *unused,
 			key_replace_session_keyring();
 	}
 }
+
+#ifdef CONFIG_SMP
+static int smp_save_fp_context(struct sigcontext __user *sc)
+{
+	return raw_cpu_has_fpu
+	       ? _save_fp_context(sc)
+	       : fpu_emulator_save_context(sc);
+}
+
+static int smp_restore_fp_context(struct sigcontext __user *sc)
+{
+	return raw_cpu_has_fpu
+	       ? _restore_fp_context(sc)
+	       : fpu_emulator_restore_context(sc);
+}
+#endif
+
+static int signal_setup(void)
+{
+#ifdef CONFIG_SMP
+	/* For now just do the cpu_has_fpu check when the functions are invoked *=
/
+	save_fp_context =3D smp_save_fp_context;
+	restore_fp_context =3D smp_restore_fp_context;
+#else
+	if (cpu_has_fpu) {
+		save_fp_context =3D _save_fp_context;
+		restore_fp_context =3D _restore_fp_context;
+	} else {
+		save_fp_context =3D fpu_emulator_save_context;
+		restore_fp_context =3D fpu_emulator_restore_context;
+	}
+#endif
+
+	return 0;
+}
+
+arch_initcall(signal_setup);
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index 2e74075..03abaf0 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -35,6 +35,15 @@
=20
 #include "signal-common.h"
=20
+static int (*save_fp_context32)(struct sigcontext32 __user *sc);
+static int (*restore_fp_context32)(struct sigcontext32 __user *sc);
+
+extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc);
+extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc=
);
+
+extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __us=
er *sc);
+extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 _=
_user *sc);
+
 /*
  * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
  */
@@ -828,3 +837,18 @@ SYSCALL_DEFINE5(32_waitid, int, which, compat_pid_t, p=
id,
 	info.si_code |=3D __SI_CHLD;
 	return copy_siginfo_to_user32(uinfo, &info);
 }
+
+static int signal32_init(void)
+{
+	if (cpu_has_fpu) {
+		save_fp_context32 =3D _save_fp_context32;
+		restore_fp_context32 =3D _restore_fp_context32;
+	} else {
+		save_fp_context32 =3D fpu_emulator_save_context32;
+		restore_fp_context32 =3D fpu_emulator_restore_context32;
+	}
+
+	return 0;
+}
+
+arch_initcall(signal32_init);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 2c5c3a2..c3d786d 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1395,77 +1395,6 @@ void *set_vi_handler(int n, vi_handler_t addr)
 	return set_vi_srs_handler(n, addr, 0);
 }
=20
-/*
- * This is used by native signal handling
- */
-asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
-asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
-
-extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
-extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
-
-extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *=
sc);
-extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __use=
r *sc);
-
-#ifdef CONFIG_SMP
-static int smp_save_fp_context(struct sigcontext __user *sc)
-{
-	return raw_cpu_has_fpu
-	       ? _save_fp_context(sc)
-	       : fpu_emulator_save_context(sc);
-}
-
-static int smp_restore_fp_context(struct sigcontext __user *sc)
-{
-	return raw_cpu_has_fpu
-	       ? _restore_fp_context(sc)
-	       : fpu_emulator_restore_context(sc);
-}
-#endif
-
-static inline void signal_init(void)
-{
-#ifdef CONFIG_SMP
-	/* For now just do the cpu_has_fpu check when the functions are invoked *=
/
-	save_fp_context =3D smp_save_fp_context;
-	restore_fp_context =3D smp_restore_fp_context;
-#else
-	if (cpu_has_fpu) {
-		save_fp_context =3D _save_fp_context;
-		restore_fp_context =3D _restore_fp_context;
-	} else {
-		save_fp_context =3D fpu_emulator_save_context;
-		restore_fp_context =3D fpu_emulator_restore_context;
-	}
-#endif
-}
-
-#ifdef CONFIG_MIPS32_COMPAT
-
-/*
- * This is used by 32-bit signal stuff on the 64-bit kernel
- */
-asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc);
-asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc);
-
-extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc);
-extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc=
);
-
-extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __us=
er *sc);
-extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 _=
_user *sc);
-
-static inline void signal32_init(void)
-{
-	if (cpu_has_fpu) {
-		save_fp_context32 =3D _save_fp_context32;
-		restore_fp_context32 =3D _restore_fp_context32;
-	} else {
-		save_fp_context32 =3D fpu_emulator_save_context32;
-		restore_fp_context32 =3D fpu_emulator_restore_context32;
-	}
-}
-#endif
-
 extern void cpu_cache_init(void);
 extern void tlb_init(void);
 extern void flush_tlb_handlers(void);
@@ -1779,11 +1708,6 @@ void __init trap_init(void)
 	else
 		memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80);
=20
-	signal_init();
-#ifdef CONFIG_MIPS32_COMPAT
-	signal32_init();
-#endif
-
 	local_flush_icache_range(ebase, ebase + 0x400);
 	flush_tlb_handlers();
=20

