Skip to content

Commit

Permalink
Remove Dma[Rx|Tx]Buffer::length
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Fischer committed Nov 22, 2024
1 parent 9c1d99d commit 877201d
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 96 deletions.
45 changes: 0 additions & 45 deletions esp-hal/src/dma/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ pub unsafe trait DmaTxBuffer {

/// This is called after the DMA is done using the buffer.
fn from_view(view: Self::View) -> Self;

/// Returns the maximum number of bytes that would be transmitted by this
/// buffer.
///
/// This is a convenience hint for SPI. Most peripherals don't care how long
/// the transfer is.
fn length(&self) -> usize;
}

/// [DmaRxBuffer] is a DMA descriptor + memory combo that can be used for
Expand Down Expand Up @@ -156,12 +149,6 @@ pub unsafe trait DmaRxBuffer {

/// This is called after the DMA is done using the buffer.
fn from_view(view: Self::View) -> Self;

/// Returns the maximum number of bytes that can be received by this buffer.
///
/// This is a convenience hint for SPI. Most peripherals don't care how long
/// the transfer is.
fn length(&self) -> usize;
}

/// An in-progress view into [DmaRxBuf]/[DmaTxBuf].
Expand Down Expand Up @@ -387,10 +374,6 @@ unsafe impl DmaTxBuffer for DmaTxBuf {
fn from_view(view: Self::View) -> Self {
view.0
}

fn length(&self) -> usize {
self.len()
}
}

/// DMA receive buffer
Expand Down Expand Up @@ -543,10 +526,6 @@ unsafe impl DmaRxBuffer for DmaRxBuf {
fn from_view(view: Self::View) -> Self {
view.0
}

fn length(&self) -> usize {
self.len()
}
}

/// DMA transmit and receive buffer.
Expand Down Expand Up @@ -675,10 +654,6 @@ unsafe impl DmaTxBuffer for DmaRxTxBuf {
fn from_view(view: Self::View) -> Self {
view.0
}

fn length(&self) -> usize {
self.len()
}
}

unsafe impl DmaRxBuffer for DmaRxTxBuf {
Expand Down Expand Up @@ -711,10 +686,6 @@ unsafe impl DmaRxBuffer for DmaRxTxBuf {
fn from_view(view: Self::View) -> Self {
view.0
}

fn length(&self) -> usize {
self.len()
}
}

/// DMA Streaming Receive Buffer.
Expand Down Expand Up @@ -865,10 +836,6 @@ unsafe impl DmaRxBuffer for DmaRxStreamBuf {
fn from_view(view: Self::View) -> Self {
view.buf
}

fn length(&self) -> usize {
panic!("DmaCircularBuf doesn't have a length")
}
}

/// A view into a [DmaRxStreamBuf]
Expand Down Expand Up @@ -1072,10 +1039,6 @@ unsafe impl DmaTxBuffer for EmptyBuf {
fn from_view(view: Self::View) -> Self {
view
}

fn length(&self) -> usize {
0
}
}

unsafe impl DmaRxBuffer for EmptyBuf {
Expand Down Expand Up @@ -1103,10 +1066,6 @@ unsafe impl DmaRxBuffer for EmptyBuf {
fn from_view(view: Self::View) -> Self {
view
}

fn length(&self) -> usize {
0
}
}

/// DMA Loop Buffer
Expand Down Expand Up @@ -1180,10 +1139,6 @@ unsafe impl DmaTxBuffer for DmaLoopBuf {
fn from_view(view: Self::View) -> Self {
view
}

fn length(&self) -> usize {
panic!("DmaLoopBuf does not have a length")
}
}

impl Deref for DmaLoopBuf {
Expand Down
Loading

0 comments on commit 877201d

Please sign in to comment.