Skip to content

Commit 6f0f977

Browse files
author
Jyri Sarha
committed
copier: Covert copier_host.c
1 parent a5fb43e commit 6f0f977

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/audio/copier/copier.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ __cold static int copier_init(struct processing_module *mod)
191191
switch (node_id.f.dma_type) {
192192
case ipc4_hda_host_output_class:
193193
case ipc4_hda_host_input_class:
194-
ret = copier_host_create(dev, cd, copier, ipc_pipe->pipeline);
194+
ret = copier_host_create(mod, cd, copier, ipc_pipe->pipeline);
195195
if (ret < 0) {
196196
comp_err(dev, "unable to create host");
197197
return ret;
@@ -271,7 +271,7 @@ __cold static int copier_free(struct processing_module *mod)
271271
switch (dev->ipc_config.type) {
272272
case SOF_COMP_HOST:
273273
if (!cd->ipc_gtw)
274-
copier_host_free(cd);
274+
copier_host_free(mod);
275275
else
276276
/* handle gtw case */
277277
copier_ipcgtw_free(cd);

src/audio/copier/copier_host.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ __cold static int init_pipeline_reg(struct comp_dev *dev)
131131
* Sof host component can support this case so copier reuses host
132132
* component to support host gateway.
133133
*/
134-
__cold int copier_host_create(struct comp_dev *dev, struct copier_data *cd,
134+
__cold int copier_host_create(struct processing_module *mod, struct copier_data *cd,
135135
const struct ipc4_copier_module_cfg *copier_cfg,
136136
struct pipeline *pipeline)
137137
{
138-
struct processing_module *mod = comp_mod(dev);
138+
struct comp_dev *dev = mod->dev;
139139
struct comp_ipc_config *config = &dev->ipc_config;
140140
struct ipc_config_host ipc_host;
141141
struct host_data *hd;
@@ -177,16 +177,17 @@ __cold int copier_host_create(struct comp_dev *dev, struct copier_data *cd,
177177
ipc_host.dma_buffer_size = copier_cfg->gtw_cfg.dma_buffer_size;
178178
ipc_host.feature_mask = copier_cfg->copier_feature_mask;
179179

180-
hd = rzalloc(SOF_MEM_FLAG_USER, sizeof(*hd));
180+
hd = mod_zalloc(mod, sizeof(*hd));
181181
if (!hd)
182182
return -ENOMEM;
183183

184184
ret = host_common_new(hd, dev, &ipc_host, config->id);
185185
if (ret < 0) {
186186
comp_err(dev, "copier: host new failed with exit");
187-
goto e_data;
187+
return ret;
188188
}
189189
#if CONFIG_HOST_DMA_STREAM_SYNCHRONIZATION
190+
/* NOTE: Should use goto e_conv this #if section, not direct return */
190191
/* Size of a configuration without optional parameters. */
191192
const uint32_t basic_size = sizeof(*copier_cfg) +
192193
(copier_cfg->gtw_cfg.config_length - 1) * sizeof(uint32_t);
@@ -248,22 +249,21 @@ __cold int copier_host_create(struct comp_dev *dev, struct copier_data *cd,
248249

249250
e_conv:
250251
host_common_free(hd);
251-
e_data:
252-
rfree(hd);
253252

254253
return ret;
255254
}
256255

257-
__cold void copier_host_free(struct copier_data *cd)
256+
__cold void copier_host_free(struct processing_module *mod)
258257
{
258+
struct copier_data *cd = module_get_private_data(mod);
259+
259260
assert_can_be_cold();
260261

261262
#if CONFIG_HOST_DMA_STREAM_SYNCHRONIZATION
262263
if (cd->hd->is_grouped)
263264
delete_from_fpi_sync_group(cd->hd);
264265
#endif
265266
host_common_free(cd->hd);
266-
rfree(cd->hd);
267267
}
268268

269269
/* This is called by DMA driver every time when DMA completes its current

src/audio/copier/host_copier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ static inline int host_common_copy(struct host_data *hd, struct comp_dev *dev, c
129129
}
130130
void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t bytes);
131131
void host_common_one_shot(struct host_data *hd, uint32_t bytes);
132-
int copier_host_create(struct comp_dev *dev, struct copier_data *cd,
132+
int copier_host_create(struct processing_module *mod, struct copier_data *cd,
133133
const struct ipc4_copier_module_cfg *copier_cfg,
134134
struct pipeline *pipeline);
135-
void copier_host_free(struct copier_data *cd);
135+
void copier_host_free(struct processing_module *mod);
136136
int copier_host_params(struct copier_data *cd, struct comp_dev *dev,
137137
struct sof_ipc_stream_params *params);
138138
void copier_host_dma_cb(struct comp_dev *dev, size_t bytes);

0 commit comments

Comments
 (0)