lib: sbi: factorize previous mode computation

Previous privilege mode retrieval from mstatus is done at different
places, factorize it rather than copy/pasting it again.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
This commit is contained in:
Clément Léger
2024-10-18 10:40:03 +02:00
committed by Anup Patel
parent daa282573f
commit 80656bdb1d
6 changed files with 13 additions and 8 deletions

View File

@@ -158,7 +158,7 @@ int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque)
if (ret != SBI_OK)
return ret;
prev_mode = (csr_read(CSR_MSTATUS) & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;
prev_mode = sbi_mstatus_prev_mode(csr_read(CSR_MSTATUS));
if (prev_mode != PRV_S && prev_mode != PRV_U)
return SBI_EFAIL;