From: gagachang Date: Fri, 15 Jul 2022 00:20:59 +0800 Subject: [PATCH] lib: sbi_hart: Shorten the code to set MPV bit Message-ID: <20220714162059.3294-1-vivahavey@gmail.com> List-Id: To: opensbi@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit MPV bit is set when the value of next_virt boolean variable equals true. Since the value of next_virt is either 0 or 1, we can set MPV bit without if-else logic. Signed-off-by: Che-Chia Chang --- lib/sbi/sbi_hart.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index de86fee..23ad341 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -769,18 +769,12 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1, #if __riscv_xlen == 32 if (misa_extension('H')) { valH = csr_read(CSR_MSTATUSH); - if (next_virt) - valH = INSERT_FIELD(valH, MSTATUSH_MPV, 1); - else - valH = INSERT_FIELD(valH, MSTATUSH_MPV, 0); + valH = INSERT_FIELD(valH, MSTATUSH_MPV, next_virt); csr_write(CSR_MSTATUSH, valH); } #else if (misa_extension('H')) { - if (next_virt) - val = INSERT_FIELD(val, MSTATUS_MPV, 1); - else - val = INSERT_FIELD(val, MSTATUS_MPV, 0); + val = INSERT_FIELD(val, MSTATUS_MPV, next_virt); } #endif csr_write(CSR_MSTATUS, val); -- 2.25.1