riscv: remove the switch statement in do_trap_break()
[linux-2.6-microblaze.git] / arch / riscv / kernel / traps.c
index 93742df..1ac75f7 100644 (file)
@@ -124,24 +124,24 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
 
 asmlinkage void do_trap_break(struct pt_regs *regs)
 {
-       if (!user_mode(regs)) {
+       if (user_mode(regs)) {
+               force_sig_fault(SIGTRAP, TRAP_BRKPT,
+                               (void __user *)(regs->sepc));
+               return;
+       }
+#ifdef CONFIG_GENERIC_BUG
+       {
                enum bug_trap_type type;
 
                type = report_bug(regs->sepc, regs);
-               switch (type) {
-#ifdef CONFIG_GENERIC_BUG
-               case BUG_TRAP_TYPE_WARN:
+               if (type == BUG_TRAP_TYPE_WARN) {
                        regs->sepc += get_break_insn_length(regs->sepc);
                        return;
-               case BUG_TRAP_TYPE_BUG:
-#endif /* CONFIG_GENERIC_BUG */
-               default:
-                       die(regs, "Kernel BUG");
                }
-       } else {
-               force_sig_fault(SIGTRAP, TRAP_BRKPT,
-                               (void __user *)(regs->sepc));
        }
+#endif /* CONFIG_GENERIC_BUG */
+
+       die(regs, "Kernel BUG");
 }
 
 #ifdef CONFIG_GENERIC_BUG