comp: use comp_alloc in existing components

Replaces the common, required part of the initialization
copied by every implementation.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
This commit is contained in:
Marcin Maka 2020-04-06 19:42:34 +02:00 committed by Daniel Baluta
parent e66b40a5b4
commit 5f24796630
15 changed files with 15 additions and 73 deletions

View File

@ -273,13 +273,9 @@ static struct comp_dev *asrc_new(const struct comp_driver *drv,
return NULL;
}
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_asrc));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_asrc));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_asrc);
asrc = COMP_GET_IPC(dev, sof_ipc_comp_asrc);
err = memcpy_s(asrc, sizeof(*asrc), ipc_asrc,

View File

@ -135,13 +135,9 @@ static struct comp_dev *dai_new(const struct comp_driver *drv,
comp_cl_dbg(&comp_dai, "dai_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_dai));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_dai));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_dai);
dai = COMP_GET_IPC(dev, sof_ipc_comp_dai);
ret = memcpy_s(dai, sizeof(*dai), ipc_dai,

View File

@ -78,13 +78,9 @@ static struct comp_dev *dcblock_new(const struct comp_driver *drv,
comp_cl_info(&comp_dcblock, "dcblock_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
dcblock = COMP_GET_IPC(dev, sof_ipc_comp_process);
ret = memcpy_s(dcblock, sizeof(*dcblock), ipc_dcblock,

View File

@ -299,13 +299,9 @@ static struct comp_dev *test_keyword_new(const struct comp_driver *drv,
comp_cl_info(&comp_keyword, "test_keyword_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
keyword = COMP_GET_IPC(dev, sof_ipc_comp_process);
ret = memcpy_s(keyword, sizeof(*keyword), ipc_keyword,

View File

@ -416,13 +416,9 @@ static struct comp_dev *eq_fir_new(const struct comp_driver *drv,
return NULL;
}
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
fir = COMP_GET_IPC(dev, sof_ipc_comp_process);
ret = memcpy_s(fir, sizeof(*fir), ipc_fir,

View File

@ -522,13 +522,9 @@ static struct comp_dev *eq_iir_new(const struct comp_driver *drv,
return NULL;
}
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
iir = COMP_GET_IPC(dev, sof_ipc_comp_process);
ret = memcpy_s(iir, sizeof(*iir), ipc_iir,

View File

@ -333,13 +333,9 @@ static struct comp_dev *host_new(const struct comp_driver *drv,
comp_cl_dbg(&comp_host, "host_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_host));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_host));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_host);
host = COMP_GET_IPC(dev, sof_ipc_comp_host);
ret = memcpy_s(host, sizeof(*host),

View File

@ -133,13 +133,9 @@ static struct comp_dev *kpb_new(const struct comp_driver *drv,
comp_cl_info(&comp_kpb, "kpb_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
ret = memcpy_s(COMP_GET_IPC(dev, sof_ipc_comp_process),
sizeof(struct sof_ipc_comp_process),

View File

@ -123,13 +123,9 @@ static struct comp_dev *mixer_new(const struct comp_driver *drv,
comp_cl_dbg(&comp_mixer, "mixer_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_mixer));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_mixer));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_mixer);
mixer = COMP_GET_IPC(dev, sof_ipc_comp_mixer);

View File

@ -89,15 +89,11 @@ static struct comp_dev *mux_new(const struct comp_driver *drv,
comp_cl_info(&comp_mux, "mux_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->state = COMP_STATE_INIT;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
memcpy_s(COMP_GET_IPC(dev, sof_ipc_comp_process),
sizeof(struct sof_ipc_comp_process),

View File

@ -58,13 +58,9 @@ static struct comp_dev *selector_new(const struct comp_driver *drv,
comp_cl_info(&comp_selector, "selector_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_process));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_process));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_process);
ret = memcpy_s(COMP_GET_IPC(dev, sof_ipc_comp_process),
sizeof(struct sof_ipc_comp_process), comp,

View File

@ -465,13 +465,9 @@ static struct comp_dev *src_new(const struct comp_driver *drv,
return NULL;
}
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_src));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_src));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_src);
src = COMP_GET_IPC(dev, sof_ipc_comp_src);

View File

@ -383,13 +383,9 @@ static struct comp_dev *tone_new(const struct comp_driver *drv,
comp_cl_info(&comp_tone, "tone_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_tone));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_tone));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_tone);
tone = COMP_GET_IPC(dev, sof_ipc_comp_tone);
ret = memcpy_s(tone, sizeof(*tone), ipc_tone,

View File

@ -211,13 +211,9 @@ static struct comp_dev *volume_new(const struct comp_driver *drv,
comp_cl_dbg(&comp_volume, "volume_new()");
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_volume));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_volume));
if (!dev)
return NULL;
dev->drv = drv;
dev->size = COMP_SIZE(struct sof_ipc_comp_volume);
vol = COMP_GET_IPC(dev, sof_ipc_comp_volume);
ret = memcpy_s(vol, sizeof(*vol), ipc_vol,

View File

@ -422,11 +422,9 @@ static struct comp_dev *file_new(const struct comp_driver *drv,
return NULL;
}
dev = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM,
COMP_SIZE(struct sof_ipc_comp_file));
dev = comp_alloc(drv, COMP_SIZE(struct sof_ipc_comp_file));
if (!dev)
return NULL;
dev->drv = drv;
file = COMP_GET_IPC(dev, sof_ipc_comp_file);
assert(!memcpy_s(file, sizeof(*file), ipc_file,