Remove unnecessary use of atomic-polyfill.

Only use it when CAS is actually needed.
This commit is contained in:
Dario Nieuwenhuis 2022-12-23 20:46:49 +01:00
parent cd9a65ba39
commit 10c9cc31b1
15 changed files with 22 additions and 28 deletions

11
.vscode/settings.json vendored
View file

@ -4,7 +4,8 @@
"rust-analyzer.checkOnSave.noDefaultFeatures": true,
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
//"rust-analyzer.cargo.target": "thumbv7em-none-eabi",
"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
"rust-analyzer.cargo.features": [
// These are needed to prevent embassy-net from failing to build
//"embassy-net/medium-ethernet",
@ -12,19 +13,19 @@
//"embassy-net/pool-16",
//"time-tick-16mhz",
//"defmt-timestamp-uptime",
"nightly",
//"nightly",
//"unstable-traits",
],
"rust-analyzer.linkedProjects": [
// Declare for the target you wish to develop
//"embassy-executor/Cargo.toml",
//"embassy-sync/Cargo.toml",
"examples/nrf/Cargo.toml",
//"examples/nrf/Cargo.toml",
// "examples/nrf-rtos-trace/Cargo.toml",
// "examples/rp/Cargo.toml",
// "examples/std/Cargo.toml",
// "examples/stm32f0/Cargo.toml",
// "examples/stm32f1/Cargo.toml",
//"examples/stm32f1/Cargo.toml",
// "examples/stm32f2/Cargo.toml",
// "examples/stm32f3/Cargo.toml",
// "examples/stm32f4/Cargo.toml",
@ -35,7 +36,7 @@
// "examples/stm32l0/Cargo.toml",
// "examples/stm32l1/Cargo.toml",
// "examples/stm32l4/Cargo.toml",
// "examples/stm32l5/Cargo.toml",
"examples/stm32l5/Cargo.toml",
// "examples/stm32u5/Cargo.toml",
// "examples/stm32wb/Cargo.toml",
// "examples/stm32wb55/Cargo.toml",

View file

@ -1,7 +1,6 @@
use core::marker::PhantomData;
use core::ptr;
use atomic_polyfill::{AtomicBool, Ordering};
use core::sync::atomic::{AtomicBool, Ordering};
use super::{raw, Spawner};

View file

@ -1,7 +1,6 @@
use core::marker::PhantomData;
use core::ptr;
use atomic_polyfill::{AtomicBool, Ordering};
use core::sync::atomic::{AtomicBool, Ordering};
use super::{raw, Spawner};

View file

@ -51,7 +51,6 @@ generic-array = { version = "0.14.4", default-features = false }
stable_deref_trait = { version = "1.2.0", default-features = false }
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
atomic-pool = "1.0"
atomic-polyfill = "1.0.1"
embedded-nal-async = { version = "0.3.0", optional = true }
[dependencies.smoltcp]

View file

@ -329,8 +329,8 @@ pub mod client {
use core::cell::UnsafeCell;
use core::mem::MaybeUninit;
use core::ptr::NonNull;
use core::sync::atomic::{AtomicBool, Ordering};
use atomic_polyfill::{AtomicBool, Ordering};
use embedded_nal_async::IpAddr;
use super::*;

View file

@ -29,9 +29,7 @@
//! ```
use core::mem::ManuallyDrop;
use core::sync::atomic::{compiler_fence, Ordering};
use atomic_polyfill::AtomicBool;
use core::sync::atomic::{compiler_fence, AtomicBool, Ordering};
use crate::interrupt::{Interrupt, InterruptExt};
use crate::peripherals::CORE1;

View file

@ -1,10 +1,9 @@
use core::future::poll_fn;
use core::marker::PhantomData;
use core::slice;
use core::sync::atomic::Ordering;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;
use atomic_polyfill::compiler_fence;
use embassy_hal_common::into_ref;
use embassy_sync::waitqueue::AtomicWaker;
use embassy_usb_driver as driver;

View file

@ -1,4 +1,5 @@
use atomic_polyfill::{AtomicU8, Ordering};
use core::sync::atomic::{AtomicU8, Ordering};
use embedded_hal_02::blocking::delay::DelayUs;
use pac::adc::vals::{Adcaldif, Boost, Difsel, Exten, Pcsel};
use pac::adccommon::vals::Presc;

View file

@ -1,7 +1,6 @@
use core::convert::TryInto;
use core::ptr::write_volatile;
use atomic_polyfill::{fence, Ordering};
use core::sync::atomic::{fence, Ordering};
use super::{ERASE_SIZE, FLASH_BASE, FLASH_SIZE};
use crate::flash::Error;

View file

@ -1,7 +1,6 @@
use core::convert::TryInto;
use core::ptr::write_volatile;
use atomic_polyfill::{fence, Ordering};
use core::sync::atomic::{fence, Ordering};
use crate::flash::Error;
use crate::pac;

View file

@ -41,7 +41,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
cortex_m::asm::isb();
cortex_m::asm::dsb();
atomic_polyfill::fence(atomic_polyfill::Ordering::SeqCst);
core::sync::atomic::fence(core::sync::atomic::Ordering::SeqCst);
let ret = {
let mut ret: Result<(), Error> = Ok(());
@ -70,7 +70,7 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
cortex_m::asm::isb();
cortex_m::asm::dsb();
atomic_polyfill::fence(atomic_polyfill::Ordering::SeqCst);
core::sync::atomic::fence(core::sync::atomic::Ordering::SeqCst);
ret
}

View file

@ -1,8 +1,8 @@
use core::cmp;
use core::future::poll_fn;
use core::sync::atomic::{AtomicUsize, Ordering};
use core::task::Poll;
use atomic_polyfill::{AtomicUsize, Ordering};
use embassy_embedded_hal::SetConfig;
use embassy_hal_common::drop::OnDrop;
use embassy_hal_common::{into_ref, PeripheralRef};
@ -131,7 +131,8 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
if isr.tcr() || isr.tc() {
let state = T::state();
state.chunks_transferred.fetch_add(1, Ordering::Relaxed);
let transferred = state.chunks_transferred.load(Ordering::Relaxed);
state.chunks_transferred.store(transferred + 1, Ordering::Relaxed);
state.waker.wake();
}
// The flag can only be cleared by writting to nbytes, we won't do that here, so disable

View file

@ -1,8 +1,8 @@
use core::cell::RefCell;
use core::future::poll_fn;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;
use atomic_polyfill::{compiler_fence, Ordering};
use embassy_cortex_m::peripheral::{PeripheralMutex, PeripheralState, StateStorage};
use embassy_hal_common::ring_buffer::RingBuffer;
use embassy_sync::waitqueue::WakerRegistration;

View file

@ -2,9 +2,9 @@
use core::future::poll_fn;
use core::marker::PhantomData;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;
use atomic_polyfill::{compiler_fence, Ordering};
use embassy_cortex_m::interrupt::InterruptExt;
use embassy_futures::select::{select, Either};
use embassy_hal_common::drop::OnDrop;

View file

@ -31,7 +31,6 @@ defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }
futures-util = { version = "0.3.17", default-features = false }
atomic-polyfill = "1.0.1"
critical-section = "1.1"
heapless = "0.7.5"
cfg-if = "1.0.0"