Skip to content

Commit 023efff

Browse files
author
Jyri Sarha
committed
Audio: up_down_mixer: 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. The two rballoc() calls are converted to mod_balloc(). 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 dcbcd74 commit 023efff

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/audio/up_down_mixer/up_down_mixer.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sof/audio/pipeline.h>
1212
#include <rtos/panic.h>
1313
#include <sof/ipc/msg.h>
14-
#include <rtos/alloc.h>
1514
#include <rtos/cache.h>
1615
#include <rtos/init.h>
1716
#include <sof/lib/notifier.h>
@@ -324,12 +323,6 @@ static int init_mix(struct processing_module *mod,
324323

325324
static int up_down_mixer_free(struct processing_module *mod)
326325
{
327-
struct up_down_mixer_data *cd = module_get_private_data(mod);
328-
329-
rfree(cd->buf_in);
330-
rfree(cd->buf_out);
331-
rfree(cd);
332-
333326
return 0;
334327
}
335328

@@ -342,20 +335,18 @@ static int up_down_mixer_init(struct processing_module *mod)
342335
struct up_down_mixer_data *cd;
343336
int ret;
344337

345-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
338+
cd = mod_zalloc(mod, sizeof(*cd));
346339
if (!cd) {
347340
comp_free(dev);
348341
return -ENOMEM;
349342
}
350343

351344
mod_data->private = cd;
352345

353-
cd->buf_in = rballoc(SOF_MEM_FLAG_USER, mod->priv.cfg.base_cfg.ibs);
354-
cd->buf_out = rballoc(SOF_MEM_FLAG_USER, mod->priv.cfg.base_cfg.obs);
355-
if (!cd->buf_in || !cd->buf_out) {
356-
ret = -ENOMEM;
357-
goto err;
358-
}
346+
cd->buf_in = mod_balloc(mod, mod->priv.cfg.base_cfg.ibs);
347+
cd->buf_out = mod_balloc(mod, mod->priv.cfg.base_cfg.obs);
348+
if (!cd->buf_in || !cd->buf_out)
349+
return -ENOMEM;
359350

360351
switch (up_down_mixer->coefficients_select) {
361352
case DEFAULT_COEFFICIENTS:
@@ -380,20 +371,15 @@ static int up_down_mixer_init(struct processing_module *mod)
380371
break;
381372
default:
382373
comp_err(dev, "unsupported coefficient type");
383-
ret = -EINVAL;
384-
break;
374+
return -EINVAL;
385375
}
386376

387377
if (ret < 0) {
388378
comp_err(dev, "failed to initialize up_down_mix");
389-
goto err;
379+
return ret;
390380
}
391381

392382
return 0;
393-
394-
err:
395-
up_down_mixer_free(mod);
396-
return ret;
397383
}
398384

399385
static int

0 commit comments

Comments
 (0)