[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1569199517-5884-5-git-send-email-vincent.chen@sifive.com>
Date: Mon, 23 Sep 2019 08:45:17 +0800
From: Vincent Chen <vincent.chen@...ive.com>
To: linux-riscv@...ts.infradead.org
Cc: paul.walmsley@...ive.com, palmer@...ive.com, aou@...s.berkeley.edu,
linux-kernel@...r.kernel.org, vincent.chen@...ive.com
Subject: [PATCH 4/4] riscv: remove the switch statement in do_trap_break()
To make the code more straightforward, replacing the switch statement
with if statement.
Suggested-by: Paul Walmsley <paul.walmsley@...ive.com>
Signed-off-by: Vincent Chen <vincent.chen@...ive.com>
---
arch/riscv/kernel/traps.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index dd13bc90aeb6..1ac75f7d0bff 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -124,23 +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
--
2.7.4
Powered by blists - more mailing lists