55 */
66#pragma once
77
8- #include <platsupport/delay.h>
9- #include <platsupport/io.h>
108#include <stdlib.h>
11- #include <usb/usb_host.h>
9+ #include <platsupport/io.h>
10+ #include <platsupport/delay.h>
1211#include <utils/ansi.h>
1312#include <utils/util.h>
1413#include <utils/zf_log.h>
14+ #include <usb/usb_host.h>
1515
1616void otg_irq (void );
1717
@@ -21,64 +21,65 @@ void otg_irq(void);
2121extern ps_malloc_ops_t * ps_malloc_ops ;
2222static inline void * usb_malloc (size_t size )
2323{
24- int ret ;
24+ int ret ;
2525
26- if (ps_malloc_ops && ps_malloc_ops -> calloc ) {
27- void * ptr ;
28- ret = ps_calloc (ps_malloc_ops , 1 , size , & ptr );
29- if (0 != ret ) {
30- ZF_LOGF ("Malloc error %d \n" , ret );
31- }
32- return ptr ;
33- } else {
34- return calloc (1 , size );
35- }
26+ if (ps_malloc_ops && ps_malloc_ops -> calloc ) {
27+ void * ptr ;
28+ ret = ps_calloc (ps_malloc_ops , 1 , size , & ptr );
29+ if (! ret ) {
30+ ZF_LOGF ("Malloc error\n" );
31+ }
32+ return ptr ;
33+ } else {
34+ return calloc (1 , size );
35+ }
3636}
3737
3838static inline void usb_free (void * ptr )
3939{
40- int ret ;
40+ int ret ;
4141
42- if (ps_malloc_ops && ps_malloc_ops -> free ) {
43- ret = ps_free (ps_malloc_ops , 1 , ptr );
44- if (!ret ) {
45- ZF_LOGF ("Free error\n" );
46- }
47- } else {
48- free (ptr );
49- }
42+ if (ps_malloc_ops && ps_malloc_ops -> free ) {
43+ ret = ps_free (ps_malloc_ops , 1 , ptr );
44+ if (!ret ) {
45+ ZF_LOGF ("Free error\n" );
46+ }
47+ } else {
48+ free (ptr );
49+ }
5050}
5151
5252static inline void dsb ()
5353{
5454#ifdef ARCH_ARM
55- asm volatile ("dsb" );
55+ asm volatile ("dsb" );
5656#else
57- asm volatile ("" ::
58- : "memory" );
57+ asm volatile ("" ::: "memory" );
5958#endif
6059}
6160
62- static inline void * ps_dma_alloc_pinned (ps_dma_man_t * dma_man , size_t size ,
63- int align , int cache ,
64- ps_mem_flags_t flags , uintptr_t * paddr )
61+ static inline void * ps_dma_alloc_pinned (ps_dma_man_t * dma_man , size_t size ,
62+ int align , int cache ,
63+ ps_mem_flags_t flags , uintptr_t * paddr )
6564{
66- void * addr ;
67- if (!dma_man ) {
68- ZF_LOGF ("Invalid arguments\n" );
69- }
70- addr = ps_dma_alloc (dma_man , size , align , cache , flags );
71- if (addr != NULL ) {
72- * paddr = ps_dma_pin (dma_man , addr , size );
73- }
74- return addr ;
65+ void * addr ;
66+ if (!dma_man ) {
67+ ZF_LOGF ("Invalid arguments\n" );
68+ }
69+ addr = ps_dma_alloc (dma_man , size , align , cache , flags );
70+ if (addr != NULL ) {
71+ * paddr = ps_dma_pin (dma_man , addr , size );
72+ }
73+ return addr ;
7574}
7675
77- static inline void ps_dma_free_pinned (ps_dma_man_t * dma_man , void * addr , size_t size )
76+ static inline void
77+ ps_dma_free_pinned (ps_dma_man_t * dma_man , void * addr , size_t size )
7878{
79- if (!dma_man ) {
80- ZF_LOGF ("Invalid arguments\n" );
81- }
82- ps_dma_unpin (dma_man , addr , size );
83- ps_dma_free (dma_man , addr , size );
79+ if (!dma_man ) {
80+ ZF_LOGF ("Invalid arguments\n" );
81+ }
82+ ps_dma_unpin (dma_man , addr , size );
83+ ps_dma_free (dma_man , addr , size );
8484}
85+
0 commit comments