aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs12
-rw-r--r--src/pipe.rs11
-rw-r--r--src/pipe/addr.rs4
-rw-r--r--src/pipe/ctrl_pipe.rs14
-rw-r--r--src/pipe/ext_reg.rs2
-rw-r--r--src/pipe/pck_size.rs54
-rw-r--r--src/pipe/status_bk.rs2
-rw-r--r--src/pipe/status_pipe.rs2
8 files changed, 51 insertions, 50 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1d6db93..7df6394 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -82,7 +82,7 @@ impl DeviceTable {
unsafe { mem::transmute(devs) }
};
- Self { tbl: tbl }
+ Self { tbl }
}
/// Allocate a device with the next available address.
@@ -101,8 +101,7 @@ impl DeviceTable {
/// Remove the device at address `addr`.
fn remove(&mut self, addr: u8) -> Option<Device> {
- let v = core::mem::replace(&mut self.tbl[addr as usize], None);
- v
+ core::mem::replace(&mut self.tbl[addr as usize], None)
}
}
@@ -136,6 +135,7 @@ impl<'a, F> SAMDHost<'a, F>
where
F: Fn() -> usize,
{
+ #[allow(clippy::too_many_arguments)]
pub fn new(
usb: USB,
sof_pin: gpio::Pa23<Input<Floating>>,
@@ -150,7 +150,7 @@ where
let (eventr, mut eventw) = unsafe { EVENTS.split() };
let mut rc = Self {
- usb: usb,
+ usb,
events: eventr,
task_state: TaskState::Detached(DetachedState::Initialize),
@@ -164,7 +164,7 @@ where
_dp_pad: dp_pin.into_function_g(port),
host_enable_pin: None,
- millis: millis,
+ millis,
};
if let Some(he_pin) = host_enable_pin {
@@ -375,7 +375,7 @@ where
_ => 8,
};
let mut a0ep0 = Addr0EP0 {
- max_packet_size: max_packet_size,
+ max_packet_size,
in_toggle: true,
out_toggle: true,
};
diff --git a/src/pipe.rs b/src/pipe.rs
index 59ae342..3715149 100644
--- a/src/pipe.rs
+++ b/src/pipe.rs
@@ -76,7 +76,7 @@ impl PipeTable {
unsafe { core::mem::transmute(tbl) }
};
- Self { tbl: tbl }
+ Self { tbl }
}
pub(crate) fn pipe_for<'a, 'b>(
@@ -144,6 +144,7 @@ pub(crate) struct Pipe<'a, 'b> {
pub(crate) desc: &'a mut PipeDesc,
}
impl Pipe<'_, '_> {
+ #[allow(clippy::too_many_arguments)]
pub(crate) fn control_transfer(
&mut self,
ep: &mut dyn Endpoint,
@@ -159,10 +160,10 @@ impl Pipe<'_, '_> {
*/
let buflen = buf.as_ref().map_or(0, |b| b.len() as u16);
let mut setup_packet = SetupPacket {
- bm_request_type: bm_request_type,
- b_request: b_request,
- w_value: w_value,
- w_index: w_index,
+ bm_request_type,
+ b_request,
+ w_value,
+ w_index,
w_length: buflen,
};
self.send(
diff --git a/src/pipe/addr.rs b/src/pipe/addr.rs
index b3548cf..d71ee2d 100644
--- a/src/pipe/addr.rs
+++ b/src/pipe/addr.rs
@@ -17,7 +17,7 @@ pub struct W {
}
impl Addr {
- pub fn read(&self) -> R {
+ pub fn read(self) -> R {
R { bits: self.0 }
}
@@ -89,7 +89,7 @@ impl<'a> AddrW<'a> {
pub unsafe fn bits(self, v: u32) -> &'a mut W {
// Address must be 32-bit aligned. cf ยง32.8.7.2 of SAMD21 data
// sheet.
- assert!((v & 0x3) == 0);
+ debug_assert!(v.trailing_zeros() >= 2);
self.w.bits = v;
self.w
}
diff --git a/src/pipe/ctrl_pipe.rs b/src/pipe/ctrl_pipe.rs
index 91235cd..360a0e7 100644
--- a/src/pipe/ctrl_pipe.rs
+++ b/src/pipe/ctrl_pipe.rs
@@ -16,7 +16,7 @@ pub struct W {
}
impl CtrlPipe {
- pub fn read(&self) -> R {
+ pub fn read(self) -> R {
R { bits: self.0 }
}
@@ -142,8 +142,8 @@ impl<'a> PErMaxW<'a> {
pub unsafe fn bits(self, v: u8) -> &'a mut W {
const POS: u8 = 12;
const MASK: u8 = 0xf;
- self.w.bits &= !((MASK as u16) << POS);
- self.w.bits |= ((v & MASK) as u16) << POS;
+ self.w.bits &= !(u16::from(MASK) << POS);
+ self.w.bits |= u16::from(v & MASK) << POS;
self.w
}
@@ -159,8 +159,8 @@ impl<'a> PEpNumW<'a> {
pub unsafe fn bits(self, v: u8) -> &'a mut W {
const POS: u8 = 8;
const MASK: u8 = 0xf;
- self.w.bits &= !((MASK as u16) << POS);
- self.w.bits |= ((v & MASK) as u16) << POS;
+ self.w.bits &= !(u16::from(MASK) << POS);
+ self.w.bits |= u16::from(v & MASK) << POS;
self.w
}
@@ -176,8 +176,8 @@ impl<'a> PDAddrW<'a> {
pub unsafe fn bits(self, v: u8) -> &'a mut W {
const POS: u8 = 0;
const MASK: u8 = 0x3f;
- self.w.bits &= !((MASK as u16) << POS);
- self.w.bits |= ((v & MASK) as u16) << POS;
+ self.w.bits &= !(u16::from(MASK) << POS);
+ self.w.bits |= u16::from(v & MASK) << POS;
self.w
}
diff --git a/src/pipe/ext_reg.rs b/src/pipe/ext_reg.rs
index 9778f1b..cd2a8dc 100644
--- a/src/pipe/ext_reg.rs
+++ b/src/pipe/ext_reg.rs
@@ -17,7 +17,7 @@ pub(crate) struct W {
}
impl ExtReg {
- pub fn read(&self) -> R {
+ pub fn read(self) -> R {
R { bits: self.0 }
}
diff --git a/src/pipe/pck_size.rs b/src/pipe/pck_size.rs
index c95140d..48441a8 100644
--- a/src/pipe/pck_size.rs
+++ b/src/pipe/pck_size.rs
@@ -17,7 +17,7 @@ pub(crate) struct W {
}
impl PckSize {
- pub fn read(&self) -> R {
+ pub fn read(self) -> R {
R { bits: self.0 }
}
@@ -137,8 +137,8 @@ pub(crate) enum SizeR {
}
impl SizeR {
- pub fn bits(&self) -> u8 {
- match *self {
+ pub fn bits(self) -> u8 {
+ match self {
Self::Bytes8 => 0x0,
Self::Bytes16 => 0x1,
Self::Bytes32 => 0x2,
@@ -150,29 +150,29 @@ impl SizeR {
}
}
- fn is_bytes8(&self) -> bool {
- *self == Self::Bytes8
+ fn is_bytes8(self) -> bool {
+ self == Self::Bytes8
}
- fn is_bytes16(&self) -> bool {
- *self == Self::Bytes16
+ fn is_bytes16(self) -> bool {
+ self == Self::Bytes16
}
- fn is_bytes32(&self) -> bool {
- *self == Self::Bytes32
+ fn is_bytes32(self) -> bool {
+ self == Self::Bytes32
}
- fn is_bytes64(&self) -> bool {
- *self == Self::Bytes64
+ fn is_bytes64(self) -> bool {
+ self == Self::Bytes64
}
- fn is_bytes128(&self) -> bool {
- *self == Self::Bytes128
+ fn is_bytes128(self) -> bool {
+ self == Self::Bytes128
}
- fn is_bytes256(&self) -> bool {
- *self == Self::Bytes256
+ fn is_bytes256(self) -> bool {
+ self == Self::Bytes256
}
- fn is_bytes512(&self) -> bool {
- *self == Self::Bytes512
+ fn is_bytes512(self) -> bool {
+ self == Self::Bytes512
}
- fn is_bytes1024(&self) -> bool {
- *self == Self::Bytes1024
+ fn is_bytes1024(self) -> bool {
+ self == Self::Bytes1024
}
}
@@ -281,8 +281,8 @@ pub(crate) enum SizeW {
Bytes1024,
}
impl SizeW {
- pub fn bits(&self) -> u8 {
- match *self {
+ pub fn bits(self) -> u8 {
+ match self {
Self::Bytes8 => 0,
Self::Bytes16 => 1,
Self::Bytes32 => 2,
@@ -303,8 +303,8 @@ impl<'a> _SizeW<'a> {
pub unsafe fn bits(self, v: u8) -> &'a mut W {
const POS: u8 = 28;
const MASK: u8 = 0x7;
- self.w.bits &= !((MASK as u32) << POS);
- self.w.bits |= ((v & MASK) as u32) << POS;
+ self.w.bits &= !(u32::from(MASK) << POS);
+ self.w.bits |= u32::from(v & MASK) << POS;
self.w
}
@@ -354,8 +354,8 @@ impl<'a> MultiPacketSizeW<'a> {
const POS: u8 = 14;
const MASK: u16 = 0x3fff;
- self.w.bits &= !((MASK as u32) << POS);
- self.w.bits |= ((v & MASK) as u32) << POS;
+ self.w.bits &= !(u32::from(MASK) << POS);
+ self.w.bits |= u32::from(v & MASK) << POS;
self.w
}
}
@@ -371,8 +371,8 @@ impl<'a> ByteCountW<'a> {
const POS: u8 = 0;
const MASK: u16 = 0x3fff;
- self.w.bits &= !((MASK as u32) << POS);
- self.w.bits |= ((v & MASK) as u32) << POS;
+ self.w.bits &= !(u32::from(MASK) << POS);
+ self.w.bits |= u32::from(v & MASK) << POS;
self.w
}
}
diff --git a/src/pipe/status_bk.rs b/src/pipe/status_bk.rs
index 489fc62..50a549c 100644
--- a/src/pipe/status_bk.rs
+++ b/src/pipe/status_bk.rs
@@ -17,7 +17,7 @@ pub(crate) struct W {
}
impl StatusBk {
- pub fn read(&self) -> R {
+ pub fn read(self) -> R {
R { bits: self.0 }
}
diff --git a/src/pipe/status_pipe.rs b/src/pipe/status_pipe.rs
index be135c5..d7db9c6 100644
--- a/src/pipe/status_pipe.rs
+++ b/src/pipe/status_pipe.rs
@@ -15,7 +15,7 @@ pub(crate) struct W {
}
impl StatusPipe {
- pub fn read(&self) -> R {
+ pub fn read(self) -> R {
R { bits: self.0 }
}