Skip to content

Commit bff4c63

Browse files
committed
Fix clippy lints
1 parent 5a20108 commit bff4c63

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

cortex-r/src/pmsav7.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl MemAttrBits {
347347
(0b010, false, false) => Some(MemAttr::Device { shareable: false }),
348348
(tex, c, b) if tex >= 0b100 => {
349349
let outer = tex & 0b11;
350-
let inner = (c as u8) << 1 | (b as u8);
350+
let inner = ((c as u8) << 1) | (b as u8);
351351
Some(MemAttr::Cacheable {
352352
outer: CacheablePolicy::new_with_raw_value(u2::from_u8(outer)),
353353
inner: CacheablePolicy::new_with_raw_value(u2::from_u8(inner)),
@@ -356,7 +356,7 @@ impl MemAttrBits {
356356
}
357357
_ => {
358358
// failed to decode
359-
return None;
359+
None
360360
}
361361
}
362362
}

cortex-r/src/register/cpsr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ impl Cpsr {
103103
}
104104

105105
/// Modify SCTLR (*System Control Register*)
106+
///
107+
/// # Safety
108+
///
109+
/// See docs for [Self::write].
106110
#[inline]
107111
pub unsafe fn modify<F>(f: F)
108112
where

cortex-r/src/register/mod.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ pub mod amair0;
99
pub mod amair1;
1010
pub mod ccsidr;
1111
pub mod clidr;
12-
pub mod cntfrq;
13-
pub mod cntkctl;
14-
pub mod cntp_ctl;
15-
pub mod cntp_cval;
16-
pub mod cntp_tval;
17-
pub mod cntpct;
18-
pub mod cntv_ctl;
19-
pub mod cntv_cval;
20-
pub mod cntv_tval;
21-
pub mod cntvct;
22-
pub mod cntvoff;
2312
pub mod contextidr;
2413
pub mod cpacr;
2514
pub mod cpsr;
@@ -108,17 +97,6 @@ pub use amair0::Amair0;
10897
pub use amair1::Amair1;
10998
pub use ccsidr::Ccsidr;
11099
pub use clidr::Clidr;
111-
pub use cntfrq::Cntfrq;
112-
pub use cntkctl::Cntkctl;
113-
pub use cntp_ctl::CntpCtl;
114-
pub use cntp_cval::CntpCval;
115-
pub use cntp_tval::CntpTval;
116-
pub use cntpct::CntPct;
117-
pub use cntv_ctl::CntvCtl;
118-
pub use cntv_cval::CntvCval;
119-
pub use cntv_tval::CntvTval;
120-
pub use cntvct::CntVct;
121-
pub use cntvoff::CntVoff;
122100
pub use contextidr::Contextidr;
123101
pub use cpacr::Cpacr;
124102
pub use cpsr::Cpsr;
@@ -220,6 +198,12 @@ pub trait SysReg {
220198

221199
/// 32-bit Readable System Registers
222200
pub trait SysRegRead: SysReg {
201+
/// Read a value from this 32-bit register
202+
///
203+
/// # Safety
204+
///
205+
/// You need to read the Architecture Reference Manual because this read
206+
/// may have side-effects.
223207
#[inline]
224208
unsafe fn read_raw() -> u32 {
225209
let r: u32;
@@ -246,6 +230,12 @@ pub trait SysRegRead: SysReg {
246230

247231
/// Writable 32-bit System Registers
248232
pub trait SysRegWrite: SysReg {
233+
/// Write a value to this 32-bit register
234+
///
235+
/// # Safety
236+
///
237+
/// You need to read the Architecture Reference Manual to verify that you are
238+
/// writing valid data here.
249239
#[inline]
250240
unsafe fn write_raw(_value: u32) {
251241
#[cfg(target_arch = "arm")]
@@ -276,6 +266,12 @@ pub trait SysReg64 {
276266

277267
/// 64-bit Readable System Registers
278268
pub trait SysRegRead64: SysReg64 {
269+
/// Read a value from this 64-bit register
270+
///
271+
/// # Safety
272+
///
273+
/// You need to read the Architecture Reference Manual because this read
274+
/// may have side-effects.
279275
#[inline]
280276
unsafe fn read_raw() -> u64 {
281277
let r_lo: u32;
@@ -297,12 +293,18 @@ pub trait SysRegRead64: SysReg64 {
297293
r_lo = 0;
298294
r_hi = 0;
299295
}
300-
(r_hi as u64) << 32 | (r_lo as u64)
296+
((r_hi as u64) << 32) | (r_lo as u64)
301297
}
302298
}
303299

304300
/// Writable 64-bit System Registers
305301
pub trait SysRegWrite64: SysReg64 {
302+
/// Write a value to this 64-bit register
303+
///
304+
/// # Safety
305+
///
306+
/// You need to read the Architecture Reference Manual to verify that you are
307+
/// writing valid data here.
306308
#[inline]
307309
unsafe fn write_raw(_value: u64) {
308310
#[cfg(target_arch = "arm")]

0 commit comments

Comments
 (0)