From ba319eecffe6e37dd7f3142c354e8f765cd095b6 Mon Sep 17 00:00:00 2001 From: doryan Date: Fri, 25 Apr 2025 14:35:11 +0400 Subject: [PATCH] refactor: move function down + set #[inline(always)] for small functions --- src/types/usb_device.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/types/usb_device.rs b/src/types/usb_device.rs index b31d7cb..ac4be91 100644 --- a/src/types/usb_device.rs +++ b/src/types/usb_device.rs @@ -82,13 +82,6 @@ pub(crate) const ENDPOINTS_ALLOC_LAYOUT: [u16; MAX_ENDPOINTS] = [64, 256, 64, 64 pub(crate) const ONE_MS_16_MGHZ: u32 = 16000; impl UsbDevice { - #[inline] - pub(crate) fn get_size(&self, cs: CriticalSection<'_>) -> usize { - let usb = self.usb.borrow(cs); - - (((usb.uebchx.read().bits() as u16) << 8) | (usb.uebclx.read().bits() as u16)).into() - } - #[inline] pub fn new(pll: PLL, usb: USB_DEVICE) -> UsbBusAllocator { UsbBusAllocator::new(Self { @@ -101,6 +94,8 @@ impl UsbDevice { } #[inline] + + #[inline(always)] pub(crate) fn allocated_endpoints(&self) -> impl Iterator { self.ep_table .iter() @@ -178,4 +173,11 @@ impl UsbDevice { Err(exception) => Err(exception), } } + + #[inline(always)] + pub(crate) fn get_size(&self, cs: CriticalSection<'_>) -> usize { + let usb = self.usb.borrow(cs); + + (((usb.uebchx.read().bits() as u16) << 8) | (usb.uebclx.read().bits() as u16)).into() + } }