Skip to content

Commit 8f07859

Browse files
committed
gpdma: clear event flags & clean up api
1 parent c40b715 commit 8f07859

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/gpdma/future.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use core::{
22
future::{Future, IntoFuture},
33
ops::{Deref, DerefMut},
44
pin::Pin,
5+
sync::atomic::{fence, Ordering},
56
task::{Context, Poll},
67
};
78

@@ -59,14 +60,15 @@ where
5960
CH: DmaChannel,
6061
{
6162
fn drop(&mut self) {
62-
match self.abort() {
63-
Ok(()) => {}
64-
Err(_error) => {
65-
#[cfg(feature = "log")]
66-
log::error!("Error aborting DMA transfer: {_error:?}");
67-
}
63+
if self.is_running() {
64+
self.channel.abort();
6865
}
66+
6967
self.disable_interrupts();
68+
69+
// Preserve the instruction and bus sequence of the preceding operation and
70+
// the subsequent buffer access.
71+
fence(Ordering::SeqCst);
7072
}
7173
}
7274

@@ -80,7 +82,7 @@ where
8082

8183
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
8284
self.channel.waker().register(cx.waker());
83-
if self.is_transfer_complete()? {
85+
if self.channel.check_transfer_complete()? {
8486
Poll::Ready(Ok(()))
8587
} else {
8688
Poll::Pending
@@ -98,8 +100,8 @@ where
98100
#[inline(always)]
99101
fn handle_interrupt() {
100102
let ch = Self::new();
101-
ch.waker().wake();
102103
ch.disable_transfer_interrupts();
104+
ch.waker().wake();
103105
}
104106
}
105107

0 commit comments

Comments
 (0)