MIPS: Provide more elevant interface cu2_notifier for CP2 extensions.
authorRalf Baechle <ralf@linux-mips.org>
Thu, 5 Aug 2010 12:25:59 +0000 (13:25 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 5 Aug 2010 12:25:59 +0000 (13:25 +0100)
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Patchwork: https://patchwork.linux-mips.org/patch/1504/

arch/mips/cavium-octeon/cpu.c
arch/mips/include/asm/cop2.h
arch/mips/kernel/traps.c

index b6df5387e855d10ad1d483851f3f3d553ef1335c..c664c8cc2b42cb8970b9f57531a03e2998075566 100644 (file)
@@ -41,12 +41,8 @@ static int cnmips_cu2_call(struct notifier_block *nfb, unsigned long action,
        return NOTIFY_OK;               /* Let default notifier send signals */
 }
 
-static struct notifier_block cnmips_cu2_notifier = {
-       .notifier_call = cnmips_cu2_call,
-};
-
 static int cnmips_cu2_setup(void)
 {
-       return register_cu2_notifier(&cnmips_cu2_notifier);
+       return cu2_notifier(cnmips_cu2_call, 0);
 }
 early_initcall(cnmips_cu2_setup);
index 6b04c98b7fad1dd5be1ff7a64e9cda1b88537835..2cb2f0c2c4f89342ae5256a79d8082f01af4d319 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef __ASM_COP2_H
 #define __ASM_COP2_H
 
+#include <linux/notifier.h>
+
 enum cu2_ops {
        CU2_EXCEPTION,
        CU2_LWC2_OP,
@@ -20,4 +22,14 @@ enum cu2_ops {
 extern int register_cu2_notifier(struct notifier_block *nb);
 extern int cu2_notifier_call_chain(unsigned long val, void *v);
 
+#define cu2_notifier(fn, pri)                                          \
+({                                                                     \
+       static struct notifier_block fn##_nb __cpuinitdata = {          \
+               .notifier_call = fn,                                    \
+               .priority = pri                                         \
+       };                                                              \
+                                                                       \
+       register_cu2_notifier(&fn##_nb);                                \
+})
+
 #endif /* __ASM_COP2_H */
index 852780868fb4914e4711107e96c388e1ad8ab38d..1515b673179d45248259edb131da92675d00b6e2 100644 (file)
@@ -907,11 +907,6 @@ static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
        return NOTIFY_OK;
 }
 
-static struct notifier_block default_cu2_notifier = {
-       .notifier_call  = default_cu2_call,
-       .priority       = 0x80000000,           /* Run last  */
-};
-
 asmlinkage void do_cpu(struct pt_regs *regs)
 {
        unsigned int __user *epc;
@@ -1734,5 +1729,5 @@ void __init trap_init(void)
 
        sort_extable(__start___dbe_table, __stop___dbe_table);
 
-       register_cu2_notifier(&default_cu2_notifier);
+       cu2_notifier(default_cu2_call, 0x80000000);     /* Run last  */
 }