Skip to content

Commit 553acea

Browse files
author
Jyri Sarha
committed
modules: tensorflow: 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. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 6120029 commit 553acea

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

src/audio/tensorflow/tflm-classify.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <ipc/stream.h>
1919
#include <ipc/topology.h>
2020
#include <module/module/llext.h>
21-
#include <rtos/alloc.h>
2221
#include <rtos/init.h>
2322
#include <rtos/panic.h>
2423
#include <rtos/string.h>
@@ -61,25 +60,24 @@ __cold static int tflm_init(struct processing_module *mod)
6160

6261
comp_info(dev, "tflm_init()");
6362

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

6867
md->private = cd;
6968

7069
/* Handler for configuration data */
71-
cd->model_handler = comp_data_blob_handler_new(dev);
70+
cd->model_handler = mod_data_blob_handler_new(mod);
7271
if (!cd->model_handler) {
7372
comp_err(dev, "comp_data_blob_handler_new() failed.");
74-
ret = -ENOMEM;
75-
goto cd_fail;
73+
return -ENOMEM;
7674
}
7775

7876
/* Get configuration data and reset DRC state */
7977
ret = comp_init_data_blob(cd->model_handler, bs, cfg->data);
8078
if (ret < 0) {
8179
comp_err(dev, "comp_init_data_blob() failed.");
82-
goto cd_fail;
80+
return ret;
8381
}
8482

8583
/* hard coded atm */
@@ -100,20 +98,12 @@ __cold static int tflm_init(struct processing_module *mod)
10098
}
10199

102100
return ret;
103-
104-
cd_fail:
105-
rfree(cd);
106-
return ret;
107101
}
108102

109103
__cold static int tflm_free(struct processing_module *mod)
110104
{
111-
struct tflm_comp_data *cd = module_get_private_data(mod);
112-
113105
assert_can_be_cold();
114106

115-
comp_data_blob_handler_free(cd->model_handler);
116-
rfree(cd);
117107
return 0;
118108
}
119109

0 commit comments

Comments
 (0)