aboutsummaryrefslogtreecommitdiffstats
path: root/src/pipe
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-09-09 21:19:01 -0400
committerBrian Cully <bjc@kublai.com>2019-09-09 21:19:01 -0400
commit58a268850f34b660c9c71a3442b7cc70d21944da (patch)
treeeb730c6f5590a1825aae0651c5bd0f8835806f18 /src/pipe
parent27177f3d9b82c51a1131784123e9492f6d852c45 (diff)
downloadatsamd-usb-host-58a268850f34b660c9c71a3442b7cc70d21944da.tar.gz
atsamd-usb-host-58a268850f34b660c9c71a3442b7cc70d21944da.zip
Clippy.
Diffstat (limited to 'src/pipe')
-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
6 files changed, 39 insertions, 39 deletions
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 }
}