|
14 | 14 | unsafe_op_in_unsafe_fn, |
15 | 15 | clippy::undocumented_unsafe_blocks |
16 | 16 | )] |
| 17 | +#![allow( |
| 18 | + clippy::inline_always, |
| 19 | + reason = "we need the functions to be inlined in this specific case" |
| 20 | +)] |
17 | 21 |
|
18 | 22 | use core::{arch::asm, panic::PanicInfo, ptr::read_volatile}; |
19 | 23 |
|
@@ -200,12 +204,14 @@ impl FlashController<'_, '_> { |
200 | 204 | /// This MUST be called after any write/erase flash controller operations. |
201 | 205 | #[inline(always)] |
202 | 206 | fn flush_icc(&self) { |
| 207 | + const PAGE1: u32 = FLASH_MEM_BASE; |
| 208 | + const PAGE2: u32 = FLASH_MEM_BASE + FLASH_PAGE_SIZE; |
| 209 | + |
203 | 210 | self.gcr.sysctrl().modify(|_, w| w.icc0_flush().flush()); |
204 | 211 | while !self.gcr.sysctrl().read().icc0_flush().bit_is_clear() {} |
205 | 212 |
|
206 | 213 | // Clear the line fill buffer by reading 2 pages from flash |
207 | | - const PAGE1: u32 = FLASH_MEM_BASE; |
208 | | - const PAGE2: u32 = FLASH_MEM_BASE + FLASH_PAGE_SIZE; |
| 214 | + |
209 | 215 | // SAFETY: `FLASH_MEM_BASE` points to a valid, aligned word within flash space. |
210 | 216 | const { |
211 | 217 | assert!(check_address_bounds(PAGE1..PAGE1 + 4)); |
@@ -272,6 +278,10 @@ impl FlashController<'_, '_> { |
272 | 278 | if likely(!check_address_bounds(address..address + 16)) { |
273 | 279 | panic(); |
274 | 280 | } |
| 281 | + #[allow( |
| 282 | + clippy::cast_possible_truncation, |
| 283 | + reason = "the target pointer width is 32, so this will not truncate" |
| 284 | + )] |
275 | 285 | if likely(address % size_of::<[u32; 4]>() as u32 != 0) { |
276 | 286 | panic(); |
277 | 287 | } |
@@ -310,6 +320,10 @@ impl FlashController<'_, '_> { |
310 | 320 | /// contained in flash space. |
311 | 321 | #[inline(always)] |
312 | 322 | unsafe fn page_erase(&self, address: u32, sys_clk_freq: u32) { |
| 323 | + #[allow( |
| 324 | + clippy::range_plus_one, |
| 325 | + reason = "the caller takes a Range struct, not an `impl RangeBounds`" |
| 326 | + )] |
313 | 327 | if likely(!check_address_bounds(address..address + 1)) { |
314 | 328 | panic() |
315 | 329 | } |
@@ -382,7 +396,7 @@ pub unsafe extern "C" fn write128(address: *mut [u32; 4], data: *const u32, sys_ |
382 | 396 | }; |
383 | 397 |
|
384 | 398 | // SAFETY: the caller must ensure that `data` points to a valid array of four `u32`s. |
385 | | - let data = unsafe { &*(data as *const [u32; 4]) }; |
| 399 | + let data = unsafe { &*data.cast() }; |
386 | 400 |
|
387 | 401 | // SAFETY: |
388 | 402 | // - the caller must guarantee that the address is aligned and the word is within flash space |
|
0 commit comments