diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-01-20 20:41:39 +0100 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-02-03 05:43:42 +0100 |
commit | d795a93900d1760c1a4296377557918e464d72ba (patch) | |
tree | 428e20ceaa04a7cabad88f038173ae80f51daad2 /nrf-softdevice | |
parent | a7508c0ee43b525d07f075c734ddcf8e60797ae4 (diff) | |
download | nrf-softdevice-d795a93900d1760c1a4296377557918e464d72ba.zip |
Remove use of deprecated compare_and_swap
Diffstat (limited to 'nrf-softdevice')
-rw-r--r-- | nrf-softdevice/src/ble/l2cap.rs | 5 | ||||
-rw-r--r-- | nrf-softdevice/src/flash.rs | 5 | ||||
-rw-r--r-- | nrf-softdevice/src/softdevice.rs | 5 |
3 files changed, 12 insertions, 3 deletions
diff --git a/nrf-softdevice/src/ble/l2cap.rs b/nrf-softdevice/src/ble/l2cap.rs index 23c456d..c22e9bc 100644 --- a/nrf-softdevice/src/ble/l2cap.rs +++ b/nrf-softdevice/src/ble/l2cap.rs @@ -154,7 +154,10 @@ static mut PACKET_FREE: Option<unsafe fn(NonNull<u8>)> = None; impl<P: Packet> L2cap<P> { pub fn init(_sd: &Softdevice) -> Self { - if IS_INIT.compare_and_swap(false, true, Ordering::AcqRel) { + if IS_INIT + .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire) + .is_err() + { panic!("L2cap::init() called multiple times.") } diff --git a/nrf-softdevice/src/flash.rs b/nrf-softdevice/src/flash.rs index 4f9f8af..6f9aaad 100644 --- a/nrf-softdevice/src/flash.rs +++ b/nrf-softdevice/src/flash.rs @@ -25,7 +25,10 @@ impl Flash { /// /// Panics if called more than once. pub fn take(_sd: &Softdevice) -> Flash { - if FLASH_TAKEN.compare_and_swap(false, true, Ordering::AcqRel) { + if FLASH_TAKEN + .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire) + .is_err() + { panic!("nrf_softdevice::Softdevice::take_flash() called multiple times.") } diff --git a/nrf-softdevice/src/softdevice.rs b/nrf-softdevice/src/softdevice.rs index 52ab002..d62e014 100644 --- a/nrf-softdevice/src/softdevice.rs +++ b/nrf-softdevice/src/softdevice.rs @@ -110,7 +110,10 @@ impl Softdevice { /// - Panics if the requested configuration has too high memory requirements for the softdevice. The softdevice supports a maximum dynamic memory size of 64kb. /// - Panics if called multiple times. Must be called at most once. pub fn enable(_peripherals: Peripherals, config: &Config) -> &'static Softdevice { - if ENABLED.compare_and_swap(false, true, Ordering::AcqRel) { + if ENABLED + .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire) + .is_err() + { panic!("nrf_softdevice::enable() called multiple times.") } |