From bf766e1d1b2f0815be95e28cd85ab0cb31e2deca Mon Sep 17 00:00:00 2001 From: rmsyn Date: Sun, 20 Oct 2024 23:03:49 +0000 Subject: [PATCH] riscv: re-use `mcountinhibit` `try_*` functions Re-uses the `try_*` functions in their panicking equivalents for a slight code-size reduction. --- riscv/CHANGELOG.md | 1 + riscv/src/register/mcountinhibit.rs | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/riscv/CHANGELOG.md b/riscv/CHANGELOG.md index a662702f..7cf701b6 100644 --- a/riscv/CHANGELOG.md +++ b/riscv/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Use CSR helper macros to define `marchid` register +- Re-use `try_*` functions in `mcountinhibit` ## [v0.12.1] - 2024-10-20 diff --git a/riscv/src/register/mcountinhibit.rs b/riscv/src/register/mcountinhibit.rs index daa71c67..a3895124 100644 --- a/riscv/src/register/mcountinhibit.rs +++ b/riscv/src/register/mcountinhibit.rs @@ -41,8 +41,7 @@ set_clear_csr!( #[inline] pub unsafe fn set_hpm(index: usize) { - assert!((3..32).contains(&index)); - _set(1 << index); + try_set_hpm(index).unwrap(); } #[inline] @@ -60,8 +59,7 @@ pub unsafe fn try_set_hpm(index: usize) -> Result<()> { #[inline] pub unsafe fn clear_hpm(index: usize) { - assert!((3..32).contains(&index)); - _clear(1 << index); + try_clear_hpm(index).unwrap(); } #[inline]