Skip to content

Commit 58d0c51

Browse files
author
Jyri Sarha
committed
Audio: igo_nr: 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 one rballoc() call is converted to mod_balloc(). Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 5a170b8 commit 58d0c51

1 file changed

Lines changed: 9 additions & 30 deletions

File tree

src/audio/igo_nr/igo_nr.c

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <user/trace.h>
1313
#include <sof/common.h>
1414
#include <rtos/panic.h>
15-
#include <rtos/alloc.h>
1615
#include <rtos/init.h>
1716
#include <sof/lib/uuid.h>
1817
#include <sof/list.h>
@@ -421,68 +420,48 @@ static int igo_nr_init(struct processing_module *mod)
421420
return -EINVAL;
422421
}
423422

424-
cd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*cd));
423+
cd = mod_zalloc(mod, sizeof(*cd));
425424
if (!cd)
426425
return -ENOMEM;
427426

428427
md->private = cd;
429428
ret = IgoLibGetInfo(&cd->igo_lib_info);
430429
if (ret != IGO_RET_OK) {
431430
comp_err(dev, "IgoLibGetInfo() Failed.");
432-
ret = -EINVAL;
433-
goto cd_fail;
431+
return -EINVAL;
434432
}
435433

436-
cd->p_handle = rballoc(SOF_MEM_FLAG_USER, cd->igo_lib_info.handle_size);
434+
cd->p_handle = mod_balloc(mod, cd->igo_lib_info.handle_size);
437435
if (!cd->p_handle) {
438-
comp_err(dev, "igo_handle memory rballoc error for size %d",
436+
comp_err(dev, "igo_handle memory mod_balloc error for size %d",
439437
cd->igo_lib_info.handle_size);
440-
ret = -ENOMEM;
441-
goto cd_fail;
438+
return -ENOMEM;
442439
}
443440

444441
/* Handler for configuration data */
445-
cd->model_handler = comp_data_blob_handler_new(dev);
442+
cd->model_handler = mod_data_blob_handler_new(mod);
446443
if (!cd->model_handler) {
447-
comp_err(dev, "comp_data_blob_handler_new() failed.");
448-
ret = -ENOMEM;
449-
goto cd_fail2;
444+
comp_err(dev, "mod_data_blob_handler_new() failed.");
445+
return -ENOMEM;
450446
}
451447

452448
/* Get configuration data */
453449
ret = comp_init_data_blob(cd->model_handler, bs, cfg->data);
454450
if (ret < 0) {
455451
comp_err(dev, "comp_init_data_blob() failed.");
456-
ret = -ENOMEM;
457-
goto cd_fail3;
452+
return -ENOMEM;
458453
}
459454

460455
/* update downstream (playback) or upstream (capture) buffer parameters */
461456
mod->verify_params_flags = BUFF_PARAMS_RATE;
462457
comp_info(dev, "igo_nr created");
463458
return 0;
464-
465-
cd_fail3:
466-
comp_data_blob_handler_free(cd->model_handler);
467-
468-
cd_fail2:
469-
rfree(cd->p_handle);
470-
471-
cd_fail:
472-
rfree(cd);
473-
return ret;
474459
}
475460

476461
static int igo_nr_free(struct processing_module *mod)
477462
{
478-
struct comp_data *cd = module_get_private_data(mod);
479-
480463
comp_info(mod->dev, "igo_nr_free()");
481464

482-
comp_data_blob_handler_free(cd->model_handler);
483-
484-
rfree(cd->p_handle);
485-
rfree(cd);
486465
return 0;
487466
}
488467

0 commit comments

Comments
 (0)