Skip to content

Commit 83c8490

Browse files
committed
riscv: apply review suggestions
1 parent 928f9f8 commit 83c8490

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

riscv/src/register/mvien.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,10 @@ impl Mvien {
5353
///
5454
/// Returns `Error` if the interrupt number is invalid.
5555
#[inline]
56-
pub fn is_enabled<I: InterruptNumber>(&self, interrupt: I) -> Result<bool> {
56+
pub fn is_enabled<I: InterruptNumber>(&self, interrupt: I) -> bool {
5757
let n = interrupt.number();
58-
if Self::is_valid_interrupt(n) {
59-
Ok(bf_extract(self.bits, n, 1) != 0)
60-
} else {
61-
Err(Error::InvalidVariant(n))
62-
}
58+
59+
Self::is_valid_interrupt(n) && bf_extract(self.bits, n, 1) != 0
6360
}
6461

6562
/// Enable a specific core interrupt source.
@@ -148,13 +145,13 @@ mod tests {
148145
(0..=VirtualInterrupt::MAX_INTERRUPT_NUMBER)
149146
.filter_map(|n| VirtualInterrupt::from_number(n).ok())
150147
.for_each(|int| {
151-
assert_eq!(m.is_enabled(int), Ok(false));
148+
assert!(!m.is_enabled(int));
152149

153150
assert!(m.enable(int).is_ok());
154-
assert_eq!(m.is_enabled(int), Ok(true));
151+
assert!(m.is_enabled(int));
155152

156153
assert!(m.disable(int).is_ok());
157-
assert_eq!(m.is_enabled(int), Ok(false));
154+
assert!(!m.is_enabled(int));
158155
});
159156
}
160157
}

riscv/src/register/mvienh.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ impl Mvienh {
3737
///
3838
/// Returns `Error` if the interrupt number is invalid.
3939
#[inline]
40-
pub fn is_enabled<I: InterruptNumber>(&self, interrupt: I) -> Result<bool> {
40+
pub fn is_enabled<I: InterruptNumber>(&self, interrupt: I) -> bool {
4141
let n = interrupt.number();
4242

43-
if Self::is_valid_interrupt(n) {
44-
Ok(bf_extract(self.bits, Self::shift_interrupt(n), 1) != 0)
45-
} else {
46-
Err(Error::InvalidVariant(n))
47-
}
43+
Self::is_valid_interrupt(n) && bf_extract(self.bits, Self::shift_interrupt(n), 1) != 0
4844
}
4945

5046
/// Enable a specific core interrupt source.
@@ -110,13 +106,13 @@ mod tests {
110106
(Mvienh::MIN_INTERRUPT..=Mvienh::MAX_INTERRUPT)
111107
.filter_map(|n| VirtualInterrupt::from_number(n).ok())
112108
.for_each(|int| {
113-
assert_eq!(m.is_enabled(int), Ok(false));
109+
assert!(!m.is_enabled(int));
114110

115111
assert!(m.enable(int).is_ok());
116-
assert_eq!(m.is_enabled(int), Ok(true));
112+
assert!(m.is_enabled(int));
117113

118114
assert!(m.disable(int).is_ok());
119-
assert_eq!(m.is_enabled(int), Ok(false));
115+
assert!(!m.is_enabled(int));
120116
});
121117
}
122118
}

0 commit comments

Comments
 (0)