diff options
author | Atish Patra <atish.patra@wdc.com> | 2019-10-02 23:59:38 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-10-03 06:25:25 +0300 |
commit | 848ed4f644097d1c9ba44bef3307fa2538c84bd4 (patch) | |
tree | f6009248eb753336fc93cac6d5f8065af63ade6f /lib/sbi/sbi_ecall.c | |
parent | 26aec6afed528518dbd633a6e0d951b7646d95c5 (diff) | |
download | opensbi-848ed4f644097d1c9ba44bef3307fa2538c84bd4.tar.xz |
lib: Remove redundant variable assignment
An ecall handler should only return error if valid SBI function
fails. Otherwise, it should succeed with appropriate error in a0.
Get rid of unnecessary setting of the temporary return variable to
zero for the cases where errors are not expected.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_ecall.c')
-rw-r--r-- | lib/sbi/sbi_ecall.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index 311c4cf..b8e444f 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -35,7 +35,7 @@ int sbi_ecall_0_1_handler(u32 hartid, struct sbi_trap_regs *regs, struct sbi_scratch *scratch, struct unpriv_trap *uptrap) { - int ret = SBI_ENOTSUPP; + int ret = 0; struct sbi_tlb_info tlb_info; u32 source_hart = sbi_current_hartid(); @@ -47,19 +47,15 @@ int sbi_ecall_0_1_handler(u32 hartid, struct sbi_trap_regs *regs, #else sbi_timer_event_start(scratch, (u64)regs->a0); #endif - ret = 0; break; case SBI_EXT_0_1_CONSOLE_PUTCHAR: sbi_putc(regs->a0); - ret = 0; break; case SBI_EXT_0_1_CONSOLE_GETCHAR: regs->a0 = sbi_getc(); - ret = 0; break; case SBI_EXT_0_1_CLEAR_IPI: sbi_ipi_clear_smode(scratch); - ret = 0; break; case SBI_EXT_0_1_SEND_IPI: ret = sbi_ipi_send_many(scratch, uptrap, (ulong *)regs->a0, @@ -95,21 +91,18 @@ int sbi_ecall_0_1_handler(u32 hartid, struct sbi_trap_regs *regs, break; case SBI_EXT_0_1_SHUTDOWN: sbi_system_shutdown(scratch, 0); - ret = 0; break; default: regs->a0 = SBI_ENOTSUPP; - ret = 0; }; return ret; - } int sbi_ecall_handler(u32 hartid, ulong mcause, struct sbi_trap_regs *regs, struct sbi_scratch *scratch) { - int ret = SBI_ENOTSUPP; + int ret = 0; struct unpriv_trap uptrap; u32 extension_id = regs->a7; @@ -118,7 +111,6 @@ int sbi_ecall_handler(u32 hartid, ulong mcause, struct sbi_trap_regs *regs, ret = sbi_ecall_0_1_handler(hartid, regs, scratch, &uptrap); } else { regs->a0 = SBI_ENOTSUPP; - ret = 0; } if (!ret) { |