Skip to content

Commit fcfbf24

Browse files
decsnycfriedt
authored andcommitted
dma_mcux_edma: Simplify max data size code
Instead of having preprocessor code, make a hidden kconfig to indicate this and be smarter about the C code (these are all powers of two) Signed-off-by: Declan Snyder <[email protected]>
1 parent 2a24490 commit fcfbf24

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

drivers/dma/Kconfig.mcux_edma

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ config DMA_MCUX_EDMA_V5
3535
help
3636
DMA version 5 driver for MCUX series SoCs.
3737

38+
config DMA_MCUX_MAX_DATA_SIZE
39+
int
40+
default 64 if DMA_MCUX_EDMA_V5 || DMA_MCUX_EDMA_V4 || DMA_MCUX_EDMA_V3
41+
default 32
42+
3843
if DMA_MCUX_EDMA || DMA_MCUX_EDMA_V3 || DMA_MCUX_EDMA_V4 || DMA_MCUX_EDMA_V5
3944

4045
config DMA_TCD_QUEUE_SIZE

drivers/dma/dma_mcux_edma.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,8 @@ static ALWAYS_INLINE uint32_t dma_mcux_edma_remove_channel_gap(const struct devi
179179

180180
static bool data_size_valid(const size_t data_size)
181181
{
182-
return (data_size == 4U || data_size == 2U ||
183-
data_size == 1U || data_size == 8U ||
184-
data_size == 16U || data_size == 32U
185-
#if defined(CONFIG_DMA_MCUX_EDMA_V3) || defined(CONFIG_DMA_MCUX_EDMA_V4) \
186-
|| defined(CONFIG_DMA_MCUX_EDMA_V5)
187-
|| data_size == 64U
188-
#endif
189-
);
182+
return IS_POWER_OF_TWO(data_size) &&
183+
(data_size <= CONFIG_DMA_MCUX_MAX_DATA_SIZE);
190184
}
191185

192186
static void nxp_edma_callback(edma_handle_t *handle, void *param, bool transferDone,

0 commit comments

Comments
 (0)