common/peripheral: do not require mut in PeripheralRef clone_unchecked.
This commit is contained in:
@ -180,7 +180,7 @@ fn main() {
|
||||
|
||||
#[cfg(flash)]
|
||||
impl<'d> FlashLayout<'d> {
|
||||
pub(crate) fn new(mut p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
|
||||
pub(crate) fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self {
|
||||
Self {
|
||||
#(#inits),*
|
||||
}
|
||||
|
@ -33,8 +33,7 @@ impl<'d> Flash<'d> {
|
||||
}
|
||||
|
||||
pub(crate) fn release(self) -> PeripheralRef<'d, crate::peripherals::FLASH> {
|
||||
let mut flash = self;
|
||||
unsafe { flash.inner.clone_unchecked() }
|
||||
unsafe { self.inner.clone_unchecked() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ mod alt_regions {
|
||||
|
||||
// SAFETY: We never expose the cloned peripheral references, and their instance is not public.
|
||||
// Also, all flash region operations are protected with a cs.
|
||||
let mut p = self.release();
|
||||
let p = self.release();
|
||||
AltFlashLayout {
|
||||
bank1_region1: Bank1Region1(&BANK1_REGION1, unsafe { p.clone_unchecked() }),
|
||||
bank1_region2: Bank1Region2(&BANK1_REGION2, unsafe { p.clone_unchecked() }),
|
||||
|
@ -29,7 +29,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn degrade(mut self) -> Flex<'d, AnyPin> {
|
||||
pub fn degrade(self) -> Flex<'d, AnyPin> {
|
||||
// Safety: We are about to drop the other copy of this pin, so
|
||||
// this clone is safe.
|
||||
let pin = unsafe { self.pin.clone_unchecked() };
|
||||
|
Reference in New Issue
Block a user