Skip to content

Commit 4b6045d

Browse files
committed
Remove the SPI::Error as a generic parameter.
1 parent ca588f9 commit 4b6045d

File tree

1 file changed

+11
-19
lines changed
  • embassy-net-adin1110/src

1 file changed

+11
-19
lines changed

embassy-net-adin1110/src/lib.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub enum AdinError<E> {
4444
MDIO_ACC_TIMEOUT,
4545
}
4646

47-
pub type AEResult<T, SPIE> = core::result::Result<T, AdinError<SPIE>>;
47+
pub type AEResult<T, SPIError> = core::result::Result<T, AdinError<SPIError>>;
4848
pub const MDIO_PHY_ADDR: u8 = 0x01;
4949

5050
/// Maximum Transmission Unit
@@ -100,16 +100,12 @@ pub(crate) fn size_align_u32(size: u32) -> u32 {
100100
(size + 3) & 0xFFFF_FFFC
101101
}
102102

103-
impl<SpiE, SPI> ADIN1110<SPI>
104-
where
105-
SPI: SpiDevice<u8, Error = SpiE>,
106-
SpiE: core::fmt::Debug,
107-
{
103+
impl<SPI: SpiDevice> ADIN1110<SPI> {
108104
pub fn new(spi: SPI, crc: bool) -> Self {
109105
Self { spi, crc }
110106
}
111107

112-
pub async fn read_reg(&mut self, reg: sr) -> AEResult<u32, SpiE> {
108+
pub async fn read_reg(&mut self, reg: sr) -> AEResult<u32, SPI::Error> {
113109
let mut tx_buf = Vec::<u8, 16>::new();
114110

115111
let mut spi_hdr = SpiHeader(0);
@@ -148,7 +144,7 @@ where
148144
Ok(value)
149145
}
150146

151-
pub async fn write_reg(&mut self, reg: sr, value: u32) -> AEResult<(), SpiE> {
147+
pub async fn write_reg(&mut self, reg: sr, value: u32) -> AEResult<(), SPI::Error> {
152148
let mut tx_buf = Vec::<u8, 16>::new();
153149

154150
let mut spi_hdr = SpiHeader(0);
@@ -177,7 +173,7 @@ where
177173
}
178174

179175
/// helper function for write to `MDIO_ACC` register and wait for ready!
180-
async fn write_mdio_acc_reg(&mut self, mdio_acc_val: u32) -> AEResult<u32, SpiE> {
176+
async fn write_mdio_acc_reg(&mut self, mdio_acc_val: u32) -> AEResult<u32, SPI::Error> {
181177
self.write_reg(sr::MDIO_ACC, mdio_acc_val).await?;
182178

183179
// TODO: Add proper timeout!
@@ -192,7 +188,7 @@ where
192188
}
193189

194190
/// Read out fifo ethernet packet memory received via the wire.
195-
pub async fn read_fifo(&mut self, packet: &mut [u8]) -> AEResult<usize, SpiE> {
191+
pub async fn read_fifo(&mut self, packet: &mut [u8]) -> AEResult<usize, SPI::Error> {
196192
let mut tx_buf = Vec::<u8, 16>::new();
197193

198194
// Size of the frame, also includes the appednded header.
@@ -238,7 +234,7 @@ where
238234
}
239235

240236
/// Write to fifo ethernet packet memory send over the wire.
241-
pub async fn write_fifo(&mut self, frame: &[u8]) -> AEResult<(), SpiE> {
237+
pub async fn write_fifo(&mut self, frame: &[u8]) -> AEResult<(), SPI::Error> {
242238
let header_len = self.header_write_len();
243239

244240
let mut packet = Packet::new();
@@ -318,7 +314,7 @@ where
318314
/// Programs the mac address in the mac filters.
319315
/// Also set the boardcast address.
320316
/// The chip supports 2 priority queues but current code doesn't support this mode.
321-
pub async fn set_mac_addr(&mut self, mac: &[u8; 6]) -> AEResult<(), SpiE> {
317+
pub async fn set_mac_addr(&mut self, mac: &[u8; 6]) -> AEResult<(), SPI::Error> {
322318
let mac_high_part = u16::from_be_bytes(mac[0..2].try_into().unwrap());
323319
let mac_low_part = u32::from_be_bytes(mac[2..6].try_into().unwrap());
324320

@@ -341,12 +337,8 @@ where
341337
}
342338
}
343339

344-
impl<SpiE, SPI> mdio::MdioBus for ADIN1110<SPI>
345-
where
346-
SPI: SpiDevice<u8, Error = SpiE>,
347-
SpiE: core::fmt::Debug,
348-
{
349-
type Error = AdinError<SpiE>;
340+
impl<SPI: SpiDevice> mdio::MdioBus for ADIN1110<SPI> {
341+
type Error = AdinError<SPI::Error>;
350342

351343
/// Read from the PHY Registers as Clause 22.
352344
async fn read_cl22(&mut self, phy_id: u8, reg: u8) -> Result<u16, Self::Error> {
@@ -380,7 +372,7 @@ where
380372
}
381373

382374
/// Write to the PHY Registers as Clause 45.
383-
async fn write_cl45(&mut self, phy_id: u8, regc45: (u8, u16), value: u16) -> AEResult<(), SpiE> {
375+
async fn write_cl45(&mut self, phy_id: u8, regc45: (u8, u16), value: u16) -> AEResult<(), SPI::Error> {
384376
let phy_id = u32::from(phy_id & 0x1F) << 21;
385377
let dev_addr = u32::from(regc45.0 & 0x1F) << 16;
386378
let reg = u32::from(regc45.1);

0 commit comments

Comments
 (0)