Skip to content

Commit e999fde

Browse files
author
Jyri Sarha
committed
Audio: Mux: 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 <[email protected]>
1 parent 7846e39 commit e999fde

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

src/audio/mux/mux.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <sof/audio/ipc-config.h>
1212
#include <sof/common.h>
1313
#include <sof/ipc/msg.h>
14-
#include <rtos/alloc.h>
1514
#include <rtos/init.h>
1615
#include <sof/lib/uuid.h>
1716
#include <sof/list.h>
@@ -94,36 +93,27 @@ static int mux_demux_common_init(struct processing_module *mod, enum sof_comp_ty
9493
return -EINVAL;
9594
}
9695

97-
cd = rzalloc(SOF_MEM_FLAG_USER,
98-
sizeof(*cd) + MUX_BLOB_STREAMS_SIZE);
96+
cd = mod_zalloc(mod, sizeof(*cd) + MUX_BLOB_STREAMS_SIZE);
9997
if (!cd)
10098
return -ENOMEM;
10199

102-
cd->model_handler = comp_data_blob_handler_new(dev);
100+
cd->model_handler = mod_data_blob_handler_new(mod);
103101
if (!cd->model_handler) {
104-
comp_err(dev, "comp_data_blob_handler_new() failed.");
105-
ret = -ENOMEM;
106-
goto err;
102+
comp_err(dev, "mod_data_blob_handler_new() failed.");
103+
return -ENOMEM;
107104
}
108105

109106
module_data->private = cd;
110107
ret = comp_init_data_blob(cd->model_handler, cfg->size, cfg->init_data);
111108
if (ret < 0) {
112-
comp_err(dev, "comp_init_data_blob() failed.");
113-
goto err_init;
109+
comp_err(dev, "module data blob initialization failed.");
110+
return ret;
114111
}
115112

116113
mod->verify_params_flags = BUFF_PARAMS_CHANNELS;
117114
mod->no_pause = true;
118115
cd->comp_type = type;
119116
return 0;
120-
121-
err_init:
122-
comp_data_blob_handler_free(cd->model_handler);
123-
124-
err:
125-
rfree(cd);
126-
return ret;
127117
}
128118

129119
static int mux_init(struct processing_module *mod)
@@ -135,12 +125,8 @@ static int mux_init(struct processing_module *mod)
135125

136126
static int mux_free(struct processing_module *mod)
137127
{
138-
struct comp_data *cd = module_get_private_data(mod);
139-
140128
comp_dbg(mod->dev, "mux_free()");
141129

142-
comp_data_blob_handler_free(cd->model_handler);
143-
rfree(cd);
144130
return 0;
145131
}
146132

0 commit comments

Comments
 (0)