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 authored and Anup Patel committed 2024-10-25 23:53:18 +05:30
1 parent daa282573f
commit 80656bdb1d
6 files changed
+13 -8

No files matched your search

+1 -1
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;