From 32eb437922a76273b22ff12b41a4e36361f44fba Mon Sep 17 00:00:00 2001 From: rmsyn Date: Sun, 20 Oct 2024 22:53:38 +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/src/register/mcountinhibit.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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]