sh: Move lookup_exception_vector() out to asm/system_32.h.
authorPaul Mundt <lethal@linux-sh.org>
Sun, 21 Sep 2008 03:00:23 +0000 (12:00 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Sun, 21 Sep 2008 03:00:23 +0000 (12:00 +0900)
There are other places where we want to have access to the trap/exception
number, so move out the lookup_exception_vector() helper. While we're at
it, refactor it slightly to return the vector instead.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/include/asm/system_32.h
arch/sh/kernel/traps_32.c

index f7f105627fd9427cb0dc484d5bb488c784823049..a726d5d07277a6d53e91b90d743201c10f4fd52d 100644 (file)
@@ -97,6 +97,31 @@ do {                                                 \
                : "=&r" (__dummy));                     \
 } while (0)
 
+#ifdef CONFIG_CPU_HAS_SR_RB
+#define lookup_exception_vector()      \
+({                                     \
+       unsigned long _vec;             \
+                                       \
+       __asm__ __volatile__ (          \
+               "stc r2_bank, %0\n\t"   \
+               : "=r" (_vec)           \
+       );                              \
+                                       \
+       _vec;                           \
+})
+#else
+#define lookup_exception_vector()      \
+({                                     \
+       unsigned long _vec;             \
+       __asm__ __volatile__ (          \
+               "mov r4, %0\n\t"        \
+               : "=r" (_vec)           \
+       );                              \
+                                       \
+       _vec;                           \
+})
+#endif
+
 int handle_unaligned_access(opcode_t instruction, struct pt_regs *regs,
                            struct mem_access *ma);
 
index 35b901ed6de36bb9c192db8350e381427202f3eb..b359b08a8e33a9cb827145abe0c02c6ad66dc9d9 100644 (file)
@@ -514,14 +514,6 @@ int handle_unaligned_access(opcode_t instruction, struct pt_regs *regs,
        return ret;
 }
 
-#ifdef CONFIG_CPU_HAS_SR_RB
-#define lookup_exception_vector(x)     \
-       __asm__ __volatile__ ("stc r2_bank, %0\n\t" : "=r" ((x)))
-#else
-#define lookup_exception_vector(x)     \
-       __asm__ __volatile__ ("mov r4, %0\n\t" : "=r" ((x)))
-#endif
-
 /*
  * Handle various address error exceptions:
  *  - instruction address error:
@@ -545,7 +537,7 @@ asmlinkage void do_address_error(struct pt_regs *regs,
 
        /* Intentional ifdef */
 #ifdef CONFIG_CPU_HAS_SR_RB
-       lookup_exception_vector(error_code);
+       error_code = lookup_exception_vector();
 #endif
 
        oldfs = get_fs();
@@ -686,7 +678,7 @@ asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
        }
 #endif
 
-       lookup_exception_vector(error_code);
+       error_code = lookup_exception_vector();
 
        local_irq_enable();
        CHK_REMOTE_DEBUG(regs);
@@ -759,7 +751,7 @@ asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5,
        /* not a FPU inst. */
 #endif
 
-       lookup_exception_vector(inst);
+       inst = lookup_exception_vector();
 
        local_irq_enable();
        CHK_REMOTE_DEBUG(regs);
@@ -774,7 +766,7 @@ asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
        struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
        long ex;
 
-       lookup_exception_vector(ex);
+       ex = lookup_exception_vector();
        die_if_kernel("exception", regs, ex);
 }