summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2021-12-17 20:02:58 +0300
committerAnup Patel <anup@brainfault.org>2021-12-22 06:35:05 +0300
commit2082153fc90c54b98647b1fbaeb7511fd57b7d2b (patch)
tree27afbf0ba9f31a9be6125909ca3e46f210ff80b3
parentf27035981096e8d272d94dc17402b10567429869 (diff)
downloadopensbi-2082153fc90c54b98647b1fbaeb7511fd57b7d2b.tar.xz
lib: sbi: simplify pmp_set(), pmp_get()
pmpcfg_csr and pmpcfg_shift are only negative for an unexpected value of __riscv_xlen. We can immediately return in this case. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Anup Patel <anup.patel@wdc.com>
-rw-r--r--lib/sbi/riscv_asm.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c
index 2e2e148..847bdba 100644
--- a/lib/sbi/riscv_asm.c
+++ b/lib/sbi/riscv_asm.c
@@ -261,12 +261,9 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
pmpcfg_csr = (CSR_PMPCFG0 + (n >> 2)) & ~1;
pmpcfg_shift = (n & 7) << 3;
#else
- pmpcfg_csr = -1;
- pmpcfg_shift = -1;
+ return SBI_ENOTSUPP;
#endif
pmpaddr_csr = CSR_PMPADDR0 + n;
- if (pmpcfg_csr < 0 || pmpcfg_shift < 0)
- return SBI_ENOTSUPP;
/* encode PMP config */
prot &= ~PMP_A;
@@ -315,12 +312,9 @@ int pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,
pmpcfg_csr = (CSR_PMPCFG0 + (n >> 2)) & ~1;
pmpcfg_shift = (n & 7) << 3;
#else
- pmpcfg_csr = -1;
- pmpcfg_shift = -1;
+ return SBI_ENOTSUPP;
#endif
pmpaddr_csr = CSR_PMPADDR0 + n;
- if (pmpcfg_csr < 0 || pmpcfg_shift < 0)
- return SBI_ENOTSUPP;
/* decode PMP config */
cfgmask = (0xffUL << pmpcfg_shift);