aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan McIntyre <me@mciantyre.dev>2025-07-17 18:10:17 -0400
committerIan McIntyre <me@mciantyre.dev>2025-07-17 20:44:19 -0400
commit48b00ed3b83db5205b848f152f6e3139f5dea4b9 (patch)
treebc7776979c86954f52844d0df368cfaa9f0d3573
parentd2bee58caa082ed476d5b1d8bda39992df29fd07 (diff)
Let clippy fix warnings
-rw-r--r--src/bd.rs8
-rw-r--r--src/lib.rs6
2 files changed, 9 insertions, 5 deletions
diff --git a/src/bd.rs b/src/bd.rs
index 1bfe9f7..5508770 100644
--- a/src/bd.rs
+++ b/src/bd.rs
@@ -76,6 +76,12 @@ unsafe impl<D, const COUNT: usize, const MTU: usize> Sync for IoBuffers<D, COUNT
pub type TransmitBuffers<const COUNT: usize, const MTU: usize> = IoBuffers<txbd::TxBD, COUNT, MTU>;
pub type ReceiveBuffers<const COUNT: usize, const MTU: usize> = IoBuffers<rxbd::RxBD, COUNT, MTU>;
+impl<D, const COUNT: usize, const MTU: usize> Default for IoBuffers<D, COUNT, MTU> {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl<D, const COUNT: usize, const MTU: usize> IoBuffers<D, COUNT, MTU> {
const MTU_IS_MULTIPLE_OF_16: () = assert!(MTU % 16 == 0);
@@ -91,7 +97,7 @@ impl<D, const COUNT: usize, const MTU: usize> IoBuffers<D, COUNT, MTU> {
fn init(
&'static mut self,
init_descriptors: impl Fn(&mut [D], &mut [DataBuffer<MTU>]),
- ) -> IoSlices<D> {
+ ) -> IoSlices<'static, D> {
// Safety: by taking 'static mut reference, we
// ensure that we can only be called once.
let ring = unsafe { self.ring.init() };
diff --git a/src/lib.rs b/src/lib.rs
index 895288c..e24ccb7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -75,10 +75,8 @@ impl<const N: u8> Enet<N> {
ral::write_reg!(ral::enet, enet, RDSR, rx_ring.as_ptr() as _);
const SMI_MDC_FREQUENCY_HZ: u32 = 2_500_000;
- let mii_speed =
- (source_clock_hz + 2 * SMI_MDC_FREQUENCY_HZ - 1) / (2 * SMI_MDC_FREQUENCY_HZ) - 1;
- let hold_time =
- (10 + 1_000_000_000 / source_clock_hz - 1) / (1_000_000_000 / source_clock_hz) - 1;
+ let mii_speed = source_clock_hz.div_ceil(2 * SMI_MDC_FREQUENCY_HZ) - 1;
+ let hold_time = 10_u32.div_ceil(1_000_000_000 / source_clock_hz) - 1;
// TODO no way to enable / disable the MII management frame preamble. Maybe a new method
// for the user?
ral::modify_reg!(ral::enet, enet, MSCR, HOLDTIME: hold_time, MII_SPEED: mii_speed);