diff --git a/libs/bao1x-api/src/iox.rs b/libs/bao1x-api/src/iox.rs index bce11974e..62c0217f0 100644 --- a/libs/bao1x-api/src/iox.rs +++ b/libs/bao1x-api/src/iox.rs @@ -1,8 +1,3 @@ -#[cfg(feature = "std")] -use core::sync::atomic::{AtomicU32, Ordering}; -#[cfg(feature = "std")] -static REFCOUNT: AtomicU32 = AtomicU32::new(0); - #[cfg(feature = "std")] use num_traits::ToPrimitive; @@ -133,7 +128,6 @@ pub struct IoxHal { #[cfg(feature = "std")] impl IoxHal { pub fn new() -> Self { - REFCOUNT.fetch_add(1, Ordering::Relaxed); let xns = xous_names::XousNames::new().unwrap(); let conn = xns.request_connection(SERVER_NAME_BAO1X_HAL).expect("Couldn't connect to bao1x HAL server"); @@ -329,19 +323,6 @@ impl IoGpio for IoxHal { } } -#[cfg(feature = "std")] -impl Drop for IoxHal { - fn drop(&mut self) { - // de-allocate myself. It's unsafe because we are responsible to make sure nobody else is using the - // connection. - if REFCOUNT.fetch_sub(1, Ordering::Relaxed) == 1 { - unsafe { - xous::disconnect(self.conn).ok(); - } - } - } -} - #[cfg(feature = "std")] impl IoIrq for IoxHal { fn set_irq_pin(&self, port: IoxPort, pin: u8, active: IoxValue, server: &str, opcode: usize) { diff --git a/libs/bao1x-api/src/keyboard.rs b/libs/bao1x-api/src/keyboard.rs index ea870dc60..b83b69495 100644 --- a/libs/bao1x-api/src/keyboard.rs +++ b/libs/bao1x-api/src/keyboard.rs @@ -121,7 +121,6 @@ pub struct Keyboard { } impl Keyboard { pub fn new(xns: &xous_names::XousNames) -> Result { - REFCOUNT.fetch_add(1, Ordering::Relaxed); let conn = xns.request_connection_blocking(crate::SERVER_NAME_KBD).expect("Can't connect to KBD"); Ok(Keyboard { conn }) } @@ -205,17 +204,3 @@ impl Keyboard { /// Reveal the connection ID for use with unsafe FFI calls pub fn conn(&self) -> xous::CID { self.conn } } - -use core::sync::atomic::{AtomicU32, Ordering}; -static REFCOUNT: AtomicU32 = AtomicU32::new(0); -impl Drop for Keyboard { - fn drop(&mut self) { - // now de-allocate myself. It's unsafe because we are responsible to make sure nobody else is using - // the connection. - if REFCOUNT.fetch_sub(1, Ordering::Relaxed) == 1 { - unsafe { - xous::disconnect(self.conn).unwrap(); - } - } - } -}