summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2023-11-17 21:05:31 +0800
committersakumisu <[email protected]>2023-11-17 21:05:31 +0800
commit73eb69bfa26819b9a175669b2aba8d46c07eb0e1 (patch)
treefea5d5cf2b7da510f74fd9181a53a7a3c73ffff5
parenta08097c90e725370aea9060e4425f7082a0265ed (diff)
remove usb_mem.h
-rw-r--r--common/usb_mem.h60
-rw-r--r--common/usb_osal.h (renamed from osal/usb_osal.h)0
-rw-r--r--common/usb_util.h2
-rw-r--r--core/usbd_core.h1
-rw-r--r--core/usbh_core.h1
5 files changed, 2 insertions, 62 deletions
diff --git a/common/usb_mem.h b/common/usb_mem.h
deleted file mode 100644
index 77a82bb8..00000000
--- a/common/usb_mem.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2022, sakumisu
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-#ifndef USB_MEM_H
-#define USB_MEM_H
-
-#define USB_MEM_ALIGNX __attribute__((aligned(CONFIG_USB_ALIGN_SIZE)))
-
-#if (CONFIG_USB_ALIGN_SIZE > 4)
-static inline void *usb_iomalloc(size_t size)
-{
- void *ptr;
- void *align_ptr;
- int uintptr_size;
- size_t align_size;
- uint32_t align = CONFIG_USB_ALIGN_SIZE;
-
- /* sizeof pointer */
- uintptr_size = sizeof(void *);
- uintptr_size -= 1;
-
- /* align the alignment size to uintptr size byte */
- align = ((align + uintptr_size) & ~uintptr_size);
-
- /* get total aligned size */
- align_size = ((size + uintptr_size) & ~uintptr_size) + align;
- /* allocate memory block from heap */
- ptr = usb_malloc(align_size);
- if (ptr != NULL) {
- /* the allocated memory block is aligned */
- if (((unsigned long)ptr & (align - 1)) == 0) {
- align_ptr = (void *)((unsigned long)ptr + align);
- } else {
- align_ptr = (void *)(((unsigned long)ptr + (align - 1)) & ~(align - 1));
- }
-
- /* set the pointer before alignment pointer to the real pointer */
- *((unsigned long *)((unsigned long)align_ptr - sizeof(void *))) = (unsigned long)ptr;
-
- ptr = align_ptr;
- }
-
- return ptr;
-}
-
-static inline void usb_iofree(void *ptr)
-{
- void *real_ptr;
-
- real_ptr = (void *)*(unsigned long *)((unsigned long)ptr - sizeof(void *));
- usb_free(real_ptr);
-}
-#else
-#define usb_iomalloc(size) usb_malloc(size)
-#define usb_iofree(ptr) usb_free(ptr)
-#endif
-
-#endif /* USB_MEM_H */
diff --git a/osal/usb_osal.h b/common/usb_osal.h
index 560b73ab..560b73ab 100644
--- a/osal/usb_osal.h
+++ b/common/usb_osal.h
diff --git a/common/usb_util.h b/common/usb_util.h
index 7b5d0f3f..797e7b26 100644
--- a/common/usb_util.h
+++ b/common/usb_util.h
@@ -203,4 +203,6 @@
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
+#define USB_MEM_ALIGNX __attribute__((aligned(CONFIG_USB_ALIGN_SIZE)))
+
#endif /* USB_UTIL_H */
diff --git a/core/usbd_core.h b/core/usbd_core.h
index f54ee992..77913907 100644
--- a/core/usbd_core.h
+++ b/core/usbd_core.h
@@ -20,7 +20,6 @@ extern "C" {
#include "usb_errno.h"
#include "usb_def.h"
#include "usb_list.h"
-#include "usb_mem.h"
#include "usb_log.h"
#include "usb_dc.h"
diff --git a/core/usbh_core.h b/core/usbh_core.h
index 6678b6be..93732a54 100644
--- a/core/usbh_core.h
+++ b/core/usbh_core.h
@@ -16,7 +16,6 @@
#include "usb_errno.h"
#include "usb_def.h"
#include "usb_list.h"
-#include "usb_mem.h"
#include "usb_log.h"
#include "usb_hc.h"
#include "usb_osal.h"