Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy 1.66 #562

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Update readme
- Update readme, clippy fixes

## [v0.14.0] - 2022-12-12

Expand Down
1 change: 1 addition & 0 deletions examples/usb-serial-irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn main() -> ! {
cortex_m::peripheral::NVIC::unmask(Interrupt::OTG_FS);
}

#[allow(clippy::empty_loop)]
loop {
// Do nothing. Everything is done in the IRQ handler
}
Expand Down
36 changes: 17 additions & 19 deletions src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ where
let (buf_ptr, buf_len) = buf;

// Set the memory address
stream.set_memory_address(buf_ptr as u32);
stream.set_memory_address(buf_ptr);

let is_mem2mem = DIR::direction() == DmaDirection::MemoryToMemory;
if is_mem2mem {
Expand All @@ -1431,9 +1431,9 @@ where
let db_len = if let Some((db_ptr, db_len)) = db {
if is_mem2mem {
// Double buffer is the source in mem2mem mode
stream.set_peripheral_address(db_ptr as u32);
stream.set_peripheral_address(db_ptr);
} else {
stream.set_memory_double_buffer_address(db_ptr as u32);
stream.set_memory_double_buffer_address(db_ptr);
}
Some(db_len)
} else {
Expand All @@ -1445,9 +1445,9 @@ where
};

let n_transfers = if let Some(db) = db_len {
buf_len.min(db) as u16
buf_len.min(db)
} else {
buf_len as u16
buf_len
};
stream.set_number_of_transfers(n_transfers);

Expand Down Expand Up @@ -1477,10 +1477,10 @@ where
if STREAM::current_buffer() == CurrentBuffer::DoubleBuffer {
// "Preceding reads and writes cannot be moved past subsequent writes"
compiler_fence(Ordering::Release);
self.stream.set_memory_address(new_buf_ptr as u32);
self.stream.set_memory_address(new_buf_ptr);

// Check if an overrun occurred, the buffer address won't be updated in that case
if self.stream.get_memory_address() != new_buf_ptr as u32 {
if self.stream.get_memory_address() != new_buf_ptr {
self.stream.clear_transfer_complete_interrupt();
return Err(DMAError::Overrun(new_buf));
}
Expand All @@ -1495,11 +1495,10 @@ where
} else {
// "Preceding reads and writes cannot be moved past subsequent writes"
compiler_fence(Ordering::Release);
self.stream
.set_memory_double_buffer_address(new_buf_ptr as u32);
self.stream.set_memory_double_buffer_address(new_buf_ptr);

// Check if an overrun occurred, the buffer address won't be updated in that case
if self.stream.get_memory_double_buffer_address() != new_buf_ptr as u32 {
if self.stream.get_memory_double_buffer_address() != new_buf_ptr {
self.stream.clear_transfer_complete_interrupt();
return Err(DMAError::Overrun(new_buf));
}
Expand All @@ -1520,8 +1519,8 @@ where
compiler_fence(Ordering::SeqCst);

let (buf_ptr, buf_len) = ptr_and_len;
self.stream.set_memory_address(buf_ptr as u32);
self.stream.set_number_of_transfers(buf_len as u16);
self.stream.set_memory_address(buf_ptr);
self.stream.set_number_of_transfers(buf_len);
let old_buf = self.buf.replace(new_buf);

unsafe {
Expand Down Expand Up @@ -1566,11 +1565,11 @@ where
if current_buffer == CurrentBuffer::DoubleBuffer {
// "Preceding reads and writes cannot be moved past subsequent writes"
compiler_fence(Ordering::Release);
self.stream.set_memory_address(new_buf_ptr as u32);
self.stream.set_memory_address(new_buf_ptr);

// Check again if an overrun occurred, the buffer address won't be updated in that
// case
if self.stream.get_memory_address() != new_buf_ptr as u32 {
if self.stream.get_memory_address() != new_buf_ptr {
panic!("Overrun");
}

Expand All @@ -1581,10 +1580,9 @@ where
} else {
// "Preceding reads and writes cannot be moved past subsequent writes"
compiler_fence(Ordering::Release);
self.stream
.set_memory_double_buffer_address(new_buf_ptr as u32);
self.stream.set_memory_double_buffer_address(new_buf_ptr);

if self.stream.get_memory_double_buffer_address() != new_buf_ptr as u32 {
if self.stream.get_memory_double_buffer_address() != new_buf_ptr {
panic!("Overrun");
}

Expand All @@ -1596,8 +1594,8 @@ where
return;
}
let (buf_ptr, buf_len) = ptr_and_len;
self.stream.set_memory_address(buf_ptr as u32);
self.stream.set_number_of_transfers(buf_len as u16);
self.stream.set_memory_address(buf_ptr);
self.stream.set_number_of_transfers(buf_len);
self.buf.replace(new_buf);

self.stream.enable();
Expand Down