Skip to content

Commit 501b3c1

Browse files
bors[bot]jordens
andauthored
Merge #67
67: Clippy lint r=jordens a=jordens bors r+ Co-authored-by: Robert Jördens <rj@quartiq.de>
2 parents d2f8b60 + 8c2c0a2 commit 501b3c1

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/eeprom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::i2c;
33

44
const I2C_ADDR: u8 = 0xa0;
55

6-
pub fn read_eui48<'a>(i2c: &pac::I2C2) -> Result<[u8; 6], i2c::Error> {
6+
pub fn read_eui48(i2c: &pac::I2C2) -> Result<[u8; 6], i2c::Error> {
77
let mut buffer = [0u8; 6];
88
i2c::write_read(i2c, I2C_ADDR, &[0xFAu8], &mut buffer)?;
99
Ok(buffer)

src/eth.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ impl Device {
328328
Self{ rx: RxRing::new(), tx: TxRing::new() }
329329
}
330330

331+
// Initialize the ethernet peripherals
332+
//
333+
// # Safety
334+
//
335+
// This iis transitively unsafe since it sets potentially
336+
// unsafe register values. Might ultimately be safe if the values
337+
// are correct.
338+
//
331339
// After `init` is called, `Device` shall not be moved.
332340
pub unsafe fn init(&mut self, mac: EthernetAddress,
333341
eth_mac: &pac::ETHERNET_MAC,

src/i2c.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn poll_for_start_ack(
101101
}
102102
}
103103

104-
return Err(Error::Timeout);
104+
Err(Error::Timeout)
105105
}
106106

107107

@@ -111,10 +111,10 @@ pub fn write_read(
111111
bytes: &[u8],
112112
buffer: &mut [u8],
113113
) -> Result<(), Error> {
114-
assert!(bytes.len() < 256 && bytes.len() > 0);
115-
assert!(buffer.len() < 256 && buffer.len() > 0);
114+
assert!(bytes.len() < 256 && !bytes.is_empty());
115+
assert!(buffer.len() < 256 && !buffer.is_empty());
116116

117-
poll_for_start_ack(i2c, addr|0, false, bytes.len(), false, true)?;
117+
poll_for_start_ack(i2c, addr, false, bytes.len(), false, true)?;
118118

119119
for byte in bytes {
120120
// Wait until we are allowed to send data (START has been ACKed or last

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![deny(warnings)]
2+
#![allow(clippy::missing_safety_doc)]
23

34
#![no_std]
45
#![no_main]

0 commit comments

Comments
 (0)