Skip to content

Commit 69ea54c

Browse files
author
Jyri Sarha
committed
Audio: IIR: Memory, blob, and fast_get allocs to module API
Allocate all memory, blob handlers, and fast_get() buffers through module API mod_alloc() and friends and remove all redundant rfree(), comp_data_blob_handler_free(), and fast_put() calls from module unload functions and init error branches. When resources are allocated through module API functions they are automatically freed when the module is unloaded. This simplifies error handling and unloading process. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 0928c53 commit 69ea54c

File tree

5 files changed

+13
-26
lines changed

5 files changed

+13
-26
lines changed

src/audio/eq_iir/eq_iir.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <sof/common.h>
1818
#include <rtos/panic.h>
1919
#include <sof/ipc/msg.h>
20-
#include <rtos/alloc.h>
2120
#include <rtos/init.h>
2221
#include <sof/lib/uuid.h>
2322
#include <sof/list.h>
@@ -60,18 +59,17 @@ static int eq_iir_init(struct processing_module *mod)
6059
return -EINVAL;
6160
}
6261

63-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
62+
cd = mod_zalloc(mod, sizeof(*cd));
6463
if (!cd)
6564
return -ENOMEM;
6665

6766
md->private = cd;
6867

6968
/* component model data handler */
70-
cd->model_handler = comp_data_blob_handler_new(dev);
69+
cd->model_handler = mod_data_blob_handler_new(mod);
7170
if (!cd->model_handler) {
72-
comp_err(dev, "comp_data_blob_handler_new() failed.");
73-
ret = -ENOMEM;
74-
goto err;
71+
comp_err(dev, "mod_data_blob_handler_new() failed.");
72+
return -ENOMEM;
7573
}
7674

7775
/* Allocate and make a copy of the coefficients blob and reset IIR. If
@@ -80,27 +78,18 @@ static int eq_iir_init(struct processing_module *mod)
8078
ret = comp_init_data_blob(cd->model_handler, bs, cfg->data);
8179
if (ret < 0) {
8280
comp_err(dev, "comp_init_data_blob() failed with error: %d", ret);
83-
comp_data_blob_handler_free(cd->model_handler);
84-
goto err;
81+
return ret;
8582
}
8683

8784
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
8885
iir_reset_df1(&cd->iir[i]);
8986

9087
return 0;
91-
err:
92-
rfree(cd);
93-
return ret;
9488
}
9589

9690
static int eq_iir_free(struct processing_module *mod)
9791
{
98-
struct comp_data *cd = module_get_private_data(mod);
99-
100-
eq_iir_free_delaylines(cd);
101-
comp_data_blob_handler_free(cd->model_handler);
102-
103-
rfree(cd);
92+
eq_iir_free_delaylines(mod);
10493
return 0;
10594
}
10695

@@ -234,7 +223,7 @@ static int eq_iir_reset(struct processing_module *mod)
234223
struct comp_data *cd = module_get_private_data(mod);
235224
int i;
236225

237-
eq_iir_free_delaylines(cd);
226+
eq_iir_free_delaylines(mod);
238227

239228
cd->eq_iir_func = NULL;
240229
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)

src/audio/eq_iir/eq_iir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ void eq_iir_pass(struct processing_module *mod, struct input_stream_buffer *bsou
7171

7272
int eq_iir_setup(struct processing_module *mod, int nch);
7373

74-
void eq_iir_free_delaylines(struct comp_data *cd);
74+
void eq_iir_free_delaylines(struct processing_module *mod);
7575
#endif /* __SOF_AUDIO_EQ_IIR_EQ_IIR_H__ */

src/audio/eq_iir/eq_iir_generic.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,16 @@ static void eq_iir_init_delay(struct iir_state_df1 *iir,
285285
}
286286
}
287287

288-
void eq_iir_free_delaylines(struct comp_data *cd)
288+
void eq_iir_free_delaylines(struct processing_module *mod)
289289
{
290+
struct comp_data *cd = module_get_private_data(mod);
290291
struct iir_state_df1 *iir = cd->iir;
291292
int i = 0;
292293

293294
/* Free the common buffer for all EQs and point then
294295
* each IIR channel delay line to NULL.
295296
*/
296-
rfree(cd->iir_delay);
297+
mod_free(mod, cd->iir_delay);
297298
cd->iir_delay = NULL;
298299
cd->iir_delay_size = 0;
299300
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
@@ -315,7 +316,7 @@ int eq_iir_setup(struct processing_module *mod, int nch)
315316
int delay_size;
316317

317318
/* Free existing IIR channels data if it was allocated */
318-
eq_iir_free_delaylines(cd);
319+
eq_iir_free_delaylines(mod);
319320

320321
/* Set coefficients for each channel EQ from coefficient blob */
321322
delay_size = eq_iir_init_coef(mod, nch);
@@ -329,8 +330,7 @@ int eq_iir_setup(struct processing_module *mod, int nch)
329330
return 0;
330331

331332
/* Allocate all IIR channels data in a big chunk and clear it */
332-
cd->iir_delay = rzalloc(SOF_MEM_FLAG_USER,
333-
delay_size);
333+
cd->iir_delay = mod_zalloc(mod, delay_size);
334334
if (!cd->iir_delay) {
335335
comp_err(mod->dev, "eq_iir_setup(), delay allocation fail");
336336
return -ENOMEM;

src/audio/eq_iir/eq_iir_ipc3.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <sof/common.h>
1818
#include <rtos/panic.h>
1919
#include <sof/ipc/msg.h>
20-
#include <rtos/alloc.h>
2120
#include <rtos/init.h>
2221
#include <sof/lib/uuid.h>
2322
#include <sof/list.h>

src/audio/eq_iir/eq_iir_ipc4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <sof/common.h>
1818
#include <rtos/panic.h>
1919
#include <sof/ipc/msg.h>
20-
#include <rtos/alloc.h>
2120
#include <rtos/init.h>
2221
#include <sof/lib/uuid.h>
2322
#include <sof/list.h>

0 commit comments

Comments
 (0)