]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/wilc1000/wilc_memory.h
staging: wilc1000: remove WILC_FREE_IF_TRUE macro
[karo-tx-linux.git] / drivers / staging / wilc1000 / wilc_memory.h
1 #ifndef __WILC_MEMORY_H__
2 #define __WILC_MEMORY_H__
3
4 /*!
5  *  @file       wilc_memory.h
6  *  @brief      Memory OS wrapper functionality
7  *  @author     syounan
8  *  @sa         wilc_oswrapper.h top level OS wrapper file
9  *  @date       16 Aug 2010
10  *  @version    1.0
11  */
12
13 #include <linux/types.h>
14 #include <linux/slab.h>
15
16 /*!
17  *  @struct             tstrWILC_MemoryAttrs
18  *  @brief              Memory API options
19  *  @author             syounan
20  *  @date               16 Aug 2010
21  *  @version            1.0
22  */
23 typedef struct {
24 } tstrWILC_MemoryAttrs;
25
26 /*!
27  *  @brief      Allocates a given size of bytes
28  *  @param[in]  u32Size size of memory in bytes to be allocated
29  *  @param[in]  strAttrs Optional attributes, NULL for default
30  *              if not NULL, pAllocationPool should point to the pool to use for
31  *              this allocation. if NULL memory will be allocated directly from
32  *              the system
33  *  @param[in]  pcFileName file name of the calling code for debugging
34  *  @param[in]  u32LineNo line number of the calling code for debugging
35  *  @return     The new allocated block, NULL if allocation fails
36  *  @note       It is recommended to use of of the wrapper macros instead of
37  *              calling this function directly
38  *  @sa         sttrWILC_MemoryAttrs
39  *  @sa         WILC_MALLOC
40  *  @sa         WILC_MALLOC_EX
41  *  @sa         WILC_NEW
42  *  @sa         WILC_NEW_EX
43  *  @author     syounan
44  *  @date       16 Aug 2010
45  *  @version    1.0
46  */
47 void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
48                        char *pcFileName, u32 u32LineNo);
49
50
51
52 /*!
53  *  @brief      Frees given block
54  *  @param[in]  pvBlock the memory block to be freed
55  *  @param[in]  strAttrs Optional attributes, NULL for default
56  *  @param[in]  pcFileName file name of the calling code for debugging
57  *  @param[in]  u32LineNo line number of the calling code for debugging
58  *  @note       It is recommended to use of of the wrapper macros instead of
59  *              calling this function directly
60  *  @sa         sttrWILC_MemoryAttrs
61  *  @sa         WILC_FREE
62  *  @sa         WILC_FREE_EX
63  *  @sa         WILC_FREE_SET_NULL
64  *  @author     syounan
65  *  @date       16 Aug 2010
66  *  @version    1.0
67  */
68 void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs,
69                         char *pcFileName, u32 u32LineNo);
70
71 /*!
72  * @brief       standrad malloc wrapper with custom attributes
73  */
74         #define WILC_MALLOC_EX(__size__, __attrs__) \
75         (WILC_MemoryAlloc( \
76                  (__size__), __attrs__, NULL, 0))
77
78
79 /*!
80  * @brief       standrad free wrapper with custom attributes
81  */
82         #define WILC_FREE_EX(__ptr__, __attrs__) \
83         (WILC_MemoryFree( \
84                  (__ptr__), __attrs__, NULL, 0))
85
86 /*!
87  * @brief       Allocates a block (with custom attributes) of given type and number of
88  * elements
89  */
90 #define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \
91         ((__struct_type__ *)WILC_MALLOC_EX( \
92                  sizeof(__struct_type__) * (u32)(__n_structs__), __attrs__))
93
94 /*!
95  * @brief       standrad malloc wrapper with default attributes
96  */
97 #define WILC_MALLOC(__size__) \
98         WILC_MALLOC_EX(__size__, NULL)
99
100
101
102
103 /*!
104  * @brief       Allocates a block (with default attributes) of given type and number of
105  * elements
106  */
107 #define WILC_NEW(__struct_type__, __n_structs__) \
108         WILC_NEW_EX(__struct_type__, __n_structs__, NULL)
109
110 #endif