From 8b8f7bd384be9168c075eb498400e6280a57477a Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 2 Nov 2023 17:29:56 +0100 Subject: [PATCH] module: (cosmetic) regroup some declarations and assignments Regroup code in modules_init() to move declarations and assignments closer to where they're needed. Signed-off-by: Guennadi Liakhovetski --- src/audio/module_adapter/module/modules.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/audio/module_adapter/module/modules.c b/src/audio/module_adapter/module/modules.c index 4534aa1dbee9..b1b4ea6bf5e5 100644 --- a/src/audio/module_adapter/module/modules.c +++ b/src/audio/module_adapter/module/modules.c @@ -63,28 +63,19 @@ static int modules_init(struct processing_module *mod) int ret; if (!md->module_adapter) { - byte_array_t mod_cfg; - - mod_cfg.data = (uint8_t *)md->cfg.init_data; - /* Intel modules expects DW size here */ - mod_cfg.size = md->cfg.size >> 2; - md->private = mod; - struct comp_ipc_config *config = &(mod->dev->ipc_config); - /* At this point module resources are allocated and it is moved to L2 memory. */ const void *buildinfo = NULL; uint32_t module_entry_point = lib_manager_allocate_module(mod, config, src_cfg, &buildinfo); + if (module_entry_point == 0) { comp_err(dev, "modules_init(), lib_manager_allocate_module() failed!"); return -EINVAL; } - md->module_entry_point = module_entry_point; uint32_t module_id = IPC4_MOD_ID(config->id); uint32_t instance_id = IPC4_INST_ID(config->id); - uint32_t log_handle = (uint32_t) mod->dev->drv->tctx; /* Connect loadable module interfaces with module adapter entity. */ /* Check if native Zephyr lib is loaded */ struct sof_man_fw_desc *desc; @@ -107,21 +98,29 @@ static int modules_init(struct processing_module *mod) (module_entry->segment[SOF_MAN_SEGMENT_TEXT].v_base_addr); } + uint32_t log_handle = (uint32_t)mod->dev->drv->tctx; + byte_array_t mod_cfg = { + .data = (uint8_t *)md->cfg.init_data, + /* Intel modules expects DW size here */ + .size = md->cfg.size >> 2, + }; void *mod_adp; /* Check if module is FDK */ if (mod_buildinfo->api_version_number.fields.major < SOF_MODULE_API_MAJOR_VERSION) { - mod_adp = system_agent_start(md->module_entry_point, module_id, + mod_adp = system_agent_start(module_entry_point, module_id, instance_id, 0, log_handle, &mod_cfg); } else { /* If not start agent for sof loadable */ mod->is_native_sof = true; - mod_adp = native_system_agent_start(mod->sys_service, md->module_entry_point, + mod_adp = native_system_agent_start(mod->sys_service, module_entry_point, module_id, instance_id, 0, log_handle, &mod_cfg); } + md->module_entry_point = module_entry_point; md->module_adapter = mod_adp; + md->private = mod; } /* Allocate module buffers */