drivers: dmamux: Remove need for kmalloc
Use file static variable for the channel config data, instead of a dynamic array allocated with kmalloc. Signed-off-by: Erwin Rol <erwin@erwinrol.com>
This commit is contained in:
parent
8c4c72d213
commit
4cc15d73dd
1 changed files with 22 additions and 26 deletions
|
@ -172,13 +172,6 @@ static int dmamux_stm32_init(const struct device *dev)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size_stream =
|
|
||||||
sizeof(struct dmamux_stm32_channel) * config->channel_nb;
|
|
||||||
data->mux_channels = k_malloc(size_stream);
|
|
||||||
if (!data->mux_channels) {
|
|
||||||
LOG_ERR("HEAP_MEM_POOL_SIZE is too small");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < config->channel_nb; i++) {
|
for (int i = 0; i < config->channel_nb; i++) {
|
||||||
/*
|
/*
|
||||||
* associates the dmamux channel
|
* associates the dmamux channel
|
||||||
|
@ -209,26 +202,29 @@ static const struct dma_driver_api dma_funcs = {
|
||||||
.get_status = dmamux_stm32_get_status,
|
.get_status = dmamux_stm32_get_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DMAMUX_INIT(index) \
|
#define DMAMUX_INIT(index) \
|
||||||
\
|
\
|
||||||
const struct dmamux_stm32_config dmamux_stm32_config_##index = {\
|
const struct dmamux_stm32_config dmamux_stm32_config_##index = { \
|
||||||
.pclken = { .bus = DT_INST_CLOCKS_CELL(index, bus), \
|
.pclken = { .bus = DT_INST_CLOCKS_CELL(index, bus), \
|
||||||
.enr = DT_INST_CLOCKS_CELL(index, bits) }, \
|
.enr = DT_INST_CLOCKS_CELL(index, bits) }, \
|
||||||
.base = DT_INST_REG_ADDR(index), \
|
.base = DT_INST_REG_ADDR(index), \
|
||||||
.channel_nb = DT_INST_PROP(index, dma_channels), \
|
.channel_nb = DT_INST_PROP(index, dma_channels), \
|
||||||
.gen_nb = DT_INST_PROP(index, dma_generators), \
|
.gen_nb = DT_INST_PROP(index, dma_generators), \
|
||||||
.req_nb = DT_INST_PROP(index, dma_requests), \
|
.req_nb = DT_INST_PROP(index, dma_requests), \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static struct dmamux_stm32_data dmamux_stm32_data_##index = { \
|
static struct dmamux_stm32_channel \
|
||||||
.mux_channels = NULL, \
|
dmamux_stm32_channels_##index[DT_INST_PROP(index, dma_channels)]; \
|
||||||
}; \
|
\
|
||||||
\
|
static struct dmamux_stm32_data dmamux_stm32_data_##index = { \
|
||||||
DEVICE_DT_INST_DEFINE(index, \
|
.mux_channels = dmamux_stm32_channels_##index, \
|
||||||
&dmamux_stm32_init, \
|
}; \
|
||||||
device_pm_control_nop, \
|
\
|
||||||
|
DEVICE_DT_INST_DEFINE(index, \
|
||||||
|
&dmamux_stm32_init, \
|
||||||
|
device_pm_control_nop, \
|
||||||
&dmamux_stm32_data_##index, &dmamux_stm32_config_##index,\
|
&dmamux_stm32_data_##index, &dmamux_stm32_config_##index,\
|
||||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,\
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||||
&dma_funcs);
|
&dma_funcs);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(DMAMUX_INIT)
|
DT_INST_FOREACH_STATUS_OKAY(DMAMUX_INIT)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue