Skip to content

Commit b9577e6

Browse files
erwangokartben
authored andcommitted
drivers: dma: stm32: Align channel offset handling in all API functions
To ease code understanding of offset handling within the driver, harmonize its treatment within impacted functions. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 5e4bf37 commit b9577e6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/dma/dma_stm32.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,9 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
273273
struct dma_config *config)
274274
{
275275
const struct dma_stm32_config *dev_config = dev->config;
276-
struct dma_stm32_stream *stream =
277-
&dev_config->streams[id - STM32_DMA_STREAM_OFFSET];
278276
DMA_TypeDef *dma = (DMA_TypeDef *)dev_config->base;
279277
LL_DMA_InitTypeDef DMA_InitStruct;
278+
struct dma_stm32_stream *stream;
280279
int ret;
281280

282281
LL_DMA_StructInit(&DMA_InitStruct);
@@ -289,6 +288,7 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
289288
return -EINVAL;
290289
}
291290

291+
stream = &dev_config->streams[id];
292292
if (stream->busy) {
293293
LOG_ERR("dma stream %d is busy.", id);
294294
return -EBUSY;
@@ -594,8 +594,8 @@ DMA_STM32_EXPORT_API int dma_stm32_start(const struct device *dev, uint32_t id)
594594
DMA_STM32_EXPORT_API int dma_stm32_stop(const struct device *dev, uint32_t id)
595595
{
596596
const struct dma_stm32_config *config = dev->config;
597-
struct dma_stm32_stream *stream = &config->streams[id - STM32_DMA_STREAM_OFFSET];
598597
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
598+
struct dma_stm32_stream *stream;
599599

600600
/* Give channel from index 0 */
601601
id = id - STM32_DMA_STREAM_OFFSET;
@@ -604,6 +604,8 @@ DMA_STM32_EXPORT_API int dma_stm32_stop(const struct device *dev, uint32_t id)
604604
return -EINVAL;
605605
}
606606

607+
stream = &config->streams[id];
608+
607609
if (stream->hal_override) {
608610
stream->busy = false;
609611
return 0;

0 commit comments

Comments
 (0)