Use a variable 'code' to store the exception code to simplify the codes in handle_trap().
Signed-off-by: Bin Meng <bmeng...@gmail.com> --- arch/riscv/lib/interrupts.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/riscv/lib/interrupts.c b/arch/riscv/lib/interrupts.c index 5e09196..0c13588 100644 --- a/arch/riscv/lib/interrupts.c +++ b/arch/riscv/lib/interrupts.c @@ -66,14 +66,18 @@ int disable_interrupts(void) ulong handle_trap(ulong mcause, ulong epc, struct pt_regs *regs) { ulong is_int; + ulong code; is_int = (mcause & MCAUSE_INT); - if ((is_int) && ((mcause & MCAUSE_CAUSE) == IRQ_M_EXT)) - external_interrupt(0); /* handle_m_ext_interrupt */ - else if ((is_int) && ((mcause & MCAUSE_CAUSE) == IRQ_M_TIMER)) - timer_interrupt(0); /* handle_m_timer_interrupt */ - else - _exit_trap(mcause & MCAUSE_CAUSE, epc, regs); + code = mcause & MCAUSE_CAUSE; + if (is_int) { + if (code == IRQ_M_EXT) + external_interrupt(0); /* handle_m_ext_interrupt */ + else if (code == IRQ_M_TIMER) + timer_interrupt(0); /* handle_m_timer_interrupt */ + } else { + _exit_trap(code, epc, regs); + } return epc; } -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot