Skip to content

Commit 8738c3c

Browse files
committed
Make all running state public, and use "stateless" access
1 parent 245f586 commit 8738c3c

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/dma/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,12 @@ impl<'rx, 'tx> EthernetDMA<'rx, 'tx> {
402402
/// It stops if the ring is full. Call [`EthernetDMA::recv_next()`] to free an
403403
/// entry and to demand poll from the hardware.
404404
pub fn rx_is_running(&self) -> bool {
405-
self.rx_ring.running_state().is_running()
405+
RxRing::running_state().is_running()
406406
}
407407

408408
/// Is Tx DMA currently running?
409409
pub fn tx_is_running(&self) -> bool {
410-
self.tx_ring.is_running()
410+
TxRing::is_running()
411411
}
412412

413413
/// Try to send a packet with data.

src/dma/rx/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a> RxRing<'a> {
149149
// DMA accesses do not stop before the running state
150150
// of the DMA has changed to something other than
151151
// running.
152-
while self.running_state().is_running() {}
152+
while Self::running_state().is_running() {}
153153
}
154154

155155
/// Demand that the DMA engine polls the current `RxDescriptor`
@@ -176,8 +176,8 @@ impl<'a> RxRing<'a> {
176176
.modify(|r, w| unsafe { w.bits(r.bits()) });
177177
}
178178

179-
/// Get current `RunningState`
180-
pub fn running_state(&self) -> RunningState {
179+
/// Get current state of the RxDMA
180+
pub fn running_state() -> RunningState {
181181
// SAFETY: we only perform an atomic read of `dmasr`.
182182
let eth_dma = unsafe { &*ETHERNET_DMA::ptr() };
183183

@@ -229,7 +229,7 @@ impl<'a> RxRing<'a> {
229229
// NOTE(allow): packet_id is unused if ptp is disabled.
230230
#[allow(unused_variables)] packet_id: Option<PacketId>,
231231
) -> Result<usize, RxError> {
232-
if !self.running_state().is_running() {
232+
if !Self::running_state().is_running() {
233233
Self::demand_poll();
234234
}
235235

src/dma/tx/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'ring> TxRing<'ring> {
121121
// DMA accesses do not stop before the running state
122122
// of the DMA has changed to something other than
123123
// running.
124-
while self.is_running() {}
124+
while Self::is_running() {}
125125
}
126126

127127
fn entry_available(&self, index: usize) -> bool {
@@ -248,11 +248,12 @@ impl<'ring> TxRing<'ring> {
248248
}
249249

250250
/// Is the Tx DMA engine running?
251-
pub fn is_running(&self) -> bool {
252-
self.running_state().is_running()
251+
pub fn is_running() -> bool {
252+
Self::running_state().is_running()
253253
}
254254

255-
pub(crate) fn running_state(&self) -> RunningState {
255+
/// Get the current state of the TxDMA
256+
pub fn running_state() -> RunningState {
256257
// SAFETY: we only perform an atomic read of `dmasr` or
257258
// `dmadsr`.
258259
let eth_dma = unsafe { &*ETHERNET_DMA::ptr() };

0 commit comments

Comments
 (0)