@@ -110,7 +110,16 @@ int module_init(struct processing_module *mod)
110110 return 0 ;
111111}
112112
113- void * mod_alloc (struct processing_module * mod , uint32_t size , uint32_t alignment )
113+ /**
114+ * Allocates aligned memory block for module.
115+ * @param mod Pointer to the module this memory block is allocatd for.
116+ * @param bytes Size in bytes.
117+ * @param alignment Alignment in bytes.
118+ * @return Pointer to the allocated memory or NULL if failed.
119+ *
120+ * The allocated memory is automatically freed when the module is unloaded.
121+ */
122+ void * mod_alloc_align (struct processing_module * mod , uint32_t size , uint32_t alignment )
114123{
115124 struct comp_dev * dev = mod -> dev ;
116125 struct module_memory * container ;
@@ -147,11 +156,34 @@ void *mod_alloc(struct processing_module *mod, uint32_t size, uint32_t alignment
147156
148157 return ptr ;
149158}
159+ EXPORT_SYMBOL (mod_alloc_align );
160+
161+ /**
162+ * Allocates memory block for module.
163+ * @param mod Pointer to module this memory block is allocated for.
164+ * @param bytes Size in bytes.
165+ * @return Pointer to the allocated memory or NULL if failed.
166+ *
167+ * Like mod_alloc_align() but the alignment can not be specified. However,
168+ * rballoc() will always aligns the memory to PLATFORM_DCACHE_ALIGN.
169+ */
170+ void * mod_alloc (struct processing_module * mod , uint32_t size )
171+ {
172+ return mod_alloc_align (mod , size , 0 );
173+ }
150174EXPORT_SYMBOL (mod_alloc );
151175
152- void * mod_zalloc (struct processing_module * mod , uint32_t size , uint32_t alignment )
176+ /**
177+ * Allocates memory block for module and initializes it to zero.
178+ * @param mod Pointer to module this memory block is allocated for.
179+ * @param bytes Size in bytes.
180+ * @return Pointer to the allocated memory or NULL if failed.
181+ *
182+ * Like mod_alloc() but the allocated memory is initialized to zero.
183+ */
184+ void * mod_zalloc (struct processing_module * mod , uint32_t size )
153185{
154- void * ret = mod_alloc (mod , size , alignment );
186+ void * ret = mod_alloc (mod , size );
155187
156188 if (ret )
157189 memset (ret , 0 , size );
@@ -160,6 +192,11 @@ void *mod_zalloc(struct processing_module *mod, uint32_t size, uint32_t alignmen
160192}
161193EXPORT_SYMBOL (mod_zalloc );
162194
195+ /**
196+ * Frees the memory block removes it from module's book keeping.
197+ * @param mod Pointer to module this memory block was allocated for.
198+ * @param ptr Pointer to the memory block.
199+ */
163200int mod_free (struct processing_module * mod , void * ptr )
164201{
165202 struct module_memory * mem ;
@@ -357,6 +394,12 @@ int module_reset(struct processing_module *mod)
357394 return 0 ;
358395}
359396
397+ /**
398+ * Frees all the memory allocated for this module
399+ * @param mod Pointer to module this memory block was allocated for.
400+ *
401+ * This function is called automatically when the module is unloaded.
402+ */
360403void mod_free_all (struct processing_module * mod )
361404{
362405 struct module_memory * mem ;
0 commit comments