diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-04-11 23:00:14 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-04-11 23:09:02 +0200 |
| commit | 9a677ab618aa7a7612cd079b77d3240bdb02fdac (patch) | |
| tree | 17eacc9698a823a8ad5af3fd44468f54e69a5c1d /embassy-stm32 | |
| parent | 5c42ca13bd207c5923cb36e1454f3f838582b6cb (diff) | |
common/peripheral: do not require mut in PeripheralRef clone_unchecked.
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/build.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/common.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 2 |
4 files changed, 4 insertions, 5 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index b01e8ba45..73bd29fcf 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -180,7 +180,7 @@ fn main() { | |||
| 180 | 180 | ||
| 181 | #[cfg(flash)] | 181 | #[cfg(flash)] |
| 182 | impl<'d> FlashLayout<'d> { | 182 | impl<'d> FlashLayout<'d> { |
| 183 | pub(crate) fn new(mut p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self { | 183 | pub(crate) fn new(p: embassy_hal_common::PeripheralRef<'d, crate::peripherals::FLASH>) -> Self { |
| 184 | Self { | 184 | Self { |
| 185 | #(#inits),* | 185 | #(#inits),* |
| 186 | } | 186 | } |
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 8235d6f08..1189e447e 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs | |||
| @@ -33,8 +33,7 @@ impl<'d> Flash<'d> { | |||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | pub(crate) fn release(self) -> PeripheralRef<'d, crate::peripherals::FLASH> { | 35 | pub(crate) fn release(self) -> PeripheralRef<'d, crate::peripherals::FLASH> { |
| 36 | let mut flash = self; | 36 | unsafe { self.inner.clone_unchecked() } |
| 37 | unsafe { flash.inner.clone_unchecked() } | ||
| 38 | } | 37 | } |
| 39 | } | 38 | } |
| 40 | 39 | ||
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 2ce9df69f..60ac62c17 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -67,7 +67,7 @@ mod alt_regions { | |||
| 67 | 67 | ||
| 68 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. | 68 | // SAFETY: We never expose the cloned peripheral references, and their instance is not public. |
| 69 | // Also, all flash region operations are protected with a cs. | 69 | // Also, all flash region operations are protected with a cs. |
| 70 | let mut p = self.release(); | 70 | let p = self.release(); |
| 71 | AltFlashLayout { | 71 | AltFlashLayout { |
| 72 | bank1_region1: Bank1Region1(&BANK1_REGION1, unsafe { p.clone_unchecked() }), | 72 | bank1_region1: Bank1Region1(&BANK1_REGION1, unsafe { p.clone_unchecked() }), |
| 73 | bank1_region2: Bank1Region2(&BANK1_REGION2, unsafe { p.clone_unchecked() }), | 73 | bank1_region2: Bank1Region2(&BANK1_REGION2, unsafe { p.clone_unchecked() }), |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 3024f1ffa..4895684e0 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -29,7 +29,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | #[inline] | 31 | #[inline] |
| 32 | pub fn degrade(mut self) -> Flex<'d, AnyPin> { | 32 | pub fn degrade(self) -> Flex<'d, AnyPin> { |
| 33 | // Safety: We are about to drop the other copy of this pin, so | 33 | // Safety: We are about to drop the other copy of this pin, so |
| 34 | // this clone is safe. | 34 | // this clone is safe. |
| 35 | let pin = unsafe { self.pin.clone_unchecked() }; | 35 | let pin = unsafe { self.pin.clone_unchecked() }; |
