Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed May 30, 2024
1 parent 7762939 commit ff22137
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion riscv-peripheral/src/plic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub(crate) mod test {

#[pac_enum(unsafe InterruptNumber)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u16)]
#[repr(usize)]
pub(crate) enum Interrupt {
I1 = 1,
I2 = 2,
Expand Down
10 changes: 5 additions & 5 deletions riscv-peripheral/src/plic/enables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl ENABLES {
/// Checks if an interrupt source is enabled for the PLIC context.
#[inline]
pub fn is_enabled<I: ExternalInterruptNumber>(self, source: I) -> bool {
let source = source.number() as usize;
let source = source.number();
let offset = (source / u32::BITS as usize) as _;
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(offset)) };
Expand All @@ -48,7 +48,7 @@ impl ENABLES {
/// * Enabling an interrupt source can break mask-based critical sections.
#[inline]
pub unsafe fn enable<I: ExternalInterruptNumber>(self, source: I) {
let source = source.number() as usize;
let source = source.number();
let offset = (source / u32::BITS as usize) as _;
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(offset)) };
Expand All @@ -73,7 +73,7 @@ impl ENABLES {
source: I,
order: core::sync::atomic::Ordering,
) {
let source = source.number() as usize;
let source = source.number();
let offset = (source / u32::BITS as usize) as _;
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(offset)) };
Expand All @@ -87,7 +87,7 @@ impl ENABLES {
/// It performs non-atomic read-modify-write operations, which may lead to **wrong** behavior.
#[inline]
pub fn disable<I: ExternalInterruptNumber>(self, source: I) {
let source = source.number() as usize;
let source = source.number();
let offset = (source / u32::BITS as usize) as _;
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(offset)) };
Expand All @@ -111,7 +111,7 @@ impl ENABLES {
source: I,
order: core::sync::atomic::Ordering,
) {
let source = source.number() as usize;
let source = source.number();
let offset = (source / u32::BITS as usize) as _;
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(offset)) };
Expand Down
2 changes: 1 addition & 1 deletion riscv-peripheral/src/plic/pendings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl PENDINGS {
/// Checks if an interrupt triggered by a given source is pending.
#[inline]
pub fn is_pending<I: ExternalInterruptNumber>(self, source: I) -> bool {
let source = source.number() as usize;
let source = source.number();
let offset = (source / u32::BITS as usize) as _;
// SAFETY: valid interrupt number
let reg: Reg<u32, RO> = unsafe { Reg::new(self.ptr.offset(offset)) };
Expand Down
4 changes: 2 additions & 2 deletions riscv-peripheral/src/plic/priorities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl PRIORITIES {
#[inline]
pub fn get_priority<I: ExternalInterruptNumber, P: PriorityNumber>(self, source: I) -> P {
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(source.number() as _)) };
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.add(source.number())) };
P::from_number(reg.read() as _).unwrap()
}

Expand All @@ -47,7 +47,7 @@ impl PRIORITIES {
priority: P,
) {
// SAFETY: valid interrupt number
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.offset(source.number() as _)) };
let reg: Reg<u32, RW> = unsafe { Reg::new(self.ptr.add(source.number())) };
reg.write(priority.number() as _);
}

Expand Down

0 comments on commit ff22137

Please sign in to comment.